comparison geotemco/js/Util/FilterBar.js @ 0:b12c99b7c3f0

commit for previous development
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Mon, 19 Jan 2015 17:13:49 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:b12c99b7c3f0
1 /*
2 * FilterBar.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 FilterBar
24 * Implementation for FilterBar Object
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} parent parent to call filter functions
31 * @param {HTML object} parentDiv div to append filter buttons
32 */
33 FilterBarFactory = {
34 filterBarArray :[],
35 push : function(newFilterBar){
36 FilterBarFactory.filterBarArray.push(newFilterBar);
37 },
38 resetAll : function(show) {
39 $(FilterBarFactory.filterBarArray).each(function(){
40 if (show) {
41 this.filter.setAttribute('class', 'smallButton filter');
42 this.filterInverse.setAttribute('class', 'smallButton filterInverse');
43 this.cancelSelection.setAttribute('class', 'smallButton filterCancel');
44 } else {
45 this.filter.setAttribute('class', 'smallButton filterDisabled');
46 this.filterInverse.setAttribute('class', 'smallButton filterInverseDisabled');
47 this.cancelSelection.setAttribute('class', 'smallButton filterCancelDisabled');
48 }
49 });
50 }
51 };
52
53 function FilterBar(parent, parentDiv) {
54 FilterBarFactory.push(this);
55
56 var bar = this;
57
58 this.filter = document.createElement('div');
59 this.filter.setAttribute('class', 'smallButton filterDisabled');
60 this.filter.onclick = function() {
61 parent.filtering();
62 };
63
64 this.filterInverse = document.createElement('div');
65 this.filterInverse.setAttribute('class', 'smallButton filterInverseDisabled');
66 this.filterInverse.onclick = function() {
67 parent.inverseFiltering();
68 };
69 if (!GeoTemConfig.inverseFilter) {
70 this.filterInverse.style.display = 'none';
71 }
72
73 this.cancelSelection = document.createElement('div');
74 this.cancelSelection.setAttribute('class', 'smallButton filterCancelDisabled');
75 this.cancelSelection.onclick = function() {
76 parent.deselection();
77 };
78
79 this.appendTo = function(parentDiv) {
80 parentDiv.appendChild(this.filter);
81 parentDiv.appendChild(this.filterInverse);
82 parentDiv.appendChild(this.cancelSelection);
83 }
84 if ( typeof parentDiv != 'undefined') {
85 this.appendTo(parentDiv);
86 }
87
88 this.reset = function(show) {
89 FilterBarFactory.resetAll(show);
90 };
91
92 };