Check in map of science's comparison view for 1.4 release testing

Remaining works:
- support csv download for sub-entity
- show sub-entity mapping results
This commit is contained in:
kongchinhua 2011-11-07 05:34:58 +00:00
parent 60a87403d1
commit be65655c7e
14 changed files with 895 additions and 316 deletions

View file

@ -0,0 +1,267 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
var ComparisonDataTableWidget = Class.extend({
dom: {
searchBarParentContainerClass : "comparisonSearchbar",
paginationContainerClass : "paginatedtabs",
containerID: "main-science-areas-table-container",
footerID: "main-science-areas-table-footer",
firstFilterID: "comparison-first-filter",
secondFilterID: "comparison-second-filter",
filterOptionClass: "comparison-filter-option",
activeFilterClass: "comparison-active-filter",
filterInfoIconClass: "comparisonFilterInfoIcon"
},
init: function(sciMapWidget) {
var me = this;
me.sciMapWidget = sciMapWidget;
me.widgetType = "COMPARISON_SCIENCE_AREAS";
me.currentSelectedFilter = COMPARISON_TYPE.ORGANIZATION;
me.widget = '';
me.tableDiv = $('<div />');
$("#" + me.dom.containerID).append(this.tableDiv);
},
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.subEntities = data.subEntities;
me.setupView();
},
hasKey: function(key) {
return (this.keyToMarkerManagers.hasOwnProperty(key));
},
show: function(key) {
this.tableDiv.show();
},
hide: function(key) {
this.tableDiv.hide();
},
cleanView: function() {
this.hide();
},
initView: function() {
this.show();
this.changeFilter(this.currentSelectedFilter);
},
setupView: function() {
var me = this;
/* Create filter */
var dom = me.dom;
var filter = $('<div class="science-areas-filter">' +
'<span id="' + dom.firstFilterID + '" class="' + dom.filterOptionClass + ' ' + dom.activeFilterClass + '">Organizations</span> | ' +
'<span id="' + dom.secondFilterID + '" class="' + dom.filterOptionClass + '">People</span>' +
'<img class="' + dom.filterInfoIconClass + '" id="comparisonImageIconTwo" src="'+ infoIconUrl +'" alt="information icon" title="" /></div>');
me.tableDiv.append(filter);
createToolTip($("#comparisonImageIconTwo"), $("#comparisonToolTipTwo").html(), "topLeft");
initFilter(dom);
/* Create table */
var table = $('<table>');
table.attr('id', 'comparisonDatatable');
table.addClass('datatable-table');
var thead = $('<thead>');
var tr = $('<tr>');
var levelOfScienceAreaTH = $('<th>');
levelOfScienceAreaTH.html('Entity Type');
var checkBoxTH = $('<th>');
checkBoxTH.html('');
var scienceAreasTH = $('<th>');
scienceAreasTH.attr("id", "comparison-science-areas-th");
if (this.currentSelectedFilter === COMPARISON_TYPE.ORGANIZATION ) {
scienceAreasTH.html('Organization');
} else {
scienceAreasTH.html('Person');
}
var activityCountTH = $('<th>');
activityCountTH.html('# of pubs.');
activityCountTH.attr("id", "activity-count-column");
tr.append(levelOfScienceAreaTH);
tr.append(checkBoxTH);
tr.append(scienceAreasTH);
tr.append(activityCountTH);
thead.append(tr);
table.append(thead);
var tbody = $('<tbody id="comparisonTbody">');
var rowsToInsert = [];
var i = 0;
$.each(me.subEntities, function(index, item) {
rowsToInsert[i++] = '<tr id="' + index + '" style="color: grey;"><td>' + item.type + '</td>';
rowsToInsert[i++] = '<td><input class="chk" type="checkbox" value="' + index + '"/></td>';
rowsToInsert[i++] = '<td>' + item.label + '</td>';
rowsToInsert[i++] = '<td>' + item.pubs.toFixed(2) + '</td></tr>';
});
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("The maximum number of items for comparison is 3.");
} 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": "No matching science areas found",
"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("<span id='comparison-reset-search' title='Clear search query'>X</span>"
+ "<img class='comparisonFilterInfoIcon' id='comparisonSearchInfoIcon' src='" + infoIconUrl + "' alt='information icon' title='' />");
$("#comparison-reset-search").live('click', function() {
me.widget.fnFilter("");
});
createToolTip($("#comparisonSearchInfoIcon"), $("#comparisonSearchInfoTooltipText").html(), "topLeft");
/* Create csv download button */
var csvButton = '<hr class="subtle-hr"/><div id="main-science-areas-table-footer"><a id="csv" href="' +
entityMapOfScienceSubDisciplineCSVURL +
'" class="map-of-science-links">Save All as CSV</a></div>';
me.tableDiv.append(csvButton);
/* Create mapping statistic result */
var totalPublications = me.pubsWithNoJournals + me.pubsWithInvalidJournals + me.pubsMapped;
$("#mapped-publications").text(addCommasToNumber(me.pubsMapped));
$("#percent-mapped-info").show();
$("#percent-mapped").text((100 * me.pubsMapped / totalPublications).toFixed(2));
$("#total-publications").text(addCommasToNumber(totalPublications));
},
changeFilter: function(filterType) {
var me = this;
if (filterType === COMPARISON_TYPE.ORGANIZATION) {
$("#comparison-science-areas-th").html("Organization");
me.currentSelectedFilter = COMPARISON_TYPE.ORGANIZATION;
$("a#csv").attr("href", entityMapOfScienceSubDisciplineCSVURL);
} else {
$("#comparison-science-areas-th").html("Person");
me.currentSelectedFilter = COMPARISON_TYPE.PERSON;
$("a#csv").attr("href", entityMapOfScienceDisciplineCSVURL);
}
ACTIVE_DISCIPLINE_SUBDISCIPLINE_FILTER = me.currentSelectedFilter;
if (me.widget) {
me.widget.fnSettings()._iDisplayLength = 10;
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.download(url, function(data) {
me.sciMapWidget.loadEntity(data[0]);
// This is ugly, need fix!!!
$("#comparisonTbody > tr[id=" + index + "]").css("color", me.sciMapWidget.getColor(me.currentSelectedFilter, me.subEntities[index].label));
});
},
unloadEntity: function(key, childKey, index) {
this.sciMapWidget.unloadEntity(key, childKey);
// This is ugly, need fix!!!
$("#comparisonTbody > tr[id=" + index + "]").css("color", "grey");
}
});

