2011-07-13 20:25:50 +00:00
|
|
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
|
|
|
var ENTITY_VIS_MODE = "ENTITY";
|
2011-11-02 01:04:53 +00:00
|
|
|
var COMPARISON_VIS_MODE = "COMPARISON";
|
2011-07-13 20:25:50 +00:00
|
|
|
|
2011-11-07 05:34:58 +00:00
|
|
|
var dataMarket = {};
|
|
|
|
|
2011-11-02 01:04:53 +00:00
|
|
|
var VisModeController = Class.extend({
|
|
|
|
init: function(map) {
|
2011-07-13 20:25:50 +00:00
|
|
|
this.visMode = ENTITY_VIS_MODE;
|
|
|
|
this.isUnloaded = true;
|
2011-11-02 01:04:53 +00:00
|
|
|
this.initWidgets(map);
|
|
|
|
},
|
|
|
|
initWidgets: function(map) {
|
|
|
|
this.widgets = {};
|
|
|
|
},
|
|
|
|
needLoaded: function() {
|
|
|
|
return this.isUnloaded;
|
|
|
|
},
|
2011-11-07 05:34:58 +00:00
|
|
|
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;
|
|
|
|
},
|
2011-11-02 01:04:53 +00:00
|
|
|
initView: function() {
|
|
|
|
$.each(this.widgets, function(i, widget) {
|
|
|
|
widget.initView();
|
|
|
|
});
|
|
|
|
},
|
|
|
|
// key can be discippline or subdiscipline
|
|
|
|
show: function(key) {
|
|
|
|
$.each(this.widgets, function(i, widget) {
|
|
|
|
widget.show(key);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
hide: function(key) {
|
|
|
|
$.each(this.widgets, function(i, widget) {
|
|
|
|
widget.hide(key);
|
|
|
|
});
|
|
|
|
},
|
2011-11-07 05:34:58 +00:00
|
|
|
cleanView: function() {
|
2011-11-02 01:04:53 +00:00
|
|
|
$.each(this.widgets, function(i, widget) {
|
2011-11-07 05:34:58 +00:00
|
|
|
widget.cleanView();
|
2011-11-02 01:04:53 +00:00
|
|
|
});
|
2011-11-07 05:34:58 +00:00
|
|
|
},
|
|
|
|
changeFilter: function(value) {
|
|
|
|
var type = this.getFilterType(value);
|
|
|
|
|
|
|
|
$.each(this.widgets, function(i, widget) {
|
|
|
|
widget.changeFilter(type);
|
|
|
|
});
|
|
|
|
},
|
2011-11-02 01:04:53 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
var EntityVisModeController = VisModeController.extend({
|
|
|
|
init: function(map) {
|
|
|
|
this._super(map);
|
|
|
|
this.visMode = ENTITY_VIS_MODE;
|
2011-11-07 05:34:58 +00:00
|
|
|
this.firstFilterLabel = "554 Sub-Disciplines";
|
|
|
|
this.secondFilterLabel = "13 Disciplines";
|
2011-07-13 20:25:50 +00:00
|
|
|
},
|
2011-11-07 05:34:58 +00:00
|
|
|
getFilterType: function(value) {
|
|
|
|
if (value === 1) {
|
|
|
|
return SCIMAP_TYPE.SUBDISCIPLINE;
|
|
|
|
}
|
|
|
|
return SCIMAP_TYPE.DISCIPLINE;
|
2011-07-13 20:25:50 +00:00
|
|
|
},
|
2011-11-02 01:04:53 +00:00
|
|
|
initWidgets: function(map) {
|
2011-07-13 20:25:50 +00:00
|
|
|
var widgets = {};
|
2011-11-02 01:04:53 +00:00
|
|
|
widgets['scimap'] = new ScimapWidget(map);
|
2011-07-13 20:25:50 +00:00
|
|
|
widgets['sci_area_table'] = new DataTableWidget(widgets['scimap']);
|
|
|
|
|
|
|
|
this.widgets = widgets;
|
2011-11-02 01:04:53 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2011-11-07 05:34:58 +00:00
|
|
|
var ComparisonVisModeController = VisModeController.extend({
|
2011-11-02 01:04:53 +00:00
|
|
|
init: function(map) {
|
|
|
|
this._super(map);
|
|
|
|
this.visMode = COMPARISON_VIS_MODE;
|
2011-11-07 05:34:58 +00:00
|
|
|
this.firstFilterLabel = "Organizations";
|
|
|
|
this.secondFilterLabel = "People";
|
2011-07-13 20:25:50 +00:00
|
|
|
},
|
2011-11-07 05:34:58 +00:00
|
|
|
getFilterType: function(value) {
|
|
|
|
if (value === 1) {
|
|
|
|
return COMPARISON_TYPE.ORGANIZATION;
|
|
|
|
}
|
|
|
|
return COMPARISON_TYPE.PERSON;
|
2011-07-13 20:25:50 +00:00
|
|
|
},
|
2011-11-02 01:04:53 +00:00
|
|
|
initWidgets: function(map) {
|
|
|
|
var widgets = {};
|
2011-11-07 05:34:58 +00:00
|
|
|
widgets['scimap'] = new ComparisonScimapWidget(map);
|
2011-11-10 21:38:08 +00:00
|
|
|
widgets['entity_area_table'] = new EntityTablesWidget(widgets['scimap']);
|
|
|
|
widgets['sci_area_table'] = new ComparisonDataTableWidget(widgets['scimap'], widgets['entity_area_table']);
|
2011-11-02 01:04:53 +00:00
|
|
|
|
|
|
|
this.widgets = widgets;
|
2011-07-13 20:25:50 +00:00
|
|
|
}
|
2011-05-19 15:16:56 +00:00
|
|
|
});
|