0
|
1 /*
|
|
2 * Selection.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 Selection
|
|
24 * Selection Class
|
|
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 {Array} objects array of selected objects
|
|
31 * @param {Object} widget which belongs to selection
|
|
32 */
|
|
33 function Selection(objects, widget) {
|
|
34
|
|
35 this.objects = objects;
|
|
36 if ( typeof objects == 'undefined') {
|
|
37 this.objects = [];
|
|
38 for (var i = 0; i < GeoTemConfig.datasets.length; i++) {
|
|
39 this.objects.push([]);
|
|
40 }
|
|
41 }
|
|
42 this.widget = widget;
|
|
43
|
|
44 this.getObjects = function(widget) {
|
|
45 if (!this.equal(widget)) {
|
|
46 return this.objects;
|
|
47 }
|
|
48 this.objects = [];
|
|
49 for (var i = 0; i < GeoTemConfig.datasets.length; i++) {
|
|
50 this.objects.push([]);
|
|
51 }
|
|
52 return this.objects;
|
|
53 };
|
|
54
|
|
55 this.equal = function(widget) {
|
|
56 if (this.valid() && this.widget != widget) {
|
|
57 return false;
|
|
58 }
|
|
59 return true;
|
|
60 };
|
|
61
|
|
62 this.valid = function() {
|
|
63 if ( typeof this.widget != 'undefined') {
|
|
64 return true;
|
|
65 }
|
|
66 return false;
|
|
67 };
|
|
68
|
|
69 this.loadAllObjects = function() {
|
|
70 allObjects = [];
|
|
71 $(GeoTemConfig.datasets).each(function(){
|
|
72 var singleDatasetObjects = [];
|
|
73 $(this.objects).each(function(){
|
|
74 singleDatasetObjects.push(this);
|
|
75 });
|
|
76 allObjects.push(singleDatasetObjects);
|
|
77 });
|
|
78 this.objects = allObjects;
|
|
79 };
|
|
80 };
|
|
81
|