View file

@ -0,0 +1,249 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
COMPARISON = {
"one":{ "name": "one", "color": "#1e90ff"},
"two":{ "name": "two", "color": "#ff69b4"},
"three":{ "name": "three", "color": "#32cd32"}
}
COMPARISON_TYPE = {
"ORGANIZATION": "ORGANIZATION",
"PERSON": "PERSON"
}
var ManagerRegistry = Class.extend({
init: function(itemArray) {
this.occupied = {};
this.availability = itemArray;
},
register: function(key) {
var me = this;
if (me.occupied[key] == null && me.isAvailable()) {
me.occupied[key] = me.availability.pop();
}
return me.occupied[key];
},
unregister: function(key) {
var me = this;
var item = me.occupied[key];
if (item) {
me.availability.push(me.occupied[key]);
delete me.occupied[key];
}
return item;
},
isAvailable: function() {
return (this.availability.length != 0);
}
});
var ComparisonScimapWidget = Class.extend({
init: function(map) {
var me = this;
me.activeCompositeManager = null;
me.map = map;
me.initView();
},
initView: function(){
var me = this;
me.initControlPanels();
me.initMarkerManagers();
me.show(COMPARISON_TYPE.ORGANIZATION);
this.activeCompositeManager.addManagersToMap();
this.updateDisplayedMarkers();
},
cleanView: function() {
var me = this;
me._cleanUpManagers();
me.sliderControl.removeFromMap();
me.disciplineLabelsControl.removeFromMap();
me.labelsMarkerManager.removeMarkersFromMap();
},
initControlPanels: function() {
var me = this;
/* Create slider control panel */
if (me.sliderControl == null) {
me.sliderControl = new SliderControlPanel({
map:me.map,
controlPositions: google.maps.ControlPosition.RIGHT_BOTTOM
});
}
/* Register event */
me.sliderControl.addToMap();
me.sliderControl.setChangeEventHandler(function(event, ui) {
if (me.keyToCompositeManager) {
me.updateDisplayedMarkers();
}
});
/* create */
if (me.disciplineLabelsControl == null) {
me.labelsMarkerManager = new DisciplineLabelsMarkerManager(map);
me.disciplineLabelsControl = new CheckBoxPanel({
map: map,
checked: true,
text: "Show discipline labels",
click: function() {
if($(this).attr('checked')) {
me.labelsMarkerManager.showMarkers();
} else {
me.labelsMarkerManager.hideMarkers();
}
}
});
}
/* Display labels if checked */
me.disciplineLabelsControl.addToMap();
me.labelsMarkerManager.addMarkersToMap();
if (me.disciplineLabelsControl.isChecked()) {
me.labelsMarkerManager.showMarkers();
}
},
initMarkerManagers: function() {
if (this.keyToCompositeManager == null) {
// Create all the marker managers
var me = this;
me.keyToCompositeManager = {};
$.each(COMPARISON_TYPE, function(type, value) {
var managerArray = [];
$.each(COMPARISON, function(key, attrs) {
var manager = new SubdisciplineMarkerManager(
me.map,
new SingleColorStrategy(attrs.color),
null
);
manager.color = attrs.color;
managerArray.push(manager);
});
me.keyToCompositeManager[type] = new CompositeMarkerManager();
me.keyToCompositeManager[type].registry = new ManagerRegistry(managerArray);
});
}
},
loadJsonData: function(data) {
this.isUnloaded = false;
},
loadEntity: 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;
var scienceActivities = data.subdisciplineActivity;
var childKey = data.label;
var compositeManager = me.getCompositeManager(data.type);
// Avoid reload if data was loaded
if (compositeManager.hasKey(childKey)) {
me.updateMap();
} else {
var manager = compositeManager.registry.register(childKey);
if (manager) {
// clean previous markers
manager.removeAll();
// Need to create the AreaSizeCoding function
manager.setSizeCoder(new CircleSizeCoder({
scaler: new Scaler({ maxValue: me.pubsMapped })
}));
$.each(scienceActivities, function(science, density) {
// Create marker and add it to manager
manager.createMarker(science, density);
}); // end each scienceActivity
manager.sort();
compositeManager.addManager(childKey, manager);
me.updateMap();
}
}
},
unloadEntity: function(key, childKey) {
this.removeManager(key, childKey);
},
getCompositeManager: function(key) {
return this.keyToCompositeManager[key];
},
mouseIn: function(key, childKey) {
var compositeManager = this.getCompositeManager(key);
// Focus if only it is a valid manager
if (compositeManager == this.activeCompositeManager) {
// Focus all
compositeManager.mouseIn(childKey);
}
},
mouseOut: function(key, childKey) {
var compositeManager = this.getCompositeManager(key);
// Unfocus if only it is a valid manager
if (compositeManager == this.activeCompositeManager) {
// Unfocus all
compositeManager.mouseOut(childKey);
}
},
removeManager: function(key, childKey) {
var compositeManager = this.getCompositeManager(key);
// Remove manager
if (compositeManager == this.activeCompositeManager) {
this.activeCompositeManager.removeManager(childKey);
this.activeCompositeManager.registry.unregister(childKey);
}
},
show: function(key) {
var compositeManager = this.getCompositeManager(key);
if (compositeManager) {
this._switchActiveCompositeManager(compositeManager);
}
},
hide: function(key) {
var compositeManager = this.getCompositeManager(key);
if (this.activeCompositeManager == compositeManager) {
this._cleanupMarkers();
}
},
_switchActiveCompositeManager: function(compositeManager) {
if (this.activeCompositeManager != compositeManager) {
this._cleanUpManagers();
compositeManager.addManagersToMap();
this.activeCompositeManager = compositeManager;
this.updateMap();
}
},
_cleanUpManagers: function() {
if (this.activeCompositeManager) {
this.activeCompositeManager.removeManagersFromMap();
INFO_WINDOW.close();
}
},
updateDisplayedMarkers: function() {
this.activeCompositeManager.display(this.sliderControl.getValue());
},
updateMap: function() {
var compositeManager = this.activeCompositeManager;
if (compositeManager) {
var length = compositeManager.length();
var slider = this.sliderControl;
slider.setMin(Math.min(1, length));
slider.setMax(length);
slider.setValue(length);
}
},
changeFilter: function(filterType) {
this.show(filterType);
},
getColor: function(key, childKey) {
return this.getCompositeManager(key).registry.register(childKey).color;
}
});

