0
|
1 /*
|
|
2 * WidgetWrapper.js
|
|
3 *
|
|
4 * Copyright (c) 2012, Stefan Jänicke. All rights reserved.
|
|
5 *
|
|
6 * This library is free software; you can redistribute it and/or
|
|
7 * modify it under the terms of the GNU Lesser General Public
|
|
8 * License as published by the Free Software Foundation; either
|
|
9 * version 3 of the License, or (at your option) any later version.
|
|
10 *
|
|
11 * This library is distributed in the hope that it will be useful,
|
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
14 * Lesser General Public License for more details.
|
|
15 *
|
|
16 * You should have received a copy of the GNU Lesser General Public
|
|
17 * License along with this library; if not, write to the Free Software
|
|
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
19 * MA 02110-1301 USA
|
|
20 */
|
|
21
|
|
22 /**
|
|
23 * @class WidgetWrapper
|
|
24 * Interface-like implementation for widgets interaction to each other; aimed to be modified for dynamic data sources
|
|
25 * @author Stefan Jänicke (stjaenicke@informatik.uni-leipzig.de)
|
|
26 * @release 1.0
|
|
27 * @release date: 2012-07-27
|
|
28 * @version date: 2012-07-27
|
|
29 *
|
|
30 * @param {Object} widget either a map, time or table widget
|
|
31 */
|
|
32 WidgetWrapper = function() {
|
|
33
|
|
34 var wrapper = this;
|
|
35
|
|
36 this.setWidget = function(widget) {
|
|
37 this.widget = widget;
|
|
38 }
|
|
39
|
|
40 this.display = function(data) {
|
|
41 if ( data instanceof Array) {
|
|
42 GeoTemConfig.datasets = data;
|
|
43 if ( typeof wrapper.widget != 'undefined') {
|
|
44 this.widget.initWidget(data);
|
|
45 }
|
|
46 }
|
|
47 };
|
|
48
|
|
49 Publisher.Subscribe('highlight', this, function(data) {
|
|
50 if (data == undefined) {
|
|
51 return;
|
|
52 }
|
|
53 if ( typeof wrapper.widget != 'undefined') {
|
|
54 wrapper.widget.highlightChanged(data);
|
|
55 }
|
|
56 });
|
|
57
|
|
58 Publisher.Subscribe('selection', this, function(data) {
|
|
59 if ( typeof wrapper.widget != 'undefined') {
|
|
60 wrapper.widget.selectionChanged(data);
|
|
61 }
|
|
62 });
|
|
63
|
|
64 Publisher.Subscribe('filterData', this, function(data) {
|
|
65 wrapper.display(data);
|
|
66 });
|
|
67
|
|
68 Publisher.Subscribe('rise', this, function(id) {
|
|
69 if ( typeof wrapper.widget != 'undefined' && typeof wrapper.widget.riseLayer != 'undefined') {
|
|
70 wrapper.widget.riseLayer(id);
|
|
71 }
|
|
72 });
|
|
73
|
|
74 Publisher.Subscribe('resizeWidget', this, function() {
|
|
75 if ( typeof wrapper.widget != 'undefined' && typeof wrapper.widget.gui != 'undefined' && typeof wrapper.widget.gui.resize != 'undefined' ) {
|
|
76 wrapper.widget.gui.resize();
|
|
77 }
|
|
78 });
|
|
79
|
|
80 this.triggerRefining = function(datasets) {
|
|
81 Publisher.Publish('filterData', datasets, null);
|
|
82 };
|
|
83
|
|
84 this.triggerSelection = function(selectedObjects) {
|
|
85 Publisher.Publish('selection', selectedObjects, this);
|
|
86 };
|
|
87
|
|
88 this.triggerHighlight = function(highlightedObjects) {
|
|
89 Publisher.Publish('highlight', highlightedObjects, this);
|
|
90 };
|
|
91
|
|
92 this.triggerRise = function(id) {
|
|
93 Publisher.Publish('rise', id);
|
|
94 };
|
|
95
|
|
96 };
|