summaryrefslogtreecommitdiff
path: root/frontend/gamma/js/Clipperz/PM/UI/Web/Components/DirectLoginsColumnManager.js
Unidiff
Diffstat (limited to 'frontend/gamma/js/Clipperz/PM/UI/Web/Components/DirectLoginsColumnManager.js') (more/less context) (ignore whitespace changes)
-rw-r--r--frontend/gamma/js/Clipperz/PM/UI/Web/Components/DirectLoginsColumnManager.js271
1 files changed, 271 insertions, 0 deletions
diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/DirectLoginsColumnManager.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/DirectLoginsColumnManager.js
new file mode 100644
index 0000000..1f49575
--- a/dev/null
+++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/DirectLoginsColumnManager.js
@@ -0,0 +1,271 @@
1/*
2
3Copyright 2008-2011 Clipperz Srl
4
5This file is part of Clipperz's Javascript Crypto Library.
6Javascript Crypto Library provides web developers with an extensive
7and efficient set of cryptographic functions. The library aims to
8obtain maximum execution speed while preserving modularity and
9reusability.
10For further information about its features and functionalities please
11refer 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
29Clipperz.Base.module('Clipperz.PM.UI.Web.Components');
30
31//#############################################################################
32
33Clipperz.PM.UI.Web.Components.DirectLoginsColumnManager = function(args) {
34 args = args || {};
35 Clipperz.PM.UI.Web.Components.DirectLoginsColumnManager.superclass.constructor.call(this, args);
36
37 this._enterLeaveCounter = 0;
38 this._selectedRowObject = null;
39
40 return this;
41}
42
43//=============================================================================
44
45Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.DirectLoginsColumnManager, Clipperz.PM.UI.Web.Components.ColumnManager, {
46
47 'toString': function () {
48 return "Clipperz.PM.UI.Web.Components.DirectLoginsColumnManager component";
49 },
50
51 //-------------------------------------------------------------------------
52
53 'renderHeader': function(aTRElement) {
54 Clipperz.PM.UI.Web.Components.DirectLoginsColumnManager.superclass.renderHeader.call(this, aTRElement);
55
56 Clipperz.DOM.Helper.append(MochiKit.DOM.currentDocument().body, {tag:'div', cls:'DirectLoginListPopup', id:this.getId('DirectLoginListPopup'), children:[
57 {tag:'div', cls:'DirectLoginListPopup_body', children:[
58 {tag:'ul', id:this.getId('DirectLoginListPopup_list'), children:[
59 // {tag:'li', children:[
60 // {tag:'img', cls:'favicon', src:'http://www.microsoft.com/favicon.ico'},
61 // {tag:'a', href:'#', html:"Google Mail"}
62 // ]},
63 // ...
64 ]}
65 ]},
66 {tag:'div', cls:'DirectLoginListPopup_footer'}
67 ]});
68
69 MochiKit.Style.hideElement(this.getId('DirectLoginListPopup'));
70
71 //BEWARE: use MochiKit.Signal.connect instead of this.connectEvent, as the HEADER is NOT redrawn after each refresh
72 MochiKit.Signal.connect(this.getId('DirectLoginListPopup'), 'onmouseenter', this, 'handleDirectLoginListPopupEnter');
73 MochiKit.Signal.connect(this.getId('DirectLoginListPopup'), 'onmouseleave', this, 'handleDirectLoginListPopupLeave');
74 },
75
76 //-------------------------------------------------------------------------
77
78 'renderCell': function(aRowElement, anObject) {
79 var i,c;
80 var directLoginsInfo;
81
82 directLoginsInfo = anObject[this.name()];
83
84 TDElement = Clipperz.DOM.Helper.append(aRowElement, {tag:'td', cls:'card_directLogins'});
85
86 c = Math.min(2, directLoginsInfo.length);
87 for (i=0; i<c; i++) {
88 var elementID;
89
90 elementID = 'directLogin_' + directLoginsInfo[i]['_reference'];
91
92 Clipperz.DOM.Helper.append(TDElement, {tag:'div', cls:'card_directLogin', children:[
93 {tag:'div', cls:'card_directLogin_body', children:[
94 {tag:'a', href:'#', id:elementID, html:directLoginsInfo[i]['label']}
95 ]}
96 ]});
97 // MochiKit.Signal.connect(elementID, 'onclick', MochiKit.Base.method(this, 'handleDirectLoginClick', directLoginsInfo[i]['_rowObject']));
98 this.connectEvent(elementID, 'onclick', MochiKit.Base.method(this, 'handleDirectLoginClick', directLoginsInfo[i]['_rowObject']));
99 }
100
101 if (directLoginsInfo.length > 2) {
102 var ellipsesElement;
103
104 ellipsesElement = Clipperz.DOM.Helper.append(TDElement, {tag:'div', cls:'card_directLogin_ellipses', children:[
105 {tag:'div', cls:'card_directLogin_ellipses_body', children:[
106 {tag:'span', html:'&hellip;'}
107 ]}
108 ]});
109
110 /// MochiKit.Signal.connect(ellipsesElement, 'onmouseenter', MochiKit.Base.method(this, 'handleEllipsesEnter', anObject));
111 /// MochiKit.Signal.connect(ellipsesElement, 'onmouseleave', MochiKit.Base.method(this, 'handleEllipsesLeave'));
112 // MochiKit.Signal.connect(TDElement, 'onmouseleave', MochiKit.Base.method(this, 'handleTDLeave'));
113 this.connectEvent(TDElement, 'onmouseleave', MochiKit.Base.method(this, 'handleTDLeave'));
114 }
115 // MochiKit.Signal.connect(TDElement, 'onmouseenter', MochiKit.Base.method(this, 'handleTDEnter', anObject));
116 this.connectEvent(TDElement, 'onmouseenter', MochiKit.Base.method(this, 'handleTDEnter', anObject));
117
118 },
119
120 //=========================================================================
121/*
122 'handleEllipsesEnter': function (aRecordInfo, anEvent) {
123 this._enterLeaveCounter ++;
124 if (this._enterLeaveCounter > 2) {
125 this._enterLeaveCounter = 2;
126 }
127
128 if (this._enterLeaveCounter == 1) {
129 this.showDirectLoginListPopup(aRecordInfo, anEvent.src());
130 }
131 },
132
133 'handleEllipsesLeave': function (anEvent) {
134 this._enterLeaveCounter --;
135
136 MochiKit.Async.callLater(0.3, MochiKit.Base.bind(function () {
137 if (this._enterLeaveCounter == 0) {
138 this.hideDirectLoginListPopup();
139 }
140 }, this))
141 },
142*/
143 //-------------------------------------------------------------------------
144
145 'handleTDEnter': function (aRecordInfo, anEvent) {
146 if (MochiKit.Selector.findChildElements(anEvent.src(), ['div.card_directLogin_ellipses']).length > 0) {
147 this._enterLeaveCounter ++;
148 if (this._enterLeaveCounter > 2) {
149 this._enterLeaveCounter = 2;
150 }
151
152 if (this._enterLeaveCounter == 1) {
153 this.showDirectLoginListPopup(aRecordInfo, anEvent.src());
154 }
155 } else {
156 if (this._selectedRowObject != null) {
157 this.hideDirectLoginListPopup();
158 }
159 }
160 },
161
162 'handleTDLeave': function (anEvent) {
163 this._enterLeaveCounter --;
164 if (this._enterLeaveCounter < 0) {
165 this._enterLeaveCounter = 0;
166 }
167
168 MochiKit.Async.callLater(0.3, MochiKit.Base.bind(function () {
169 if (this._enterLeaveCounter == 0) {
170 this.hideDirectLoginListPopup();
171 }
172 }, this))
173 },
174
175 //-------------------------------------------------------------------------
176
177 'handleDirectLoginListPopupEnter': function (anEvent) {
178 this._enterLeaveCounter ++;
179 if (this._enterLeaveCounter > 2) {
180 this._enterLeaveCounter = 2;
181 }
182 },
183
184 'handleDirectLoginListPopupLeave': function (anEvent) {
185 this._enterLeaveCounter --;
186 if (this._enterLeaveCounter < 0) {
187 this._enterLeaveCounter = 0;
188 }
189
190 MochiKit.Async.callLater(0.3, MochiKit.Base.bind(function () {
191 if (this._enterLeaveCounter == 0) {
192 this.hideDirectLoginListPopup();
193 }
194 }, this))
195 },
196
197 //=========================================================================
198
199 'showDirectLoginListPopup': function (aRecordInfo, anElement) {
200 var position;
201 var directLoginsInfo;
202 var directLoginsListElement;
203 var ellipsesElement;
204
205
206 ellipsesElement = MochiKit.Selector.findChildElements(anElement, ['div.card_directLogin_ellipses'])[0];
207 position = MochiKit.Style.getElementPosition(ellipsesElement);
208 // position = MochiKit.Style.getElementPosition(anElement);
209 position.x += 14;
210 position.y -= 26;
211
212 MochiKit.Style.setElementPosition(this.getId('DirectLoginListPopup'), position /*[, units='px'] */);
213
214 directLoginsListElement = this.getElement('DirectLoginListPopup_list');
215 directLoginsListElement.innerHTML = '';
216
217 directLoginsInfo = aRecordInfo[this.name()];
218 c = directLoginsInfo.length;
219 for (i=0; i<c; i++) {
220 varelementID;
221 varlabel;
222 var trunkedLabel;
223
224 label = directLoginsInfo[i]['label'];
225 trunkedLabel = (label.length > 20 ? label.slice(0,20) + '&hellip;' : label);
226
227 elementID = this.getId('directLoginList_' + directLoginsInfo[i]['_reference']);
228
229 Clipperz.DOM.Helper.append(directLoginsListElement, {tag:'li', children:[
230 {tag:'div', children:[
231 {tag:'img', cls:'favicon', src:directLoginsInfo[i]['favicon']},
232 (label == trunkedLabel ? {tag:'a', href:'#', id:elementID, html:trunkedLabel} : {tag:'a', href:'#', id:elementID, title:label, html:trunkedLabel})
233 ]}
234 ]});
235
236 // MochiKit.Signal.connect(elementID, 'onclick', MochiKit.Base.method(this, 'handleDirectLoginClick', directLoginsInfo[i]['_rowObject']));
237 this.connectEvent(elementID, 'onclick', MochiKit.Base.method(this, 'handleDirectLoginClick', directLoginsInfo[i]['_rowObject']));
238 }
239
240 // MochiKit.Style.showElement(this.getId('DirectLoginListPopup'));
241 MochiKit.Visual.appear(this.getId('DirectLoginListPopup'), {duration:0.5});
242 MochiKit.Signal.signal(this, 'selectRow', aRecordInfo);
243
244 this._selectedRowObject = aRecordInfo;
245 },
246
247 //-------------------------------------------------------------------------
248
249 'hideDirectLoginListPopup': function () {
250 if (this._selectedRowObject != null) {
251 MochiKit.Signal.signal(this, 'unselectRow', this._selectedRowObject);
252 MochiKit.Visual.fade(this.getId('DirectLoginListPopup'), {duration:0.5});
253 this._selectedRowObject = null;
254 this._enterLeaveCounter = 0;
255 }
256 },
257
258 //=========================================================================
259
260 'handleDirectLoginClick': function (aDirectLogin, anEvent) {
261 anEvent.preventDefault();
262 // aDirectLogin.runDirectLogin();
263 Clipperz.PM.UI.Common.Controllers.DirectLoginRunner.openDirectLogin(aDirectLogin);
264 },
265
266 //-------------------------------------------------------------------------
267
268 '__syntax_fix__' : 'syntax fix'
269
270});
271