View file

@ -26,19 +26,20 @@ var ScinodePolygon = CirclePolygon.extend({
registerEvents : function() {
var me = this;
var polygon = me.polygon;
this._super();
this.registerEvent(addClickListener(polygon, function() {
me._super();
me.registerEvent(addClickListener(polygon, function() {
INFO_WINDOW.setPosition(this.center);
var content = this.content;
INFO_WINDOW.setContent(content);
INFO_WINDOW.open(this.map);
}));
this.registerEvent(addMouseOverListener(polygon, function() {
me.registerEvent(addMouseOverListener(polygon, function() {
me.focus();
}));
this.registerEvent(addMouseOutListener(polygon, function() {
me.registerEvent(addMouseOutListener(polygon, function() {
me.unfocus();
}));
}

View file

@ -2,30 +2,27 @@
var DataTableWidget = Class.extend({
widgetType: "MAIN_SCIENCE_AREAS",
currentSelectedFilter: SCIMAP_TYPE.DISCIPLINE,
dom: {
searchBarParentContainerClass : "searchbar",
paginationContainerClass : "paginatedtabs",
containerID: "main-science-areas-table-container",
footerID: "main-science-areas-table-footer",
disciplineFilterID: "discipline-filter",
subdisciplinesFilterID: "subdisciplines-filter",
firstFilterID: "first-filter",
secondFilterID: "second-filter",
filterOptionClass: "filter-option",
activeFilterClass: "active-filter"
activeFilterClass: "active-filter",
filterInfoIconClass: "filterInfoIcon"
},
widget: '',
init: function(sciMapWidget) {
this.sciMapWidget = sciMapWidget;
this.subdisciplineInfo = {};
this.disciplineInfo = {};
var me = this;
me.sciMapWidget = sciMapWidget;
me.widgetType = "MAIN_SCIENCE_AREAS";
me.currentSelectedFilter = SCIMAP_TYPE.SUBDISCIPLINE;
me.subdisciplineInfo = {};
me.disciplineInfo = {};
me.widget = '';
me.tableDiv = $('<div />');
$("#" + me.dom.containerID).append(this.tableDiv);
$.each(DISCIPLINES, function(index, item) {
var emptyScienceAreaElement = {
@ -42,7 +39,6 @@ var DataTableWidget = Class.extend({
};
me.subdisciplineInfo[index] = emptyScienceAreaElement;
});
},
loadJsonData: function(data) {
@ -74,12 +70,17 @@ var DataTableWidget = Class.extend({
return (this.keyToMarkerManagers.hasOwnProperty(key));
},
show: function(key) {
this.tableDiv.show();
},
hide: function(key) {
this.tableDiv.hide();
},
cleanUp: function() {
cleanView: function() {
this.hide();
},
initView: function() {
this.show();
this.changeFilter(me.currentSelectedFilter);
},
parseIDIntoScienceTypeAreaID: function(rawID) {
@ -92,6 +93,15 @@ var DataTableWidget = Class.extend({
var me = this;
var dom = me.dom;
var filter = $('<div class="science-areas-filter">' +
'<span id="' + dom.firstFilterID + '" class="' + dom.filterOptionClass + ' ' + dom.activeFilterClass + '">Sub-Disciplines</span> | ' +
'<span id="' + dom.secondFilterID + '" class="' + dom.filterOptionClass + '">Disciplines</span>' +
'<img class="'+ dom.filterInfoIconClass +'" id="imageIconTwo" src="'+ infoIconUrl +'" alt="information icon" title="" /></div>');
me.tableDiv.append(filter);
createToolTip($("#imageIconTwo"), $('#toolTipTwo').html(), "topLeft");
initFilter(dom);
var table = $('<table>');
table.attr('id', 'datatable');
table.addClass('datatable-table');
@ -150,7 +160,7 @@ var DataTableWidget = Class.extend({
tbody.append(rowsToInsert.join(''));
table.append(tbody);
$("#" + me.dom.containerID).append(table);
me.tableDiv.append(table);
table.children("tbody").children("tr").mouseenter(function() {
@ -208,16 +218,18 @@ var DataTableWidget = Class.extend({
var searchInputBox = $("." + me.dom.searchBarParentContainerClass).find("input[type=text]");
searchInputBox.css("width", "140px");
searchInputBox.after("<span id='reset-search' title='Clear search query'>X</span>"
+ "<img class='filterInfoIcon' id='searchInfoIcon' src='" + baseImageFolderPrefix + "/iconInfo.png' alt='information icon' title='' />");
+ "<img class='filterInfoIcon' id='searchInfoIcon' src='" + infoIconUrl + "' alt='information icon' title='' />");
$("#reset-search").live('click', function() {
me.widget.fnFilter("");
});
createToolTip($("#searchInfoIcon"), $('#searchInfoTooltipText').html(), "topLeft");
var csvButton = '<hr class="subtle-hr"/><div id="main-science-areas-table-footer"><a id="csv" href="' +
entityMapOfScienceSubDisciplineCSVURL +
'" class="map-of-science-links">Save All as CSV</a></div>';
this.tableDiv.append(csvButton);
var totalPublications = me.pubsWithNoJournals + me.pubsWithInvalidJournals + me.pubsMapped;
$("#mapped-publications").text(addCommasToNumber(me.pubsMapped));
@ -228,7 +240,6 @@ var DataTableWidget = Class.extend({
},
changeFilter: function(filterType) {
var me = this;
if (filterType === SCIMAP_TYPE.SUBDISCIPLINE) {
$("#science-areas-th").html("Sub-Disciplines");
@ -250,6 +261,7 @@ var DataTableWidget = Class.extend({
}
ACTIVE_DISCIPLINE_SUBDISCIPLINE_FILTER = me.currentSelectedFilter;
if (me.widget) {
me.widget.fnDraw();
}

View file

@ -68,9 +68,10 @@ function initMap() {
}
function initVisModeController() {
var controller = new EntityVisModeController(map);
visModeControllers[controller.visMode] = controller;
var controller = getVisModeController(ENTITY_VIS_MODE);
switchVisMode(controller.visMode);
initVisModeTypeButton();
initGlobalToolTips();
currentController.loadData(scienceMapDataURL, false);
}

View file

@ -50,7 +50,11 @@ var Marker = Class.extend({
this.handlers = handlers;
},
unregisterEvents : function() {
removeListeners(this.handlers);
this.handlers = null;
if (this.handlers) {
$.each(this.handlers, function(i, handler) {
removeListener(handler);
});
this.handlers = null;
}
}
});

View file

@ -47,6 +47,10 @@ var MarkerManager = Class.extend({
$.each(this.keyToMarker, function(i, marker) {
marker.removeFromMap();
});
},
removeAll: function() {
this.removeMarkersFromMap();
this.keyToMarker = {};
}
});
@ -204,3 +208,95 @@ var SubdisciplineMarkerManager = ScimapMarkerManager.extend({
return marker;
}
});
var CompositeMarkerManager = Class.extend({
init: function() {
this.keyToManager = {};
},
addManager: function(key, manager) {
this.keyToManager[key] = manager;
},
length: function() {
var size = 0;
$.each(this.keyToManager, function(i, manager) {
msize = manager.length();
if (size < msize) {
size = msize;
}
});
return size;
},
getManager: function(key) {
return this.keyToManager[key];
},
getManagerArray: function() {
var array = [];
$.each(this.keyToManager, function(i, e){
array.push(e);
});
return array;
},
hasKey: function(key) {
return (this.keyToManager.hasOwnProperty(key));
},
showManager: function() {
$.each(this.keyToManager, function(i, manager) {
manager.showMarkers();
});
},
hideManager: function() {
$.each(this.keyToManager, function(i, manager) {
manager.hideMarkers();
});
},
addManagersToMap: function() {
$.each(this.keyToManager, function(i, manager) {
manager.addMarkersToMap();
});
},
removeManagersFromMap: function() {
$.each(this.keyToManager, function(i, manager) {
manager.removeMarkersFromMap();
});
},
removeManager: function(key) {
if (this.hasKey(key)) {
this.getManager(key).removeAll();
delete this.keyToManager[key];
}
},
removeAll: function() {
$.each(this.keyToManager, function(i, manager) {
manager.removeAll();
});
this.keyToManager = {};
},
mouseIn: function(key) {
var manager = this.getManager(key);
if (manager) {
manager.mouseInAll();
}
},
mouseInAll: function() {
$.each(this.keyToManager, function(i, manager) {
manager.mouseInAll();
});
},
mouseOut: function(key) {
var manager = this.getManager(key);
if (manager) {
manager.mouseOutAll();
}
},
mouseOutAll: function() {
$.each(this.keyToManager, function(i, manager) {
manager.mouseOutAll();
});
},
display: function(numberOfMarkers) {
$.each(this.keyToManager, function(i, manager) {
manager.display(numberOfMarkers);
});
}
});

View file

@ -58,10 +58,12 @@ var Polygon = Class.extend({
registerEvents : function() {
},
unregisterEvents : function() {
$.each(this.handlers, function(){
removeListener(this);
});
this.handlers = null;
if (this.handlers) {
$.each(this.handlers, function(i, handler) {
removeListener(handler);
});
this.handlers = null;
}
}
});
@ -92,7 +94,6 @@ var CirclePolygon = Polygon.extend({
if (!this.isPointsCreated()) {
this.initCirclePoints();
}
this._super();
},
isPointsCreated: function() {

View file

@ -13,7 +13,15 @@ var ScimapWidget = Class.extend({
var me = this;
me.initControlPanels();
me.initMarkerManagers();
me.show(SCIMAP_TYPE.SUBDISCIPLINE);
me.activeManager.addMarkersToMap();
me.updateDisplayedMarkers();
},
cleanView: function() {
var me = this;
me._cleanUpMarkers();
me.sliderControl.removeFromMap();
me.disciplineLabelsControl.removeFromMap();
me.labelsMarkerManager.removeMarkersFromMap();
},
initControlPanels: function() {
var me = this;
@ -30,7 +38,7 @@ var ScimapWidget = Class.extend({
me.sliderControl.addToMap();
me.sliderControl.setChangeEventHandler(function(event, ui) {
if (me.keyToMarkerManagers) {
me.updateDisplayedMarkers(ui.value);
me.updateDisplayedMarkers();
}
});
@ -53,6 +61,7 @@ var ScimapWidget = Class.extend({
/* Display labels if checked */
me.disciplineLabelsControl.addToMap();
me.labelsMarkerManager.addMarkersToMap();
if (me.disciplineLabelsControl.isChecked()) {
me.labelsMarkerManager.showMarkers();
}
@ -75,6 +84,7 @@ var ScimapWidget = Class.extend({
null
);
this.keyToMarkerManagers = managers;
this.show(SCIMAP_TYPE.SUBDISCIPLINE);
}
},
needLoaded: function(){
@ -185,14 +195,8 @@ var ScimapWidget = Class.extend({
INFO_WINDOW.close();
}
},
cleanup: function() {
var me = this;
me._cleanUpMarkers();
me.sliderControl.RemoveFromMap();
me.disciplineLabelsControl.RemoveFromMap();
},
updateDisplayedMarkers: function(numberOfMarkers) {
this.activeManager.display(numberOfMarkers);
updateDisplayedMarkers: function() {
this.activeManager.display(this.sliderControl.getValue());
},
updateMap: function() {
var manager = this.activeManager;

View file

@ -14,22 +14,110 @@ function switchMarkerManager(id) {
}
}
function createVisModeController(visMode) {
if (visMode === ENTITY_VIS_MODE) {
var controller = new EntityVisModeController(map);
visModeControllers[controller.visMode] = controller;
}
if (visMode === COMPARISON_VIS_MODE) {
var controller = new ComparisonVisModeController(map);
visModeControllers[controller.visMode] = controller;
controller.loadData(scienceMapDataURL, false);
}
}
function isActiveVisMode(visMode) {
return (currentVisMode == visMode);
return (currentVisMode === visMode);
}
function getVisModeController(visMode){
if (visModeControllers[visMode] == null) {
createVisModeController(visMode);
}
return visModeControllers[visMode];
}
function switchVisMode(visMode) {
if (currentVisMode != visMode) {
currentVisMode = visMode;
if (!isActiveVisMode(visMode)) {
if (currentController) {
currentController.cleanView();
}
currentController = getVisModeController(visMode);
currentVisMode = visMode;
currentController.initView();
}
return
}
function initFilter(dom) {
// Switch filter handling
$("." + dom.filterOptionClass).live('click', function() {
var obj = $(this);
if (!obj.hasClass(dom.activeFilterClass)) {
var checked = obj.attr('id');
if (checked === dom.secondFilterID) {
$("#" + dom.firstFilterID).removeClass(dom.activeFilterClass);
currentController.changeFilter(2);
} else if (checked === dom.firstFilterID) {
$("#" + dom.secondFilterID).removeClass(dom.activeFilterClass);
currentController.changeFilter(1);
}
obj.addClass(dom.activeFilterClass);
}
});
$("#" + dom.firstFilterID).trigger('click');
}
function initVisModeTypeButton() {
// Switch vis mode handling
var viewTypeRadio = "input[name='view-type']";
$(viewTypeRadio).change( function() {
var visMode = $(viewTypeRadio+ ":checked").val();
switchVisMode(visMode);
});
/* Init default filter */
$(viewTypeRadio+ ":eq(0)").click();
}
function initGlobalToolTips() {
createToolTip($("#imageIconOne"), $('#toolTipOne').html(), "topLeft");
createToolTip($("#imageIconThree"), $('#toolTipThree').html(), "topRight");
}
function createToolTip(target, tipText, tipLocation) {
target.qtip({
content: {
text: tipText
},
position: {
corner: {
target: 'center',
tooltip: tipLocation
}
},
show: {
when: {
event: 'mouseover'
}
},
hide: {
fixed: true // Make it fixed so it can be hovered over
},
style: {
padding: '6px 6px',
// Give it some extra padding
width: 500,
textAlign: 'left',
backgroundColor: '#ffffc0',
fontSize: '.7em',
padding: '6px 10px 6px 10px',
lineHeight: '14px'
}
});
}

View file

@ -2,6 +2,8 @@
var ENTITY_VIS_MODE = "ENTITY";
var COMPARISON_VIS_MODE = "COMPARISON";
var dataMarket = {};
var VisModeController = Class.extend({
init: function(map) {
this.visMode = ENTITY_VIS_MODE;
@ -14,6 +16,47 @@ var VisModeController = Class.extend({
needLoaded: function() {
return this.isUnloaded;
},
loadData: function(url, sync) {
// Download data from server and add to markerManager if not gotten already
var me = this;
if (me.isUnloaded) {
// Lazy loading
if (!dataMarket[url]) {
if (sync) {
downloader.downloadAndWait(url, function(data) {
dataMarket[url] = data;
me.loadJsonData(me, data);
});
} else {
downloader.download(url, function(data) {
dataMarket[url] = data;
me.loadJsonData(me, data);
});
}
} else {
me.loadJsonData(me, dataMarket[url]);
}
} // end if
},
loadJsonData: function(me, data) {
$("#" + responseContainerID).unblock();
if (ERROR_DISPLAY_WIDGET.isErrorConditionTriggered(data)) {
$("#map-of-science-response").hide();
ERROR_DISPLAY_WIDGET.show(ENTITY_TYPE, data);
return;
}
data = data[0];
$.each(me.widgets, function(i, widget) {
widget.loadJsonData(data);
});
//me.initToolTipInfo();
me.isUnloaded = false;
},
initView: function() {
$.each(this.widgets, function(i, widget) {
widget.initView();
@ -30,49 +73,32 @@ var VisModeController = Class.extend({
widget.hide(key);
});
},
cleanUp: function() {
cleanView: function() {
$.each(this.widgets, function(i, widget) {
widget.cleanUp(key);
widget.cleanView();
});
}
},
changeFilter: function(value) {
var type = this.getFilterType(value);
$.each(this.widgets, function(i, widget) {
widget.changeFilter(type);
});
},
});
var EntityVisModeController = VisModeController.extend({
init: function(map) {
this._super(map);
this.visMode = ENTITY_VIS_MODE;
this.initFilter();
this.firstFilterLabel = "554 Sub-Disciplines";
this.secondFilterLabel = "13 Disciplines";
},
initFilter: function() {
var widgets = this.widgets;
var dom = {
disciplineFilterID: "discipline-filter",
subdisciplinesFilterID: "subdisciplines-filter",
filterOptionClass: "filter-option",
activeFilterClass: "active-filter"
};
$("." + dom.filterOptionClass).live('click', function() {
if (!$(this).hasClass(dom.activeFilterClass)) {
if ($(this).attr('id') === dom.subdisciplinesFilterID) {
$("#" + dom.disciplineFilterID).removeClass(dom.activeFilterClass);
$.each(widgets, function(i, widget) {
widget.changeFilter(SCIMAP_TYPE.SUBDISCIPLINE);
});
} else if ($(this).attr('id') === dom.disciplineFilterID) {
$("#" + dom.subdisciplinesFilterID).removeClass(dom.activeFilterClass);
$.each(widgets, function(i, widget) {
widget.changeFilter(SCIMAP_TYPE.DISCIPLINE);
});
}
$(this).addClass('active-filter');
}
});
/* Init default filter */
$("#" + dom.subdisciplinesFilterID).trigger('click');
getFilterType: function(value) {
if (value === 1) {
return SCIMAP_TYPE.SUBDISCIPLINE;
}
return SCIMAP_TYPE.DISCIPLINE;
},
initWidgets: function(map) {
var widgets = {};
@ -80,223 +106,27 @@ var EntityVisModeController = VisModeController.extend({
widgets['sci_area_table'] = new DataTableWidget(widgets['scimap']);
this.widgets = widgets;
},
loadData: function(url, sync) {
// Download data from server and add to markerManager if not gotten already
var me = this;
if (me.isUnloaded) {
if (sync) {
downloader.downloadAndWait(url, function(data) {
me.loadJsonData(me, data);
});
} else {
downloader.download(url, function(data) {
me.loadJsonData(me, data);
});
}
} // end if
},
loadJsonData: function(me, data) {
$("#" + responseContainerID).unblock();
if (ERROR_DISPLAY_WIDGET.isErrorConditionTriggered(data)) {
$("#map-of-science-response").hide();
ERROR_DISPLAY_WIDGET.show(ENTITY_TYPE, data);
return;
}
data = data[0];
$.each(me.widgets, function(i, widget) {
widget.loadJsonData(data);
});
me.isUnloaded = false;
me.initToolTipInfo();
},
initToolTipInfo: function() {
$('.filterInfoIcon').each(function () {
var me = $(this);
var tipText;
var tipLocation = "topLeft";
if (me.attr('id') == 'imageIconOne') {
tipText = $('#toolTipOne').html();
} else if (me.attr('id') == 'imageIconTwo') {
tipText = $('#toolTipTwo').html();
} else if (me.attr('id') == 'searchInfoIcon') {
tipText = $('#searchInfoTooltipText').html();
} else {
tipText = $('#toolTipThree').html();
tipLocation = "topRight";
}
me.qtip({
content: {
text: tipText
},
position: {
corner: {
target: 'center',
tooltip: tipLocation
}
},
show: {
when: {
event: 'mouseover'
}
},
hide: {
fixed: true // Make it fixed so it can be hovered over
},
style: {
padding: '6px 6px',
// Give it some extra padding
width: 500,
textAlign: 'left',
backgroundColor: '#ffffc0',
fontSize: '.7em',
padding: '6px 10px 6px 10px',
lineHeight: '14px'
}
});
});
}
});
var ComparisonVisModeController = Class.extend({
var ComparisonVisModeController = VisModeController.extend({
init: function(map) {
this._super(map);
this.visMode = COMPARISON_VIS_MODE;
this.initFilter();
this.firstFilterLabel = "Organizations";
this.secondFilterLabel = "People";
},
initFilter: function() {
var widgets = this.widgets;
var dom = {
disciplineFilterID: "discipline-filter",
subdisciplinesFilterID: "subdisciplines-filter",
filterOptionClass: "filter-option",
activeFilterClass: "active-filter"
};
$("." + dom.filterOptionClass).live('click', function() {
if (!$(this).hasClass(dom.activeFilterClass)) {
if ($(this).attr('id') === dom.subdisciplinesFilterID) {
$("#" + dom.disciplineFilterID).removeClass(dom.activeFilterClass);
$.each(widgets, function(i, widget) {
widget.changeFilter(SCIMAP_TYPE.SUBDISCIPLINE);
});
} else if ($(this).attr('id') === dom.disciplineFilterID) {
$("#" + dom.subdisciplinesFilterID).removeClass(dom.activeFilterClass);
$.each(widgets, function(i, widget) {
widget.changeFilter(SCIMAP_TYPE.DISCIPLINE);
});
}
$(this).addClass('active-filter');
}
});
/* Init default filter */
$("#" + dom.subdisciplinesFilterID).trigger('click');
getFilterType: function(value) {
if (value === 1) {
return COMPARISON_TYPE.ORGANIZATION;
}
return COMPARISON_TYPE.PERSON;
},
initWidgets: function(map) {
var widgets = {};
widgets['scimap'] = new ScimapWidget(map);
widgets['sci_area_table'] = new DataTableWidget(widgets['scimap']);
widgets['scimap'] = new ComparisonScimapWidget(map);
widgets['sci_area_table'] = new ComparisonDataTableWidget(widgets['scimap']);
this.widgets = widgets;
},
loadData: function(url, sync) {
// Download data from server and add to markerManager if not gotten already
var me = this;
if (me.isUnloaded) {
if (sync) {
downloader.downloadAndWait(url, function(data) {
me.loadJsonData(me, data);
});
} else {
downloader.download(url, function(data) {
me.loadJsonData(me, data);
});
}
} // end if
},
loadJsonData: function(me, data) {
$("#" + responseContainerID).unblock();
if (ERROR_DISPLAY_WIDGET.isErrorConditionTriggered(data)) {
$("#map-of-science-response").hide();
ERROR_DISPLAY_WIDGET.show(ENTITY_TYPE, data);
return;
}
data = data[0];
$.each(me.widgets, function(i, widget) {
widget.loadJsonData(data);
});
me.isUnloaded = false;
me.initToolTipInfo();
},
initToolTipInfo: function() {
$('.filterInfoIcon').each(function () {
var me = $(this);
var tipText;
var tipLocation = "topLeft";
if (me.attr('id') == 'imageIconOne') {
tipText = $('#toolTipOne').html();
} else if (me.attr('id') == 'imageIconTwo') {
tipText = $('#toolTipTwo').html();
} else if (me.attr('id') == 'searchInfoIcon') {
tipText = $('#searchInfoTooltipText').html();
} else {
tipText = $('#toolTipThree').html();
tipLocation = "topRight";
}
me.qtip({
content: {
text: tipText
},
position: {
corner: {
target: 'center',
tooltip: tipLocation
}
},
show: {
when: {
event: 'mouseover'
}
},
hide: {
fixed: true // Make it fixed so it can be hovered over
},
style: {
padding: '6px 6px',
// Give it some extra padding
width: 500,
textAlign: 'left',
backgroundColor: '#ffffc0',
fontSize: '.7em',
padding: '6px 10px 6px 10px',
lineHeight: '14px'
}
});
});
}
});