Diffstat (limited to 'frontend/gamma/js/Clipperz/PM/UI/Web/Components/ColumnManager.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/gamma/js/Clipperz/PM/UI/Web/Components/ColumnManager.js | 203 |
1 files changed, 203 insertions, 0 deletions
diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/ColumnManager.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/ColumnManager.js new file mode 100644 index 0000000..bfc7e61 --- a/dev/null +++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/ColumnManager.js | |||
@@ -0,0 +1,203 @@ | |||
1 | /* | ||
2 | |||
3 | Copyright 2008-2011 Clipperz Srl | ||
4 | |||
5 | This file is part of Clipperz's Javascript Crypto Library. | ||
6 | Javascript Crypto Library provides web developers with an extensive | ||
7 | and efficient set of cryptographic functions. The library aims to | ||
8 | obtain maximum execution speed while preserving modularity and | ||
9 | reusability. | ||
10 | For further information about its features and functionalities please | ||
11 | refer to http://www.clipperz.com | ||
12 | |||
13 | * Javascript Crypto Library is free software: you can redistribute | ||
14 | it and/or modify it under the terms of the GNU Affero General Public | ||
15 | License as published by the Free Software Foundation, either version | ||
16 | 3 of the License, or (at your option) any later version. | ||
17 | |||
18 | * Javascript Crypto Library is distributed in the hope that it will | ||
19 | be useful, but WITHOUT ANY WARRANTY; without even the implied | ||
20 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
21 | See the GNU Affero General Public License for more details. | ||
22 | |||
23 | * You should have received a copy of the GNU Affero General Public | ||
24 | License along with Javascript Crypto Library. If not, see | ||
25 | <http://www.gnu.org/licenses/>. | ||
26 | |||
27 | */ | ||
28 | |||
29 | Clipperz.Base.module('Clipperz.PM.UI.Web.Components'); | ||
30 | |||
31 | //############################################################################# | ||
32 | |||
33 | Clipperz.PM.UI.Web.Components.ColumnManager = function(args) { | ||
34 | args = args || {}; | ||
35 | Clipperz.PM.UI.Web.Components.ColumnManager.superclass.constructor.call(this, args); | ||
36 | |||
37 | this._name = args.name || Clipperz.Base.exception.raise('MandatoryParameter'); | ||
38 | this._selector = args.selector|| Clipperz.Base.exception.raise('MandatoryParameter');; | ||
39 | this._label = args.label || null; | ||
40 | this._isSortable = args.sortable|| false; | ||
41 | this._comparator = args.comparator|| null; | ||
42 | this._sorted = args.sorted || 'UNSORTED'; //'ASCENDING' | 'DESCENDING' | 'UNSORTED' | ||
43 | this._cssClass = args.cssClass|| ''; | ||
44 | |||
45 | this._signalIdentifiers = []; | ||
46 | |||
47 | return this; | ||
48 | } | ||
49 | |||
50 | //============================================================================= | ||
51 | |||
52 | Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.ColumnManager, Clipperz.PM.UI.Common.Components.BaseComponent, { | ||
53 | |||
54 | 'toString': function () { | ||
55 | return "Clipperz.PM.UI.Web.Components.ColumnManager - " + this._name; | ||
56 | }, | ||
57 | |||
58 | 'name': function () { | ||
59 | return this._name; | ||
60 | }, | ||
61 | |||
62 | 'label': function () { | ||
63 | return this._label; | ||
64 | }, | ||
65 | |||
66 | 'selector': function () { | ||
67 | return this._selector; | ||
68 | }, | ||
69 | |||
70 | 'comparator': function() { | ||
71 | return this._comparator; | ||
72 | }, | ||
73 | |||
74 | 'cssClass': function() { | ||
75 | return this._cssClass; | ||
76 | }, | ||
77 | |||
78 | //------------------------------------------------------------------------- | ||
79 | |||
80 | 'isSortable': function () { | ||
81 | return this._isSortable; | ||
82 | }, | ||
83 | |||
84 | //------------------------------------------------------------------------- | ||
85 | |||
86 | 'sorted': function () { | ||
87 | return this._sorted; | ||
88 | }, | ||
89 | |||
90 | 'isSorted': function () { | ||
91 | return (this.sorted() != 'UNSORTED'); | ||
92 | }, | ||
93 | |||
94 | 'setSorted': function(aValue) { | ||
95 | this._sorted = aValue; | ||
96 | this.updateSortIcon(); | ||
97 | }, | ||
98 | |||
99 | //------------------------------------------------------------------------- | ||
100 | |||
101 | 'signalIdentifiers': function () { | ||
102 | return this._signalIdentifiers; | ||
103 | }, | ||
104 | |||
105 | 'resetSignalIdentifiers': function () { | ||
106 | this._signalIdentifiers = []; | ||
107 | }, | ||
108 | |||
109 | //------------------------------------------------------------------------- | ||
110 | |||
111 | 'disconnectRowsSignals': function () { | ||
112 | MochiKit.Base.map(MochiKit.Signal.disconnect, this.signalIdentifiers()); | ||
113 | this.resetSignalIdentifiers(); | ||
114 | }, | ||
115 | |||
116 | 'connectEvent': function () { | ||
117 | var ident; | ||
118 | |||
119 | ident = MochiKit.Signal.connect.apply(null, arguments); | ||
120 | this.signalIdentifiers().push(ident); | ||
121 | }, | ||
122 | |||
123 | //------------------------------------------------------------------------- | ||
124 | |||
125 | 'renderHeader': function(aTRElement) { | ||
126 | varthElement; | ||
127 | |||
128 | thElement = Clipperz.DOM.Helper.append(aTRElement, {tag:'th', cls:(this.cssClass() + 'TH'), id:this.getId('sortLink'), children:[ | ||
129 | {tag:'span', html:this.label() ? this.label() : ' '} | ||
130 | ]}); | ||
131 | |||
132 | if (this.isSortable()) { | ||
133 | Clipperz.DOM.Helper.append(thElement, {tag:'span', cls:'sortable', children:[ | ||
134 | {tag:'a', href:'#'/*, id:this.getId('sortLink')*/, html:' '} | ||
135 | ]}); | ||
136 | |||
137 | MochiKit.DOM.addElementClass(thElement, 'sortable'); | ||
138 | MochiKit.Signal.connect(thElement, 'onclick', this, 'handleClickOnSortingCriteria'); | ||
139 | }; | ||
140 | |||
141 | this.updateSortIcon(); | ||
142 | }, | ||
143 | |||
144 | //------------------------------------------------------------------------- | ||
145 | |||
146 | 'toggleSorting': function () { | ||
147 | var result; | ||
148 | switch (this.sorted()) { | ||
149 | case 'UNSORTED': | ||
150 | result = 'ASCENDING'; | ||
151 | break; | ||
152 | case 'ASCENDING': | ||
153 | result = 'DESCENDING'; | ||
154 | break; | ||
155 | case 'DESCENDING': | ||
156 | result = 'ASCENDING'; | ||
157 | break; | ||
158 | default: | ||
159 | result = 'UNSORTED'; | ||
160 | break; | ||
161 | } | ||
162 | |||
163 | this.setSorted(result); | ||
164 | |||
165 | return result; | ||
166 | }, | ||
167 | |||
168 | //------------------------------------------------------------------------- | ||
169 | |||
170 | 'sortElementClass': function () { | ||
171 | return this.sorted().toLowerCase(); | ||
172 | }, | ||
173 | |||
174 | //------------------------------------------------------------------------- | ||
175 | |||
176 | 'updateSortIcon': function () { | ||
177 | if (this.isSortable()) { | ||
178 | MochiKit.DOM.removeElementClass(this.getId('sortLink'), 'ascending'); | ||
179 | MochiKit.DOM.removeElementClass(this.getId('sortLink'), 'descending'); | ||
180 | MochiKit.DOM.removeElementClass(this.getId('sortLink'), 'unsorted'); | ||
181 | |||
182 | MochiKit.DOM.addElementClass(this.getId('sortLink'), this.sortElementClass()); | ||
183 | } | ||
184 | }, | ||
185 | |||
186 | //------------------------------------------------------------------------- | ||
187 | |||
188 | 'renderCell': function(aRowElement, anObject) { | ||
189 | Clipperz.DOM.Helper.append(aRowElement, {tag:'td', cls:this.cssClass(), children:[{tag:'span', html:anObject[this.name()]}]}); | ||
190 | }, | ||
191 | |||
192 | //----------------------------------------------------- | ||
193 | |||
194 | 'handleClickOnSortingCriteria': function (anEvent) { | ||
195 | anEvent.preventDefault(); | ||
196 | MochiKit.Signal.signal(this, 'sort', this); | ||
197 | }, | ||
198 | |||
199 | //----------------------------------------------------- | ||
200 | '__syntax_fix__' : 'syntax fix' | ||
201 | |||
202 | }); | ||
203 | |||