1. Code cleanup & refactor of temporal graph front-end.
2. Added the feature that top 3 entities are always selected by default when page is loaded.
This commit is contained in:
parent
02aa704916
commit
ee81f45917
3 changed files with 140 additions and 127 deletions
|
@ -110,6 +110,21 @@ position: inherit;
|
||||||
color:red;
|
color:red;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.ellipsis {
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.entity-label-url {
|
||||||
|
width: 125px;
|
||||||
|
margin-right: 10px;
|
||||||
|
display:inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ellipsis.multiline {
|
||||||
|
white-space: normal;
|
||||||
|
}
|
||||||
|
|
||||||
#searchresult {
|
#searchresult {
|
||||||
margin-top: 50px;
|
margin-top: 50px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -212,10 +212,13 @@ function calcZeroLessMinAndMax(jsonObject, year) {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if (globalMinYear > minYear)
|
if (globalMinYear > minYear) {
|
||||||
globalMinYear = minYear;
|
globalMinYear = minYear;
|
||||||
if (globalMaxYear < maxYear)
|
}
|
||||||
|
|
||||||
|
if (globalMaxYear < maxYear) {
|
||||||
globalMaxYear = maxYear;
|
globalMaxYear = maxYear;
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -327,8 +330,10 @@ function calcSumOfComparisonParameter(jsonObject) {
|
||||||
function contains(objectArray, object) {
|
function contains(objectArray, object) {
|
||||||
var i = 0, flag = 0;
|
var i = 0, flag = 0;
|
||||||
for (i = 0; i < objectArray.length; i++) {
|
for (i = 0; i < objectArray.length; i++) {
|
||||||
if (objectArray[i] == object)
|
if (objectArray[i] == object) {
|
||||||
flag = i;
|
flag = i;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return flag;
|
return flag;
|
||||||
}
|
}
|
||||||
|
@ -387,9 +392,7 @@ function createLegendRow(entity, bottomDiv) {
|
||||||
var parentP = $('<p>');
|
var parentP = $('<p>');
|
||||||
parentP.attr('id', slugify(entity.label));
|
parentP.attr('id', slugify(entity.label));
|
||||||
|
|
||||||
console.log("entity label in create", entity.label);
|
var labelDiv = $('<div>');
|
||||||
|
|
||||||
var labelDiv = $('<div>')
|
|
||||||
labelDiv.attr('class', 'easy-deselect-label');
|
labelDiv.attr('class', 'easy-deselect-label');
|
||||||
labelDiv.html('<div class="entity-label-url ellipsis"></div>');
|
labelDiv.html('<div class="entity-label-url ellipsis"></div>');
|
||||||
labelDiv.append('<a class="temporal-vis-url" href="' + getTemporalVisURL(entity) + '"><img src = "' + temporalGraphSmallIcon + '"/></a>');
|
labelDiv.append('<a class="temporal-vis-url" href="' + getTemporalVisURL(entity) + '"><img src = "' + temporalGraphSmallIcon + '"/></a>');
|
||||||
|
@ -438,7 +441,7 @@ function renderBarAndLabel(entity, divBar, divLabel, spanElement) {
|
||||||
var entityLabelForLegend = divLabel.find(".entity-label-url");
|
var entityLabelForLegend = divLabel.find(".entity-label-url");
|
||||||
entityLabelForLegend.html(entity.label);
|
entityLabelForLegend.html(entity.label);
|
||||||
entityLabelForLegend.ellipsis();
|
entityLabelForLegend.ellipsis();
|
||||||
entityLabelForLegend.wrap("<a class='entity-url' href='" + getVIVOURL(entity) + "'></a>");
|
entityLabelForLegend.wrap("<a class='entity-url' title='" + entity.label + "' href='" + getVIVOURL(entity) + "'></a>");
|
||||||
|
|
||||||
spanElement.text(sum).css("font-size", "0.8em").css("color", "#595B5B");
|
spanElement.text(sum).css("font-size", "0.8em").css("color", "#595B5B");
|
||||||
|
|
||||||
|
@ -589,17 +592,6 @@ function getNextFreeColor(entity){
|
||||||
colors[entity.label] = colorToAssign;
|
colors[entity.label] = colorToAssign;
|
||||||
}
|
}
|
||||||
|
|
||||||
function createVIVOProfileImage(url){
|
|
||||||
|
|
||||||
var vivoImage = $(url);
|
|
||||||
|
|
||||||
/* vivoImage.html("profile");
|
|
||||||
vivoImage.css("background-color","#727272" );
|
|
||||||
vivoImage.css("color", "white");
|
|
||||||
*/
|
|
||||||
vivoImage.css("padding", "2px");
|
|
||||||
}
|
|
||||||
|
|
||||||
function getNormalizedWidth(entity, sum){
|
function getNormalizedWidth(entity, sum){
|
||||||
|
|
||||||
var maxValueOfComparisonParameter = calcMaxOfComparisonParameter(labelToEntityRecord);
|
var maxValueOfComparisonParameter = calcMaxOfComparisonParameter(labelToEntityRecord);
|
||||||
|
@ -775,13 +767,11 @@ function prepareTableForDataTablePagination(jsonData){
|
||||||
var labelTD = $('<td>');
|
var labelTD = $('<td>');
|
||||||
labelTD.css("width", "100px");
|
labelTD.css("width", "100px");
|
||||||
labelTD.html(index);
|
labelTD.html(index);
|
||||||
// labelTD.autoEllipsis();
|
|
||||||
|
|
||||||
var publicationCountTD = $('<td>');
|
var publicationCountTD = $('<td>');
|
||||||
publicationCountTD.html(calcSumOfComparisonParameter(val));
|
publicationCountTD.html(calcSumOfComparisonParameter(val));
|
||||||
|
|
||||||
var entityTypeTD = $('<td>');
|
var entityTypeTD = $('<td>');
|
||||||
//entityTypeTD.html(val.organizationType.join(", "));
|
|
||||||
entityTypeTD.html(entityTypesWithoutStopWords);
|
entityTypeTD.html(entityTypesWithoutStopWords);
|
||||||
|
|
||||||
row.append(checkboxTD);
|
row.append(checkboxTD);
|
||||||
|
@ -793,8 +783,6 @@ function prepareTableForDataTablePagination(jsonData){
|
||||||
checkboxCount++;
|
checkboxCount++;
|
||||||
});
|
});
|
||||||
|
|
||||||
// console.log('creating '+ checkboxCount + ' checkboxes inside the data table');
|
|
||||||
|
|
||||||
table.append(tbody);
|
table.append(tbody);
|
||||||
tableDiv.append(table);
|
tableDiv.append(table);
|
||||||
|
|
||||||
|
@ -811,17 +799,6 @@ function prepareTableForDataTablePagination(jsonData){
|
||||||
// "aLengthMenu" : [5,10,15],
|
// "aLengthMenu" : [5,10,15],
|
||||||
"fnDrawCallback": function () {
|
"fnDrawCallback": function () {
|
||||||
|
|
||||||
/*
|
|
||||||
* To highlight the rows belonging to selected entities.
|
|
||||||
* */
|
|
||||||
$('input.if_clicked_on_school').bind('click', function () {
|
|
||||||
if ($(this).is(':checked')) {
|
|
||||||
$(this).closest("tr").addClass('datatablerowhighlight')
|
|
||||||
} else {
|
|
||||||
$(this).closest("tr").removeClass('datatablerowhighlight')
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/* We check whether max number of allowed comparisions (currently 10) is reached
|
/* We check whether max number of allowed comparisions (currently 10) is reached
|
||||||
* here as well becasue the only function that is guaranteed to be called during
|
* here as well becasue the only function that is guaranteed to be called during
|
||||||
* page navigation is this. No need to bind it to the nav-buttons becuase 1. It is over-ridden
|
* page navigation is this. No need to bind it to the nav-buttons becuase 1. It is over-ridden
|
||||||
|
@ -834,6 +811,7 @@ function prepareTableForDataTablePagination(jsonData){
|
||||||
// "bAutoWidth": false
|
// "bAutoWidth": false
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
var searchInputBox = $("." + searchBarParentContainerDIVClass).find("input[type=text]");
|
var searchInputBox = $("." + searchBarParentContainerDIVClass).find("input[type=text]");
|
||||||
|
|
||||||
searchInputBox.after("<span id='reset-search' title='Clear Search query'>X</span>");
|
searchInputBox.after("<span id='reset-search' title='Clear Search query'>X</span>");
|
||||||
|
@ -920,7 +898,6 @@ function disableUncheckedEntities(){
|
||||||
* Note that the usual Error message will still display if the user tries to click on the white box
|
* Note that the usual Error message will still display if the user tries to click on the white box
|
||||||
* (or a disabled checkbox in case of non-IE browsers).
|
* (or a disabled checkbox in case of non-IE browsers).
|
||||||
* */
|
* */
|
||||||
|
|
||||||
if ($("#datatable").data("isEntitySelectionAllowed")) {
|
if ($("#datatable").data("isEntitySelectionAllowed")) {
|
||||||
if ($.browser.msie) {
|
if ($.browser.msie) {
|
||||||
createNotification("warning-notification", { title:'Information',
|
createNotification("warning-notification", { title:'Information',
|
||||||
|
|
|
@ -94,8 +94,6 @@ var subOrganizationTemporalGraphURL = "${subOrganizationTemporalGraphURL}";
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
|
||||||
//$(".ellipsis").ellipsis();
|
|
||||||
|
|
||||||
var jsonString = '${jsonContent}';
|
var jsonString = '${jsonContent}';
|
||||||
var organizationLabel = '${organizationLabel}';
|
var organizationLabel = '${organizationLabel}';
|
||||||
|
|
||||||
|
@ -163,108 +161,135 @@ var subOrganizationTemporalGraphURL = "${subOrganizationTemporalGraphURL}";
|
||||||
|
|
||||||
//parse the json object and pass it to loadData
|
//parse the json object and pass it to loadData
|
||||||
jsonObject.prepare(jQuery.parseJSON(jsonString));
|
jsonObject.prepare(jQuery.parseJSON(jsonString));
|
||||||
|
|
||||||
|
function performEntityCheckboxUnselectedActions(entity, checkboxValue, checkbox) {
|
||||||
|
|
||||||
|
removeUsedColor(entity);
|
||||||
|
removeEntityUnChecked(renderedObjects, entity);
|
||||||
|
removeLegendRow(checkbox);
|
||||||
|
removeCheckBoxFromGlobalSet(checkbox);
|
||||||
|
|
||||||
|
checkbox.closest("tr").removeClass('datatablerowhighlight');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function performEntityCheckboxSelectedActions(entity, checkboxValue, checkbox) {
|
||||||
|
|
||||||
|
getNextFreeColor(entity);
|
||||||
|
|
||||||
|
//Generate the bar, checkbox and label for the legend.
|
||||||
|
createLegendRow(entity, $("#bottom"));
|
||||||
|
|
||||||
|
renderLineGraph(renderedObjects, entity);
|
||||||
|
labelToCheckedEntities[checkboxValue] = checkbox;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* To highlight the rows belonging to selected entities.
|
||||||
|
* */
|
||||||
|
checkbox.closest("tr").addClass('datatablerowhighlight');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function performEntityCheckboxClickedRedrawActions() {
|
||||||
|
|
||||||
|
setTickSizeOfAxes();
|
||||||
|
checkIfColorLimitIsReached();
|
||||||
|
displayLineGraphs();
|
||||||
|
updateCounter();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* function to populate the labelToEntityRecord object with the
|
* function to populate the labelToEntityRecord object with the
|
||||||
* values from the json file and
|
* values from the json file and
|
||||||
* dynamically generate checkboxes
|
* dynamically generate checkboxes
|
||||||
*/
|
*/
|
||||||
function loadData(jsonData){
|
function loadData(jsonData) {
|
||||||
|
|
||||||
// var yearRange;
|
|
||||||
|
|
||||||
$.each(jsonData, function(index, val){
|
|
||||||
setOfLabels.push(val.label);
|
|
||||||
labelToEntityRecord[val.label] = val;
|
|
||||||
});
|
|
||||||
|
|
||||||
getEntityVisMode(jsonData);
|
|
||||||
prepareTableForDataTablePagination(jsonData);
|
|
||||||
setEntityLevel();
|
|
||||||
// calcMinandMaxYears(labelToEntityRecord, year);
|
|
||||||
//yearRange = (year.max - year.min);
|
|
||||||
|
|
||||||
// setLineWidthAndTickSize(yearRange, FlotOptions);
|
|
||||||
//setTickSizeOfYAxis(calcMaxOfComparisonParameter(labelToEntityRecord), FlotOptions);
|
|
||||||
|
|
||||||
|
|
||||||
$(".disabled-checkbox-event-receiver").live("click", function() {
|
|
||||||
|
|
||||||
if ($(this).next().is(':disabled')) {
|
|
||||||
|
|
||||||
createNotification("error-notification", { title:'Error',
|
|
||||||
text:'A Maximum 10 entities can be compared. Please remove some & try again.' },{
|
|
||||||
custom: true,
|
|
||||||
expires: 3500
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
// var yearRange;
|
||||||
|
$.each(jsonData, function (index, val) {
|
||||||
|
setOfLabels.push(val.label);
|
||||||
});
|
labelToEntityRecord[val.label] = val;
|
||||||
|
});
|
||||||
/*
|
|
||||||
* When the elements in the paginated div
|
|
||||||
* are clicked this event handler is called
|
|
||||||
*/
|
|
||||||
$("input.if_clicked_on_school").live('click', function(){
|
|
||||||
|
|
||||||
var checkbox = $(this);
|
|
||||||
var checkboxValue = $(this).attr("value");
|
|
||||||
var entity = labelToEntityRecord[checkboxValue];
|
|
||||||
|
|
||||||
if (checkbox.is(':checked')) {
|
|
||||||
|
|
||||||
getNextFreeColor(entity);
|
|
||||||
|
|
||||||
//Dynamically generate the bar, checkbox and label.
|
|
||||||
createLegendRow(entity, $("#bottom"));
|
|
||||||
|
|
||||||
renderLineGraph(renderedObjects, entity);
|
|
||||||
labelToCheckedEntities[checkboxValue] = checkbox;
|
|
||||||
|
|
||||||
} else if (!checkbox.is(':checked')) {
|
|
||||||
|
|
||||||
removeUsedColor(entity);
|
getEntityVisMode(jsonData);
|
||||||
removeEntityUnChecked(renderedObjects, entity);
|
prepareTableForDataTablePagination(jsonData);
|
||||||
removeLegendRow(checkbox);
|
setEntityLevel();
|
||||||
removeCheckBoxFromGlobalSet(checkbox);
|
|
||||||
|
/*
|
||||||
}
|
calcMinandMaxYears(labelToEntityRecord, year);
|
||||||
//console.log('Number of checked entities: ' + getSize(labelToCheckedEntities));
|
yearRange = (year.max - year.min);
|
||||||
//disableUncheckedEntities();
|
|
||||||
setTickSizeOfAxes();
|
setLineWidthAndTickSize(yearRange, FlotOptions);
|
||||||
checkIfColorLimitIsReached();
|
setTickSizeOfYAxis(calcMaxOfComparisonParameter(labelToEntityRecord), FlotOptions);
|
||||||
//populateMapOfCheckedEntities();
|
*/
|
||||||
displayLineGraphs();
|
|
||||||
updateCounter();
|
$(".disabled-checkbox-event-receiver").live("click", function () {
|
||||||
|
|
||||||
|
if ($(this).next().is(':disabled')) {
|
||||||
|
|
||||||
|
createNotification("error-notification", {
|
||||||
|
title: 'Error',
|
||||||
|
text: 'A Maximum 10 entities can be compared. Please remove some & try again.'
|
||||||
|
}, {
|
||||||
|
custom: true,
|
||||||
|
expires: 3500
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
/*
|
||||||
|
* When the elements in the paginated div
|
||||||
|
* are clicked this event handler is called
|
||||||
|
*/
|
||||||
|
$("input.if_clicked_on_school").live('click', function () {
|
||||||
|
|
||||||
|
var checkbox = $(this);
|
||||||
|
var checkboxValue = $(this).attr("value");
|
||||||
|
var entity = labelToEntityRecord[checkboxValue];
|
||||||
|
|
||||||
|
if (checkbox.is(':checked')) {
|
||||||
|
|
||||||
|
performEntityCheckboxSelectedActions(entity, checkboxValue, checkbox);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
performEntityCheckboxUnselectedActions(entity, checkboxValue, checkbox);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
performEntityCheckboxClickedRedrawActions();
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
This will make sure that top 3 entites are selected by default when the page loads.
|
||||||
|
|
||||||
|
*/
|
||||||
|
$.each($("input.if_clicked_on_school"), function(index, checkbox) {
|
||||||
|
|
||||||
|
if (index > 2) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$(this).attr('checked', true);
|
||||||
|
|
||||||
|
var checkboxValue = $(this).attr("value");
|
||||||
|
var entity = labelToEntityRecord[checkboxValue];
|
||||||
|
|
||||||
|
performEntityCheckboxSelectedActions(entity, checkboxValue, $(this));
|
||||||
|
|
||||||
|
performEntityCheckboxClickedRedrawActions();
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
|
||||||
|
|
||||||
.ellipsis {
|
|
||||||
white-space: nowrap;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
.entity-label-url {
|
|
||||||
width: 125px;
|
|
||||||
margin-right: 10px;
|
|
||||||
display:inline-block;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ellipsis.multiline {
|
|
||||||
white-space: normal;
|
|
||||||
}
|
|
||||||
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<div id="body">
|
<div id="body">
|
||||||
|
|
||||||
<h2 style="width: 36%; padding-left:45px;"><a href="" id = "organizationMoniker"></a></h2>
|
<h2 style="width: 36%; padding-left:45px;"><a href="" id = "organizationMoniker"></a></h2>
|
||||||
|
@ -336,9 +361,5 @@ var subOrganizationTemporalGraphURL = "${subOrganizationTemporalGraphURL}";
|
||||||
id="total">10</span> <span id="entityleveltext"> schools</span> to compare.</p>
|
id="total">10</span> <span id="entityleveltext"> schools</span> to compare.</p>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
Loading…
Add table
Reference in a new issue