Diffstat (limited to 'frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/FilterController.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/FilterController.js | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/FilterController.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/FilterController.js index bfc093a..de59ec3 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/FilterController.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/FilterController.js | |||
@@ -1,118 +1,116 @@ | |||
1 | /* | 1 | /* |
2 | 2 | ||
3 | Copyright 2008-2011 Clipperz Srl | 3 | Copyright 2008-2013 Clipperz Srl |
4 | 4 | ||
5 | This file is part of Clipperz Community Edition. | 5 | This file is part of Clipperz, the online password manager. |
6 | Clipperz Community Edition is an online password manager. | ||
7 | For further information about its features and functionalities please | 6 | For further information about its features and functionalities please |
8 | refer to http://www.clipperz.com. | 7 | refer to http://www.clipperz.com. |
9 | 8 | ||
10 | * Clipperz Community Edition is free software: you can redistribute | 9 | * Clipperz is free software: you can redistribute it and/or modify it |
11 | it and/or modify it under the terms of the GNU Affero General Public | 10 | under the terms of the GNU Affero General Public License as published |
12 | License as published by the Free Software Foundation, either version | 11 | by the Free Software Foundation, either version 3 of the License, or |
13 | 3 of the License, or (at your option) any later version. | 12 | (at your option) any later version. |
14 | 13 | ||
15 | * Clipperz Community Edition is distributed in the hope that it will | 14 | * Clipperz is distributed in the hope that it will be useful, but |
16 | be useful, but WITHOUT ANY WARRANTY; without even the implied | 15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
18 | See the GNU Affero General Public License for more details. | 17 | See the GNU Affero General Public License for more details. |
19 | 18 | ||
20 | * You should have received a copy of the GNU Affero General Public | 19 | * You should have received a copy of the GNU Affero General Public |
21 | License along with Clipperz Community Edition. If not, see | 20 | License along with Clipperz. If not, see http://www.gnu.org/licenses/. |
22 | <http://www.gnu.org/licenses/>. | ||
23 | 21 | ||
24 | */ | 22 | */ |
25 | 23 | ||
26 | Clipperz.Base.module('Clipperz.PM.UI.Web.Controllers'); | 24 | Clipperz.Base.module('Clipperz.PM.UI.Web.Controllers'); |
27 | 25 | ||
28 | Clipperz.PM.UI.Web.Controllers.FilterController = function(args) { | 26 | Clipperz.PM.UI.Web.Controllers.FilterController = function(args) { |
29 | args = args || {}; | 27 | args = args || {}; |
30 | 28 | ||
31 | Clipperz.PM.UI.Web.Controllers.FilterController.superclass.constructor.call(this, args); | 29 | Clipperz.PM.UI.Web.Controllers.FilterController.superclass.constructor.call(this, args); |
32 | 30 | ||
33 | this._filterElements = []; | 31 | this._filterElements = []; |
34 | this._filter = ""; | 32 | this._filter = ""; |
35 | 33 | ||
36 | this._pendingSearchClicks = 0; | 34 | this._pendingSearchClicks = 0; |
37 | 35 | ||
38 | return this; | 36 | return this; |
39 | }; | 37 | }; |
40 | 38 | ||
41 | 39 | ||
42 | Clipperz.Base.extend(Clipperz.PM.UI.Web.Controllers.FilterController, Object, { | 40 | Clipperz.Base.extend(Clipperz.PM.UI.Web.Controllers.FilterController, Object, { |
43 | 41 | ||
44 | //----------------------------------------------------------------------------- | 42 | //----------------------------------------------------------------------------- |
45 | 43 | ||
46 | 'getFilter': function () { | 44 | 'getFilter': function () { |
47 | return this._filter; | 45 | return this._filter; |
48 | }, | 46 | }, |
49 | 47 | ||
50 | '_setFilter': function (aFilterElement, aFilter) { | 48 | '_setFilter': function (aFilterElement, aFilter) { |
51 | if (aFilter != this._filter) { | 49 | if (aFilter != this._filter) { |
52 | this._filter = aFilter; | 50 | this._filter = aFilter; |
53 | MochiKit.Signal.signal(this, 'filterUpdated', aFilter); | 51 | MochiKit.Signal.signal(this, 'filterUpdated', aFilter); |
54 | this.updateFilterElements(aFilterElement, aFilter); | 52 | this.updateFilterElements(aFilterElement, aFilter); |
55 | } | 53 | } |
56 | }, | 54 | }, |
57 | 55 | ||
58 | 'setFilter': function (aFilter) { | 56 | 'setFilter': function (aFilter) { |
59 | this._setFilter(null, aFilter); | 57 | this._setFilter(null, aFilter); |
60 | }, | 58 | }, |
61 | 59 | ||
62 | //----------------------------------------------------------------------------- | 60 | //----------------------------------------------------------------------------- |
63 | 61 | ||
64 | 'filterElements': function () { | 62 | 'filterElements': function () { |
65 | return this._filterElements; | 63 | return this._filterElements; |
66 | }, | 64 | }, |
67 | 65 | ||
68 | 'registerFilterElement': function (aFilterElement) { | 66 | 'registerFilterElement': function (aFilterElement) { |
69 | //Clipperz.log("=== FilterController.registerFilterElement", aFilterElement); | 67 | //Clipperz.log("=== FilterController.registerFilterElement", aFilterElement); |
70 | this._filterElements.push(aFilterElement); | 68 | this._filterElements.push(aFilterElement); |
71 | MochiKit.Signal.connect(aFilterElement, 'onkeydown', this, 'searchClickHandler'); | 69 | MochiKit.Signal.connect(aFilterElement, 'onkeydown', this, 'searchClickHandler'); |
72 | MochiKit.Signal.connect(aFilterElement, 'onfocus', this, 'searchClickHandler'); | 70 | MochiKit.Signal.connect(aFilterElement, 'onfocus', this, 'searchClickHandler'); |
73 | }, | 71 | }, |
74 | 72 | ||
75 | 'removeFilterElement': function (aFilterElement) { | 73 | 'removeFilterElement': function (aFilterElement) { |
76 | var i; | 74 | var i; |
77 | var filterElements; | 75 | var filterElements; |
78 | for (i=0; i < filterElements; i++) { | 76 | for (i=0; i < filterElements; i++) { |
79 | if (filterElements[i] == aFilterElement); | 77 | if (filterElements[i] == aFilterElement); |
80 | filterElements.splice(i, 1); | 78 | filterElements.splice(i, 1); |
81 | // TODO unregister/disconnect filterElement ??MochiKit.Signal.disconnect(this.grid().filterElement(), 'updateFilter', this.filterController(), 'handleUpdateFilter'); | 79 | // TODO unregister/disconnect filterElement ??MochiKit.Signal.disconnect(this.grid().filterElement(), 'updateFilter', this.filterController(), 'handleUpdateFilter'); |
82 | } | 80 | } |
83 | }, | 81 | }, |
84 | 82 | ||
85 | 'updateFilterElements': function (aSourceElement, aFilterString) { | 83 | 'updateFilterElements': function (aSourceElement, aFilterString) { |
86 | MochiKit.Iter.forEach(this.filterElements(), | 84 | MochiKit.Iter.forEach(this.filterElements(), |
87 | function (aFilterElement) { | 85 | function (aFilterElement) { |
88 | if (aFilterElement != aSourceElement) { | 86 | if (aFilterElement != aSourceElement) { |
89 | aFilterElement.value = aFilterString; | 87 | aFilterElement.value = aFilterString; |
90 | } | 88 | } |
91 | } | 89 | } |
92 | ); | 90 | ); |
93 | 91 | ||
94 | if (aSourceElement != null) { | 92 | if (aSourceElement != null) { |
95 | aSourceElement.focus(); | 93 | aSourceElement.focus(); |
96 | } | 94 | } |
97 | }, | 95 | }, |
98 | 96 | ||
99 | //----------------------------------------------------------------------------- | 97 | //----------------------------------------------------------------------------- |
100 | 98 | ||
101 | 'run': function () { | 99 | 'run': function () { |
102 | //Clipperz.log("=== FilterController.run"); | 100 | //Clipperz.log("=== FilterController.run"); |
103 | }, | 101 | }, |
104 | 102 | ||
105 | //----------------------------------------------------------------------------- | 103 | //----------------------------------------------------------------------------- |
106 | 104 | ||
107 | 'pendingSearchClicks': function () { | 105 | 'pendingSearchClicks': function () { |
108 | return this._pendingSearchClicks; | 106 | return this._pendingSearchClicks; |
109 | }, | 107 | }, |
110 | 108 | ||
111 | 'incrementPendingSearchClicks': function () { | 109 | 'incrementPendingSearchClicks': function () { |
112 | this._pendingSearchClicks++; | 110 | this._pendingSearchClicks++; |
113 | }, | 111 | }, |
114 | 112 | ||
115 | 'decrementPendingSearchClicks': function () { | 113 | 'decrementPendingSearchClicks': function () { |
116 | this._pendingSearchClicks--; | 114 | this._pendingSearchClicks--; |
117 | }, | 115 | }, |
118 | 116 | ||