' +
'' + dom.firstFilterLabel + ''+
/* This is temporary removed due to the person's publications mapping rate is too low to be displayed.
' | ' +
'' + dom.secondFilterLabel + '' +
*/
'
');
var rowsToInsert = [];
var i = 0;
$.each(me.subEntities, function(index, item) {
rowsToInsert[i++] = '
' + item.type + '
';
rowsToInsert[i++] = '
';
rowsToInsert[i++] = '
' + item.label + '
';
rowsToInsert[i++] = '
' + item.pubs + '
';
});
tbody.append(rowsToInsert.join(''));
table.append(tbody);
me.tableDiv.append(table);
table.children("tbody").children("tr").mouseenter(function() {
var item = me.subEntities[$(this).attr("id")];
me.sciMapWidget.mouseIn(item.type, item.label);
});
table.children("tbody").children("tr").mouseleave(function() {
var item = me.subEntities[$(this).attr("id")];
me.sciMapWidget.mouseOut(item.type, item.label);
});
$('.chk').click(function() {
var element = $(this);
var index = element.attr("value");
var item = me.subEntities[index];
var color = "grey";
if (element.attr('checked')) {
if ($("input:checkbox[class=chk]:checked").length > 3) {
element.attr('checked', false);
alert(i18nStrings.maxNbrForComp);
} else {
me.loadEntity(item.uri, index);
}
} else {
me.unloadEntity(item.type, item.label, index);
}
});
/*
* GMAIL_STYLE_PAGINATION_CONTAINER_CLASS, ACTIVE_DISCIPLINE_SUBDISCIPLINE_FILTER has to be declared
* for the filter & pagination to work properly.
* */
GMAIL_STYLE_PAGINATION_CONTAINER_CLASS = me.dom.paginationContainerClass;
ACTIVE_DISCIPLINE_SUBDISCIPLINE_FILTER = me.currentSelectedFilter;
if($.inArray(disciplineOrSubdisciplineDataTableFilter, $.fn.dataTableExt.afnFiltering) < 0) {
$.fn.dataTableExt.afnFiltering.push(disciplineOrSubdisciplineDataTableFilter);
}
me.widget = table.dataTable({
"sDom": '<"' + me.dom.searchBarParentContainerClass
+ '"f><"filterInfo"i><"'
+ me.dom.paginationContainerClass + '"p><"table-separator"><"datatablewrapper"t>',
"aaSorting": [
[3, "desc"], [2,'asc']
],
"asStripClasses": [],
"aoColumns": [{ "bVisible": false, "bSearchable": false },
null,
null,
null],
"iDisplayLength": 10,
"bInfo": true,
"oLanguage": {
"sInfo": "_START_ - _END_ of _TOTAL_",
"sInfoEmpty": i18nStrings.noMatchingScienceAreas,
"sInfoFiltered": ""
},
"sPaginationType": "gmail_style",
"fnDrawCallback": function () {
/* 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
* page navigation is this. No need to bind it to the nav-buttons becuase 1. It is over-ridden
* by built-in navigation events & this is much cleaner.
* */
// checkIfColorLimitIsReached();
}
});
/* Create search box */
var searchInputBox = $("." + me.dom.searchBarParentContainerClass).find("input[type=text]");
searchInputBox.css("width", "140px");
searchInputBox.after("X"
+ "");
$("#comparison-reset-search").live('click', function() {
me.widget.fnFilter("");
});
createToolTip($("#comparisonSearchInfoIcon"), $("#comparisonSearchInfoTooltipText").html(), "topLeft");
/* Create csv download button */
var csvButton = '';
me.tableDiv.append(csvButton);
},
changeFilter: function(filterType) {
var me = this;
if (filterType === COMPARISON_TYPE.ORGANIZATION) {
$("#comparison-science-areas-th").html(i18nStrings.organizationString);
me.currentSelectedFilter = COMPARISON_TYPE.ORGANIZATION;
} else {
$("#comparison-science-areas-th").html(i18nStrings.personString);
me.currentSelectedFilter = COMPARISON_TYPE.PERSON;
}
ACTIVE_DISCIPLINE_SUBDISCIPLINE_FILTER = me.currentSelectedFilter;
if (me.widget) {
me.widget.fnDraw();
// load one item if no item is selected. Need to be improved
if ($("input:checkbox[class=chk]:checked").length == 0) {
$("input:checkbox[class=chk]").each(function(){
var item = me.subEntities[$(this).attr("value")];
if (item.type == me.currentSelectedFilter) {
// click event didn't work at this point???
$(this).click();
me.loadEntity(item.uri, $(this).attr("value"));
return false;
}
});
}
}
},
loadEntity: function(uri, index) {
// Download data from server and add to markerManager if not gotten already
var me = this;
var url = scienceMapDataPrefix + uri;
downloader.downloadAndWait(url, function(data) {
me.sciMapWidget.loadEntity(data[0]);
// This is ugly, need fix!!!
var color = me.sciMapWidget.getColor(me.currentSelectedFilter, me.subEntities[index].label);
$("#comparisonTbody > tr[id=" + index + "]").css("color", color);
me.entityTablesWidget.loadEntity(data[0], color);
});
},
unloadEntity: function(key, childKey, index) {
this.sciMapWidget.unloadEntity(key, childKey);
this.entityTablesWidget.unloadEntity(childKey);
// This is ugly, need fix!!!
$("#comparisonTbody > tr[id=" + index + "]").css("color", "grey");
}
});