/* $This file is distributed under the terms of the license in /doc/license.txt$ */ var SimpleDataTableWidget = Class.extend({ dom: { paginationContainerClass : "subpaginatedtabs" }, init: function(options) { var me = this; me.options = options; me.sciMapWidget = options.sciMapWidget; me.currentSelectedFilter = COMPARISON_TYPE.SUBDISCIPLINE; me.widget = ''; me.tableDiv = $('
'); me.addToContainer(); }, loadJsonData: function(data) { var me = this; me.uri = data.uri; me.label = data.label; me.pubsWithNoJournals = data.pubsWithNoJournals; me.pubsWithInvalidJournals = data.pubsWithInvalidJournals; me.pubsMapped = data.pubsMapped; me.type = data.type; me.color = data.color; me.subdisciplineActivity = data.subdisciplineActivity; me.setupView(); }, addToContainer: function() { this.options.container.append(this.tableDiv); }, removeFromContainer: function() { this.tableDiv.remove(); }, hasKey: function(key) { return (this.keyToMarkerManagers.hasOwnProperty(key)); }, show: function(key) { this.tableDiv.show(); }, hide: function(key) { this.tableDiv.hide(); }, cleanView: function() { this.removeFromContainer(); }, initView: function() { this.addToContainer(this.tableDiv); this.show(); }, setupView: function() { var me = this; me.tableDiv.addClass("subEntityTable"); /* Create filter */ entityVivoProfileURLPrefix var organizationHeader = $('
' + truncateText(me.label, 23) + 'drill down
'); me.tableDiv.append(organizationHeader); /* Create table */ var table = $(''); table.attr('id', 'entityDatatable'); table.addClass('entity-datatable-table'); /* Create table header */ var thead = $(''); var tr = $(''); /*var levelOfScienceAreaTH = $(''); var rowsToInsert = []; var i = 0; $.each(me.subdisciplineActivity, function(index, density) { rowsToInsert[i++] = ''; rowsToInsert[i++] = ''; rowsToInsert[i++] = ''; }); tbody.append(rowsToInsert.join('')); table.append(tbody); me.tableDiv.append(table); /* Register events */ table.children("tbody").children("tr").mouseenter(function() { me.sciMapWidget.mouseInNode(me.type, me.label, $(this).attr("id")); }); table.children("tbody").children("tr").mouseleave(function() { me.sciMapWidget.mouseOutNode(me.type, me.label, $(this).attr("id")); }); /* Init DataTable object */ me.widget = table.dataTable({ "sDom": '<"' + me.dom.paginationContainerClass + '"p><"table-separator"><"datatablewrapper"t>', "aaSorting": [ [1, "desc"], [0,'asc'] ], "asStripClasses": [], "aoColumns": [{ "bSearchable": false }, { "bSearchable": false }], "iDisplayLength": 10, "bInfo": true, "bFilter": false, "oLanguage": { "sInfo": "_START_ - _END_ of _TOTAL_", "sInfoEmpty": "No matching science areas found", "sInfoFiltered": "" }, "sPaginationType": "gmail_style", "fnDrawCallback": function () { } }); /* Create csv download button */ var csvButton = '
'; me.tableDiv.append(csvButton); /* Create mapping statistic result */ var totalPublications = me.pubsWithNoJournals + me.pubsWithInvalidJournals + me.pubsMapped; var mappedText = '' + (100 * me.pubsMapped / totalPublications).toFixed(2) + '% mapped'; me.tableDiv.append($(mappedText)); me.widget.fnDraw(); } }); function truncateText(text, len) { var trunc = text; if (text.length > len) { trunc = text.substring(0, len); trunc = trunc.replace(/\w+$/, '') + '...' } return trunc; }
'); levelOfScienceAreaTH.html('Level of Science Area');*/ var scienceAreasTH = $(''); scienceAreasTH.attr("id", "entity-science-areas-th"); scienceAreasTH.html('Subdisciplines'); var activityCountTH = $(''); activityCountTH.html('# of pubs.'); //tr.append(levelOfScienceAreaTH); tr.append(scienceAreasTH); tr.append(activityCountTH); thead.append(tr); table.append(thead); /* Create tbody and contents */ var tbody = $('
' + truncateText(SUBDISCIPLINES[index].label, 20) + '' + density.toFixed(1) + '