author | Giulio Cesare Solaroli <giulio.cesare@clipperz.com> | 2011-10-02 23:56:18 (UTC) |
---|---|---|
committer | Giulio Cesare Solaroli <giulio.cesare@clipperz.com> | 2011-10-02 23:56:18 (UTC) |
commit | ef68436ac04da078ffdcacd7e1f785473a303d45 (patch) (unidiff) | |
tree | c403752d66a2c4775f00affd4fa8431b29c5b68c /frontend/beta/js/Clipperz/PM/Components | |
parent | 597ecfbc0249d83e1b856cbd558340c01237a360 (diff) | |
download | clipperz-ef68436ac04da078ffdcacd7e1f785473a303d45.zip clipperz-ef68436ac04da078ffdcacd7e1f785473a303d45.tar.gz clipperz-ef68436ac04da078ffdcacd7e1f785473a303d45.tar.bz2 |
First version of the newly restructured repository
Diffstat (limited to 'frontend/beta/js/Clipperz/PM/Components') (more/less context) (ignore whitespace changes)
51 files changed, 14013 insertions, 0 deletions
diff --git a/frontend/beta/js/Clipperz/PM/Components/BaseComponent.js b/frontend/beta/js/Clipperz/PM/Components/BaseComponent.js new file mode 100644 index 0000000..67e257b --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/BaseComponent.js | |||
@@ -0,0 +1,124 @@ | |||
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 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | ||
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | ||
31 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } | ||
32 | |||
33 | //############################################################################# | ||
34 | |||
35 | var _Clipperz_PM_Components_Panels_base_id_ = 0; | ||
36 | |||
37 | //############################################################################# | ||
38 | |||
39 | Clipperz.PM.Components.BaseComponent = function(anElement, args) { | ||
40 | args = args || {}; | ||
41 | //MochiKit.Base.bindMethods(this); | ||
42 | //Clipperz.PM.Components.BaseComponent.superclass.constructor.call(this, args); | ||
43 | |||
44 | this._element = anElement; | ||
45 | this._ids = {}; | ||
46 | |||
47 | return this; | ||
48 | } | ||
49 | |||
50 | //============================================================================= | ||
51 | |||
52 | //MochiKit.Base.update(Clipperz.PM.Components.BaseComponent.prototype, { | ||
53 | YAHOO.extendX(Clipperz.PM.Components.BaseComponent, YAHOO.ext.util.Observable, { | ||
54 | |||
55 | 'isClipperzPMComponent': true, | ||
56 | |||
57 | //------------------------------------------------------------------------- | ||
58 | |||
59 | 'toString': function () { | ||
60 | return "Clipperz.PM.Components.BaseComponent component"; | ||
61 | }, | ||
62 | |||
63 | //------------------------------------------------------------------------- | ||
64 | |||
65 | 'domHelper': function() { | ||
66 | return Clipperz.YUI.DomHelper; | ||
67 | }, | ||
68 | |||
69 | //------------------------------------------------------------------------- | ||
70 | |||
71 | 'element': function() { | ||
72 | //MochiKit.Logging.logDebug(">>> BaseComponent.element"); | ||
73 | return this._element; | ||
74 | }, | ||
75 | |||
76 | 'setElement': function(aValue) { | ||
77 | this._element = aValue; | ||
78 | }, | ||
79 | |||
80 | //----------------------------------------------------- | ||
81 | |||
82 | 'remove': function() { | ||
83 | //MochiKit.Logging.logDebug(">>> BaseComponent.remove"); | ||
84 | Clipperz.NotificationCenter.unregister(this); | ||
85 | MochiKit.Signal.disconnectAllTo(this); | ||
86 | //MochiKit.Logging.logDebug("<<< BaseComponent.remove"); | ||
87 | }, | ||
88 | |||
89 | //------------------------------------------------------------------------- | ||
90 | |||
91 | 'getId': function(aValue) { | ||
92 | varresult; | ||
93 | |||
94 | result = this._ids[aValue]; | ||
95 | |||
96 | if (typeof(result) == 'undefined') { | ||
97 | _Clipperz_PM_Components_Panels_base_id_ ++; | ||
98 | |||
99 | result = "Clipperz_PM_Components_Panels_" + aValue + "_" + _Clipperz_PM_Components_Panels_base_id_; | ||
100 | this._ids[aValue] = result; | ||
101 | //MochiKit.Logging.logDebug(">>> getId(" + aValue + ") = " + result); | ||
102 | } else { | ||
103 | //MochiKit.Logging.logDebug("<<< getId(" + aValue + ") = " + result); | ||
104 | } | ||
105 | |||
106 | return result; | ||
107 | }, | ||
108 | |||
109 | 'getDom': function(aValue) { | ||
110 | return YAHOO.util.Dom.get(this.getId(aValue)); | ||
111 | }, | ||
112 | |||
113 | 'getElement': function(aValue) { | ||
114 | return YAHOO.ext.Element.get(this.getId(aValue)); | ||
115 | }, | ||
116 | |||
117 | 'getActor': function(aValue, anAnimator) { | ||
118 | return new YAHOO.ext.Actor(this.getDom(aValue), anAnimator); | ||
119 | }, | ||
120 | |||
121 | //------------------------------------------------------------------------- | ||
122 | __syntaxFix__: "syntax fix" | ||
123 | |||
124 | }); | ||
diff --git a/frontend/beta/js/Clipperz/PM/Components/Compact/CompactHeader.js b/frontend/beta/js/Clipperz/PM/Components/Compact/CompactHeader.js new file mode 100644 index 0000000..e51b56f --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/Compact/CompactHeader.js | |||
@@ -0,0 +1,86 @@ | |||
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 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | ||
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | ||
31 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } | ||
32 | if (typeof(Clipperz.PM.Components.Compact) == 'undefined') { Clipperz.PM.Components.Compact = {}; } | ||
33 | |||
34 | Clipperz.PM.Components.Compact.CompactHeader = function(anElement, args) { | ||
35 | |||
36 | Clipperz.PM.Components.Compact.CompactHeader.superclass.constructor.call(this, anElement, args); | ||
37 | |||
38 | this.render(); | ||
39 | |||
40 | return this; | ||
41 | }; | ||
42 | |||
43 | YAHOO.extendX(Clipperz.PM.Components.Compact.CompactHeader, Clipperz.PM.Components.BaseComponent, { | ||
44 | |||
45 | 'toString': function() { | ||
46 | return "Clipperz.PM.Components.Compact.CompactHeader"; | ||
47 | }, | ||
48 | |||
49 | //----------------------------------------------------- | ||
50 | |||
51 | 'render': function() { | ||
52 | this.element().update(""); | ||
53 | |||
54 | Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'div', children:[ | ||
55 | {tag:'img', src:'./images/logo.gif'}, | ||
56 | {tag:'div', id:'lockBlock', children:[ | ||
57 | {tag:'input', type:'checkbox', id:'autolock'}, | ||
58 | {tag:'span', html:'auto'}, | ||
59 | {tag:'a', href:'#', htmlString:Clipperz.PM.Strings['lockMenuLabel'], id:'lock'} | ||
60 | ]} | ||
61 | ]}); | ||
62 | |||
63 | Clipperz.YUI.DomHelper.append(this.element().dom, | ||
64 | {tag:'div', id:'compactMiscLinks', children:[ | ||
65 | {tag:'a', id:'donateHeaderIconLink', target:'_blank', href:Clipperz.PM.Strings['donateHeaderLinkUrl'], children:[ | ||
66 | {tag:'img', id:'donateHeaderLinkIcon', src:'./images/smiles_small.gif'} | ||
67 | ]}, | ||
68 | {tag:'ul', children:[ | ||
69 | {tag:'li', children:[{tag:'a', id:'donateHeaderLink', html:'donate', target:'_blank'}]}, | ||
70 | {tag:'li', children:[{tag:'a', id:'creditsHeaderLink', html:'credits', target:'_blank'}]}, | ||
71 | {tag:'li', children:[{tag:'a', id:'feedbackHeaderLink', html:'feedback', target:'_blank'}]}, | ||
72 | {tag:'li', children:[{tag:'a', id:'helpHeaderLink', html:'help', target:'_blank'}]}, | ||
73 | {tag:'li', children:[{tag:'a', id:'forumHeaderLink', html:'forum', target:'_blank'}]} | ||
74 | ]} | ||
75 | ]} | ||
76 | ); | ||
77 | |||
78 | YAHOO.ext.Element.get('lockBlock').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); | ||
79 | Clipperz.NotificationCenter.notify(this, 'switchLanguage'); | ||
80 | }, | ||
81 | |||
82 | //----------------------------------------------------- | ||
83 | __syntaxFix__: '__syntaxFix__' | ||
84 | }); | ||
85 | |||
86 | |||
diff --git a/frontend/beta/js/Clipperz/PM/Components/Compact/CompactInterface.js b/frontend/beta/js/Clipperz/PM/Components/Compact/CompactInterface.js new file mode 100644 index 0000000..492f815 --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/Compact/CompactInterface.js | |||
@@ -0,0 +1,312 @@ | |||
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 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | ||
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | ||
31 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } | ||
32 | if (typeof(Clipperz.PM.Components.Compact) == 'undefined') { Clipperz.PM.Components.Compact = {}; } | ||
33 | |||
34 | Clipperz.PM.Components.Compact.CompactInterface = function(anElement, args) { | ||
35 | |||
36 | Clipperz.PM.Components.Compact.CompactInterface.superclass.constructor.call(this, anElement, args); | ||
37 | |||
38 | this._directLoginItemTemplate = null; | ||
39 | this._user = args.user; | ||
40 | this._autoLockTimer = null; | ||
41 | |||
42 | Clipperz.NotificationCenter.register(null, 'updatedProgressState', this, 'userNotificationHandler') | ||
43 | Clipperz.NotificationCenter.register(null, 'directLoginAdded', this, 'directLoginAddedHandler'); | ||
44 | |||
45 | this.render(); | ||
46 | |||
47 | return this; | ||
48 | }; | ||
49 | |||
50 | YAHOO.extendX(Clipperz.PM.Components.Compact.CompactInterface, Clipperz.PM.Components.BaseComponent, { | ||
51 | |||
52 | 'toString': function() { | ||
53 | return "Clipperz.PM.Components.Compact.CompactInterface"; | ||
54 | }, | ||
55 | |||
56 | //----------------------------------------------------- | ||
57 | |||
58 | 'render': function() { | ||
59 | var result; | ||
60 | varlayout; | ||
61 | var registerButton; | ||
62 | |||
63 | //MochiKit.Logging.logDebug(">>> CompactInterface.render"); | ||
64 | this.element().update(""); | ||
65 | |||
66 | Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'div', children:[ | ||
67 | {tag:'div', id:this.getId('cantentPanel'), children:[ | ||
68 | {tag:'h4', id:this.getId('message')}, | ||
69 | {tag:'ul', id:'directLogins', children:[]} | ||
70 | ]}, | ||
71 | {tag:'div', id:this.getId('lockPanel'), cls:'lockPanel', children:[ | ||
72 | {tag:'div', htmlString:Clipperz.PM.Strings['lockDescription']}, | ||
73 | {tag:'form', id:'lockDialogForm', children:[ | ||
74 | {tag:'input', type:'password', id:this.getId('lockPassphrase')} | ||
75 | ]}, | ||
76 | {tag:'div', id:this.getId('unlock')} | ||
77 | ]} | ||
78 | ]}); | ||
79 | |||
80 | this.getElement('lockPanel').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); | ||
81 | |||
82 | YAHOO.ext.Element.get('lockBlock').show(); | ||
83 | MochiKit.Signal.connect(YAHOO.ext.Element.get('lock').dom, 'onclick', this, 'doLockEventHandler'); | ||
84 | new YAHOO.ext.Button(this.getId('unlock'), {text:Clipperz.PM.Strings['unlockButtonLabel'], handler:this.doUnlockEventHandler, scope:this, minWidth:0}); | ||
85 | this.getElement('unlock').swallowEvent('click', true); | ||
86 | new Clipperz.PM.Components.PasswordEntropyDisplay(this.getElement('lockPassphrase')); | ||
87 | MochiKit.Signal.connect('lockDialogForm', 'onsubmit', this, 'doUnlockEventHandler'); | ||
88 | |||
89 | this.getElement('cantentPanel').setVisibilityMode(YAHOO.ext.Element.DISPLAY); | ||
90 | //MochiKit.Logging.logDebug("<<< CompactInterface.render"); | ||
91 | |||
92 | return result; | ||
93 | }, | ||
94 | |||
95 | //----------------------------------------------------- | ||
96 | |||
97 | 'directLoginAddedHandler': function(anEvent) { | ||
98 | this.redrawDirectLoginItems(); | ||
99 | }, | ||
100 | |||
101 | //----------------------------------------------------- | ||
102 | |||
103 | 'compareDirectLogins': function(a, b) { | ||
104 | return MochiKit.Base.compare(a.label().toLowerCase(), b.label().toLowerCase()); | ||
105 | }, | ||
106 | |||
107 | //----------------------------------------------------- | ||
108 | |||
109 | 'redrawDirectLoginItems': function() { | ||
110 | var template; | ||
111 | var allDirectLogins; | ||
112 | |||
113 | this.getElement('message').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); | ||
114 | //MochiKit.Logging.logDebug(">>> CompactInterface.redrawDirectLoginItems"); | ||
115 | //MochiKit.Logging.logDebug("--- CompactInterface.redrawDirectLoginItems - 0"); | ||
116 | MochiKit.Iter.forEach(YAHOO.ext.Element.get('directLogins').getChildrenByTagName('li'), function(aDirectLoginElement) { | ||
117 | MochiKit.Signal.disconnectAll(aDirectLoginElement.dom); | ||
118 | //MochiKit.Logging.logDebug("disconnecting IMG " + aDirectLoginElement.getChildrenByTagName('img')[0].dom.src); | ||
119 | MochiKit.Signal.disconnectAll(aDirectLoginElement.getChildrenByTagName('img')[0].dom); | ||
120 | }) | ||
121 | //MochiKit.Logging.logDebug("--- CompactInterface.redrawDirectLoginItems - 1"); | ||
122 | YAHOO.ext.Element.get('directLogins').update(""); | ||
123 | //MochiKit.Logging.logDebug("--- CompactInterface.redrawDirectLoginItems - 2"); | ||
124 | allDirectLogins = MochiKit.Base.values(this.user().directLoginReferences()); | ||
125 | //MochiKit.Logging.logDebug("--- CompactInterface.redrawDirectLoginItems - 3"); | ||
126 | allDirectLogins.sort(this.compareDirectLogins); | ||
127 | |||
128 | //MochiKit.Logging.logDebug("--- CompactInterface.redrawDirectLoginItems - 4"); | ||
129 | template = this.directLoginItemTemplate(); | ||
130 | //MochiKit.Logging.logDebug("--- CompactInterface.redrawDirectLoginItems - 5"); | ||
131 | MochiKit.Iter.forEach(allDirectLogins, MochiKit.Base.bind(function(aDirectLogin) { | ||
132 | vardirectLoginElement; | ||
133 | varfaviconImageElementID; | ||
134 | |||
135 | faviconImageElementID = aDirectLogin.reference() + "_faviconIMG"; | ||
136 | directLoginElement = template.append('directLogins', { | ||
137 | elementID:faviconImageElementID, | ||
138 | faviconUrl:aDirectLogin.fixedFavicon(), | ||
139 | directLoginTitle:aDirectLogin.label(), | ||
140 | directLoginReference:aDirectLogin.reference() | ||
141 | }, true); | ||
142 | //MochiKit.Logging.logDebug("--- CompactInterface.redrawDirectLoginItems - 6: " + recordElement.dom); | ||
143 | directLoginElement.addClassOnOver("hover"); | ||
144 | MochiKit.Signal.connect(directLoginElement.dom, 'onclick', this, 'handleDirectLoginClick'); | ||
145 | |||
146 | MochiKit.Signal.connect(faviconImageElementID, 'onload', this, 'handleLoadedFaviconImage'); | ||
147 | MochiKit.Signal.connect(faviconImageElementID, 'onerror', aDirectLogin, 'handleMissingFaviconImage'); | ||
148 | MochiKit.Signal.connect(faviconImageElementID, 'onabort', aDirectLogin, 'handleMissingFaviconImage'); | ||
149 | |||
150 | // YAHOO.ext.Element.get(faviconImageElementID).dom.src = aDirectLogin.fixedFavicon(); | ||
151 | }, this)); | ||
152 | |||
153 | this.resetAutoLockTimer(); | ||
154 | //MochiKit.Logging.logDebug("<<< CompactInterface.redrawDirectLoginItems"); | ||
155 | }, | ||
156 | |||
157 | //----------------------------------------------------- | ||
158 | |||
159 | 'directLoginItemTemplate': function() { | ||
160 | if (this._directLoginItemTemplate == null) { | ||
161 | this._directLoginItemTemplate = Clipperz.YUI.DomHelper.createTemplate({tag:'li', id:'{directLoginReference}', children:[ | ||
162 | {tag:'table', border:'0', cellpadding:'0', cellspacing:'0', children:[ | ||
163 | {tag:'tbody', children:[ | ||
164 | {tag:'tr', children:[ | ||
165 | {tag:'td', width:'20', align:'center', valign:'top', children:[ | ||
166 | {tag:'img', id:'{elementID}', src:'{faviconUrl}'} | ||
167 | ]}, | ||
168 | {tag:'td', valign:'top', children:[ | ||
169 | {tag:'a', cls:'directLoginItemTitle', html:'{directLoginTitle}'} | ||
170 | ]} | ||
171 | ]} | ||
172 | ]} | ||
173 | ]} | ||
174 | ]}); | ||
175 | this._directLoginItemTemplate.compile(); | ||
176 | } | ||
177 | |||
178 | return this._directLoginItemTemplate; | ||
179 | }, | ||
180 | |||
181 | //------------------------------------------------------------------------- | ||
182 | |||
183 | 'handleDirectLoginClick': function(anEvent) { | ||
184 | vardirectLoginReference; | ||
185 | //MochiKit.Logging.logDebug(">>> MainPanel.handleDirectLoginClick !!!"); | ||
186 | |||
187 | directLoginReference = this.user().directLoginReferences()[anEvent.src().id]; | ||
188 | this.openDirectLogin(directLoginReference); | ||
189 | this.resetAutoLockTimer(); | ||
190 | //MochiKit.Logging.logDebug("<<< MainPanel.handleDirectLoginClick"); | ||
191 | }, | ||
192 | |||
193 | //----------------------------------------------------- | ||
194 | |||
195 | 'openDirectLogin': function(aDirectLoginReference) { | ||
196 | vardeferredResult; | ||
197 | varnewWindow; | ||
198 | |||
199 | //MochiKit.Logging.logDebug(">>> MainPanel.openDirectLogin - " + aDirectLoginReference.label()); | ||
200 | deferredResult = new MochiKit.Async.Deferred(); | ||
201 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("MainPanel.openDirectLogin - 1: " + res); return res;}); | ||
202 | deferredResult.addCallback(MochiKit.Base.method(aDirectLoginReference, 'setupJumpPageWindow')); | ||
203 | deferredResult.addCallback(MochiKit.Base.method(aDirectLoginReference, 'deferredDirectLogin')); | ||
204 | deferredResult.addCallback(function(aDirectLogin) { | ||
205 | aDirectLogin.runDirectLogin(newWindow); | ||
206 | }); | ||
207 | |||
208 | newWindow = window.open(Clipperz.PM.Strings['directLoginJumpPageUrl'], ""); | ||
209 | // MochiKit.Signal.connect(newWindow, 'onload', MochiKit.Base.method(deferredResult, 'callback', newWindow)) | ||
210 | // MochiKit.Signal.connect(newWindow, 'onload', MochiKit.Base.partial(alert, "done")); | ||
211 | deferredResult.callback(newWindow); | ||
212 | //MochiKit.Logging.logDebug("<<< MainPanel.openDirectLogin"); | ||
213 | }, | ||
214 | |||
215 | //------------------------------------------------------------------------- | ||
216 | |||
217 | 'handleLoadedFaviconImage': function(anEvent) { | ||
218 | //MochiKit.Logging.logDebug(">>> MainPanel.handleLoadedFaviconImage"); | ||
219 | MochiKit.Signal.disconnectAll(anEvent.src()) | ||
220 | //MochiKit.Logging.logDebug("<<< MainPanel.handleLoadedFaviconImage"); | ||
221 | }, | ||
222 | |||
223 | //------------------------------------------------------------------------- | ||
224 | |||
225 | 'doLockEventHandler': function(anEvent) { | ||
226 | anEvent.stop(); | ||
227 | this.lock(); | ||
228 | }, | ||
229 | |||
230 | 'doUnlockEventHandler': function(anEvent) { | ||
231 | if (typeof(anEvent.stop) != 'undefined') { | ||
232 | anEvent.stop(); | ||
233 | } | ||
234 | this.unlock(); | ||
235 | }, | ||
236 | |||
237 | //------------------------------------------------------------------------- | ||
238 | |||
239 | 'autolock': function() { | ||
240 | varshouldAutoLock; | ||
241 | |||
242 | shouldAutoLock = YAHOO.ext.Element.get('autolock').dom.checked; | ||
243 | |||
244 | if (shouldAutoLock) { | ||
245 | this.lock(); | ||
246 | } else { | ||
247 | this.resetAutoLockTimer(); | ||
248 | } | ||
249 | }, | ||
250 | |||
251 | 'lock': function() { | ||
252 | //MochiKit.Logging.logDebug(">>> lock"); | ||
253 | this.getDom('lockPassphrase').value = ""; | ||
254 | this.getElement('lockPanel').show(); | ||
255 | this.getElement('cantentPanel').hide(); | ||
256 | YAHOO.ext.Element.get('lockBlock').hide(); | ||
257 | //this.getElement('lockPassphrase').focus(); | ||
258 | //MochiKit.Logging.logDebug("<<< lock"); | ||
259 | }, | ||
260 | |||
261 | 'unlock': function(anEvent) { | ||
262 | //MochiKit.Logging.logDebug(">>> unlock"); | ||
263 | if (this.getDom('lockPassphrase').value == this.user().passphrase()) { | ||
264 | this.getElement('lockPanel').hide(); | ||
265 | this.getElement('cantentPanel').show(); | ||
266 | YAHOO.ext.Element.get('lockBlock').show(); | ||
267 | this.resetAutoLockTimer(); | ||
268 | } else { | ||
269 | this.getDom('lockPassphrase').value = ""; | ||
270 | this.getElement('lockPassphrase').focus(); | ||
271 | } | ||
272 | //MochiKit.Logging.logDebug("<<< unlock"); | ||
273 | }, | ||
274 | |||
275 | //------------------------------------------------------------------------- | ||
276 | |||
277 | 'user': function() { | ||
278 | return this._user; | ||
279 | }, | ||
280 | |||
281 | //----------------------------------------------------- | ||
282 | |||
283 | 'autoLockTimer': function() { | ||
284 | if (this._autoLockTimer == null) { | ||
285 | //MochiKit.Logging.logDebug("--- timer started - 1"); | ||
286 | this._autoLockTimer = MochiKit.Async.callLater(60, MochiKit.Base.method(this, 'autolock')); | ||
287 | //MochiKit.Logging.logDebug("--- timer started - 2"); | ||
288 | } | ||
289 | |||
290 | return this._autoLockTimer; | ||
291 | }, | ||
292 | |||
293 | 'resetAutoLockTimer': function() { | ||
294 | //MochiKit.Logging.logDebug(">>> timer resetted"); | ||
295 | this.autoLockTimer().cancel(); | ||
296 | this._autoLockTimer = null; | ||
297 | //MochiKit.Logging.logDebug("--- timer resetted - 1"); | ||
298 | this.autoLockTimer(); | ||
299 | //MochiKit.Logging.logDebug("<<< timer resetted"); | ||
300 | }, | ||
301 | |||
302 | //----------------------------------------------------- | ||
303 | |||
304 | 'userNotificationHandler': function(anEvent) { | ||
305 | this.getElement('message').update(anEvent.parameters().text); | ||
306 | }, | ||
307 | |||
308 | //----------------------------------------------------- | ||
309 | __syntaxFix__: '__syntaxFix__' | ||
310 | }); | ||
311 | |||
312 | |||
diff --git a/frontend/beta/js/Clipperz/PM/Components/Compact/LoginForm.js b/frontend/beta/js/Clipperz/PM/Components/Compact/LoginForm.js new file mode 100644 index 0000000..d708464 --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/Compact/LoginForm.js | |||
@@ -0,0 +1,189 @@ | |||
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 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | ||
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | ||
31 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } | ||
32 | if (typeof(Clipperz.PM.Components.Compact) == 'undefined') { Clipperz.PM.Components.Compact = {}; } | ||
33 | |||
34 | Clipperz.PM.Components.Compact.LoginForm = function(anElement, args) { | ||
35 | |||
36 | Clipperz.PM.Components.Compact.LoginForm.superclass.constructor.call(this, anElement, args); | ||
37 | |||
38 | this.render(); | ||
39 | Clipperz.NotificationCenter.register(null, 'updatedProgressState', this, 'userNotificationHandler') | ||
40 | |||
41 | return this; | ||
42 | }; | ||
43 | |||
44 | YAHOO.extendX(Clipperz.PM.Components.Compact.LoginForm, Clipperz.PM.Components.BaseComponent, { | ||
45 | |||
46 | 'toString': function() { | ||
47 | return "Clipperz.PM.Components.Compact.LoginForm"; | ||
48 | }, | ||
49 | |||
50 | //----------------------------------------------------- | ||
51 | |||
52 | 'render': function() { | ||
53 | var result; | ||
54 | varlayout; | ||
55 | |||
56 | MochiKit.Signal.disconnectAllTo(this); | ||
57 | this.element().update(""); | ||
58 | |||
59 | Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'div', id:this.getId('baseDiv'), cls:'LoginPanel', children:[ | ||
60 | {tag:'div', id:'compactHeader'}, | ||
61 | {tag:'div', id:'compactBody', children:[ | ||
62 | {tag:'form', id:this.getId('loginForm_form'), children:[ | ||
63 | {tag:'dl', children:[ | ||
64 | {tag:'dt', htmlString:Clipperz.PM.Strings['loginFormUsernameLabel']}, | ||
65 | {tag:'dd', children:[ | ||
66 | {tag:'input', id:this.getId('login_username'), type:'text', size:'30', name:'username'} | ||
67 | ]}, | ||
68 | {tag:'dt', htmlString:Clipperz.PM.Strings['loginFormPassphraseLabel']}, | ||
69 | {tag:'dd', children:[ | ||
70 | {tag:'input', id:this.getId('login_passphrase'), type:'password', size:'30', name:'passphrase'} | ||
71 | ]} | ||
72 | ]}, | ||
73 | {tag:'div', id:this.getId('login_submit')} | ||
74 | ]}, | ||
75 | {tag:'h4', id:this.getId('message')} | ||
76 | ]} | ||
77 | ]}); | ||
78 | |||
79 | new Clipperz.PM.Components.Compact.CompactHeader(YAHOO.ext.Element.get('compactHeader')); | ||
80 | |||
81 | MochiKit.Signal.connect(this.getId('loginForm_form'), 'onsubmit', this, 'stopFormSubmit'); | ||
82 | new YAHOO.ext.Button(this.getId('login_submit'), {text:Clipperz.PM.Strings['loginFormButtonLabel'], handler:this.doLogin, scope:this, minWidth:0}); | ||
83 | this.getElement('login_submit').swallowEvent('click', true); | ||
84 | |||
85 | MochiKit.Signal.connect(this.getId('loginForm_form'), 'onkeydown', this, 'onkeydown'); | ||
86 | |||
87 | new Clipperz.PM.Components.PasswordEntropyDisplay(this.getElement('login_passphrase')); | ||
88 | this.getElement('login_username').focus(); | ||
89 | |||
90 | return result; | ||
91 | }, | ||
92 | |||
93 | //----------------------------------------------------- | ||
94 | |||
95 | 'doLogin': function(e) { | ||
96 | //MochiKit.Logging.logDebug(">>> compact.LoginForm.doLogin"); | ||
97 | if (this.checkLoginForm()) { | ||
98 | this.doLoginWithUsernameAndPassphrase(this.getDom('login_username').value, this.getDom('login_passphrase').value); | ||
99 | } | ||
100 | //MochiKit.Logging.logDebug("<<< compact.LoginForm.doLogin"); | ||
101 | }, | ||
102 | |||
103 | //......................................................................... | ||
104 | |||
105 | 'doLoginWithUsernameAndPassphrase': function(anUsername, aPassphrase) { | ||
106 | var deferredResult; | ||
107 | var user; | ||
108 | |||
109 | //MochiKit.Logging.logDebug(">>> compact.LoginForm.doLoginWithUsernameAndPassphrase"); | ||
110 | user = new Clipperz.PM.DataModel.User({username:anUsername, passphrase:aPassphrase}); | ||
111 | |||
112 | deferredResult = new MochiKit.Async.Deferred(); | ||
113 | deferredResult.addCallback(MochiKit.Base.method(user, 'connect')); | ||
114 | deferredResult.addCallback(MochiKit.Base.method(user, 'loadPreferences')); | ||
115 | deferredResult.addCallback(MochiKit.Base.method(user, 'loadRecords')); | ||
116 | deferredResult.addCallback(MochiKit.Base.method(user, 'loadDirectLogins')); | ||
117 | deferredResult.addErrback(MochiKit.Base.bind(function() { | ||
118 | this.getElement('loginForm_form').setVisibilityMode(YAHOO.ext.Element.DISPLAY).show(); | ||
119 | this.getElement('message').update(Clipperz.PM.Strings['loginMessagePanelFailureText']); | ||
120 | this.getDom('login_passphrase').value = ""; | ||
121 | this.getElement('login_passphrase').focus(); | ||
122 | }, this)) | ||
123 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("compact.LoginForm.doLogin - 6: " + res); return res;}); | ||
124 | deferredResult.callback("token"); | ||
125 | //MochiKit.Logging.logDebug("<<< compact.LoginForm.doLoginWithUsernameAndPassphrase"); | ||
126 | |||
127 | return deferredResult; | ||
128 | }, | ||
129 | |||
130 | //......................................................................... | ||
131 | |||
132 | 'checkLoginForm': function() { | ||
133 | var result; | ||
134 | var username | ||
135 | varpassphrase; | ||
136 | |||
137 | //MochiKit.Logging.logDebug(">>> checkLoginForm"); | ||
138 | username = this.getDom('login_username').value; | ||
139 | passphrase = this.getDom('login_passphrase').value; | ||
140 | |||
141 | if ((username != "") && (passphrase != "")) { | ||
142 | result = true; | ||
143 | } else { | ||
144 | if (username == "") { | ||
145 | this.getElement('login_username').focus(); | ||
146 | } else if (passphrase == "") { | ||
147 | this.getElement('login_passphrase').focus(); | ||
148 | } | ||
149 | |||
150 | result = false; | ||
151 | } | ||
152 | //MochiKit.Logging.logDebug("<<< checkLoginForm - " + result); | ||
153 | |||
154 | return result; | ||
155 | }, | ||
156 | |||
157 | //------------------------------------------------------------------------- | ||
158 | |||
159 | 'stopFormSubmit': function(anEvent) { | ||
160 | anEvent.stop(); | ||
161 | }, | ||
162 | |||
163 | //------------------------------------------------------------------------- | ||
164 | |||
165 | 'onkeydown': function(anEvent) { | ||
166 | //MochiKit.Logging.logDebug(">>> onkeydown - " + anEvent.src().id); | ||
167 | if (anEvent.key().code == 13) { | ||
168 | this.doLogin(); | ||
169 | anEvent.stop(); | ||
170 | } | ||
171 | }, | ||
172 | |||
173 | //----------------------------------------------------- | ||
174 | |||
175 | 'userNotificationHandler': function(anEvent) { | ||
176 | //MochiKit.Logging.logDebug(">>> compact.LoginForm.userNotificationHandler"); | ||
177 | //MochiKit.Logging.logDebug("userNotificationHandler - event: " + anEvent.event()); | ||
178 | this.getElement('loginForm_form').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); | ||
179 | if (this.getDom('message') != null) { | ||
180 | this.getElement('message').update(Clipperz.PM.Strings.messagePanelConfigurations[anEvent.parameters()]()['text']); | ||
181 | } | ||
182 | //MochiKit.Logging.logDebug("<<< compact.LoginForm.userNotificationHandler"); | ||
183 | }, | ||
184 | |||
185 | //----------------------------------------------------- | ||
186 | __syntaxFix__: '__syntaxFix__' | ||
187 | }); | ||
188 | |||
189 | |||
diff --git a/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportColumns.js b/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportColumns.js new file mode 100644 index 0000000..18b36da --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportColumns.js | |||
@@ -0,0 +1,174 @@ | |||
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 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | ||
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | ||
31 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } | ||
32 | if (typeof(Clipperz.PM.Components.Import) == 'undefined') { Clipperz.PM.Components.Import = {}; } | ||
33 | if (typeof(Clipperz.PM.Components.Import.CSVImport) == 'undefined') { Clipperz.PM.Components.Import.CSVImport = {}; } | ||
34 | |||
35 | //############################################################################# | ||
36 | |||
37 | Clipperz.PM.Components.Import.CSVImport.CSVImportColumns = function(anElement, args) { | ||
38 | args = args || {}; | ||
39 | |||
40 | Clipperz.PM.Components.Import.CSVImport.CSVImportColumns.superclass.constructor.call(this, anElement, args); | ||
41 | this._mainComponent = args.mainComponent; | ||
42 | |||
43 | return this; | ||
44 | } | ||
45 | |||
46 | //============================================================================= | ||
47 | |||
48 | YAHOO.extendX(Clipperz.PM.Components.Import.CSVImport.CSVImportColumns, Clipperz.PM.Components.BaseComponent, { | ||
49 | |||
50 | 'toString': function() { | ||
51 | return "Clipperz.PM.Components.Import.CSVImport.CSVImportColumns component"; | ||
52 | }, | ||
53 | |||
54 | //------------------------------------------------------------------------- | ||
55 | |||
56 | 'mainComponent': function() { | ||
57 | return this._mainComponent; | ||
58 | }, | ||
59 | |||
60 | //------------------------------------------------------------------------- | ||
61 | |||
62 | 'render': function() { | ||
63 | var i,c; | ||
64 | var columnSelectorCheckboxCells; | ||
65 | var checkboxes; | ||
66 | var data; | ||
67 | |||
68 | //MochiKit.Logging.logDebug(">>> CSVImportColumns.render"); | ||
69 | Clipperz.NotificationCenter.unregister(this); | ||
70 | MochiKit.Signal.disconnectAllTo(this); | ||
71 | |||
72 | this.element().update(""); | ||
73 | |||
74 | data = this.mainComponent().parsedValues(); | ||
75 | columnSelectorCheckboxCells = []; | ||
76 | |||
77 | c =data[0].length; | ||
78 | for (i=0; i<c; i++) { | ||
79 | columnSelectorCheckboxCells.push({tag:'th', valign:'top', cls:(this.mainComponent().isColumnSelected(i) ? 'selectedColumn': 'skippedColumn'), children:[ | ||
80 | {tag:'input', type:'checkbox', id:this.getId('columnCheckbox_' + i), value:i} | ||
81 | ]}) | ||
82 | } | ||
83 | |||
84 | this.domHelper().append(this.element(), {tag:'div', children:[ | ||
85 | {tag:'div', cls:'importStepDescription', htmlString:Clipperz.PM.Strings['CSV_ImportWizard_Columns']}, | ||
86 | {tag:'div', id:this.getId('dataDiv'), cls:'csvImportPreview', children:[ | ||
87 | {tag:'table', id:this.getId('previewDada'), cls:'csvImportPreview columns', cellspacing:'0', children:[ | ||
88 | {tag:'thead', id:this.getId('previewData_thead'), children:[ | ||
89 | {tag:'tr', children:columnSelectorCheckboxCells} | ||
90 | ]}, | ||
91 | {tag:'tbody', id:this.getId('previewData_tbody'), children:[]} | ||
92 | ]} | ||
93 | ]} | ||
94 | ]}); | ||
95 | |||
96 | c =data[0].length; | ||
97 | for (i=0; i<c; i++) { | ||
98 | if (this.mainComponent().isColumnSelected(i)) { | ||
99 | this.getDom('columnCheckbox_' + i).checked = true; | ||
100 | } | ||
101 | } | ||
102 | |||
103 | this.renderData(this.getElement('previewData_tbody'), data); | ||
104 | |||
105 | checkboxes = MochiKit.DOM.getElementsByTagAndClassName('input', null, this.getDom('previewData_thead')); | ||
106 | c = checkboxes.length; | ||
107 | for (i=0; i<c; i++) { | ||
108 | MochiKit.Signal.connect(checkboxes[i], 'onclick', this, 'renderDataHandler'); | ||
109 | } | ||
110 | //MochiKit.Logging.logDebug("<<< CSVImportColumns.render"); | ||
111 | }, | ||
112 | |||
113 | //------------------------------------------------------------------------- | ||
114 | |||
115 | 'renderData': function(anElement, someData) { | ||
116 | var config; | ||
117 | var i,c; | ||
118 | |||
119 | //MochiKit.Logging.logDebug(">>> CSVImportColumns.renderData"); | ||
120 | // anElement.update(""); | ||
121 | MochiKit.DOM.replaceChildNodes(anElement.dom); | ||
122 | |||
123 | config = MochiKit.Base.map(MochiKit.Base.bind(function(aRowData) { | ||
124 | var result; | ||
125 | var i,c; | ||
126 | |||
127 | result = {tag:'tr', children:[]}; | ||
128 | c = aRowData.length; | ||
129 | for (i=0; i<c; i++) { | ||
130 | var field; | ||
131 | |||
132 | field = aRowData[i]; | ||
133 | result.children.push({tag:'td', valign:'top', cls:(this.mainComponent().isColumnSelected(i) ? 'selectedColumn': 'skippedColumn'), html:(MochiKit.Base.isNotEmpty(field) ? field.replace(/\n/g, '<br>') : ' ')}); | ||
134 | } | ||
135 | |||
136 | return result; | ||
137 | }, this), someData); | ||
138 | |||
139 | MochiKit.Base.map(function(aRowConfig) {Clipperz.YUI.DomHelper.append(anElement, aRowConfig);}, config); | ||
140 | |||
141 | Clipperz.Style.applyZebraStylesToTable(this.getId('previewDada')); | ||
142 | //MochiKit.Logging.logDebug("<<< CSVImportColumns.renderData"); | ||
143 | }, | ||
144 | |||
145 | //------------------------------------------------------------------------- | ||
146 | |||
147 | 'renderDataHandler': function(anEvent) { | ||
148 | var thElement; | ||
149 | |||
150 | thElement = YAHOO.ext.Element.get(anEvent.src().parentNode); | ||
151 | |||
152 | if (anEvent.src().checked == true) { | ||
153 | this.mainComponent().skippedColumns().remove(anEvent.src().value); | ||
154 | thElement.addClass('selectedColumn'); | ||
155 | thElement.removeClass('skippedColumn'); | ||
156 | } else { | ||
157 | this.mainComponent().skippedColumns().add(anEvent.src().value); | ||
158 | thElement.removeClass('selectedColumn'); | ||
159 | thElement.addClass('skippedColumn'); | ||
160 | } | ||
161 | |||
162 | if (this.mainComponent().skippedColumns().allItems().length == this.mainComponent().parsedValues()[0].length) { | ||
163 | this.mainComponent().nextButton().disable(); | ||
164 | } else { | ||
165 | this.mainComponent().nextButton().enable(); | ||
166 | } | ||
167 | |||
168 | this.renderData(this.getElement('previewData_tbody'), this.mainComponent().parsedValues()); | ||
169 | }, | ||
170 | |||
171 | //------------------------------------------------------------------------- | ||
172 | __syntaxFix__: "syntax fix" | ||
173 | }); | ||
174 | |||
diff --git a/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportFields.js b/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportFields.js new file mode 100644 index 0000000..a368747 --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportFields.js | |||
@@ -0,0 +1,247 @@ | |||
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 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | ||
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | ||
31 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } | ||
32 | if (typeof(Clipperz.PM.Components.Import) == 'undefined') { Clipperz.PM.Components.Import = {}; } | ||
33 | if (typeof(Clipperz.PM.Components.Import.CSVImport) == 'undefined') { Clipperz.PM.Components.Import.CSVImport = {}; } | ||
34 | |||
35 | //############################################################################# | ||
36 | |||
37 | Clipperz.PM.Components.Import.CSVImport.CSVImportFields = function(anElement, args) { | ||
38 | args = args || {}; | ||
39 | |||
40 | Clipperz.PM.Components.Import.CSVImport.CSVImportFields.superclass.constructor.call(this, anElement, args); | ||
41 | this._mainComponent = args.mainComponent; | ||
42 | |||
43 | return this; | ||
44 | } | ||
45 | |||
46 | //============================================================================= | ||
47 | |||
48 | YAHOO.extendX(Clipperz.PM.Components.Import.CSVImport.CSVImportFields, Clipperz.PM.Components.BaseComponent, { | ||
49 | |||
50 | 'toString': function() { | ||
51 | return "Clipperz.PM.Components.Import.CSVImport.CSVImportFields component"; | ||
52 | }, | ||
53 | |||
54 | //------------------------------------------------------------------------- | ||
55 | |||
56 | 'mainComponent': function() { | ||
57 | return this._mainComponent; | ||
58 | }, | ||
59 | |||
60 | //------------------------------------------------------------------------- | ||
61 | |||
62 | 'render': function() { | ||
63 | varfieldsHeaderCells; | ||
64 | var titleColumnIndex; | ||
65 | var notesColumnIndex; | ||
66 | var i,c; | ||
67 | |||
68 | Clipperz.NotificationCenter.unregister(this); | ||
69 | MochiKit.Signal.disconnectAllTo(this); | ||
70 | |||
71 | this.element().update(""); | ||
72 | |||
73 | titleColumnIndex = this.mainComponent().titleColumnIndex() | ||
74 | notesColumnIndex = this.mainComponent().notesColumnIndex() | ||
75 | |||
76 | fieldsHeaderCells = []; | ||
77 | fieldsHeaderCells.push({tag:'td', valign:'top', cls:'title', html:this.mainComponent().labelForColumn(titleColumnIndex)}); | ||
78 | |||
79 | c =this.mainComponent().parsedValues()[0].length; | ||
80 | for (i=0; i<c; i++) { | ||
81 | if ((i != titleColumnIndex) && (i != notesColumnIndex) && (this.mainComponent().isColumnSelected(i))) { | ||
82 | var trimmedLabel; | ||
83 | |||
84 | trimmedLabel = Clipperz.Base.trim(this.mainComponent().labelForColumn(i)); | ||
85 | fieldsHeaderCells.push({tag:'td', valign:'top', id:this.getId('fieldHeaderTD_' + i), cls:((trimmedLabel == "") ? 'missingLabelWarning' : (this.isColumnSetup(i) ? 'configuredColumn': 'unconfiguredColumn')), children:[ | ||
86 | {tag:'span', html:((trimmedLabel == "") ? Clipperz.PM.Strings['CSV_ImportWizard_Fields_MissingLabelWarning'] : trimmedLabel)/*, cls:((trimmedLabel == "") ? 'missingLabelWarning' : '')*/}, | ||
87 | {tag:'select', id:this.getId('select_' + i), name:i, children:[ | ||
88 | {tag:'option', value:'UNDEFINED', html:"select data type", cls:'disabledOption'}, | ||
89 | {tag:'option', value:'TXT', htmlString:Clipperz.PM.Strings['recordFieldTypologies']['TXT']['shortDescription']}, | ||
90 | {tag:'option', value:'PWD', htmlString:Clipperz.PM.Strings['recordFieldTypologies']['PWD']['shortDescription']}, | ||
91 | {tag:'option', value:'URL', htmlString:Clipperz.PM.Strings['recordFieldTypologies']['URL']['shortDescription']}, | ||
92 | {tag:'option', value:'DATE', htmlString:Clipperz.PM.Strings['recordFieldTypologies']['DATE']['shortDescription']}, | ||
93 | {tag:'option', value:'ADDR', htmlString:Clipperz.PM.Strings['recordFieldTypologies']['ADDR']['shortDescription']} | ||
94 | ]} | ||
95 | ]}) | ||
96 | } | ||
97 | } | ||
98 | |||
99 | if (notesColumnIndex != -1) { | ||
100 | fieldsHeaderCells.push({tag:'td', valign:'top', cls:'notes', html:this.mainComponent().labelForColumn(notesColumnIndex)}); | ||
101 | } | ||
102 | |||
103 | this.domHelper().append(this.element(), {tag:'div', children:[ | ||
104 | {tag:'div', cls:'importStepDescription', htmlString:Clipperz.PM.Strings['CSV_ImportWizard_Fields']}, | ||
105 | {tag:'div', id:this.getId('dataDiv'), children:[ | ||
106 | {tag:'div', children:[ | ||
107 | ]}, | ||
108 | {tag:'div', cls:'csvImportPreview', children:[ | ||
109 | {tag:'table', id:this.getId('previewDada'), cls:'csvImportPreview', cellspacing:'0', children:[ | ||
110 | {tag:'thead', id:this.getId('previewData_thead'), children:[ | ||
111 | {tag:'tr', cls:'CSV_previewData_header', children:fieldsHeaderCells} | ||
112 | ]}, | ||
113 | {tag:'tbody', id:this.getId('previewData_tbody'), children:[]} | ||
114 | ]} | ||
115 | ]} | ||
116 | ]} | ||
117 | ]}); | ||
118 | |||
119 | for (i=0; i<c; i++) { | ||
120 | if ((i != titleColumnIndex) && (i != notesColumnIndex) && (this.mainComponent().isColumnSelected(i))) { | ||
121 | Clipperz.DOM.selectOptionMatchingValue(this.getDom('select_' + i), this.mainComponent().typeForColumn(i)); | ||
122 | MochiKit.Signal.connect(this.getDom('select_' + i), 'onchange', this, 'renderDataRowsHandler'); | ||
123 | } | ||
124 | } | ||
125 | |||
126 | this.renderDataRows(this.getElement('previewData_tbody')); | ||
127 | // Clipperz.NotificationCenter.register(null, 'updatedCSVImportColumnHeader', this, 'renderDataRowsHandler'); | ||
128 | }, | ||
129 | |||
130 | //------------------------------------------------------------------------- | ||
131 | |||
132 | 'isColumnSetup': function(aColumnIndex) { | ||
133 | return ((Clipperz.Base.trim(this.mainComponent().labelForColumn(aColumnIndex)) != "") && (this.mainComponent().typeForColumn(aColumnIndex) != 'UNDEFINED')); | ||
134 | }, | ||
135 | |||
136 | //------------------------------------------------------------------------- | ||
137 | |||
138 | 'renderDataRowsHandler': function(anEvent) { | ||
139 | var columnIndex; | ||
140 | var tdElement; | ||
141 | |||
142 | //MochiKit.Logging.logDebug(">>> renderDataRowsHandler") | ||
143 | columnIndex = anEvent.src().name; | ||
144 | this.mainComponent().setTypeForColumn(anEvent.src().value, columnIndex); | ||
145 | |||
146 | tdElement = this.getElement('fieldHeaderTD_' + columnIndex); | ||
147 | |||
148 | if (this.isColumnSetup(columnIndex)) { | ||
149 | tdElement.removeClass('unconfiguredColumn'); | ||
150 | tdElement.addClass('configuredColumn'); | ||
151 | } else { | ||
152 | tdElement.addClass('unconfiguredColumn'); | ||
153 | tdElement.removeClass('configuredColumn'); | ||
154 | } | ||
155 | |||
156 | this.renderDataRows(this.getElement('previewData_tbody')); | ||
157 | }, | ||
158 | |||
159 | //------------------------------------------------------------------------- | ||
160 | |||
161 | 'renderDataRows': function(anElement) { | ||
162 | var titleColumnIndex; | ||
163 | var notesColumnIndex; | ||
164 | var data | ||
165 | var i,c; | ||
166 | |||
167 | //MochiKit.Logging.logDebug("#### >> renderDataRows"); | ||
168 | // anElement.update(""); | ||
169 | MochiKit.DOM.replaceChildNodes(anElement.dom); | ||
170 | |||
171 | if (this.mainComponent().isFirstRowHeader()) { | ||
172 | data = this.mainComponent().parsedValues().slice(1); | ||
173 | } else { | ||
174 | data = this.mainComponent().parsedValues(); | ||
175 | } | ||
176 | |||
177 | |||
178 | titleColumnIndex = this.mainComponent().titleColumnIndex(); | ||
179 | notesColumnIndex = this.mainComponent().notesColumnIndex(); | ||
180 | |||
181 | c = data.length; | ||
182 | for (i=0; i<c; i++) { | ||
183 | var rowData; | ||
184 | var rowConfig; | ||
185 | var ii, cc; | ||
186 | |||
187 | rowData = data[i]; | ||
188 | |||
189 | rowConfig = {tag:'tr', children:[ | ||
190 | {tag:'td', valign:'top', cls:'title', html:(MochiKit.Base.isNotEmpty(rowData[titleColumnIndex]) ? rowData[titleColumnIndex].replace(/\n/g, '<br>') : ' ')} | ||
191 | ]}; | ||
192 | |||
193 | cc = rowData.length; | ||
194 | for (ii=0; ii<cc; ii++) { | ||
195 | // if ((ii != titleColumnIndex) && (ii != notesColumnIndex)) { | ||
196 | if ((ii != titleColumnIndex) && (ii != notesColumnIndex) && (this.mainComponent().isColumnSelected(ii))) { | ||
197 | rowConfig.children.push({ | ||
198 | tag:'td', | ||
199 | valign:'top', | ||
200 | cls:(this.isColumnSetup(ii) ? 'configuredColumn' : 'unconfiguredColumn'), | ||
201 | html:(MochiKit.Base.isNotEmpty(rowData[ii]) ? rowData[ii].replace(/\n/g, '<br>') : ' ') | ||
202 | }); | ||
203 | } | ||
204 | } | ||
205 | if (notesColumnIndex != -1) { | ||
206 | rowConfig.children.push({tag:'td', valign:'top', cls:'notes', html:(MochiKit.Base.isNotEmpty(rowData[notesColumnIndex]) ? rowData[notesColumnIndex].replace(/\n/g, '<br>') : ' ')}); | ||
207 | } | ||
208 | |||
209 | this.domHelper().append(anElement, rowConfig); | ||
210 | } | ||
211 | |||
212 | Clipperz.Style.applyZebraStylesToTable(this.getId('previewDada')); | ||
213 | |||
214 | this.checkWetherToEnableNextButton(); | ||
215 | //MochiKit.Logging.logDebug("#### << renderDataRows"); | ||
216 | }, | ||
217 | |||
218 | //------------------------------------------------------------------------- | ||
219 | |||
220 | 'checkWetherToEnableNextButton': function() { | ||
221 | var result; | ||
222 | var titleColumnIndex; | ||
223 | var notesColumnIndex; | ||
224 | var i,c; | ||
225 | |||
226 | titleColumnIndex = this.mainComponent().titleColumnIndex() | ||
227 | notesColumnIndex = this.mainComponent().notesColumnIndex() | ||
228 | |||
229 | result = true; | ||
230 | c =this.mainComponent().parsedValues()[0].length; | ||
231 | for (i=0; i<c; i++) { | ||
232 | if ((i != titleColumnIndex) && (i != notesColumnIndex) && (this.mainComponent().isColumnSelected(i))) { | ||
233 | result = result && this.isColumnSetup(i); | ||
234 | } | ||
235 | } | ||
236 | |||
237 | if (result) { | ||
238 | this.mainComponent().nextButton().enable(); | ||
239 | } else { | ||
240 | this.mainComponent().nextButton().disable(); | ||
241 | } | ||
242 | }, | ||
243 | |||
244 | //------------------------------------------------------------------------- | ||
245 | __syntaxFix__: "syntax fix" | ||
246 | }); | ||
247 | |||
diff --git a/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportHeader.js b/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportHeader.js new file mode 100644 index 0000000..ebd243a --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportHeader.js | |||
@@ -0,0 +1,240 @@ | |||
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 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | ||
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | ||
31 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } | ||
32 | if (typeof(Clipperz.PM.Components.Import) == 'undefined') { Clipperz.PM.Components.Import = {}; } | ||
33 | if (typeof(Clipperz.PM.Components.Import.CSVImport) == 'undefined') { Clipperz.PM.Components.Import.CSVImport = {}; } | ||
34 | |||
35 | //############################################################################# | ||
36 | |||
37 | Clipperz.PM.Components.Import.CSVImport.CSVImportHeader = function(anElement, args) { | ||
38 | args = args || {}; | ||
39 | |||
40 | Clipperz.PM.Components.Import.CSVImport.CSVImportHeader.superclass.constructor.call(this, anElement, args); | ||
41 | this._mainComponent = args.mainComponent; | ||
42 | |||
43 | this._pendingDeferredLabelFieldHandlerEvents = 0; | ||
44 | |||
45 | return this; | ||
46 | } | ||
47 | |||
48 | //============================================================================= | ||
49 | |||
50 | YAHOO.extendX(Clipperz.PM.Components.Import.CSVImport.CSVImportHeader, Clipperz.PM.Components.BaseComponent, { | ||
51 | |||
52 | 'toString': function() { | ||
53 | return "Clipperz.PM.Components.Import.CSVImport.CSVImportHeader component"; | ||
54 | }, | ||
55 | |||
56 | //------------------------------------------------------------------------- | ||
57 | |||
58 | 'mainComponent': function() { | ||
59 | return this._mainComponent; | ||
60 | }, | ||
61 | |||
62 | //------------------------------------------------------------------------- | ||
63 | |||
64 | 'render': function() { | ||
65 | var thConfigs; | ||
66 | var i,c; | ||
67 | |||
68 | //MochiKit.Logging.logDebug(">>> CSVImportHeader.render"); | ||
69 | Clipperz.NotificationCenter.unregister(this); | ||
70 | MochiKit.Signal.disconnectAllTo(this); | ||
71 | |||
72 | thConfigs = []; | ||
73 | c = this.mainComponent().parsedValues()[0].length; | ||
74 | for (i=0; i<c; i++) { | ||
75 | if (this.mainComponent().isColumnSelected(i)) { | ||
76 | // thConfigs.push({tag:'th', children:[{tag:'input', type:'text', id:this.getId('headerTextField_' + i), value:this.mainComponent().labelForColumn(i)}]}); | ||
77 | thConfigs.push({tag:'th', children:[{tag:'input', type:'text', id:this.getId('headerTextField_' + i), value:""}]}); | ||
78 | } | ||
79 | } | ||
80 | |||
81 | this.element().update(""); | ||
82 | this.domHelper().append(this.element(), {tag:'div', children:[ | ||
83 | {tag:'div', cls:'importStepDescription', htmlString:Clipperz.PM.Strings['CSV_ImportWizard_Header']}, | ||
84 | {tag:'div', cls:'importStepParameters', children:[ | ||
85 | {tag:'input', type:'checkbox', name:'isFistRowHeader', id:this.getId('isFirstRowHeader_checkbox')}, | ||
86 | {tag:'span', id:this.getId('isFirstRowHeader_span'), cls:'clickableSpan', htmlString:Clipperz.PM.Strings['CSV_ImportWizard_Header_Settings_firstRowHeaderLabel']} | ||
87 | ]}, | ||
88 | {tag:'div', id:this.getId('dataDiv'), children:[ | ||
89 | {tag:'div', cls:'csvImportPreview', children:[ | ||
90 | {tag:'table', id:this.getId('previewDada'), cls:'csvImportPreview header', cellspacing:'0', children:[ | ||
91 | {tag:'thead', children:[{tag:'tr', children:thConfigs}]}, | ||
92 | {tag:'tbody', id:this.getId('previewData_tbody')} | ||
93 | ]} | ||
94 | ]} | ||
95 | ]} | ||
96 | ]}); | ||
97 | |||
98 | for (i=0; i<c; i++) { | ||
99 | if (this.mainComponent().isColumnSelected(i)) { | ||
100 | this.getElement('headerTextField_' + i).dom.value = this.mainComponent().labelForColumn(i); | ||
101 | } | ||
102 | } | ||
103 | |||
104 | this.renderData(this.getElement('previewData_tbody'), this.mainComponent().parsedValues()); | ||
105 | |||
106 | if (this.mainComponent().isFirstRowHeader()) { | ||
107 | this.getDom('isFirstRowHeader_checkbox').click(); | ||
108 | } | ||
109 | |||
110 | c = this.mainComponent().parsedValues()[0].length; | ||
111 | for (i=0; i<c; i++) { | ||
112 | if (this.mainComponent().isColumnSelected(i)) { | ||
113 | MochiKit.Signal.connect(this.getDom('headerTextField_' + i), 'onchange', MochiKit.Base.partial(MochiKit.Base.method(this, 'labelFieldHandler'), i)); | ||
114 | MochiKit.Signal.connect(this.getDom('headerTextField_' + i), 'onkeypress', MochiKit.Base.partial(MochiKit.Base.method(this, 'deferredLabelFieldHandler'), i)); | ||
115 | } | ||
116 | } | ||
117 | |||
118 | MochiKit.Signal.connect(this.getDom('isFirstRowHeader_checkbox'), 'onclick', this, 'toggleFirstRowHeaderCheckboxHandler'); | ||
119 | if (Clipperz_IEisBroken != true) { | ||
120 | MochiKit.Signal.connect(this.getDom('isFirstRowHeader_span'), 'onclick', this.getDom('isFirstRowHeader_checkbox'), 'click'); | ||
121 | } | ||
122 | //MochiKit.Logging.logDebug("<<< CSVImportHeader.render"); | ||
123 | }, | ||
124 | |||
125 | //------------------------------------------------------------------------- | ||
126 | |||
127 | 'renderData': function(anElement, someData) { | ||
128 | var trConfigs; | ||
129 | var data; | ||
130 | var i,c; | ||
131 | |||
132 | // anElement.update(""); | ||
133 | MochiKit.DOM.replaceChildNodes(anElement.dom); | ||
134 | |||
135 | if (this.mainComponent().isFirstRowHeader()) { | ||
136 | data = someData.slice(1); | ||
137 | } else { | ||
138 | data = someData; | ||
139 | } | ||
140 | |||
141 | trConfigs = MochiKit.Base.map(MochiKit.Base.bind(function(aRowData) { | ||
142 | var result; | ||
143 | var i,c; | ||
144 | |||
145 | result = {tag:'tr', children:[]}; | ||
146 | c = aRowData.length; | ||
147 | for (i=0; i<c; i++) { | ||
148 | if (this.mainComponent().isColumnSelected(i)) { | ||
149 | result.children.push({tag:'td', valign:'top', html:(MochiKit.Base.isNotEmpty(aRowData[i]) ? aRowData[i].replace(/\n/g, '<br>') : ' ')}); | ||
150 | } | ||
151 | } | ||
152 | |||
153 | return result; | ||
154 | }, this), data); | ||
155 | |||
156 | MochiKit.Base.map(function(aRowConfig) {Clipperz.YUI.DomHelper.append(anElement, aRowConfig);}, trConfigs); | ||
157 | |||
158 | Clipperz.Style.applyZebraStylesToTable(this.getId('previewDada')); | ||
159 | }, | ||
160 | |||
161 | //------------------------------------------------------------------------- | ||
162 | |||
163 | 'toggleFirstRowHeaderCheckboxHandler': function() { | ||
164 | var firstRowData; | ||
165 | var i,c; | ||
166 | |||
167 | //MochiKit.Logging.logDebug(">>> toggleFirstRowHeaderCheckboxHandler"); | ||
168 | this.mainComponent().setIsFirstRowHeader(this.getDom('isFirstRowHeader_checkbox').checked); | ||
169 | |||
170 | firstRowData = this.mainComponent().parsedValues()[0]; | ||
171 | |||
172 | c = firstRowData.length; | ||
173 | for (i=0; i<c; i++) { | ||
174 | if (this.mainComponent().isColumnSelected(i)) { | ||
175 | var label; | ||
176 | |||
177 | if (this.mainComponent().isFirstRowHeader()) { | ||
178 | label = firstRowData[i]; | ||
179 | } else { | ||
180 | label = null; | ||
181 | } | ||
182 | |||
183 | this.mainComponent().setLabelForColumn(label, i); | ||
184 | } | ||
185 | }; | ||
186 | |||
187 | this.updateInputFieldValues(); | ||
188 | this.renderData(this.getElement('previewData_tbody'), this.mainComponent().parsedValues()); | ||
189 | //MochiKit.Logging.logDebug("<<< toggleFirstRowHeaderCheckboxHandler"); | ||
190 | }, | ||
191 | |||
192 | //------------------------------------------------------------------------- | ||
193 | |||
194 | 'updateInputFieldValues': function() { | ||
195 | var i,c; | ||
196 | |||
197 | //MochiKit.Logging.logDebug(">>> updateInputFieldValues"); | ||
198 | c = this.mainComponent().parsedValues()[0].length; | ||
199 | for (i=0; i<c; i++) { | ||
200 | if (this.mainComponent().isColumnSelected(i)) { | ||
201 | this.getDom('headerTextField_' + i).value = this.mainComponent().labelForColumn(i); | ||
202 | } | ||
203 | } | ||
204 | //console.log('[1] fieldSettings', fieldSettings); | ||
205 | //MochiKit.Logging.logDebug("<<< updateInputFieldValues"); | ||
206 | }, | ||
207 | |||
208 | //------------------------------------------------------------------------- | ||
209 | |||
210 | 'labelFieldHandler': function(aColumnIndex, anEvent) { | ||
211 | var inputField; | ||
212 | |||
213 | //MochiKit.Logging.logDebug(">>> labelFieldHandler"); | ||
214 | inputField = anEvent.src(); | ||
215 | |||
216 | this.mainComponent().setLabelForColumn(inputField.value, aColumnIndex); | ||
217 | //MochiKit.Logging.logDebug("##### [" + anEvent.src().id + "] -> label[" + aColumnIndex + "]: '" + inputField.value + "'"); | ||
218 | //MochiKit.Logging.logDebug("<<< labelFieldHandler"); | ||
219 | }, | ||
220 | |||
221 | 'deferredLabelFieldHandler': function(aColumnIndex, anEvent) { | ||
222 | //MochiKit.Logging.logDebug(">>> deferredLabelFieldHandler"); | ||
223 | this._pendingDeferredLabelFieldHandlerEvents ++; | ||
224 | MochiKit.Async.callLater(1, MochiKit.Base.partial(MochiKit.Base.method(this, 'deferredLabelFieldHandlerCatcher'), aColumnIndex, anEvent)); | ||
225 | //MochiKit.Logging.logDebug("<<< deferredLabelFieldHandler"); | ||
226 | }, | ||
227 | |||
228 | 'deferredLabelFieldHandlerCatcher': function(aColumnIndex, anEvent) { | ||
229 | //MochiKit.Logging.logDebug(">>> deferredLabelFieldHandlerCatcher"); | ||
230 | this._pendingDeferredLabelFieldHandlerEvents --; | ||
231 | if (this._pendingDeferredLabelFieldHandlerEvents == 0) { | ||
232 | this.labelFieldHandler(aColumnIndex, anEvent); | ||
233 | } | ||
234 | //MochiKit.Logging.logDebug("<<< deferredLabelFieldHandlerCatcher"); | ||
235 | }, | ||
236 | |||
237 | //------------------------------------------------------------------------- | ||
238 | __syntaxFix__: "syntax fix" | ||
239 | }); | ||
240 | |||
diff --git a/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportNotes.js b/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportNotes.js new file mode 100644 index 0000000..a53c531 --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportNotes.js | |||
@@ -0,0 +1,212 @@ | |||
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 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | ||
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | ||
31 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } | ||
32 | if (typeof(Clipperz.PM.Components.Import) == 'undefined') { Clipperz.PM.Components.Import = {}; } | ||
33 | if (typeof(Clipperz.PM.Components.Import.CSVImport) == 'undefined') { Clipperz.PM.Components.Import.CSVImport = {}; } | ||
34 | |||
35 | //############################################################################# | ||
36 | |||
37 | Clipperz.PM.Components.Import.CSVImport.CSVImportNotes = function(anElement, args) { | ||
38 | args = args || {}; | ||
39 | |||
40 | Clipperz.PM.Components.Import.CSVImport.CSVImportNotes.superclass.constructor.call(this, anElement, args); | ||
41 | this._mainComponent = args.mainComponent; | ||
42 | |||
43 | return this; | ||
44 | } | ||
45 | |||
46 | //============================================================================= | ||
47 | |||
48 | YAHOO.extendX(Clipperz.PM.Components.Import.CSVImport.CSVImportNotes, Clipperz.PM.Components.BaseComponent, { | ||
49 | |||
50 | 'toString': function() { | ||
51 | return "Clipperz.PM.Components.Import.CSVImport.CSVImportNotes component"; | ||
52 | }, | ||
53 | |||
54 | //------------------------------------------------------------------------- | ||
55 | |||
56 | 'mainComponent': function() { | ||
57 | return this._mainComponent; | ||
58 | }, | ||
59 | |||
60 | //------------------------------------------------------------------------- | ||
61 | |||
62 | 'render': function() { | ||
63 | varnotesSelectorCheckboxCells; | ||
64 | var totalNumberOfColumns; | ||
65 | var titleColumnIndex; | ||
66 | var notesColumnIndex; | ||
67 | var i,c; | ||
68 | |||
69 | Clipperz.NotificationCenter.unregister(this); | ||
70 | MochiKit.Signal.disconnectAllTo(this); | ||
71 | |||
72 | this.element().update(""); | ||
73 | |||
74 | titleColumnIndex = this.mainComponent().titleColumnIndex() | ||
75 | notesColumnIndex = this.mainComponent().notesColumnIndex() | ||
76 | |||
77 | totalNumberOfColumns = this.mainComponent().parsedValues()[0].length; | ||
78 | |||
79 | notesSelectorCheckboxCells = [{tag:'th', cls:'title', html:this.mainComponent().labelForColumn(titleColumnIndex)}]; | ||
80 | c =totalNumberOfColumns; | ||
81 | for (i=0; i<c; i++) { | ||
82 | if ((i != titleColumnIndex) && (this.mainComponent().isColumnSelected(i))) { | ||
83 | notesSelectorCheckboxCells.push({tag:'th', id:this.getId('th_' + i), valign:'top', children:[ | ||
84 | {tag:'input', type:'radio', id:this.getId('radio_' + i), name:'CSVImportNotesColumn', value:i}, | ||
85 | {tag:'span', cls:'clickableSpan', id:this.getId('columnLabel_' + i), html:this.mainComponent().labelForColumn(i)} | ||
86 | ]}) | ||
87 | } | ||
88 | } | ||
89 | |||
90 | this.domHelper().append(this.element(), {tag:'div', children:[ | ||
91 | {tag:'div', cls:'importStepDescription', htmlString:Clipperz.PM.Strings['CSV_ImportWizard_Notes']}, | ||
92 | {tag:'div', id:this.getId('dataDiv'), children:[ | ||
93 | {tag:'div', cls:'importStepParameters', children:[ | ||
94 | {tag:'input', id:this.getId('doNotSetNotes_radio'), type:'radio', name:'CSVImportNotesColumn', value:-1}, | ||
95 | {tag:'span', id:this.getId('doNotSetNotes_span'), cls:'clickableSpan', htmlString:Clipperz.PM.Strings['CSV_ImportWizard_Notes_Settings_noSelectionLabel']} | ||
96 | ]}, | ||
97 | {tag:'div', cls:'csvImportPreview', children:[ | ||
98 | {tag:'table', id:this.getId('previewDada'), cls:'csvImportPreview', cellspacing:'0', children:[ | ||
99 | {tag:'thead', id:this.getId('previewData_thead'), children:[ | ||
100 | {tag:'tr', children:notesSelectorCheckboxCells} | ||
101 | ]}, | ||
102 | {tag:'tbody', id:this.getId('previewData_tbody'), children:[]} | ||
103 | ]} | ||
104 | ]} | ||
105 | ]} | ||
106 | ]}); | ||
107 | |||
108 | this.renderData(this.getElement('previewData_tbody'), this.mainComponent().parsedValues()); | ||
109 | |||
110 | if ((notesColumnIndex >= totalNumberOfColumns) || (notesColumnIndex == titleColumnIndex) || !(this.mainComponent().isColumnSelected(notesColumnIndex))) { | ||
111 | this.mainComponent().setNotesColumnIndex(-1); | ||
112 | notesColumnIndex = -1; | ||
113 | } | ||
114 | |||
115 | c =totalNumberOfColumns; | ||
116 | for (i=0; i<c; i++) { | ||
117 | if ((i != titleColumnIndex) && (this.mainComponent().isColumnSelected(i))) { | ||
118 | MochiKit.Signal.connect(this.getDom('radio_' + i), 'onclick', this, 'renderDataHandler'); | ||
119 | if (Clipperz_IEisBroken != true) { | ||
120 | MochiKit.Signal.connect(this.getDom('columnLabel_' + i), 'onclick', this.getDom('radio_' + i), 'click'); | ||
121 | } | ||
122 | } | ||
123 | } | ||
124 | |||
125 | MochiKit.Signal.connect(this.getDom('doNotSetNotes_radio'), 'onclick', this, 'renderDataHandler'); | ||
126 | if (Clipperz_IEisBroken != true) { | ||
127 | MochiKit.Signal.connect(this.getDom('doNotSetNotes_span'), 'onclick', this.getDom('doNotSetNotes_radio'), 'click'); | ||
128 | } | ||
129 | |||
130 | if (notesColumnIndex == -1) { | ||
131 | this.getDom('doNotSetNotes_radio').click(); | ||
132 | } else { | ||
133 | this.getDom('radio_' + notesColumnIndex).click(); | ||
134 | } | ||
135 | }, | ||
136 | |||
137 | //------------------------------------------------------------------------- | ||
138 | |||
139 | 'renderData': function(anElement, someData) { | ||
140 | var data; | ||
141 | var config; | ||
142 | var titleColumnIndex; | ||
143 | var notesColumnIndex; | ||
144 | var i,c; | ||
145 | |||
146 | // anElement.update(""); | ||
147 | MochiKit.DOM.replaceChildNodes(anElement.dom); | ||
148 | |||
149 | titleColumnIndex = this.mainComponent().titleColumnIndex(); | ||
150 | notesColumnIndex = this.mainComponent().notesColumnIndex(); | ||
151 | |||
152 | if (this.mainComponent().isFirstRowHeader()) { | ||
153 | data = someData.slice(1); | ||
154 | } else { | ||
155 | data = someData; | ||
156 | } | ||
157 | |||
158 | |||
159 | // config = [{tag:'tr', cls:'CSV_previewData_header', children:[{tag:'td', valign:'top', html:header[titleColumnIndex], cls:'title'}]}]; | ||
160 | // c = header.length; | ||
161 | // for (i=0; i<c; i++) { | ||
162 | // if (i != titleColumnIndex) { | ||
163 | // config[0].children.push({tag:'td', valign:'top', html:header[i], cls:((notesColumnIndex == i) ? 'notesColumn': '')}) | ||
164 | // } | ||
165 | // } | ||
166 | |||
167 | config = MochiKit.Base.map(MochiKit.Base.bind(function(aTitleColumnIndex, aRowData) { | ||
168 | var result; | ||
169 | var i,c; | ||
170 | |||
171 | result = {tag:'tr', children:[{tag:'td', valign:'top', cls:'title', html:(MochiKit.Base.isNotEmpty(aRowData[aTitleColumnIndex]) ? aRowData[aTitleColumnIndex].replace(/\n/g, '<br>') : ' ')}]}; | ||
172 | c = aRowData.length; | ||
173 | for (i=0; i<c; i++) { | ||
174 | if ((i != titleColumnIndex) && (this.mainComponent().isColumnSelected(i))) { | ||
175 | result.children.push({tag:'td', valign:'top', cls:((notesColumnIndex == i) ? 'notesColumn': ''), html:(MochiKit.Base.isNotEmpty(aRowData[i]) ? aRowData[i].replace(/\n/g, '<br>') : ' ')}); | ||
176 | } | ||
177 | } | ||
178 | |||
179 | return result; | ||
180 | }, this, titleColumnIndex), data); | ||
181 | |||
182 | MochiKit.Base.map(function(aRowConfig) {Clipperz.YUI.DomHelper.append(anElement, aRowConfig);}, config); | ||
183 | |||
184 | Clipperz.Style.applyZebraStylesToTable(this.getId('previewDada')); | ||
185 | }, | ||
186 | |||
187 | //------------------------------------------------------------------------- | ||
188 | |||
189 | 'renderDataHandler': function(anEvent) { | ||
190 | var titleColumnIndex; | ||
191 | var i,c; | ||
192 | |||
193 | this.mainComponent().setNotesColumnIndex(anEvent.src().value); | ||
194 | titleColumnIndex = this.mainComponent().titleColumnIndex(); | ||
195 | |||
196 | c = this.mainComponent().parsedValues()[0].length; | ||
197 | for (i=0; i<c; i++) { | ||
198 | if ((i != titleColumnIndex) && (this.mainComponent().isColumnSelected(i))) { | ||
199 | this.getElement('th_' + i).removeClass('notesColumn'); | ||
200 | } | ||
201 | } | ||
202 | if (anEvent.src().value != -1) { | ||
203 | this.getElement('th_' + anEvent.src().value).addClass('notesColumn'); | ||
204 | } | ||
205 | |||
206 | this.renderData(this.getElement('previewData_tbody'), this.mainComponent().parsedValues()); | ||
207 | }, | ||
208 | |||
209 | //------------------------------------------------------------------------- | ||
210 | __syntaxFix__: "syntax fix" | ||
211 | }); | ||
212 | |||
diff --git a/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportTitle.js b/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportTitle.js new file mode 100644 index 0000000..9162867 --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportTitle.js | |||
@@ -0,0 +1,189 @@ | |||
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 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | ||
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | ||
31 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } | ||
32 | if (typeof(Clipperz.PM.Components.Import) == 'undefined') { Clipperz.PM.Components.Import = {}; } | ||
33 | if (typeof(Clipperz.PM.Components.Import.CSVImport) == 'undefined') { Clipperz.PM.Components.Import.CSVImport = {}; } | ||
34 | |||
35 | //############################################################################# | ||
36 | |||
37 | Clipperz.PM.Components.Import.CSVImport.CSVImportTitle = function(anElement, args) { | ||
38 | args = args || {}; | ||
39 | |||
40 | Clipperz.PM.Components.Import.CSVImport.CSVImportTitle.superclass.constructor.call(this, anElement, args); | ||
41 | this._mainComponent = args.mainComponent; | ||
42 | |||
43 | return this; | ||
44 | } | ||
45 | |||
46 | //============================================================================= | ||
47 | |||
48 | YAHOO.extendX(Clipperz.PM.Components.Import.CSVImport.CSVImportTitle, Clipperz.PM.Components.BaseComponent, { | ||
49 | |||
50 | 'toString': function() { | ||
51 | return "Clipperz.PM.Components.Import.CSVImport.CSVImportTitle component"; | ||
52 | }, | ||
53 | |||
54 | //------------------------------------------------------------------------- | ||
55 | |||
56 | 'mainComponent': function() { | ||
57 | return this._mainComponent; | ||
58 | }, | ||
59 | |||
60 | //------------------------------------------------------------------------- | ||
61 | |||
62 | 'render': function() { | ||
63 | vartitleSelectorCheckboxCells; | ||
64 | var titleColumnIndex; | ||
65 | var i,c; | ||
66 | |||
67 | Clipperz.NotificationCenter.unregister(this); | ||
68 | MochiKit.Signal.disconnectAllTo(this); | ||
69 | |||
70 | this.element().update(""); | ||
71 | |||
72 | titleColumnIndex = this.mainComponent().titleColumnIndex() | ||
73 | titleSelectorCheckboxCells = []; | ||
74 | c =this.mainComponent().parsedValues()[0].length; | ||
75 | for (i=0; i<c; i++) { | ||
76 | if (this.mainComponent().isColumnSelected(i)) { | ||
77 | titleSelectorCheckboxCells.push({tag:'th', valign:'top', id:this.getId('th_' + i), children:[ | ||
78 | {tag:'input', type:'radio', id:this.getId('radio_' + i), name:'CSVImportTitleColumn', value:i}, | ||
79 | {tag:'span', cls:'clickableSpan', id:this.getId('columnLabel_' + i), html:this.mainComponent().labelForColumn(i)} | ||
80 | ]}) | ||
81 | } | ||
82 | } | ||
83 | |||
84 | if (titleColumnIndex >= titleSelectorCheckboxCells.length) { | ||
85 | this.mainComponent().setTitleColumnIndex(-1); | ||
86 | } | ||
87 | |||
88 | this.domHelper().append(this.element(), {tag:'div', children:[ | ||
89 | {tag:'div', cls:'importStepDescription', htmlString:Clipperz.PM.Strings['CSV_ImportWizard_Title']}, | ||
90 | {tag:'div', id:this.getId('dataDiv'), cls:'csvImportPreview', children:[ | ||
91 | {tag:'table', id:this.getId('previewDada'), cls:'csvImportPreview', cellspacing:'0', children:[ | ||
92 | {tag:'thead', id:this.getId('previewData_thead'), children:[ | ||
93 | {tag:'tr', children:titleSelectorCheckboxCells} | ||
94 | ]}, | ||
95 | {tag:'tbody', id:this.getId('previewData_tbody'), children:[]} | ||
96 | ]} | ||
97 | ]} | ||
98 | ]}); | ||
99 | |||
100 | this.renderData(this.getElement('previewData_tbody'), this.mainComponent().parsedValues()); | ||
101 | |||
102 | c =this.mainComponent().parsedValues()[0].length; | ||
103 | for (i=0; i<c; i++) { | ||
104 | if (this.mainComponent().isColumnSelected(i)) { | ||
105 | MochiKit.Signal.connect(this.getDom('radio_' + i), 'onclick', this, 'renderDataHandler'); | ||
106 | if (Clipperz_IEisBroken != true) { | ||
107 | MochiKit.Signal.connect(this.getDom('columnLabel_' + i), 'onclick', this.getDom('radio_' + i), 'click'); | ||
108 | } | ||
109 | } | ||
110 | } | ||
111 | |||
112 | if (titleColumnIndex != -1) { | ||
113 | this.getDom('radio_' + titleColumnIndex).click(); | ||
114 | } else { | ||
115 | this.mainComponent().nextButton().disable(); | ||
116 | } | ||
117 | |||
118 | }, | ||
119 | |||
120 | //------------------------------------------------------------------------- | ||
121 | |||
122 | 'renderData': function(anElement, someData) { | ||
123 | var data; | ||
124 | var config; | ||
125 | var titleColumnIndex; | ||
126 | var i,c; | ||
127 | |||
128 | // anElement.update(""); | ||
129 | MochiKit.DOM.replaceChildNodes(anElement.dom); | ||
130 | |||
131 | titleColumnIndex = this.mainComponent().titleColumnIndex() | ||
132 | |||
133 | if (this.mainComponent().isFirstRowHeader()) { | ||
134 | data = someData.slice(1); | ||
135 | } else { | ||
136 | data = someData; | ||
137 | } | ||
138 | |||
139 | config = MochiKit.Base.map(MochiKit.Base.bind(function(aRowData) { | ||
140 | var result; | ||
141 | var i,c; | ||
142 | |||
143 | result = {tag:'tr', children:[]}; | ||
144 | c = aRowData.length; | ||
145 | for (i=0; i<c; i++) { | ||
146 | if (this.mainComponent().isColumnSelected(i)) { | ||
147 | var field; | ||
148 | |||
149 | field = aRowData[i]; | ||
150 | result.children.push({tag:'td', valign:'top', cls:((titleColumnIndex == i) ? 'titleColumn': ''), html:(MochiKit.Base.isNotEmpty(field) ? field.replace(/\n/g, '<br>') : ' ')}); | ||
151 | } | ||
152 | } | ||
153 | |||
154 | return result; | ||
155 | }, this), data); | ||
156 | |||
157 | MochiKit.Base.map(function(aRowConfig) {Clipperz.YUI.DomHelper.append(anElement, aRowConfig);}, config); | ||
158 | |||
159 | Clipperz.Style.applyZebraStylesToTable(this.getId('previewDada')); | ||
160 | }, | ||
161 | |||
162 | //------------------------------------------------------------------------- | ||
163 | |||
164 | 'renderDataHandler': function(anEvent) { | ||
165 | var i,c; | ||
166 | |||
167 | this.mainComponent().setTitleColumnIndex(anEvent.src().value); | ||
168 | |||
169 | c = this.mainComponent().parsedValues()[0].length; | ||
170 | for (i=0; i<c; i++) { | ||
171 | if (this.mainComponent().isColumnSelected(i)) { | ||
172 | this.getElement('th_' + i).removeClass('titleColumn'); | ||
173 | } | ||
174 | } | ||
175 | this.getElement('th_' + anEvent.src().value).addClass('titleColumn'); | ||
176 | |||
177 | if (anEvent.src().value != -1) { | ||
178 | this.mainComponent().nextButton().enable(); | ||
179 | } else { | ||
180 | this.mainComponent().nextButton().disable(); | ||
181 | } | ||
182 | |||
183 | this.renderData(this.getElement('previewData_tbody'), this.mainComponent().parsedValues()); | ||
184 | }, | ||
185 | |||
186 | //------------------------------------------------------------------------- | ||
187 | __syntaxFix__: "syntax fix" | ||
188 | }); | ||
189 | |||
diff --git a/frontend/beta/js/Clipperz/PM/Components/Import/CSVImportComponent.js b/frontend/beta/js/Clipperz/PM/Components/Import/CSVImportComponent.js new file mode 100644 index 0000000..707a3d2 --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/Import/CSVImportComponent.js | |||
@@ -0,0 +1,548 @@ | |||
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 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | ||
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | ||
31 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } | ||
32 | if (typeof(Clipperz.PM.Components.Import) == 'undefined') { Clipperz.PM.Components.Import = {}; } | ||
33 | |||
34 | //############################################################################# | ||
35 | |||
36 | Clipperz.PM.Components.Import.CSVImportComponent = function(anElement, args) { | ||
37 | args = args || {}; | ||
38 | |||
39 | this._steps = this._steps || ['CSV_EDIT', 'CSV_COLUMNS', 'CSV_HEADER', 'CSV_TITLE', 'CSV_NOTES', 'CSV_FIELDS', 'PREVIEW', 'IMPORT']; | ||
40 | |||
41 | Clipperz.PM.Components.Import.CSVImportComponent.superclass.constructor.call(this, anElement, args); | ||
42 | |||
43 | this._step1Component = null; | ||
44 | this._step2Component = null; | ||
45 | this._step3Component = null; | ||
46 | this._step4Component = null; | ||
47 | this._step5Component = null; | ||
48 | |||
49 | this._isFirstRowHeader = false; | ||
50 | this._titleColumnIndex = -1; | ||
51 | this._notesColumnIndex = -1; | ||
52 | this._fieldSettings = {}; | ||
53 | this._skippedColumns = new Clipperz.Set(); | ||
54 | |||
55 | this.render(); | ||
56 | |||
57 | return this; | ||
58 | } | ||
59 | |||
60 | //============================================================================= | ||
61 | |||
62 | YAHOO.extendX(Clipperz.PM.Components.Import.CSVImportComponent, Clipperz.PM.Components.Import.GenericImportComponent, { | ||
63 | |||
64 | 'toString': function() { | ||
65 | return "Clipperz.PM.Components.Import.CSVImportComponent component"; | ||
66 | }, | ||
67 | |||
68 | //------------------------------------------------------------------------- | ||
69 | |||
70 | 'render': function() { | ||
71 | this.domHelper().append(this.element(), {tag:'div', cls:'csvImportWizard', children:[ | ||
72 | {tag:'h3', htmlString:Clipperz.PM.Strings['CSV_ImportWizard_Title']}, | ||
73 | {tag:'div', cls:'importSteps', id:this.getId('importSteps')}, | ||
74 | {tag:'div', cls:'importStepBlocks', children:[ | ||
75 | {tag:'div', cls:'step_0', id:this.getId('step_0'), children:[ | ||
76 | {tag:'div', children:[ | ||
77 | {tag:'div', cls:'importOptionsDescription', htmlString:Clipperz.PM.Strings['importOptions_csv_description']}, | ||
78 | {tag:'div', cls:'importOptionsParameters', children:[ | ||
79 | {tag:'div', cls:'CSVImportOptionsParameters', children:[ | ||
80 | {tag:'ul', children:[ | ||
81 | {tag:'li', children:[ | ||
82 | {tag:'label', 'for':this.getId('CSV_inputOptions_separator'), html:"separator"}, | ||
83 | {tag:'select', name:this.getId('CSV_inputOptions_separator'), id:this.getId('CSV_inputOptions_separator'), children:[ | ||
84 | {tag:'option', name:'comma', value:',', html:"comma (,)", selected:true}, | ||
85 | {tag:'option', name:'tab', value:'\t', html:"tab"} | ||
86 | ]} | ||
87 | ]}, | ||
88 | |||
89 | {tag:'li', children:[ | ||
90 | {tag:'label', 'for':this.getId('CSV_inputOptions_quote'), html:"quote"}, | ||
91 | {tag:'select', name:this.getId('CSV_inputOptions_quote'), id:this.getId('CSV_inputOptions_quote'), children:[ | ||
92 | {tag:'option', name:'doubleQuote', value:'\"', html:"double quote (\")", selected:true}, | ||
93 | {tag:'option', name:'singleQuote', value:'\'', html:"single quote (\')"} | ||
94 | ]} | ||
95 | ]}, | ||
96 | |||
97 | {tag:'li', children:[ | ||
98 | {tag:'label', 'for':this.getId('CSV_inputOptions_escape'), html:"escape"}, | ||
99 | {tag:'select', name:this.getId('CSV_inputOptions_escape'), id:this.getId('CSV_inputOptions_escape'), children:[ | ||
100 | {tag:'option', name:'doubleQuote', value:'\"', html:"double quote (\")", selected:true}, | ||
101 | {tag:'option', name:'slash', value:'\/', html:"slash (\/)"}, | ||
102 | {tag:'option', name:'backslash', value:'\\', html:"backslash (\\)"} | ||
103 | ]} | ||
104 | ]} | ||
105 | ]} | ||
106 | ]} | ||
107 | ]}, | ||
108 | this.textAreaConfig() | ||
109 | ]} | ||
110 | ]}, | ||
111 | {tag:'div', cls:'step_1', id:this.getId('step_1'), children:[]}, | ||
112 | {tag:'div', cls:'step_2', id:this.getId('step_2'), children:[]}, | ||
113 | {tag:'div', cls:'step_3', id:this.getId('step_3'), children:[]}, | ||
114 | {tag:'div', cls:'step_4', id:this.getId('step_4'), children:[]}, | ||
115 | {tag:'div', cls:'step_5', id:this.getId('step_5'), children:[]}, | ||
116 | {tag:'div', cls:'step_6', id:this.getId('step_6'), children:[ | ||
117 | {tag:'div', children:[ | ||
118 | {tag:'div', id:this.getId('previewDiv'), html:"preview"} | ||
119 | ]} | ||
120 | ]}, | ||
121 | {tag:'div', cls:'step_7', id:this.getId('step_7'), children:[ | ||
122 | {tag:'div', children:[ | ||
123 | {tag:'h4', html:"done"} | ||
124 | ]} | ||
125 | ]} | ||
126 | ]}, | ||
127 | {tag:'div', cls:'importOptionsButtons', children:[ | ||
128 | {tag:'table', children:[ | ||
129 | {tag:'tbody', children:[ | ||
130 | {tag:'tr', children:[ | ||
131 | {tag:'td', html:' '}, | ||
132 | {tag:'td', children:[ | ||
133 | {tag:'div', id:this.getId('backActionButton')} | ||
134 | ]}, | ||
135 | {tag:'td', html:' '}, | ||
136 | {tag:'td', children:[ | ||
137 | {tag:'div', id:this.getId('nextActionButton')} | ||
138 | ]}, | ||
139 | {tag:'td', html:' '} | ||
140 | ]} | ||
141 | ]} | ||
142 | ]} | ||
143 | ]} | ||
144 | ]}); | ||
145 | |||
146 | this.setBackButton(new YAHOO.ext.Button(this.getDom('backActionButton'), {text:"back", handler:this.backAction, scope:this})); | ||
147 | this.setNextButton(new YAHOO.ext.Button(this.getDom('nextActionButton'), {text:"next", handler:this.nextAction, scope:this})); | ||
148 | |||
149 | this.updateSteps(); | ||
150 | |||
151 | this.getElement('step_0').setVisibilityMode(YAHOO.ext.Element.DISPLAY).show() | ||
152 | this.getElement('step_1').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); | ||
153 | this.getElement('step_2').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); | ||
154 | this.getElement('step_3').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); | ||
155 | this.getElement('step_4').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); | ||
156 | this.getElement('step_5').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); | ||
157 | this.getElement('step_6').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); | ||
158 | this.getElement('step_7').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); | ||
159 | |||
160 | // this.backButton().disable(); | ||
161 | }, | ||
162 | |||
163 | //------------------------------------------------------------------------- | ||
164 | |||
165 | 'nextAction': function() { | ||
166 | switch (this.currentStep()) { | ||
167 | case 0: //-> 1 | ||
168 | Clipperz.PM.Components.MessageBox.showProgressPanel( | ||
169 | MochiKit.Base.method(this, 'deferredParseValues'), | ||
170 | MochiKit.Base.method(this, 'handleParseError'), | ||
171 | this.getDom('nextActionButton') | ||
172 | ); | ||
173 | break; | ||
174 | case 1: //-> 2 | ||
175 | this.getElement('step_1').hide(); | ||
176 | this.step2Component().render(); | ||
177 | this.setCurrentStep(2); | ||
178 | this.getElement('step_2').show(); | ||
179 | break; | ||
180 | case 2: //-> 3 | ||
181 | this.getElement('step_2').hide(); | ||
182 | this.step3Component().render(); | ||
183 | this.setCurrentStep(3); | ||
184 | this.getElement('step_3').show(); | ||
185 | break; | ||
186 | case 3: //-> 4 | ||
187 | this.getElement('step_3').hide(); | ||
188 | this.step4Component().render(); | ||
189 | this.setCurrentStep(4); | ||
190 | this.getElement('step_4').show(); | ||
191 | break; | ||
192 | case 4: //-> 5 | ||
193 | this.getElement('step_4').hide(); | ||
194 | this.step5Component().render(); | ||
195 | this.setCurrentStep(5); | ||
196 | this.getElement('step_5').show(); | ||
197 | break; | ||
198 | case 5: //-> 6 | ||
199 | this.previewValues(); | ||
200 | break; | ||
201 | case 6: //-> 7 | ||
202 | this.importValues(); | ||
203 | break; | ||
204 | } | ||
205 | }, | ||
206 | |||
207 | //------------------------------------------------------------------------- | ||
208 | |||
209 | 'deferredParseValues': function() { | ||
210 | var deferredResult; | ||
211 | |||
212 | deferredResult = new MochiKit.Async.Deferred(); | ||
213 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("CSVImportComponent.deferredParseValues - 1 " + res.substring(0,50)); return res;}); | ||
214 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'parseImportData'); | ||
215 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("CSVImportComponent.deferredParseValues - 2 " + res.substring(0,50)); return res;}); | ||
216 | deferredResult.addCallback(MochiKit.Base.bind(function(res) { | ||
217 | this.startProcessing(); | ||
218 | |||
219 | return res; | ||
220 | }, this)); | ||
221 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("CSVImportComponent.deferredParseValues - 3 " + res.substring(0,50)); return res;}); | ||
222 | deferredResult.addCallback(MochiKit.Base.method(this, 'parseCSVValues')); | ||
223 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("CSVImportComponent.deferredParseValues - 4 " + res); return res;}); | ||
224 | deferredResult.addCallback(MochiKit.Base.method(this, 'setParsedValues')); | ||
225 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("CSVImportComponent.deferredParseValues - 5 " + res); return res;}); | ||
226 | deferredResult.addCallback(MochiKit.Base.method(this.step1Component(), 'render')); | ||
227 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("CSVImportComponent.deferredParseValues - 6 " + res); return res;}); | ||
228 | deferredResult.addCallback(MochiKit.Base.bind(function(res) { | ||
229 | this.processingDone(); | ||
230 | this.getElement('step_0').hide(); | ||
231 | this.getElement('step_1').show(); | ||
232 | this.backButton().enable(); | ||
233 | |||
234 | return res; | ||
235 | }, this)); | ||
236 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("CSVImportComponent.deferredParseValues - 7 " + res); return res;}); | ||
237 | deferredResult.callback(this.textAreaContent()); | ||
238 | |||
239 | return deferredResult; | ||
240 | }, | ||
241 | |||
242 | //------------------------------------------------------------------------- | ||
243 | |||
244 | 'deferredPreviewValues': function() { | ||
245 | var deferredResult; | ||
246 | |||
247 | //MochiKit.Logging.logDebug(">>> CSVImportComponent.deferredPreviewValues"); | ||
248 | deferredResult = new MochiKit.Async.Deferred(); | ||
249 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassImportComponent.deferredPreviewValues - 1 " + res); return res;}); | ||
250 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'previewImportData'); | ||
251 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassImportComponent.deferredPreviewValues - 2 " + res); return res;}); | ||
252 | deferredResult.addCallback(MochiKit.Base.bind(function(res) { | ||
253 | this.startProcessing(); | ||
254 | |||
255 | return res; | ||
256 | }, this)); | ||
257 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassImportComponent.deferredPreviewValues - 3 " + res); return res;}); | ||
258 | deferredResult.addCallback(MochiKit.Base.method(this, 'processCSVParsedValues')); | ||
259 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassImportComponent.deferredPreviewValues - 4 " + res); return res;}); | ||
260 | deferredResult.addCallback(MochiKit.Base.method(this, 'setProcessedValues')); | ||
261 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassImportComponent.deferredPreviewValues - 5 " + res); return res;}); | ||
262 | deferredResult.addCallback(MochiKit.Base.method(this, 'previewRecordValues')); | ||
263 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassImportComponent.deferredPreviewValues - 6 " + res); return res;}); | ||
264 | deferredResult.addCallback(MochiKit.Base.bind(function(res) { | ||
265 | this.processingDone(); | ||
266 | this.getElement('step_5').hide(); | ||
267 | this.getElement('step_6').show(); | ||
268 | this.backButton().enable(); | ||
269 | |||
270 | return res; | ||
271 | }, this)); | ||
272 | deferredResult.callback(this.parsedValues()); | ||
273 | //MochiKit.Logging.logDebug("<<< CSVImportComponent.deferredPreviewValues"); | ||
274 | |||
275 | return deferredResult; | ||
276 | }, | ||
277 | |||
278 | //------------------------------------------------------------------------- | ||
279 | |||
280 | 'csvProcessor': function() { | ||
281 | return new Clipperz.CSVProcessor({ | ||
282 | quoteChar: this.getDom('CSV_inputOptions_quote').value, | ||
283 | escapeChar: this.getDom('CSV_inputOptions_escape').value, | ||
284 | separatorChar:this.getDom('CSV_inputOptions_separator').value, | ||
285 | binary:true | ||
286 | }); | ||
287 | }, | ||
288 | |||
289 | //------------------------------------------------------------------------- | ||
290 | |||
291 | 'parseCSVValues': function(someData) { | ||
292 | var deferredResult; | ||
293 | var csvProcessor; | ||
294 | |||
295 | csvProcessor = this.csvProcessor(); | ||
296 | deferredResult = new MochiKit.Async.Deferred(); | ||
297 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassImportComponent.parseKeePassValues - 1 " + res.substring(0,50)); return res;}); | ||
298 | deferredResult.addCallback(function(res) { | ||
299 | return Clipperz.NotificationCenter.deferredNotification(this, 'updatedProgressState', {steps:(res.length)}, res); | ||
300 | }) | ||
301 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassImportComponent.parseKeePassValues - 2 " + res.substring(0,50)); return res;}); | ||
302 | deferredResult.addCallback(MochiKit.Base.method(csvProcessor, 'deferredParse')); | ||
303 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassImportComponent.parseKeePassValues - 3 " + res); return res;}); | ||
304 | deferredResult.callback(someData); | ||
305 | |||
306 | return deferredResult; | ||
307 | }, | ||
308 | |||
309 | //------------------------------------------------------------------------- | ||
310 | |||
311 | 'processCSVParsedValues': function (someValues) { | ||
312 | var deferredResult; | ||
313 | var records; | ||
314 | var titleColumnIndex; | ||
315 | var notesColumnIndex; | ||
316 | var i,c; | ||
317 | |||
318 | deferredResult = new MochiKit.Async.Deferred(); | ||
319 | records = []; | ||
320 | |||
321 | titleColumnIndex = this.titleColumnIndex(); | ||
322 | notesColumnIndex = this.notesColumnIndex(); | ||
323 | |||
324 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', {steps:(someValues.length)}); | ||
325 | |||
326 | c = someValues.length; | ||
327 | if (this.isFirstRowHeader()) { | ||
328 | i = 1; | ||
329 | } else { | ||
330 | i = 0; | ||
331 | } | ||
332 | |||
333 | for( ; i<c; i++) { | ||
334 | deferredResult.addCallback(MochiKit.Async.wait, 0.2); | ||
335 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', {}); | ||
336 | deferredResult.addCallback(MochiKit.Base.bind(function(someRecords, someData) { | ||
337 | var record; | ||
338 | var recordVersion; | ||
339 | var ii; | ||
340 | |||
341 | record = new Clipperz.PM.DataModel.Record({user:this.user()}); | ||
342 | record.setLabel(someData[titleColumnIndex]); | ||
343 | if (notesColumnIndex != -1) { | ||
344 | record.setNotes(someData[notesColumnIndex]); | ||
345 | } | ||
346 | recordVersion = record.currentVersion() | ||
347 | |||
348 | for (ii in someData) { | ||
349 | // if ((ii != titleColumnIndex) && (ii != notesColumnIndex) && (typeof(this.fieldSettings()[ii]) != 'undefined')) { | ||
350 | if ((ii != titleColumnIndex) && (ii != notesColumnIndex) && (this.isColumnSelected(ii))) { | ||
351 | var recordField; | ||
352 | |||
353 | recordField = new Clipperz.PM.DataModel.RecordField({ | ||
354 | recordVersion:recordVersion, | ||
355 | label: this.labelForColumn(ii), | ||
356 | value: someData[ii], | ||
357 | type: this.typeForColumn(ii) | ||
358 | }); | ||
359 | recordVersion.addField(recordField); | ||
360 | } | ||
361 | } | ||
362 | |||
363 | someRecords.push(record); | ||
364 | |||
365 | return someRecords; | ||
366 | }, this), records, someValues[i]); | ||
367 | } | ||
368 | deferredResult.addCallback(MochiKit.Async.succeed, records); | ||
369 | deferredResult.callback(); | ||
370 | |||
371 | return deferredResult; | ||
372 | }, | ||
373 | |||
374 | //------------------------------------------------------------------------- | ||
375 | |||
376 | 'step1Component': function() { | ||
377 | if (this._step1Component == null) { | ||
378 | this._step1Component = new Clipperz.PM.Components.Import.CSVImport.CSVImportColumns(this.getElement('step_1'), {mainComponent:this}); | ||
379 | } | ||
380 | |||
381 | return this._step1Component; | ||
382 | }, | ||
383 | |||
384 | 'step2Component': function() { | ||
385 | if (this._step2Component == null) { | ||
386 | this._step2Component = new Clipperz.PM.Components.Import.CSVImport.CSVImportHeader(this.getElement('step_2'), {mainComponent:this}); | ||
387 | } | ||
388 | |||
389 | return this._step2Component; | ||
390 | }, | ||
391 | |||
392 | 'step3Component': function() { | ||
393 | if (this._step3Component == null) { | ||
394 | this._step3Component = new Clipperz.PM.Components.Import.CSVImport.CSVImportTitle(this.getElement('step_3'), {mainComponent:this}); | ||
395 | } | ||
396 | |||
397 | return this._step3Component; | ||
398 | }, | ||
399 | |||
400 | 'step4Component': function() { | ||
401 | if (this._step4Component == null) { | ||
402 | this._step4Component = new Clipperz.PM.Components.Import.CSVImport.CSVImportNotes(this.getElement('step_4'), {mainComponent:this}); | ||
403 | } | ||
404 | |||
405 | return this._step4Component; | ||
406 | }, | ||
407 | |||
408 | 'step5Component': function() { | ||
409 | if (this._step5Component == null) { | ||
410 | this._step5Component = new Clipperz.PM.Components.Import.CSVImport.CSVImportFields(this.getElement('step_5'), {mainComponent:this}); | ||
411 | } | ||
412 | |||
413 | return this._step5Component; | ||
414 | }, | ||
415 | |||
416 | //------------------------------------------------------------------------- | ||
417 | |||
418 | 'isFirstRowHeader': function() { | ||
419 | return this._isFirstRowHeader; | ||
420 | }, | ||
421 | |||
422 | 'setIsFirstRowHeader': function(aValue) { | ||
423 | this._isFirstRowHeader = aValue; | ||
424 | }, | ||
425 | |||
426 | //------------------------------------------------------------------------- | ||
427 | |||
428 | 'titleColumnIndex': function() { | ||
429 | return this._titleColumnIndex; | ||
430 | }, | ||
431 | |||
432 | 'setTitleColumnIndex': function(aValue) { | ||
433 | this._titleColumnIndex = aValue; | ||
434 | }, | ||
435 | |||
436 | //------------------------------------------------------------------------- | ||
437 | |||
438 | 'notesColumnIndex': function() { | ||
439 | return this._notesColumnIndex; | ||
440 | }, | ||
441 | |||
442 | 'setNotesColumnIndex': function(aValue) { | ||
443 | this._notesColumnIndex = aValue; | ||
444 | }, | ||
445 | |||
446 | //------------------------------------------------------------------------- | ||
447 | |||
448 | 'fieldSettings': function() { | ||
449 | return this._fieldSettings; | ||
450 | }, | ||
451 | |||
452 | //------------------------------------------------------------------------- | ||
453 | |||
454 | 'skippedColumns': function() { | ||
455 | return this._skippedColumns; | ||
456 | }, | ||
457 | |||
458 | //------------------------------------------------------------------------- | ||
459 | |||
460 | 'isColumnSelected': function(aColumnIndex) { | ||
461 | return !this.skippedColumns().contains("" + aColumnIndex); | ||
462 | }, | ||
463 | |||
464 | //========================================================================= | ||
465 | |||
466 | 'labelForColumn': function(aColumnIndex) { | ||
467 | var result; | ||
468 | |||
469 | if ((typeof(this.fieldSettings()) != 'undefined') && (typeof(this.fieldSettings()[aColumnIndex]) != 'undefined')) { | ||
470 | if (this.isFirstRowHeader()) { | ||
471 | result = this.fieldSettings()[aColumnIndex]['_firstRowLabel']; | ||
472 | //MochiKit.Logging.logDebug("--- updateInputFieldValues - [" + aColumnIndex + "] _firstRowLabel: " + label); | ||
473 | } else { | ||
474 | result = this.fieldSettings()[aColumnIndex]['_emptyLabel']; | ||
475 | //MochiKit.Logging.logDebug("--- updateInputFieldValues - [" + aColumnIndex + "] _emptyLabel: " + label); | ||
476 | } | ||
477 | } else { | ||
478 | result = ""; | ||
479 | } | ||
480 | |||
481 | return result; | ||
482 | }, | ||
483 | |||
484 | //------------------------------------------------------------------------- | ||
485 | |||
486 | 'setLabelForColumn': function(aLabel, aColumnIndex) { | ||
487 | var fieldSettings; | ||
488 | |||
489 | //MochiKit.Logging.logDebug(">>> setLabelForColumn[" + aColumnIndex + "]: " + aLabel); | ||
490 | fieldSettings = this.fieldSettings(); | ||
491 | |||
492 | if (typeof(fieldSettings[aColumnIndex]) == 'undefined') { | ||
493 | fieldSettings[aColumnIndex] = {} | ||
494 | } | ||
495 | |||
496 | if (this.isFirstRowHeader()) { | ||
497 | //MochiKit.Logging.logDebug("--- setLabelForColumn -> _firstRowLabel"); | ||
498 | fieldSettings[aColumnIndex]['_firstRowLabel'] = aLabel; | ||
499 | } else { | ||
500 | if (typeof(fieldSettings[aColumnIndex]['_emptyLabel']) == 'undefined') { | ||
501 | if (aLabel == null) { | ||
502 | //MochiKit.Logging.logDebug("--- setLabelForColumn -> _emptyLabel = \"\""); | ||
503 | fieldSettings[aColumnIndex]['_emptyLabel'] = ""; | ||
504 | } else { | ||
505 | fieldSettings[aColumnIndex]['_emptyLabel'] = aLabel; | ||
506 | } | ||
507 | } else { | ||
508 | //MochiKit.Logging.logDebug("--- setLabelForColumn -> _emptyLabel = " + aLabel); | ||
509 | if (aLabel != null) { | ||
510 | fieldSettings[aColumnIndex]['_emptyLabel'] = aLabel; | ||
511 | } | ||
512 | } | ||
513 | } | ||
514 | //MochiKit.Logging.logDebug("<<< setLabelForColumn[" + aColumnIndex + "]: " + aLabel); | ||
515 | }, | ||
516 | |||
517 | //========================================================================= | ||
518 | |||
519 | 'typeForColumn': function(aColumnIndex) { | ||
520 | var result; | ||
521 | |||
522 | if ((typeof(this.fieldSettings()) != 'undefined') && (typeof(this.fieldSettings()[aColumnIndex]) != 'undefined') && (typeof(this.fieldSettings()[aColumnIndex]['type']) != 'undefined')) { | ||
523 | result = this.fieldSettings()[aColumnIndex]['type']; | ||
524 | } else { | ||
525 | result = 'UNDEFINED'; | ||
526 | } | ||
527 | |||
528 | return result; | ||
529 | }, | ||
530 | |||
531 | //------------------------------------------------------------------------- | ||
532 | |||
533 | 'setTypeForColumn': function(aType, aColumnIndex) { | ||
534 | var fieldSettings; | ||
535 | |||
536 | fieldSettings = this.fieldSettings(); | ||
537 | |||
538 | if (typeof(fieldSettings[aColumnIndex]) == 'undefined') { | ||
539 | fieldSettings[aColumnIndex] = {} | ||
540 | } | ||
541 | |||
542 | fieldSettings[aColumnIndex]['type'] = aType; | ||
543 | }, | ||
544 | |||
545 | //========================================================================= | ||
546 | __syntaxFix__: "syntax fix" | ||
547 | }); | ||
548 | |||
diff --git a/frontend/beta/js/Clipperz/PM/Components/Import/ClipperzImportComponent.js b/frontend/beta/js/Clipperz/PM/Components/Import/ClipperzImportComponent.js new file mode 100644 index 0000000..50dcb93 --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/Import/ClipperzImportComponent.js | |||
@@ -0,0 +1,212 @@ | |||
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 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | ||
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | ||
31 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } | ||
32 | if (typeof(Clipperz.PM.Components.Import) == 'undefined') { Clipperz.PM.Components.Import = {}; } | ||
33 | |||
34 | //############################################################################# | ||
35 | |||
36 | Clipperz.PM.Components.Import.ClipperzImportComponent = function(anElement, args) { | ||
37 | args = args || {}; | ||
38 | |||
39 | Clipperz.PM.Components.Import.ClipperzImportComponent.superclass.constructor.call(this, anElement, args); | ||
40 | |||
41 | this.render(); | ||
42 | |||
43 | return this; | ||
44 | } | ||
45 | |||
46 | //============================================================================= | ||
47 | |||
48 | YAHOO.extendX(Clipperz.PM.Components.Import.ClipperzImportComponent, Clipperz.PM.Components.Import.GenericImportComponent, { | ||
49 | |||
50 | 'toString': function() { | ||
51 | return "Clipperz.PM.Components.Import.ClipperzImportComponent component"; | ||
52 | }, | ||
53 | |||
54 | //------------------------------------------------------------------------- | ||
55 | |||
56 | 'render': function() { | ||
57 | //MochiKit.Logging.logDebug(">>> Import.ClipperzImportComponent.render"); | ||
58 | this.domHelper().append(this.element(), {tag:'div', cls:'clipperzImportWizard', children:[ | ||
59 | {tag:'h3', htmlString:Clipperz.PM.Strings['Clipperz_ImportWizard_Title']}, | ||
60 | {tag:'div', cls:'importSteps', id:this.getId('importSteps')}, | ||
61 | {tag:'div', cls:'importStepBlocks', children:[ | ||
62 | {tag:'div', cls:'step_0', id:this.getId('step_0'), children:[ | ||
63 | {tag:'div', children:[ | ||
64 | {tag:'div', cls:'importOptionsDescription', htmlString:Clipperz.PM.Strings['importOptions_clipperz_description']}, | ||
65 | {tag:'div', cls:'importOptionsParameters', children:[]}, | ||
66 | this.textAreaConfig() | ||
67 | ]} | ||
68 | ]}, | ||
69 | {tag:'div', cls:'step_1', id:this.getId('step_1'), children:[ | ||
70 | {tag:'div', children:[ | ||
71 | {tag:'div', id:this.getId('previewDiv'), html:"preview"} | ||
72 | ]} | ||
73 | ]}, | ||
74 | {tag:'div', cls:'step_2', id:this.getId('step_2'), children:[ | ||
75 | {tag:'div', children:[ | ||
76 | {tag:'h4', html:"done"} | ||
77 | ]} | ||
78 | ]} | ||
79 | ]}, | ||
80 | {tag:'div', cls:'importOptionsButtons', children:[ | ||
81 | {tag:'table', children:[ | ||
82 | {tag:'tbody', children:[ | ||
83 | {tag:'tr', children:[ | ||
84 | {tag:'td', html:' '}, | ||
85 | {tag:'td', children:[ | ||
86 | {tag:'div', id:this.getId('backActionButton')} | ||
87 | ]}, | ||
88 | {tag:'td', html:' '}, | ||
89 | {tag:'td', children:[ | ||
90 | {tag:'div', id:this.getId('nextActionButton')} | ||
91 | ]}, | ||
92 | {tag:'td', html:' '} | ||
93 | ]} | ||
94 | ]} | ||
95 | ]} | ||
96 | ]} | ||
97 | ]}); | ||
98 | |||
99 | this.updateSteps(); | ||
100 | |||
101 | this.setBackButton(new YAHOO.ext.Button(this.getDom('backActionButton'), {text:"back", handler:this.backAction, scope:this})); | ||
102 | this.setNextButton(new YAHOO.ext.Button(this.getDom('nextActionButton'), {text:"next", handler:this.nextAction, scope:this})); | ||
103 | |||
104 | this.getElement('step_0').setVisibilityMode(YAHOO.ext.Element.DISPLAY).show() | ||
105 | this.getElement('step_1').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); | ||
106 | this.getElement('step_2').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); | ||
107 | //MochiKit.Logging.logDebug("<<< Import.ClipperzImportComponent.render"); | ||
108 | }, | ||
109 | |||
110 | //------------------------------------------------------------------------- | ||
111 | |||
112 | 'nextAction': function() { | ||
113 | switch (this.currentStep()) { | ||
114 | case 0: //-> 1 | ||
115 | this.previewValues(); | ||
116 | break; | ||
117 | case 1: //-> 2 | ||
118 | this.importValues(); | ||
119 | break; | ||
120 | } | ||
121 | }, | ||
122 | |||
123 | //------------------------------------------------------------------------- | ||
124 | |||
125 | 'deferredPreviewValues': function() { | ||
126 | var deferredResult; | ||
127 | |||
128 | deferredResult = new MochiKit.Async.Deferred(); | ||
129 | deferredResult.addCallback(MochiKit.Base.bind(function(res) { | ||
130 | this.startProcessing(); | ||
131 | |||
132 | return res; | ||
133 | }, this)); | ||
134 | deferredResult.addCallback(MochiKit.Base.method(this, 'processClipperzValues')); | ||
135 | deferredResult.addCallback(MochiKit.Base.method(this, 'setProcessedValues')); | ||
136 | deferredResult.addCallback(MochiKit.Base.method(this, 'previewRecordValues')); | ||
137 | deferredResult.addCallback(MochiKit.Base.bind(function(res) { | ||
138 | this.processingDone(); | ||
139 | this.getElement('step_0').hide(); | ||
140 | this.getElement('step_1').show(); | ||
141 | this.backButton().enable(); | ||
142 | |||
143 | return res; | ||
144 | }, this)); | ||
145 | // deferredResult.addErrback(MochiKit.Base.bind(function() { | ||
146 | // this.processingAborted(); | ||
147 | // }, this)) | ||
148 | deferredResult.callback(this.textAreaContent()); | ||
149 | |||
150 | return deferredResult; | ||
151 | }, | ||
152 | |||
153 | //------------------------------------------------------------------------- | ||
154 | |||
155 | 'processClipperzValues': function(someData) { | ||
156 | var deferredResult; | ||
157 | |||
158 | deferredResult = new MochiKit.Async.Deferred(); | ||
159 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Record.processClipperzValues - 1: " + res); return res;}); | ||
160 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'parseImportData'); | ||
161 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Record.processClipperzValues - 2: " + res); return res;}); | ||
162 | deferredResult.addCallback(Clipperz.Base.evalJSON); | ||
163 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Record.processClipperzValues - 3: " + res); return res;}); | ||
164 | deferredResult.addCallback(function(res) { | ||
165 | return Clipperz.NotificationCenter.deferredNotification(this, 'updatedProgressState', {steps:(res.length)}, res); | ||
166 | }) | ||
167 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Record.processClipperzValues - 4: " + res); return res;}); | ||
168 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'previewImportData'); | ||
169 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Record.processClipperzValues - 5: " + res); return res;}); | ||
170 | deferredResult.addCallback(MochiKit.Base.bind(function(someClipperzValues) { | ||
171 | var innerDeferredResult; | ||
172 | var records; | ||
173 | var i,c; | ||
174 | |||
175 | innerDeferredResult = new MochiKit.Async.Deferred(); | ||
176 | records = []; | ||
177 | |||
178 | c = someClipperzValues.length; | ||
179 | for(i=0; i<c; i++) { | ||
180 | innerDeferredResult.addCallback(MochiKit.Async.wait, 0.2); | ||
181 | innerDeferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', {}); | ||
182 | innerDeferredResult.addCallback(MochiKit.Base.bind(function(someRecords, someData) { | ||
183 | var record; | ||
184 | var recordVersion; | ||
185 | |||
186 | //MochiKit.Logging.logDebug("=== someData: " + Clipperz.Base.serializeJSON(someData)); | ||
187 | record = new Clipperz.PM.DataModel.Record({user:this.user()}); | ||
188 | record.setLabel(someData['label']); | ||
189 | record.setShouldProcessData(true); | ||
190 | record.processData(someData); | ||
191 | |||
192 | someRecords.push(record); | ||
193 | |||
194 | return someRecords; | ||
195 | }, this), records, someClipperzValues[i]); | ||
196 | } | ||
197 | innerDeferredResult.addCallback(MochiKit.Async.succeed, records); | ||
198 | innerDeferredResult.callback(); | ||
199 | |||
200 | return innerDeferredResult; | ||
201 | }, this)); | ||
202 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Record.processClipperzValues - 6: " + res); return res;}); | ||
203 | deferredResult.callback(someData); | ||
204 | |||
205 | return deferredResult; | ||
206 | }, | ||
207 | |||
208 | |||
209 | //------------------------------------------------------------------------- | ||
210 | __syntaxFix__: "syntax fix" | ||
211 | }); | ||
212 | |||
diff --git a/frontend/beta/js/Clipperz/PM/Components/Import/ExcelImportComponent.js b/frontend/beta/js/Clipperz/PM/Components/Import/ExcelImportComponent.js new file mode 100644 index 0000000..ecdf509 --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/Import/ExcelImportComponent.js | |||
@@ -0,0 +1,134 @@ | |||
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 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | ||
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | ||
31 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } | ||
32 | if (typeof(Clipperz.PM.Components.Import) == 'undefined') { Clipperz.PM.Components.Import = {}; } | ||
33 | |||
34 | //############################################################################# | ||
35 | |||
36 | Clipperz.PM.Components.Import.ExcelImportComponent = function(anElement, args) { | ||
37 | args = args || {}; | ||
38 | |||
39 | this._steps = ['EXCEL_EDIT', 'CSV_COLUMNS', 'CSV_HEADER', 'CSV_TITLE', 'CSV_NOTES', 'CSV_FIELDS', 'PREVIEW', 'IMPORT']; | ||
40 | |||
41 | Clipperz.PM.Components.Import.ExcelImportComponent.superclass.constructor.call(this, anElement, args); | ||
42 | |||
43 | return this; | ||
44 | } | ||
45 | |||
46 | //============================================================================= | ||
47 | |||
48 | YAHOO.extendX(Clipperz.PM.Components.Import.ExcelImportComponent, Clipperz.PM.Components.Import.CSVImportComponent, { | ||
49 | |||
50 | 'toString': function() { | ||
51 | return "Clipperz.PM.Components.Import.ExcelImportComponent component"; | ||
52 | }, | ||
53 | |||
54 | //------------------------------------------------------------------------- | ||
55 | |||
56 | 'render': function() { | ||
57 | //MochiKit.Logging.logDebug(">>> Import.ExcelImportComponent.render"); | ||
58 | this.domHelper().append(this.element(), {tag:'div', cls:'excelImportWizard', children:[ | ||
59 | {tag:'h3', htmlString:Clipperz.PM.Strings['Excel_ImportWizard_Title']}, | ||
60 | {tag:'div', cls:'importSteps', id:this.getId('importSteps')}, | ||
61 | {tag:'div', cls:'importStepBlocks', children:[ | ||
62 | {tag:'div', cls:'step_0', id:this.getId('step_0'), children:[ | ||
63 | {tag:'div', children:[ | ||
64 | {tag:'div', cls:'importOptionsDescription', htmlString:Clipperz.PM.Strings['importOptions_excel_description']}, | ||
65 | {tag:'div', cls:'importOptionsParameters', children:[]}, | ||
66 | this.textAreaConfig() | ||
67 | ]} | ||
68 | ]}, | ||
69 | {tag:'div', cls:'step_1', id:this.getId('step_1'), children:[]}, | ||
70 | {tag:'div', cls:'step_2', id:this.getId('step_2'), children:[]}, | ||
71 | {tag:'div', cls:'step_3', id:this.getId('step_3'), children:[]}, | ||
72 | {tag:'div', cls:'step_4', id:this.getId('step_4'), children:[]}, | ||
73 | {tag:'div', cls:'step_5', id:this.getId('step_5'), children:[]}, | ||
74 | {tag:'div', cls:'step_6', id:this.getId('step_6'), children:[ | ||
75 | {tag:'div', children:[ | ||
76 | {tag:'div', id:this.getId('previewDiv'), html:"preview"} | ||
77 | ]} | ||
78 | ]}, | ||
79 | {tag:'div', cls:'step_7', id:this.getId('step_7'), children:[ | ||
80 | {tag:'div', children:[ | ||
81 | {tag:'h4', html:"done"} | ||
82 | ]} | ||
83 | ]} | ||
84 | ]}, | ||
85 | {tag:'div', cls:'importOptionsButtons', children:[ | ||
86 | {tag:'table', children:[ | ||
87 | {tag:'tbody', children:[ | ||
88 | {tag:'tr', children:[ | ||
89 | {tag:'td', html:' '}, | ||
90 | {tag:'td', children:[ | ||
91 | {tag:'div', id:this.getId('backActionButton')} | ||
92 | ]}, | ||
93 | {tag:'td', html:' '}, | ||
94 | {tag:'td', children:[ | ||
95 | {tag:'div', id:this.getId('nextActionButton')} | ||
96 | ]}, | ||
97 | {tag:'td', html:' '} | ||
98 | ]} | ||
99 | ]} | ||
100 | ]} | ||
101 | ]} | ||
102 | ]}); | ||
103 | |||
104 | this.updateSteps(); | ||
105 | |||
106 | this.setBackButton(new YAHOO.ext.Button(this.getDom('backActionButton'), {text:"back", handler:this.backAction, scope:this})); | ||
107 | this.setNextButton(new YAHOO.ext.Button(this.getDom('nextActionButton'), {text:"next", handler:this.nextAction, scope:this})); | ||
108 | |||
109 | this.getElement('step_0').setVisibilityMode(YAHOO.ext.Element.DISPLAY).show() | ||
110 | this.getElement('step_1').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); | ||
111 | this.getElement('step_2').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); | ||
112 | this.getElement('step_3').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); | ||
113 | this.getElement('step_4').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); | ||
114 | this.getElement('step_5').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); | ||
115 | this.getElement('step_6').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); | ||
116 | this.getElement('step_7').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); | ||
117 | //MochiKit.Logging.logDebug("<<< Import.ExcelImportComponent.render"); | ||
118 | }, | ||
119 | |||
120 | //------------------------------------------------------------------------- | ||
121 | |||
122 | 'csvProcessor': function() { | ||
123 | return new Clipperz.CSVProcessor({ | ||
124 | // quoteChar: this.getDom('CSV_inputOptions_quote').value, | ||
125 | // escapeChar: this.getDom('CSV_inputOptions_escape').value, | ||
126 | separatorChar:'\t', | ||
127 | binary:true | ||
128 | }); | ||
129 | }, | ||
130 | |||
131 | //------------------------------------------------------------------------- | ||
132 | __syntaxFix__: "syntax fix" | ||
133 | }); | ||
134 | |||
diff --git a/frontend/beta/js/Clipperz/PM/Components/Import/GenericImportComponent.js b/frontend/beta/js/Clipperz/PM/Components/Import/GenericImportComponent.js new file mode 100644 index 0000000..4f6b1e4 --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/Import/GenericImportComponent.js | |||
@@ -0,0 +1,523 @@ | |||
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 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | ||
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | ||
31 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } | ||
32 | if (typeof(Clipperz.PM.Components.Import) == 'undefined') { Clipperz.PM.Components.Import = {}; } | ||
33 | |||
34 | //############################################################################# | ||
35 | |||
36 | Clipperz.PM.Components.Import.GenericImportComponent = function(anElement, args) { | ||
37 | args = args || {}; | ||
38 | |||
39 | this._steps = this._steps || ['EDIT', 'PREVIEW', 'IMPORT']; | ||
40 | |||
41 | Clipperz.PM.Components.Import.GenericImportComponent.superclass.constructor.call(this, anElement, args); | ||
42 | |||
43 | this._user = args['user']; | ||
44 | |||
45 | this._currentStep = 0; | ||
46 | this._currentStatus = 'IDLE'; //'PROCESSING' | ||
47 | |||
48 | this._parsedValues = null; | ||
49 | this._processedValues = null; | ||
50 | |||
51 | this._backButton = null; | ||
52 | this._nextButton = null; | ||
53 | |||
54 | Clipperz.NotificationCenter.register(null, 'importProcessorProgressUpdate', this, 'updateProgressDialogStatus'); | ||
55 | |||
56 | return this; | ||
57 | } | ||
58 | |||
59 | //============================================================================= | ||
60 | |||
61 | YAHOO.extendX(Clipperz.PM.Components.Import.GenericImportComponent, Clipperz.PM.Components.BaseComponent, { | ||
62 | |||
63 | 'toString': function() { | ||
64 | return "Clipperz.PM.Components.Import.GenericImportComponent component"; | ||
65 | }, | ||
66 | |||
67 | //------------------------------------------------------------------------- | ||
68 | |||
69 | 'user': function() { | ||
70 | return this._user; | ||
71 | }, | ||
72 | |||
73 | //------------------------------------------------------------------------- | ||
74 | |||
75 | 'textAreaConfig': function() { | ||
76 | return {tag:'textarea', name:this.getId('importTextArea'), cls:'importTextArea', id:this.getId('importTextArea'), cols:60, rows:15, html:""}; | ||
77 | }, | ||
78 | |||
79 | 'textAreaContent': function() { | ||
80 | return this.getDom('importTextArea').value | ||
81 | }, | ||
82 | |||
83 | //------------------------------------------------------------------------- | ||
84 | |||
85 | 'steps': function() { | ||
86 | return this._steps; | ||
87 | }, | ||
88 | |||
89 | 'currentStep': function() { | ||
90 | return this._currentStep; | ||
91 | }, | ||
92 | |||
93 | 'setCurrentStep': function(aValue) { | ||
94 | this._currentStep = aValue; | ||
95 | this.updateSteps(); | ||
96 | }, | ||
97 | |||
98 | //------------------------------------------------------------------------- | ||
99 | |||
100 | 'currentStatus': function() { | ||
101 | return this._currentStatus; | ||
102 | }, | ||
103 | |||
104 | 'startProcessing': function() { | ||
105 | this._currentStatus = 'PROCESSING'; | ||
106 | this.updateSteps(); | ||
107 | }, | ||
108 | |||
109 | 'processingDone': function() { | ||
110 | this._currentStatus = 'IDLE'; | ||
111 | this.setCurrentStep(this.currentStep() + 1); | ||
112 | }, | ||
113 | |||
114 | 'processingAborted': function() { | ||
115 | this._currentStatus = 'IDLE'; | ||
116 | this.updateSteps(); | ||
117 | }, | ||
118 | |||
119 | //------------------------------------------------------------------------- | ||
120 | |||
121 | 'stepsConfig': function() { | ||
122 | var result; | ||
123 | var i,c; | ||
124 | |||
125 | result = []; | ||
126 | c = this.steps().length; | ||
127 | for (i=0; i<c; i++) { | ||
128 | var cls; | ||
129 | |||
130 | if (this.currentStep() == i) { | ||
131 | if (this.currentStatus() == 'IDLE') { | ||
132 | cls = 'current'; | ||
133 | } else { | ||
134 | cls = 'currentProcessing'; | ||
135 | } | ||
136 | } else { | ||
137 | cls = ""; | ||
138 | } | ||
139 | |||
140 | result.push({tag:'td', cls:cls, children:[ | ||
141 | {tag:'div', children:[{tag:'span', htmlString:Clipperz.PM.Strings['ImportWizard'][this.steps()[i]]}]} | ||
142 | ]}) | ||
143 | if (i < (c-1)) { | ||
144 | if ((this.currentStep() == i) && (this.currentStatus() == 'PROCESSING')) { | ||
145 | cls = 'stepSeparatorProcessing'; | ||
146 | } else { | ||
147 | cls = 'stepSeparator'; | ||
148 | } | ||
149 | |||
150 | result.push({tag:'td', cls:cls, children:[ | ||
151 | {tag:'div', children:[{tag:'span', html:">"}]} | ||
152 | ]}); | ||
153 | } | ||
154 | } | ||
155 | |||
156 | result = [{tag:'div', cls:'importWizardStepsBox', children:[ | ||
157 | {tag:'div', cls:'importWizardStepsInnerBox', children:[ | ||
158 | {tag:'table', cls:'importWizardSteps', children:[ | ||
159 | {tag:'tbody', children:[ | ||
160 | {tag:'tr', children:result} | ||
161 | ]} | ||
162 | ]} | ||
163 | ]}, | ||
164 | {tag:'div', cls:'importWizardStepsBoxFooter'} | ||
165 | ]}]; | ||
166 | |||
167 | return result; | ||
168 | }, | ||
169 | |||
170 | 'updateSteps': function() { | ||
171 | this.getElement('importSteps').update(""); | ||
172 | Clipperz.YUI.DomHelper.append(this.getDom('importSteps'), {tag:'div', children:this.stepsConfig()}); | ||
173 | }, | ||
174 | |||
175 | //------------------------------------------------------------------------- | ||
176 | |||
177 | 'backAction': function() { | ||
178 | //MochiKit.Logging.logDebug(">>> backAction"); | ||
179 | if (this.currentStep() == 0) { | ||
180 | Clipperz.NotificationCenter.notify(this, 'importCancelled'); | ||
181 | } else { | ||
182 | this.getElement('step_' + this.currentStep()).hide(); | ||
183 | this.setCurrentStep(this.currentStep() - 1); | ||
184 | this.getElement('step_' + this.currentStep()).show(); | ||
185 | |||
186 | this.nextButton().enable(); | ||
187 | } | ||
188 | //MochiKit.Logging.logDebug("<<< backAction"); | ||
189 | }, | ||
190 | |||
191 | //------------------------------------------------------------------------- | ||
192 | |||
193 | 'backButton': function() { | ||
194 | return this._backButton; | ||
195 | }, | ||
196 | |||
197 | 'setBackButton': function(aValue) { | ||
198 | this._backButton = aValue; | ||
199 | }, | ||
200 | |||
201 | 'nextButton': function() { | ||
202 | return this._nextButton; | ||
203 | }, | ||
204 | |||
205 | 'setNextButton': function(aValue) { | ||
206 | this._nextButton = aValue; | ||
207 | }, | ||
208 | |||
209 | //------------------------------------------------------------------------- | ||
210 | |||
211 | 'render': function() { | ||
212 | //MochiKit.Logging.logDebug(">>> Import.GenericImportComponent.render"); | ||
213 | this.domHelper().append(this.element(), {tag:'div', children:[ | ||
214 | {tag:'h2', html:this.toString()} | ||
215 | ]}); | ||
216 | //MochiKit.Logging.logDebug("<<< Import.GenericImportComponent.render"); | ||
217 | }, | ||
218 | |||
219 | //------------------------------------------------------------------------- | ||
220 | |||
221 | 'previewValues': function() { | ||
222 | Clipperz.PM.Components.MessageBox.showProgressPanel( | ||
223 | MochiKit.Base.method(this, 'deferredPreviewValues'), | ||
224 | MochiKit.Base.method(this, 'handlePreviewError'), | ||
225 | this.getDom('nextActionButton') | ||
226 | ); | ||
227 | }, | ||
228 | |||
229 | 'deferredPreviewValues': function() { | ||
230 | throw Clipperz.Base.exception.AbstractMethod; | ||
231 | }, | ||
232 | |||
233 | 'handlePreviewError': function(anError) { | ||
234 | console.log("anError", anError); | ||
235 | MochiKit.Logging.logError("An error occurred while previewing the data: " + anError); | ||
236 | alert("An error occurred while previewing the data"); | ||
237 | Clipperz.PM.Components.MessageBox().hide(); | ||
238 | }, | ||
239 | |||
240 | //------------------------------------------------------------------------- | ||
241 | |||
242 | 'previewRecordValues': function(someProcessedRecords) { | ||
243 | //MochiKit.Logging.logDebug(">>> previewRecordValues"); | ||
244 | this.getElement('previewDiv').update(""); | ||
245 | //MochiKit.Logging.logDebug("--- previewRecordValues - 1"); | ||
246 | this.domHelper().append(this.getElement('previewDiv'), {tag:'div', cls:'importPreviewDiv', children:[{tag:'table', id:'importPreview', cellspacing:'0', children:[ | ||
247 | {tag:'tbody', children: | ||
248 | MochiKit.Base.map(MochiKit.Base.bind(function(aRecord) { | ||
249 | var result; | ||
250 | //MochiKit.Logging.logDebug("--- previewRecordValues - 1.1"); | ||
251 | //console.log("fields", aRecord.currentVersion().fields()); | ||
252 | result = {tag:'tr', children:[{tag:'td', children:[ | ||
253 | {tag:'table', cls:'importPreview_record', children:[ | ||
254 | {tag:'tbody', children:[ | ||
255 | {tag:'tr', children:[ | ||
256 | {tag:'td', rowspan:'2', valign:'top', children:[ | ||
257 | {tag:'input', type:'checkbox', id:this.getId(aRecord.reference()), value:"aRecord.reference()", checked:true} | ||
258 | ]}, | ||
259 | {tag:'td', colspan:'2', children:[ | ||
260 | {tag:'span', cls:'importPreview_title', html:aRecord.label()} | ||
261 | ]} | ||
262 | ]}, | ||
263 | {tag:'tr', children:[ | ||
264 | {tag:'td', valign:'top', children:[ | ||
265 | {tag:'span', cls:'importPreview_notes', html:(MochiKit.Base.isNotEmpty(aRecord.notes()) ? aRecord.notes().replace(/\n/g, '<br>') : ' ')} | ||
266 | ]}, | ||
267 | {tag:'td', valign:'top', cls:'importPreview_fieds', children:[ | ||
268 | {tag:'table', cls:'importPreview_fields', children:[ | ||
269 | {tag:'tbody', children:MochiKit.Base.map(function(aField) { | ||
270 | var result; | ||
271 | //MochiKit.Logging.logDebug("--- previewRecordValues - 1.1.1"); | ||
272 | result = {tag:'tr', children:[ | ||
273 | {tag:'td', valign:'top', children:[ | ||
274 | {tag:'span', cls:'importPreview_fields_label', html:aField.label()} | ||
275 | ]}, | ||
276 | {tag:'td', valign:'top', children:[ | ||
277 | {tag:'span', cls:'importPreview_fields_value', html:aField.value()} | ||
278 | ]} | ||
279 | ]}; | ||
280 | //MochiKit.Logging.logDebug("--- previewRecordValues - 1.1.2"); | ||
281 | return result; | ||
282 | }, MochiKit.Base.values(aRecord.currentVersion().fields()))} | ||
283 | ]} | ||
284 | ]} | ||
285 | ]} | ||
286 | ]} | ||
287 | ]} | ||
288 | ]}]}; | ||
289 | //MochiKit.Logging.logDebug("--- previewRecordValues - 1.2"); | ||
290 | return result; | ||
291 | }, this), someProcessedRecords) | ||
292 | } | ||
293 | ]}]}); | ||
294 | //MochiKit.Logging.logDebug("--- previewRecordValues - 2"); | ||
295 | |||
296 | MochiKit.Base.map(MochiKit.Base.bind(function(aRecord) { | ||
297 | this.getElement(aRecord.reference()).dom.value = aRecord.reference(); | ||
298 | }, this), someProcessedRecords); | ||
299 | |||
300 | Clipperz.Style.applyZebraStylesToTable('importPreview'); | ||
301 | //MochiKit.Logging.logDebug("<<< previewRecordValues"); | ||
302 | }, | ||
303 | |||
304 | //------------------------------------------------------------------------- | ||
305 | |||
306 | 'updateProgressDialogStatus': function(anEvent) { | ||
307 | Clipperz.PM.Components.MessageBox().update({step:anEvent.parameters().progress}); | ||
308 | }, | ||
309 | |||
310 | //------------------------------------------------------------------------- | ||
311 | |||
312 | 'parsedValues': function() { | ||
313 | return this._parsedValues; | ||
314 | }, | ||
315 | |||
316 | 'setParsedValues': function(aValue) { | ||
317 | this._parsedValues = aValue; | ||
318 | |||
319 | return this._parsedValues; | ||
320 | }, | ||
321 | |||
322 | //------------------------------------------------------------------------- | ||
323 | |||
324 | 'processedValues': function() { | ||
325 | return this._processedValues; | ||
326 | }, | ||
327 | |||
328 | 'setProcessedValues': function(aValue) { | ||
329 | this._processedValues = aValue; | ||
330 | return this._processedValues; | ||
331 | }, | ||
332 | |||
333 | //------------------------------------------------------------------------- | ||
334 | |||
335 | 'importValues': function() { | ||
336 | var deferredResult; | ||
337 | |||
338 | deferredResult = new MochiKit.Async.Deferred(); | ||
339 | |||
340 | deferredResult.addCallback(MochiKit.Base.bind(function() { | ||
341 | this.nextButton().disable(); | ||
342 | this.startProcessing(); | ||
343 | },this)); | ||
344 | deferredResult.addCallback(MochiKit.Base.method(this, 'importProcessedValues')); | ||
345 | deferredResult.addCallback(MochiKit.Base.method(this, 'processingDone')); | ||
346 | deferredResult.addErrback (MochiKit.Base.method(this, 'processingAborted')); | ||
347 | deferredResult.callback(); | ||
348 | |||
349 | return deferredResult; | ||
350 | }, | ||
351 | |||
352 | //------------------------------------------------------------------------- | ||
353 | |||
354 | 'importProcessedValues': function() { | ||
355 | var deferredResult; | ||
356 | var processedValues; | ||
357 | var selectedRecords; | ||
358 | var i,c; | ||
359 | |||
360 | //MochiKit.Logging.logDebug(">>> GenericImportComponent.importProcessedValues"); | ||
361 | processedValues = this.processedValues(); | ||
362 | selectedRecords = []; | ||
363 | |||
364 | c = processedValues.length; | ||
365 | for (i=0; i<c; i++) { | ||
366 | var currentRecord; | ||
367 | |||
368 | currentRecord = processedValues[i]; | ||
369 | if (this.getDom(currentRecord.reference()).checked == true) { | ||
370 | selectedRecords.push(currentRecord); | ||
371 | } | ||
372 | } | ||
373 | |||
374 | deferredResult = new MochiKit.Async.Deferred(); | ||
375 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("GenericImportComponent - 1: " + res); return res;}); | ||
376 | deferredResult.addCallback(function(someRecords) { | ||
377 | var innerDeferredResult; | ||
378 | var text; | ||
379 | |||
380 | text = Clipperz.PM.Strings['importData_importConfirmation_text']; | ||
381 | text = text.replace(/__numberOfRecords__/, someRecords.length); | ||
382 | |||
383 | innerDeferredResult = new MochiKit.Async.Deferred(); | ||
384 | //innerDeferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("GenericImportComponent - 1.1: " + res); return res;}); | ||
385 | innerDeferredResult.addCallback(MochiKit.Async.succeed, someRecords); | ||
386 | //innerDeferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("GenericImportComponent - 1.2: " + res); return res;}); | ||
387 | |||
388 | Clipperz.PM.Components.MessageBox().deferredShow({ | ||
389 | title:Clipperz.PM.Strings['importData_importConfirmation_title'], | ||
390 | text:text, | ||
391 | width:240, | ||
392 | showProgressBar:false, | ||
393 | showCloseButton:false, | ||
394 | buttons:{ | ||
395 | 'yes':"yes", //Clipperz.PM.Strings['mainPanelDeleteRecordPanelConfirmButtonLabel'], | ||
396 | 'no':"no" //Clipperz.PM.Strings['mainPanelDeleteRecordPanelDenyButtonLabel'] | ||
397 | }, | ||
398 | fn:MochiKit.Base.partial(function(aDeferred, aResult) { | ||
399 | if (aResult == 'yes') { | ||
400 | aDeferred.callback(aResult); | ||
401 | } else { | ||
402 | aDeferred.errback(aResult); | ||
403 | } | ||
404 | }, innerDeferredResult) | ||
405 | }/*, this.getId('nextActionButton')*/); | ||
406 | |||
407 | return innerDeferredResult; | ||
408 | }); | ||
409 | |||
410 | //------------------- | ||
411 | // deferredResult.addCallback(MochiKit.Base.bind(function(someRecords) { | ||
412 | // Clipperz.PM.Components.MessageBox.showProgressPanel( | ||
413 | // MochiKit.Base.method(this, 'importProcessedValues_core', someRecords), | ||
414 | // MochiKit.Base.method(this, 'handleProcessError'), | ||
415 | // this.getDom('mainDiv') | ||
416 | // ); | ||
417 | // }, this)); | ||
418 | |||
419 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("GenericImportComponent - 2: " + res); return res;}); | ||
420 | deferredResult.addCallback(MochiKit.Base.method(Clipperz.PM.Components.MessageBox(), 'deferredShow'), | ||
421 | { | ||
422 | // title:Clipperz.PM.Strings['accountPanelDeletingAccountPanelProgressTitle'], | ||
423 | // text:Clipperz.PM.Strings['accountPanelDeletingAccountPanelProgressText'], | ||
424 | width:240, | ||
425 | showProgressBar:true, | ||
426 | showCloseButton:false | ||
427 | } | ||
428 | ); | ||
429 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("GenericImportComponent - 3: " + res); return res;}); | ||
430 | |||
431 | deferredResult.addCallback(MochiKit.Base.bind(function(someRecords) { | ||
432 | var innerDeferredResult; | ||
433 | |||
434 | //MochiKit.Logging.logDebug(">>> inner deferred"); | ||
435 | innerDeferredResult = new MochiKit.Async.Deferred(); | ||
436 | |||
437 | //innerDeferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("GenericImportComponent - 3.1: " + res); return res;}); | ||
438 | innerDeferredResult.addCallback(MochiKit.Base.method(this, 'importProcessedValues_core', someRecords)); | ||
439 | //innerDeferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("GenericImportComponent - 3.2: " + res); return res;}); | ||
440 | innerDeferredResult.addErrback(MochiKit.Base.method(this, 'handleProcessError')); | ||
441 | //innerDeferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("GenericImportComponent - 3.3: " + res); return res;}); | ||
442 | innerDeferredResult.callback(someRecords); | ||
443 | //MochiKit.Logging.logDebug("<<< inner deferred"); | ||
444 | |||
445 | return innerDeferredResult; | ||
446 | }, this), selectedRecords); | ||
447 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("GenericImportComponent - 4: " + res); return res;}); | ||
448 | |||
449 | deferredResult.addCallback(MochiKit.Base.method(Clipperz.PM.Components.MessageBox(), 'hide'), 'mainDiv'); | ||
450 | |||
451 | deferredResult.addErrback(MochiKit.Base.bind(function() { | ||
452 | this.nextButton().enable(); | ||
453 | this.setCurrentStep(this.currentStep() -1); | ||
454 | }, this)); | ||
455 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("GenericImportComponent - 5: " + res); return res;}); | ||
456 | |||
457 | deferredResult.callback(selectedRecords); | ||
458 | //MochiKit.Logging.logDebug("<<< GenericImportComponent.importProcessedValues"); | ||
459 | |||
460 | return deferredResult; | ||
461 | }, | ||
462 | |||
463 | //------------------------------------------------------------------------- | ||
464 | |||
465 | 'importProcessedValues_core': function(someRecords) { | ||
466 | var deferredResult; | ||
467 | |||
468 | deferredResult = new MochiKit.Async.Deferred(); | ||
469 | |||
470 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'processingImportData'); | ||
471 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', {steps:(someRecords.length + 6 + 1)}); | ||
472 | deferredResult.addCallback(MochiKit.Async.wait, 0.5); | ||
473 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("importProcessedValues_core - 3: " + res); return res;}); | ||
474 | deferredResult.addCallback(MochiKit.Base.bind(function(someRecords) { | ||
475 | var i,c; | ||
476 | |||
477 | c = someRecords.length; | ||
478 | for (i=0; i<c; i++) { | ||
479 | this.user().addRecord(someRecords[i], true); | ||
480 | } | ||
481 | |||
482 | return someRecords; | ||
483 | }, this)); | ||
484 | deferredResult.addCallback(MochiKit.Async.wait, 0.5); | ||
485 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("importProcessedValues_core - 4: " + res); return res;}); | ||
486 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'recordAdded', null); | ||
487 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("importProcessedValues_core - 5: " + res); return res;}); | ||
488 | deferredResult.addCallback(MochiKit.Base.method(this.user(), 'saveRecords')); | ||
489 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("importProcessedValues_core - 6: " + res); return res;}); | ||
490 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'selectTab', 'mainTabPanel.recordsTab'); | ||
491 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("importProcessedValues_core - 7: " + res); return res;}); | ||
492 | |||
493 | if (this.user().preferences().shouldShowDonationPanel()) { | ||
494 | deferredResult.addCallback(Clipperz.PM.showDonationSplashScreen, this.user(), 'mainDiv'); | ||
495 | } | ||
496 | |||
497 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'importCompleted', null); | ||
498 | |||
499 | deferredResult.callback(someRecords); | ||
500 | |||
501 | return deferredResult; | ||
502 | }, | ||
503 | |||
504 | //------------------------------------------------------------------------- | ||
505 | |||
506 | 'handleParseError': function(res) { | ||
507 | this.processingAborted(); | ||
508 | MochiKit.Logging.logError("An error occurred while parsing the values: " + res); | ||
509 | alert("An error occurred while parsing the values: " + res); | ||
510 | Clipperz.PM.Components.MessageBox().hide(); | ||
511 | }, | ||
512 | |||
513 | 'handleProcessError': function(res) { | ||
514 | this.processingAborted(); | ||
515 | MochiKit.Logging.logError("An error occurred while processing the values: " + res); | ||
516 | alert("An error occurred while processing the values: " + res); | ||
517 | Clipperz.PM.Components.MessageBox().hide(); | ||
518 | }, | ||
519 | |||
520 | //------------------------------------------------------------------------- | ||
521 | __syntaxFix__: "syntax fix" | ||
522 | }); | ||
523 | |||
diff --git a/frontend/beta/js/Clipperz/PM/Components/Import/KeePassImportComponent.js b/frontend/beta/js/Clipperz/PM/Components/Import/KeePassImportComponent.js new file mode 100644 index 0000000..0657520 --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/Import/KeePassImportComponent.js | |||
@@ -0,0 +1,450 @@ | |||
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 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | ||
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | ||
31 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } | ||
32 | if (typeof(Clipperz.PM.Components.Import) == 'undefined') { Clipperz.PM.Components.Import = {}; } | ||
33 | |||
34 | //############################################################################# | ||
35 | |||
36 | Clipperz.PM.Components.Import.KeePassImportComponent = function(anElement, args) { | ||
37 | args = args || {}; | ||
38 | |||
39 | Clipperz.PM.Components.Import.KeePassImportComponent.superclass.constructor.call(this, anElement, args); | ||
40 | |||
41 | this._steps = ['EDIT', 'KEEPASS_SETTINGS', 'PREVIEW', 'IMPORT']; | ||
42 | this._definedFields = ['Group', 'Group Tree', 'UserName', 'URL', 'Password', 'Notes', 'UUID', 'Icon', 'Creation Time', 'Last Access', 'Last Modification', 'Expires', 'Attachment Description', 'Attachment']; | ||
43 | |||
44 | this.render(); | ||
45 | |||
46 | return this; | ||
47 | } | ||
48 | |||
49 | //============================================================================= | ||
50 | |||
51 | YAHOO.extendX(Clipperz.PM.Components.Import.KeePassImportComponent, Clipperz.PM.Components.Import.GenericImportComponent, { | ||
52 | |||
53 | 'toString': function() { | ||
54 | return "Clipperz.PM.Components.Import.KeePassImportComponent component"; | ||
55 | }, | ||
56 | |||
57 | //------------------------------------------------------------------------- | ||
58 | |||
59 | 'render': function() { | ||
60 | //MochiKit.Logging.logDebug(">>> Import.KeePassImportComponent.render"); | ||
61 | this.domHelper().append(this.element(), {tag:'div', cls:'keePassImportWizard', children:[ | ||
62 | {tag:'h3', htmlString:Clipperz.PM.Strings['KeePass_ImportWizard_Title']}, | ||
63 | {tag:'div', cls:'importSteps', id:this.getId('importSteps')}, | ||
64 | {tag:'div', cls:'importStepBlocks', children:[ | ||
65 | {tag:'div', cls:'step_0', id:this.getId('step_0'), children:[ | ||
66 | {tag:'div', children:[ | ||
67 | {tag:'div', cls:'importOptionsDescription', htmlString:Clipperz.PM.Strings['importOptions_keePass_description']}, | ||
68 | {tag:'div', cls:'importOptionsParameters', children:[]}, | ||
69 | this.textAreaConfig() | ||
70 | ]} | ||
71 | ]}, | ||
72 | {tag:'div', cls:'step_1', id:this.getId('step_1'), children:[ | ||
73 | {tag:'div', children:[ | ||
74 | {tag:'div', id:this.getId('settingsDiv'), children:[ | ||
75 | {tag:'table', id:'KeePassSettings', children:[ | ||
76 | {tag:'tbody', children:[ | ||
77 | {tag:'tr', children:[ | ||
78 | {tag:'td', width:'50%', valign:'top', children:[ | ||
79 | {tag:'table', children:[ | ||
80 | {tag:'tbody', children:[ | ||
81 | {tag:'tr', children:[ | ||
82 | {tag:'td', valign:'top', children:[{tag:'input', type:'checkbox', id:this.getId('Group_checkbox'), name:'Group'/*, checked:true*/}]}, | ||
83 | {tag:'td', width:'150', valign:'top', children:[{tag:'span', cls:'keePassFieldLabel', id:this.getId('Group_label'), html:"Group"}]} | ||
84 | ]}, | ||
85 | {tag:'tr', children:[ | ||
86 | {tag:'td', valign:'top', children:[{tag:'input', type:'checkbox', id:this.getId('Group Tree_checkbox'), name:'Group Tree'/*, checked:true*/}]}, | ||
87 | {tag:'td', valign:'top', children:[{tag:'span', cls:'keePassFieldLabel', id:this.getId('Group Tree_label'), html:"Group Tree"}]} | ||
88 | ]}, | ||
89 | {tag:'tr', children:[ | ||
90 | {tag:'td', valign:'top', children:[{tag:'input', type:'checkbox', id:this.getId('UserName_checkbox'), name:'UserName', checked:true}]}, | ||
91 | {tag:'td', valign:'top', children:[{tag:'span', cls:'keePassFieldLabel', id:this.getId('UserName_label'), html:"UserName"}]} | ||
92 | ]}, | ||
93 | {tag:'tr', children:[ | ||
94 | {tag:'td', valign:'top', children:[{tag:'input', type:'checkbox', id:this.getId('URL_checkbox'), name:'URL', checked:true}]}, | ||
95 | {tag:'td', valign:'top', children:[{tag:'span', cls:'keePassFieldLabel', id:this.getId('URL_label'), html:"URL"}]} | ||
96 | ]}, | ||
97 | {tag:'tr', children:[ | ||
98 | {tag:'td', valign:'top', children:[{tag:'input', type:'checkbox', id:this.getId('Password_checkbox'), name:'Password', checked:true}]}, | ||
99 | {tag:'td', valign:'top', children:[{tag:'span', cls:'keePassFieldLabel', id:this.getId('Password_label'), html:"Password"}]} | ||
100 | ]}, | ||
101 | {tag:'tr', children:[ | ||
102 | {tag:'td', valign:'top', children:[{tag:'input', type:'checkbox', id:this.getId('Notes_checkbox'), name:'Notes', checked:true}]}, | ||
103 | {tag:'td', valign:'top', children:[{tag:'span', cls:'keePassFieldLabel', id:this.getId('Notes_label'), html:"Notes"}]} | ||
104 | ]}, | ||
105 | {tag:'tr', children:[ | ||
106 | {tag:'td', valign:'top', children:[{tag:'input', type:'checkbox', id:this.getId('UUID_checkbox'), name:'UUID'/*, checked:true*/}]}, | ||
107 | {tag:'td', valign:'top', children:[{tag:'span', cls:'keePassFieldLabel', id:this.getId('UUID_label'), html:"UUID"}]} | ||
108 | ]} | ||
109 | ]} | ||
110 | ]} | ||
111 | ]}, | ||
112 | {tag:'td', width:'50%', valign:'top', children:[ | ||
113 | {tag:'table', children:[ | ||
114 | {tag:'tbody', children:[ | ||
115 | {tag:'tr', children:[ | ||
116 | {tag:'td', valign:'top', children:[{tag:'input', type:'checkbox', id:this.getId('Icon_checkbox'), name:'Icon'/*, checked:true*/}]}, | ||
117 | {tag:'td', width:'150', valign:'top', children:[{tag:'span', cls:'keePassFieldLabel', id:this.getId('Icon_label'), html:"Icon"}]} | ||
118 | ]}, | ||
119 | {tag:'tr', children:[ | ||
120 | {tag:'td', valign:'top', children:[{tag:'input', type:'checkbox', id:this.getId('Creation Time_checkbox'), name:'Creation Time'/*, checked:true*/}]}, | ||
121 | {tag:'td', valign:'top', children:[{tag:'span', cls:'keePassFieldLabel', id:this.getId('Creation Time_label'), html:"Creation Time"}]} | ||
122 | ]}, | ||
123 | {tag:'tr', children:[ | ||
124 | {tag:'td', valign:'top', children:[{tag:'input', type:'checkbox', id:this.getId('Last Access_checkbox'), name:'Last Access'/*, checked:true*/}]}, | ||
125 | {tag:'td', valign:'top', children:[{tag:'span', cls:'keePassFieldLabel', id:this.getId('Last Access_label'), html:"Last Access"}]} | ||
126 | ]}, | ||
127 | {tag:'tr', children:[ | ||
128 | {tag:'td', valign:'top', children:[{tag:'input', type:'checkbox', id:this.getId('Last Modification_checkbox'), name:'Last Modification'/*, checked:true*/}]}, | ||
129 | {tag:'td', valign:'top', children:[{tag:'span', cls:'keePassFieldLabel', id:this.getId('Last Modification_label'), html:"Last Modification"}]} | ||
130 | ]}, | ||
131 | {tag:'tr', children:[ | ||
132 | {tag:'td', valign:'top', children:[{tag:'input', type:'checkbox', id:this.getId('Expires_checkbox'), name:'Expires'/*, checked:true*/}]}, | ||
133 | {tag:'td', valign:'top', children:[{tag:'span', cls:'keePassFieldLabel', id:this.getId('Expires_label'), html:"Expires"}]} | ||
134 | ]}, | ||
135 | {tag:'tr', children:[ | ||
136 | {tag:'td', valign:'top', children:[{tag:'input', type:'checkbox', id:this.getId('Attachment Description_checkbox'), name:'Attachment Description', checked:true}]}, | ||
137 | {tag:'td', valign:'top', children:[{tag:'span', cls:'keePassFieldLabel', id:this.getId('Attachment Description_label'), html:"Attachment Description"}]} | ||
138 | ]}, | ||
139 | {tag:'tr', children:[ | ||
140 | {tag:'td', valign:'top', children:[{tag:'input', type:'checkbox', id:this.getId('Attachment_checkbox'), name:'Attachment', checked:true}]}, | ||
141 | {tag:'td', valign:'top', children:[{tag:'span', cls:'keePassFieldLabel', id:this.getId('Attachment_label'), html:"Attachment"}]} | ||
142 | ]} | ||
143 | ]} | ||
144 | ]} | ||
145 | ]} | ||
146 | ]} | ||
147 | ]} | ||
148 | ]} | ||
149 | ]} | ||
150 | ]} | ||
151 | ]}, | ||
152 | {tag:'div', cls:'step_2', id:this.getId('step_2'), children:[ | ||
153 | {tag:'div', children:[ | ||
154 | {tag:'div', id:this.getId('previewDiv'), html:"preview"} | ||
155 | ]} | ||
156 | ]}, | ||
157 | {tag:'div', cls:'step_3', id:this.getId('step_3'), children:[ | ||
158 | {tag:'div', children:[ | ||
159 | {tag:'h4', html:"done"} | ||
160 | ]} | ||
161 | ]} | ||
162 | ]}, | ||
163 | {tag:'div', cls:'importOptionsButtons', children:[ | ||
164 | {tag:'table', children:[ | ||
165 | {tag:'tbody', children:[ | ||
166 | {tag:'tr', children:[ | ||
167 | {tag:'td', html:' '}, | ||
168 | {tag:'td', children:[ | ||
169 | {tag:'div', id:this.getId('backActionButton')} | ||
170 | ]}, | ||
171 | {tag:'td', html:' '}, | ||
172 | {tag:'td', children:[ | ||
173 | {tag:'div', id:this.getId('nextActionButton')} | ||
174 | ]}, | ||
175 | {tag:'td', html:' '} | ||
176 | ]} | ||
177 | ]} | ||
178 | ]} | ||
179 | ]} | ||
180 | ]}); | ||
181 | |||
182 | this.updateSteps(); | ||
183 | |||
184 | this.setBackButton(new YAHOO.ext.Button(this.getDom('backActionButton'), {text:"back", handler:this.backAction, scope:this})); | ||
185 | this.setNextButton(new YAHOO.ext.Button(this.getDom('nextActionButton'), {text:"next", handler:this.nextAction, scope:this})); | ||
186 | |||
187 | this.getElement('step_0').setVisibilityMode(YAHOO.ext.Element.DISPLAY).show() | ||
188 | this.getElement('step_1').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); | ||
189 | this.getElement('step_2').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); | ||
190 | this.getElement('step_3').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); | ||
191 | //MochiKit.Logging.logDebug("<<< Import.KeePassImportComponent.render"); | ||
192 | }, | ||
193 | |||
194 | //------------------------------------------------------------------------- | ||
195 | |||
196 | 'nextAction': function() { | ||
197 | switch (this.currentStep()) { | ||
198 | case 0: //-> 1 | ||
199 | Clipperz.PM.Components.MessageBox.showProgressPanel( | ||
200 | MochiKit.Base.method(this, 'deferredParseValues'), | ||
201 | MochiKit.Base.method(this, 'handleParseError'), | ||
202 | this.getDom('nextActionButton') | ||
203 | ); | ||
204 | break; | ||
205 | case 1: //-> 2 | ||
206 | this.previewValues(); | ||
207 | break; | ||
208 | case 2: //-> 3 | ||
209 | this.importValues(); | ||
210 | break; | ||
211 | } | ||
212 | }, | ||
213 | |||
214 | //------------------------------------------------------------------------- | ||
215 | |||
216 | 'deferredParseValues': function() { | ||
217 | var deferredResult; | ||
218 | |||
219 | deferredResult = new MochiKit.Async.Deferred(); | ||
220 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassImportComponent.deferredParseValues - 1 " + res.substring(0,50)); return res;}); | ||
221 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'parseImportData'); | ||
222 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassImportComponent.deferredParseValues - 2 " + res.substring(0,50)); return res;}); | ||
223 | deferredResult.addCallback(MochiKit.Base.bind(function(res) { | ||
224 | this.startProcessing(); | ||
225 | |||
226 | return res; | ||
227 | }, this)); | ||
228 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassImportComponent.deferredParseValues - 3 " + res.substring(0,50)); return res;}); | ||
229 | deferredResult.addCallback(MochiKit.Base.method(this, 'parseKeePassValues')); //processPasswordPlusValues | ||
230 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassImportComponent.deferredParseValues - 4 " + res); return res;}); | ||
231 | deferredResult.addCallback(MochiKit.Base.method(this, 'setParsedValues')); //setProcessedValues | ||
232 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassImportComponent.deferredParseValues - 5 " + res); return res;}); | ||
233 | deferredResult.addCallback(MochiKit.Base.method(this, 'showSettings')); //previewRecordValues | ||
234 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassImportComponent.deferredParseValues - 6 " + res); return res;}); | ||
235 | deferredResult.addCallback(MochiKit.Base.bind(function(res) { | ||
236 | this.processingDone(); | ||
237 | this.getElement('step_0').hide(); | ||
238 | this.getElement('step_1').show(); | ||
239 | this.backButton().enable(); | ||
240 | |||
241 | return res; | ||
242 | }, this)); | ||
243 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassImportComponent.deferredParseValues - 7 " + res); return res;}); | ||
244 | deferredResult.callback(this.textAreaContent()); | ||
245 | |||
246 | return deferredResult; | ||
247 | }, | ||
248 | |||
249 | //------------------------------------------------------------------------- | ||
250 | |||
251 | 'deferredPreviewValues': function() { | ||
252 | var deferredResult; | ||
253 | |||
254 | //MochiKit.Logging.logDebug(">>> KeePassImportComonent.deferredPreviewValues"); | ||
255 | deferredResult = new MochiKit.Async.Deferred(); | ||
256 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassImportComponent.deferredPreviewValues - 1 " + res); return res;}); | ||
257 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'previewImportData'); | ||
258 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassImportComponent.deferredPreviewValues - 2 " + res); return res;}); | ||
259 | deferredResult.addCallback(MochiKit.Base.bind(function(res) { | ||
260 | this.startProcessing(); | ||
261 | |||
262 | return res; | ||
263 | }, this)); | ||
264 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassImportComponent.deferredPreviewValues - 3 " + res); return res;}); | ||
265 | deferredResult.addCallback(MochiKit.Base.method(this, 'processKeePassParsedValues')); | ||
266 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassImportComponent.deferredPreviewValues - 4 " + res); return res;}); | ||
267 | deferredResult.addCallback(MochiKit.Base.method(this, 'setProcessedValues')); | ||
268 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassImportComponent.deferredPreviewValues - 5 " + res); return res;}); | ||
269 | deferredResult.addCallback(MochiKit.Base.method(this, 'previewRecordValues')); | ||
270 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassImportComponent.deferredPreviewValues - 6 " + res); return res;}); | ||
271 | deferredResult.addCallback(MochiKit.Base.bind(function(res) { | ||
272 | this.processingDone(); | ||
273 | this.getElement('step_1').hide(); | ||
274 | this.getElement('step_2').show(); | ||
275 | this.backButton().enable(); | ||
276 | |||
277 | return res; | ||
278 | }, this)); | ||
279 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassImportComponent.deferredPreviewValues - 7 " + res); return res;}); | ||
280 | // deferredResult.addErrback(MochiKit.Base.bind(function() { | ||
281 | // this.processingAborted(); | ||
282 | // }, this)) | ||
283 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassImportComponent.deferredPreviewValues - 8 " + res); return res;}); | ||
284 | deferredResult.callback(this.parsedValues()); | ||
285 | //MochiKit.Logging.logDebug("<<< KeePassImportComonent.deferredPreviewValues"); | ||
286 | |||
287 | return deferredResult; | ||
288 | }, | ||
289 | |||
290 | //------------------------------------------------------------------------- | ||
291 | |||
292 | 'definedFields': function() { | ||
293 | return this._definedFields; | ||
294 | }, | ||
295 | |||
296 | //------------------------------------------------------------------------- | ||
297 | |||
298 | 'parseKeePassValues': function(someData) { | ||
299 | var deferredResult; | ||
300 | var keePassProcessor; | ||
301 | |||
302 | keePassProcessor = new Clipperz.KeePassExportProcessor(); | ||
303 | |||
304 | deferredResult = new MochiKit.Async.Deferred(); | ||
305 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassImportComponent.parseKeePassValues - 1 " + res.substring(0,50)); return res;}); | ||
306 | deferredResult.addCallback(function(res) { | ||
307 | return Clipperz.NotificationCenter.deferredNotification(this, 'updatedProgressState', {steps:(res.length)}, res); | ||
308 | }) | ||
309 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassImportComponent.parseKeePassValues - 2 " + res.substring(0,50)); return res;}); | ||
310 | deferredResult.addCallback(MochiKit.Base.method(keePassProcessor, 'deferredParse')); | ||
311 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassImportComponent.parseKeePassValues - 3 " + res); return res;}); | ||
312 | deferredResult.callback(someData); | ||
313 | |||
314 | return deferredResult; | ||
315 | }, | ||
316 | |||
317 | //------------------------------------------------------------------------- | ||
318 | |||
319 | 'showSettings': function(someValues) { | ||
320 | var availableFields; | ||
321 | var i,c; | ||
322 | |||
323 | //MochiKit.Logging.logDebug(">>> KeePassImportCOmponent.showSettings"); | ||
324 | availableFields = new Clipperz.Set(); | ||
325 | c = this.parsedValues().length; | ||
326 | for (i=0; i<c; i++) { | ||
327 | var fieldLabel; | ||
328 | |||
329 | for (fieldLabel in this.parsedValues()[i]) { | ||
330 | availableFields.add(fieldLabel); | ||
331 | } | ||
332 | } | ||
333 | |||
334 | c = this.definedFields().length; | ||
335 | for (i=0; i<c; i++) { | ||
336 | var definedField; | ||
337 | |||
338 | definedField = this.definedFields()[i]; | ||
339 | if (availableFields.contains(definedField)) { | ||
340 | //MochiKit.Logging.logDebug("enabling field " + definedField); | ||
341 | this.getDom(definedField + '_checkbox').disabled = false; | ||
342 | this.getElement(definedField + '_label').removeClass('disabled'); | ||
343 | } else { | ||
344 | //MochiKit.Logging.logDebug("disabling field " + definedField); | ||
345 | this.getDom(definedField + '_checkbox').disabled = true; | ||
346 | this.getDom(definedField + '_checkbox').checked = false; //???? | ||
347 | this.getElement(definedField + '_label').addClass('disabled'); | ||
348 | } | ||
349 | } | ||
350 | //MochiKit.Logging.logDebug("<<< KeePassImportCOmponent.showSettings"); | ||
351 | |||
352 | return MochiKit.Async.succeed(someValues); | ||
353 | }, | ||
354 | |||
355 | //------------------------------------------------------------------------- | ||
356 | |||
357 | 'shouldImportField': function(aFieldName) { | ||
358 | var fieldCheckbox; | ||
359 | var result; | ||
360 | |||
361 | //MochiKit.Logging.logDebug(">>> shouldImportField: " + aFieldName); | ||
362 | // fieldCheckbox = this.getDom(aFieldName + '_checkbox'); | ||
363 | fieldCheckbox = MochiKit.DOM.getElement(this.getId(aFieldName + '_checkbox')); | ||
364 | if (fieldCheckbox != null) { | ||
365 | result = fieldCheckbox.checked; | ||
366 | } else { | ||
367 | result = false; | ||
368 | } | ||
369 | //MochiKit.Logging.logDebug("<<< shouldImportField: " + result); | ||
370 | |||
371 | return result; | ||
372 | }, | ||
373 | |||
374 | //------------------------------------------------------------------------- | ||
375 | |||
376 | 'processKeePassParsedValues': function(someValues) { | ||
377 | var deferredResult; | ||
378 | var records; | ||
379 | var i,c; | ||
380 | |||
381 | //MochiKit.Logging.logDebug(">>> processKeePassParsedValues"); | ||
382 | deferredResult = new MochiKit.Async.Deferred(); | ||
383 | records = []; | ||
384 | |||
385 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("processKeePassParsedValues - 1: " + res); return res;}); | ||
386 | c = someValues.length; | ||
387 | deferredResult.addCallback(function(res) { | ||
388 | return Clipperz.NotificationCenter.deferredNotification(this, 'updatedProgressState', {steps:c}, res); | ||
389 | }) | ||
390 | for(i=0; i<c; i++) { | ||
391 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("[" + i + "] processKeePassParsedValues - 1.1: " + res); return res;}); | ||
392 | deferredResult.addCallback(MochiKit.Async.wait, 0.2); | ||
393 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("[" + i + "] processKeePassParsedValues - 1.2: " + res); return res;}); | ||
394 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', {}); | ||
395 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("[" + i + "] processKeePassParsedValues - 1.3: " + res); return res;}); | ||
396 | deferredResult.addCallback(MochiKit.Base.bind(function(someRecords, someData) { | ||
397 | var record; | ||
398 | var recordVersion; | ||
399 | var ii; | ||
400 | |||
401 | record = new Clipperz.PM.DataModel.Record({user:this.user()}); | ||
402 | record.setLabel(someData['Title']); | ||
403 | if (this.shouldImportField('Notes')) { | ||
404 | record.setNotes(someData['Notes']); | ||
405 | } | ||
406 | recordVersion = record.currentVersion() | ||
407 | |||
408 | for (ii in someData) { | ||
409 | if ((ii != 'Title') && (ii != 'Notes') && (typeof(someData[ii]) != "undefined") && (this.shouldImportField(ii))) { | ||
410 | var recordField; | ||
411 | var recordFieldType; | ||
412 | |||
413 | recordFieldType = 'TXT'; | ||
414 | if (ii == 'Password') { | ||
415 | recordFieldType = 'PWD'; | ||
416 | } else if (ii == 'URL') { | ||
417 | recordFieldType = 'URL'; | ||
418 | } else if ((ii == 'Creation Time') || (ii == 'Last Access') || (ii == 'Last Modification') || (ii == 'Expires')) { | ||
419 | recordFieldType = 'Date'; | ||
420 | } | ||
421 | |||
422 | recordField = new Clipperz.PM.DataModel.RecordField({ | ||
423 | recordVersion:recordVersion, | ||
424 | label: ii, | ||
425 | value: someData[ii], | ||
426 | type: recordFieldType | ||
427 | }); | ||
428 | recordVersion.addField(recordField); | ||
429 | } | ||
430 | } | ||
431 | |||
432 | someRecords.push(record); | ||
433 | |||
434 | return someRecords; | ||
435 | }, this), records, someValues[i]); | ||
436 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("[" + i + "] processKeePassParsedValues - 1.4: " + res); return res;}); | ||
437 | } | ||
438 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("processKeePassParsedValues - 2: " + res); return res;}); | ||
439 | deferredResult.addCallback(MochiKit.Async.succeed, records); | ||
440 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("processKeePassParsedValues - 3: " + res); return res;}); | ||
441 | deferredResult.callback(); | ||
442 | //MochiKit.Logging.logDebug("<<< processKeePassParsedValues"); | ||
443 | |||
444 | return deferredResult; | ||
445 | }, | ||
446 | |||
447 | //------------------------------------------------------------------------- | ||
448 | __syntaxFix__: "syntax fix" | ||
449 | }); | ||
450 | |||
diff --git a/frontend/beta/js/Clipperz/PM/Components/Import/MainComponent.js b/frontend/beta/js/Clipperz/PM/Components/Import/MainComponent.js new file mode 100644 index 0000000..54813bc --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/Import/MainComponent.js | |||
@@ -0,0 +1,332 @@ | |||
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 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | ||
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | ||
31 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } | ||
32 | if (typeof(Clipperz.PM.Components.Import) == 'undefined') { Clipperz.PM.Components.Import = {}; } | ||
33 | |||
34 | //############################################################################# | ||
35 | |||
36 | Clipperz.PM.Components.Import.MainComponent = function(anElement, args) { | ||
37 | args = args || {}; | ||
38 | |||
39 | Clipperz.PM.Components.Import.MainComponent.superclass.constructor.call(this, anElement, args); | ||
40 | |||
41 | this._user = args.user; | ||
42 | this._wizardComponent = null; | ||
43 | |||
44 | this._backButton = null; | ||
45 | this._nextButton = null; | ||
46 | |||
47 | this._selectedComponent = null; | ||
48 | |||
49 | this.render(); | ||
50 | |||
51 | return this; | ||
52 | } | ||
53 | |||
54 | //============================================================================= | ||
55 | |||
56 | YAHOO.extendX(Clipperz.PM.Components.Import.MainComponent, Clipperz.PM.Components.BaseComponent, { | ||
57 | |||
58 | 'toString': function() { | ||
59 | return "Clipperz.PM.Components.Import.MainComponent component"; | ||
60 | }, | ||
61 | |||
62 | //------------------------------------------------------------------------- | ||
63 | |||
64 | 'user': function() { | ||
65 | return this._user; | ||
66 | }, | ||
67 | |||
68 | //------------------------------------------------------------------------- | ||
69 | |||
70 | 'wizardComponent': function() { | ||
71 | return this._wizardComponent; | ||
72 | }, | ||
73 | |||
74 | 'setWizardComponent': function(aValue) { | ||
75 | if (this._wizardComponent != null) { | ||
76 | this._wizardComponent.remove(); | ||
77 | } | ||
78 | |||
79 | if (aValue != null) { | ||
80 | this.getElement('importCover').hide(); | ||
81 | this.getElement('importWizard').show(); | ||
82 | } | ||
83 | this._wizardComponent = aValue; | ||
84 | }, | ||
85 | |||
86 | 'resetImportComponent': function() { | ||
87 | //MochiKit.Logging.logDebug(">>> resetImportComponent"); | ||
88 | this.setWizardComponent(null); | ||
89 | this.getElement('wizardComponent').update(""); | ||
90 | |||
91 | this.getElement('importCover').show(); | ||
92 | this.getElement('importWizard').hide(); | ||
93 | //MochiKit.Logging.logDebug("<<< resetImportComponent"); | ||
94 | }, | ||
95 | |||
96 | //------------------------------------------------------------------------- | ||
97 | |||
98 | 'backButton': function() { | ||
99 | return this._backButton; | ||
100 | }, | ||
101 | |||
102 | 'setBackButton': function(aValue) { | ||
103 | this._backButton = aValue; | ||
104 | }, | ||
105 | |||
106 | 'nextButton': function() { | ||
107 | return this._nextButton; | ||
108 | }, | ||
109 | |||
110 | 'setNextButton': function(aValue) { | ||
111 | this._nextButton = aValue; | ||
112 | }, | ||
113 | |||
114 | //------------------------------------------------------------------------- | ||
115 | |||
116 | 'render': function() { | ||
117 | //MochiKit.Logging.logDebug(">>> Import.MainComponent.render"); | ||
118 | Clipperz.NotificationCenter.unregister(this); | ||
119 | MochiKit.Signal.disconnectAllTo(this); | ||
120 | |||
121 | this.element().update(""); | ||
122 | this.domHelper().append(this.element(), {tag:'div', id:this.getId('mainDiv'), children:[ | ||
123 | {tag:'div', id:this.getId('importCover'), children:[ | ||
124 | {tag:'h5', htmlString:Clipperz.PM.Strings['importTabTitle']}, | ||
125 | {tag:'div', cls:'panelDescription', htmlString:Clipperz.PM.Strings['importTabDescription']}, | ||
126 | {tag:'div', cls:'importFormats', children:[ | ||
127 | {tag:'ul', cls:'radioList', children:[ | ||
128 | {tag:'li', children:[ | ||
129 | {tag:'table', children:[{tag:'tbody', children:[{tag:'tr', children:[ | ||
130 | {tag:'td', valign:'top', children:[ | ||
131 | {tag:'input', id:this.getId('CSV_radio'), type:'radio', name:'importFormat', value:'CSV'} | ||
132 | ]}, | ||
133 | {tag:'td', valign:'top', children:[ | ||
134 | {tag:'h4', id:this.getId('CSV_title'), htmlString:Clipperz.PM.Strings['importFormats']['CSV']['label']}, | ||
135 | {tag:'div', cls:'templateDescription', htmlString:Clipperz.PM.Strings['importFormats']['CSV']['description']} | ||
136 | ]} | ||
137 | ]}]}]} | ||
138 | ]}, | ||
139 | {tag:'li', children:[ | ||
140 | {tag:'table', children:[{tag:'tbody', children:[{tag:'tr', children:[ | ||
141 | {tag:'td', valign:'top', children:[ | ||
142 | {tag:'input', id:this.getId('Excel_radio'), type:'radio', name:'importFormat', value:'EXCEL'} | ||
143 | ]}, | ||
144 | {tag:'td', valign:'top', children:[ | ||
145 | {tag:'h4', id:this.getId('Excel_title'), htmlString:Clipperz.PM.Strings['importFormats']['Excel']['label']}, | ||
146 | {tag:'div', cls:'templateDescription', htmlString:Clipperz.PM.Strings['importFormats']['Excel']['description']} | ||
147 | ]} | ||
148 | ]}]}]} | ||
149 | ]}, | ||
150 | {tag:'li', children:[ | ||
151 | {tag:'table', children:[{tag:'tbody', children:[{tag:'tr', children:[ | ||
152 | {tag:'td', valign:'top', children:[ | ||
153 | {tag:'input', id:this.getId('KeePass_radio'), type:'radio', name:'importFormat', value:'KEEPASS'} | ||
154 | ]}, | ||
155 | {tag:'td', valign:'top', children:[ | ||
156 | {tag:'h4', id:this.getId('KeePass_title'), htmlString:Clipperz.PM.Strings['importFormats']['KeePass']['label']}, | ||
157 | {tag:'div', cls:'templateDescription', htmlString:Clipperz.PM.Strings['importFormats']['KeePass']['description']} | ||
158 | ]} | ||
159 | ]}]}]} | ||
160 | ]}, | ||
161 | {tag:'li', children:[ | ||
162 | {tag:'table', children:[{tag:'tbody', children:[{tag:'tr', children:[ | ||
163 | {tag:'td', valign:'top', children:[ | ||
164 | {tag:'input', id:this.getId('Roboform_radio'), type:'radio', name:'importFormat', value:'ROBOFORM'} | ||
165 | ]}, | ||
166 | {tag:'td', valign:'top', children:[ | ||
167 | {tag:'h4', id:this.getId('Roboform_title'), htmlString:Clipperz.PM.Strings['importFormats']['Roboform']['label']}, | ||
168 | {tag:'div', cls:'templateDescription', htmlString:Clipperz.PM.Strings['importFormats']['Roboform']['description']} | ||
169 | ]} | ||
170 | ]}]}]} | ||
171 | ]}, | ||
172 | {tag:'li', children:[ | ||
173 | {tag:'table', children:[{tag:'tbody', children:[{tag:'tr', children:[ | ||
174 | {tag:'td', valign:'top', children:[ | ||
175 | {tag:'input', id:this.getId('PasswordPlus_radio'), type:'radio', name:'importFormat', value:'PASSWORD_PLUS'} | ||
176 | ]}, | ||
177 | {tag:'td', valign:'top', children:[ | ||
178 | {tag:'h4', id:this.getId('PasswordPlus_title'), htmlString:Clipperz.PM.Strings['importFormats']['PasswordPlus']['label']}, | ||
179 | {tag:'div', cls:'templateDescription', htmlString:Clipperz.PM.Strings['importFormats']['PasswordPlus']['description']} | ||
180 | ]} | ||
181 | ]}]}]} | ||
182 | ]}, | ||
183 | {tag:'li', children:[ | ||
184 | {tag:'table', children:[{tag:'tbody', children:[{tag:'tr', children:[ | ||
185 | {tag:'td', valign:'top', children:[ | ||
186 | {tag:'input', id:this.getId('ClipperzExport_radio'), type:'radio', name:'importFormat', value:'CLIPPERZ_EXPORT'} | ||
187 | ]}, | ||
188 | {tag:'td', valign:'top', children:[ | ||
189 | {tag:'h4', id:this.getId('ClipperzExport_title'), htmlString:Clipperz.PM.Strings['importFormats']['ClipperzExport']['label']}, | ||
190 | {tag:'div', cls:'templateDescription', htmlString:Clipperz.PM.Strings['importFormats']['ClipperzExport']['description']} | ||
191 | ]} | ||
192 | ]}]}]} | ||
193 | ]} | ||
194 | ]}, | ||
195 | |||
196 | {tag:'div', cls:'importOptionsButtons', children:[ | ||
197 | {tag:'table', children:[ | ||
198 | {tag:'tbody', children:[ | ||
199 | {tag:'tr', children:[ | ||
200 | {tag:'td', html:' '}, | ||
201 | {tag:'td', children:[ | ||
202 | {tag:'div', id:this.getId('backActionButton')} | ||
203 | ]}, | ||
204 | {tag:'td', html:' '}, | ||
205 | {tag:'td', children:[ | ||
206 | {tag:'div', id:this.getId('nextActionButton')} | ||
207 | ]}, | ||
208 | {tag:'td', html:' '} | ||
209 | ]} | ||
210 | ]} | ||
211 | ]} | ||
212 | ]} | ||
213 | ]} | ||
214 | ]}, | ||
215 | {tag:'div', id:this.getId('importWizard'), children:[ | ||
216 | {tag:'form', id:this.getId('importWizardForm'), children:[ | ||
217 | {tag:'div', cls:'wizardComponent', id:this.getId('wizardComponent'), children:[]} | ||
218 | ]} | ||
219 | ]} | ||
220 | ]}); | ||
221 | |||
222 | this.setBackButton(new YAHOO.ext.Button(this.getDom('backActionButton'), {text:"back", handler:this.backAction, scope:this})); | ||
223 | this.setNextButton(new YAHOO.ext.Button(this.getDom('nextActionButton'), {text:"next", handler:this.nextAction, scope:this})); | ||
224 | |||
225 | this.backButton().disable(); | ||
226 | this.nextButton().disable(); | ||
227 | |||
228 | this.getElement('importCover').setVisibilityMode(YAHOO.ext.Element.DISPLAY).show(); | ||
229 | this.getElement('importWizard').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); | ||
230 | |||
231 | if (Clipperz.PM.Proxy.defaultProxy.isReadOnly()) { | ||
232 | this.getElement('mainDiv').addClass('read-only'); | ||
233 | |||
234 | this.getDom('ClipperzExport_radio').disabled = true; | ||
235 | this.getDom('CSV_radio').disabled = true; | ||
236 | this.getDom('Excel_radio').disabled = true; | ||
237 | this.getDom('PasswordPlus_radio').disabled = true; | ||
238 | this.getDom('Roboform_radio').disabled = true; | ||
239 | this.getDom('KeePass_radio').disabled = true; | ||
240 | } else { | ||
241 | MochiKit.Signal.connect(this.getId('ClipperzExport_radio'), 'onclick', MochiKit.Base.method(this, 'selectComponent')); | ||
242 | MochiKit.Signal.connect(this.getId('CSV_radio'), 'onclick', MochiKit.Base.method(this, 'selectComponent')); | ||
243 | MochiKit.Signal.connect(this.getId('Excel_radio'), 'onclick', MochiKit.Base.method(this, 'selectComponent')); | ||
244 | MochiKit.Signal.connect(this.getId('PasswordPlus_radio'), 'onclick', MochiKit.Base.method(this, 'selectComponent')); | ||
245 | MochiKit.Signal.connect(this.getId('Roboform_radio'), 'onclick', MochiKit.Base.method(this, 'selectComponent')); | ||
246 | MochiKit.Signal.connect(this.getId('KeePass_radio'), 'onclick', MochiKit.Base.method(this, 'selectComponent')); | ||
247 | |||
248 | if (Clipperz_IEisBroken != true) { | ||
249 | MochiKit.Signal.connect(this.getId('ClipperzExport_title'), 'onclick', this.getDom('ClipperzExport_radio'), 'click'); | ||
250 | MochiKit.Signal.connect(this.getId('CSV_title'), 'onclick', this.getDom('CSV_radio'), 'click'); | ||
251 | MochiKit.Signal.connect(this.getId('Excel_title'), 'onclick', this.getDom('Excel_radio'), 'click'); | ||
252 | MochiKit.Signal.connect(this.getId('PasswordPlus_title'), 'onclick', this.getDom('PasswordPlus_radio'), 'click'); | ||
253 | MochiKit.Signal.connect(this.getId('Roboform_title'), 'onclick', this.getDom('Roboform_radio'), 'click'); | ||
254 | MochiKit.Signal.connect(this.getId('KeePass_title'), 'onclick', this.getDom('KeePass_radio'), 'click'); | ||
255 | } | ||
256 | |||
257 | Clipperz.NotificationCenter.register(null, 'importCompleted', this, 'resetImportComponent'); | ||
258 | Clipperz.NotificationCenter.register(null, 'importCancelled', this, 'resetImportComponent'); | ||
259 | } | ||
260 | |||
261 | //MochiKit.Logging.logDebug("<<< Import.MainComponent.render"); | ||
262 | }, | ||
263 | |||
264 | //------------------------------------------------------------------------- | ||
265 | /* | ||
266 | 'selectedFormat': function() { | ||
267 | return this.getDom('importSelectionOptions').value; | ||
268 | }, | ||
269 | */ | ||
270 | //------------------------------------------------------------------------- | ||
271 | |||
272 | 'updateSelectedImportWizardComponent': function(aComponent) { | ||
273 | var newWizardComponent; | ||
274 | |||
275 | //MochiKit.Logging.logDebug(">>> Import.MainComponent.updateSelectedImportWizardComponent"); | ||
276 | this.getElement('wizardComponent').update(""); | ||
277 | |||
278 | switch(aComponent) { | ||
279 | case 'CLIPPERZ_EXPORT': | ||
280 | newWizardComponent = new Clipperz.PM.Components.Import.ClipperzImportComponent(this.getElement('wizardComponent'), {user:this.user()}); | ||
281 | break; | ||
282 | case 'CSV': | ||
283 | newWizardComponent = new Clipperz.PM.Components.Import.CSVImportComponent(this.getElement('wizardComponent'), {user:this.user()}); | ||
284 | break; | ||
285 | case 'EXCEL': | ||
286 | newWizardComponent = new Clipperz.PM.Components.Import.ExcelImportComponent(this.getElement('wizardComponent'), {user:this.user()}); | ||
287 | break; | ||
288 | case 'PASSWORD_PLUS': | ||
289 | newWizardComponent = new Clipperz.PM.Components.Import.PasswordPlusImportComponent(this.getElement('wizardComponent'), {user:this.user()}); | ||
290 | break; | ||
291 | case 'ROBOFORM': | ||
292 | newWizardComponent = new Clipperz.PM.Components.Import.RoboFormImportComponent(this.getElement('wizardComponent'), {user:this.user()});; | ||
293 | break; | ||
294 | case 'KEEPASS': | ||
295 | newWizardComponent = new Clipperz.PM.Components.Import.KeePassImportComponent(this.getElement('wizardComponent'), {user:this.user()}); | ||
296 | break; | ||
297 | } | ||
298 | |||
299 | this.setWizardComponent(newWizardComponent); | ||
300 | //MochiKit.Logging.logDebug("<<< Import.MainComponent.updateSelectedWizardComponent"); | ||
301 | }, | ||
302 | |||
303 | //------------------------------------------------------------------------- | ||
304 | |||
305 | 'selectComponent': function(anEvent) { | ||
306 | this.setSelectedComponent(anEvent.src().value); | ||
307 | this.nextButton().enable(); | ||
308 | }, | ||
309 | |||
310 | 'selectedComponent': function() { | ||
311 | return this._selectedComponent; | ||
312 | }, | ||
313 | |||
314 | 'setSelectedComponent': function(aValue) { | ||
315 | this._selectedComponent = aValue; | ||
316 | }, | ||
317 | |||
318 | //------------------------------------------------------------------------- | ||
319 | |||
320 | 'backAction': function() { | ||
321 | }, | ||
322 | |||
323 | //------------------------------------------------------------------------- | ||
324 | |||
325 | 'nextAction': function() { | ||
326 | this.updateSelectedImportWizardComponent(this.selectedComponent()); | ||
327 | }, | ||
328 | |||
329 | //------------------------------------------------------------------------- | ||
330 | __syntaxFix__: "syntax fix" | ||
331 | }); | ||
332 | |||
diff --git a/frontend/beta/js/Clipperz/PM/Components/Import/PasswordPlusImportComponent.js b/frontend/beta/js/Clipperz/PM/Components/Import/PasswordPlusImportComponent.js new file mode 100644 index 0000000..f476ac2 --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/Import/PasswordPlusImportComponent.js | |||
@@ -0,0 +1,315 @@ | |||
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 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | ||
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | ||
31 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } | ||
32 | if (typeof(Clipperz.PM.Components.Import) == 'undefined') { Clipperz.PM.Components.Import = {}; } | ||
33 | |||
34 | //############################################################################# | ||
35 | |||
36 | Clipperz.PM.Components.Import.PasswordPlusImportComponent = function(anElement, args) { | ||
37 | args = args || {}; | ||
38 | |||
39 | Clipperz.PM.Components.Import.PasswordPlusImportComponent.superclass.constructor.call(this, anElement, args); | ||
40 | |||
41 | this.render(); | ||
42 | |||
43 | return this; | ||
44 | } | ||
45 | |||
46 | //============================================================================= | ||
47 | |||
48 | YAHOO.extendX(Clipperz.PM.Components.Import.PasswordPlusImportComponent, Clipperz.PM.Components.Import.GenericImportComponent, { | ||
49 | |||
50 | 'toString': function() { | ||
51 | return "Clipperz.PM.Components.Import.PasswordPlusImportComponent component"; | ||
52 | }, | ||
53 | |||
54 | //------------------------------------------------------------------------- | ||
55 | |||
56 | 'render': function() { | ||
57 | //MochiKit.Logging.logDebug(">>> Import.PasswordPlusImportComponent.render"); | ||
58 | this.domHelper().append(this.element(), {tag:'div', cls:'passwordPlusImportWizard', children:[ | ||
59 | {tag:'h3', htmlString:Clipperz.PM.Strings['PasswordPlus_ImportWizard_Title']}, | ||
60 | {tag:'div', cls:'importSteps', id:this.getId('importSteps')}, | ||
61 | {tag:'div', cls:'importStepBlocks', children:[ | ||
62 | {tag:'div', cls:'step_0', id:this.getId('step_0'), children:[ | ||
63 | {tag:'div', children:[ | ||
64 | {tag:'div', cls:'importOptionsDescription', htmlString:Clipperz.PM.Strings['importOptions_passwordPlus_description']}, | ||
65 | {tag:'div', cls:'importOptionsParameters', children:[]}, | ||
66 | this.textAreaConfig() | ||
67 | ]} | ||
68 | ]}, | ||
69 | {tag:'div', cls:'step_1', id:this.getId('step_1'), children:[ | ||
70 | {tag:'div', children:[ | ||
71 | {tag:'div', id:this.getId('previewDiv'), html:"preview"} | ||
72 | ]} | ||
73 | ]}, | ||
74 | {tag:'div', cls:'step_2', id:this.getId('step_2'), children:[ | ||
75 | {tag:'div', children:[ | ||
76 | {tag:'h4', html:"done"} | ||
77 | ]} | ||
78 | ]} | ||
79 | ]}, | ||
80 | {tag:'div', cls:'importOptionsButtons', children:[ | ||
81 | {tag:'table', children:[ | ||
82 | {tag:'tbody', children:[ | ||
83 | {tag:'tr', children:[ | ||
84 | {tag:'td', html:' '}, | ||
85 | {tag:'td', children:[ | ||
86 | {tag:'div', id:this.getId('backActionButton')} | ||
87 | ]}, | ||
88 | {tag:'td', html:' '}, | ||
89 | {tag:'td', children:[ | ||
90 | {tag:'div', id:this.getId('nextActionButton')} | ||
91 | ]}, | ||
92 | {tag:'td', html:' '} | ||
93 | ]} | ||
94 | ]} | ||
95 | ]} | ||
96 | ]} | ||
97 | ]}); | ||
98 | |||
99 | this.updateSteps(); | ||
100 | |||
101 | this.setBackButton(new YAHOO.ext.Button(this.getDom('backActionButton'), {text:"back", handler:this.backAction, scope:this})); | ||
102 | this.setNextButton(new YAHOO.ext.Button(this.getDom('nextActionButton'), {text:"next", handler:this.nextAction, scope:this})); | ||
103 | |||
104 | this.getElement('step_0').setVisibilityMode(YAHOO.ext.Element.DISPLAY).show() | ||
105 | this.getElement('step_1').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); | ||
106 | this.getElement('step_2').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); | ||
107 | //MochiKit.Logging.logDebug("<<< Import.PasswordPlusImportComponent.render"); | ||
108 | }, | ||
109 | |||
110 | //------------------------------------------------------------------------- | ||
111 | /* | ||
112 | 'backAction': function() { | ||
113 | switch (this.currentStep()) { | ||
114 | case 1: //-> 0 | ||
115 | this.backButton().disable(); | ||
116 | this.getElement('step_1').hide(); | ||
117 | this.setCurrentStep(0); | ||
118 | this.getElement('step_0').show(); | ||
119 | break; | ||
120 | } | ||
121 | }, | ||
122 | */ | ||
123 | //------------------------------------------------------------------------- | ||
124 | |||
125 | 'nextAction': function() { | ||
126 | switch (this.currentStep()) { | ||
127 | case 0: //-> 1 | ||
128 | this.previewValues(); | ||
129 | break; | ||
130 | case 1: //-> 2 | ||
131 | this.importValues(); | ||
132 | break; | ||
133 | } | ||
134 | }, | ||
135 | |||
136 | //------------------------------------------------------------------------- | ||
137 | |||
138 | 'deferredPreviewValues': function() { | ||
139 | var deferredResult; | ||
140 | |||
141 | // this.setFormValues(MochiKit.DOM.formContents(this.getDom('dataForm'))); | ||
142 | |||
143 | deferredResult = new MochiKit.Async.Deferred(); | ||
144 | deferredResult.addCallback(MochiKit.Base.bind(function(res) { | ||
145 | this.startProcessing(); | ||
146 | |||
147 | return res; | ||
148 | }, this)); | ||
149 | deferredResult.addCallback(MochiKit.Base.method(this, 'processPasswordPlusValues')); | ||
150 | deferredResult.addCallback(MochiKit.Base.method(this, 'setProcessedValues')); | ||
151 | deferredResult.addCallback(MochiKit.Base.method(this, 'previewRecordValues')); | ||
152 | deferredResult.addCallback(MochiKit.Base.bind(function(res) { | ||
153 | this.processingDone(); | ||
154 | this.getElement('step_0').hide(); | ||
155 | this.getElement('step_1').show(); | ||
156 | this.backButton().enable(); | ||
157 | |||
158 | return res; | ||
159 | }, this)); | ||
160 | // deferredResult.addErrback(MochiKit.Base.bind(function() { | ||
161 | // this.processingAborted(); | ||
162 | // }, this)) | ||
163 | deferredResult.callback(this.textAreaContent()); | ||
164 | |||
165 | return deferredResult; | ||
166 | }, | ||
167 | |||
168 | //------------------------------------------------------------------------- | ||
169 | |||
170 | 'processPasswordPlusValues': function(someData) { | ||
171 | var deferredResult; | ||
172 | var csvProcessor; | ||
173 | |||
174 | csvProcessor = new Clipperz.CSVProcessor({binary:true}); | ||
175 | |||
176 | deferredResult = new MochiKit.Async.Deferred(); | ||
177 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'parseImportData'); | ||
178 | deferredResult.addCallback(function(res) { | ||
179 | return Clipperz.NotificationCenter.deferredNotification(this, 'updatedProgressState', {steps:(res.length * 2)}, res); | ||
180 | }) | ||
181 | deferredResult.addCallback(MochiKit.Base.method(csvProcessor, 'deferredParse')); | ||
182 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'previewImportData'); | ||
183 | deferredResult.addCallback(function(res) { | ||
184 | return Clipperz.NotificationCenter.deferredNotification(this, 'updatedProgressState', {steps:(res.length * 2), step:res.length}, res); | ||
185 | }) | ||
186 | deferredResult.addCallback(MochiKit.Base.bind(function(someCSVValues) { | ||
187 | var innerDeferredResult; | ||
188 | var records; | ||
189 | var i,c; | ||
190 | |||
191 | innerDeferredResult = new MochiKit.Async.Deferred(); | ||
192 | records = []; | ||
193 | |||
194 | c = someCSVValues.length; | ||
195 | i=0; | ||
196 | i++; //Dataviz Passwords Plus Export, Version,1, Minimum Version To Read,1 | ||
197 | i++; //Is Template,Title,Category,Field 1 Label,Field 1 Value,Field 1 Hidden,Field 2 Label,Field 2 Value,Field 2 Hidden,Field 3 Label,Field 3 Value,Field 3 Hidden,Field 4 Label,Field 4 Value,Field 4 Hidden,Field 5 Label,Field 5 Value,Field 5 Hidden,Field 6 Label,Field 6 Value,Field 6 Hidden,Field 7 Label,Field 7 Value,Field 7 Hidden,Field 8 Label,Field 8 Value,Field 8 Hidden,Field 9 Label,Field 9 Value,Field 9 Hidden,Field 10 Label,Field 10 Value,Field 10 Hidden,Note | ||
198 | |||
199 | for( ; i<c; i++) { | ||
200 | innerDeferredResult.addCallback(MochiKit.Async.wait, 0.2); | ||
201 | innerDeferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', {}); | ||
202 | innerDeferredResult.addCallback(MochiKit.Base.bind(function(someRecords, someData) { | ||
203 | if (someData[0] == '0') { | ||
204 | var record; | ||
205 | var recordVersion; | ||
206 | var ii, cc; | ||
207 | |||
208 | record = new Clipperz.PM.DataModel.Record({user:this.user()}); | ||
209 | if (someData[1] != "") { | ||
210 | record.setLabel(someData[1]); | ||
211 | } else { | ||
212 | record.setLabel("imported record [" + (i+1) + "]"); | ||
213 | } | ||
214 | record.setNotes(someData[33]); | ||
215 | recordVersion = record.currentVersion() | ||
216 | |||
217 | cc = 10; | ||
218 | for (ii=0; ii<cc; ii++) { | ||
219 | var currentFieldValueIndex; | ||
220 | var currentType; | ||
221 | |||
222 | currentFieldValueIndex = (ii * 3) + 4; | ||
223 | |||
224 | if (someData[currentFieldValueIndex] != "") { | ||
225 | var recordField; | ||
226 | var recordFieldType; | ||
227 | |||
228 | recordFieldType = 'TXT'; | ||
229 | if (someData[currentFieldValueIndex + 1] == 1) { | ||
230 | recordFieldType = 'PWD'; | ||
231 | } else if (/^http/.test(someData[currentFieldValueIndex])) { | ||
232 | recordFieldType = 'URL'; | ||
233 | } | ||
234 | |||
235 | recordField = new Clipperz.PM.DataModel.RecordField({ | ||
236 | recordVersion:recordVersion, | ||
237 | label: someData[currentFieldValueIndex - 1], | ||
238 | value: someData[currentFieldValueIndex], | ||
239 | type: recordFieldType | ||
240 | }); | ||
241 | recordVersion.addField(recordField); | ||
242 | } | ||
243 | } | ||
244 | |||
245 | // this.user().addRecord(record, true); | ||
246 | |||
247 | someRecords.push(record); | ||
248 | } | ||
249 | |||
250 | return someRecords; | ||
251 | }, this), records, someCSVValues[i]); | ||
252 | } | ||
253 | innerDeferredResult.addCallback(MochiKit.Async.succeed, records); | ||
254 | innerDeferredResult.callback(); | ||
255 | |||
256 | return innerDeferredResult; | ||
257 | }, this)); | ||
258 | deferredResult.callback(someData); | ||
259 | |||
260 | return deferredResult; | ||
261 | |||
262 | /* | ||
263 | 0Is Template | ||
264 | 1Title | ||
265 | 2Category | ||
266 | |||
267 | 3Field 1 Label | ||
268 | 4Field 1 Value | ||
269 | 5Field 1 Hidden | ||
270 | |||
271 | 6Field 2 Label | ||
272 | 7Field 2 Value | ||
273 | 8Field 2 Hidden | ||
274 | |||
275 | 9Field 3 Label | ||
276 | 10Field 3 Value | ||
277 | 11Field 3 Hidden | ||
278 | |||
279 | 12Field 4 Label | ||
280 | 13Field 4 Value | ||
281 | 14Field 4 Hidden | ||
282 | |||
283 | 15Field 5 Label | ||
284 | 16Field 5 Value | ||
285 | 17Field 5 Hidden | ||
286 | |||
287 | 18Field 6 Label | ||
288 | 19Field 6 Value | ||
289 | 20Field 6 Hidden | ||
290 | |||
291 | 21Field 7 Label | ||
292 | 22Field 7 Value | ||
293 | 23Field 7 Hidden | ||
294 | |||
295 | 24Field 8 Label | ||
296 | 25Field 8 Value | ||
297 | 26Field 8 Hidden | ||
298 | |||
299 | 27Field 9 Label | ||
300 | 28Field 9 Value | ||
301 | 29Field 9 Hidden | ||
302 | |||
303 | 30Field 10 Label | ||
304 | 31Field 10 Value | ||
305 | 32Field 10 Hidden | ||
306 | |||
307 | 33Note | ||
308 | */ | ||
309 | }, | ||
310 | |||
311 | |||
312 | //------------------------------------------------------------------------- | ||
313 | __syntaxFix__: "syntax fix" | ||
314 | }); | ||
315 | |||
diff --git a/frontend/beta/js/Clipperz/PM/Components/Import/RoboFormImportComponent.js b/frontend/beta/js/Clipperz/PM/Components/Import/RoboFormImportComponent.js new file mode 100644 index 0000000..d35bdc6 --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/Import/RoboFormImportComponent.js | |||
@@ -0,0 +1,392 @@ | |||
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 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | ||
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | ||
31 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } | ||
32 | if (typeof(Clipperz.PM.Components.Import) == 'undefined') { Clipperz.PM.Components.Import = {}; } | ||
33 | |||
34 | //############################################################################# | ||
35 | |||
36 | Clipperz.PM.Components.Import.RoboFormImportComponent = function(anElement, args) { | ||
37 | args = args || {}; | ||
38 | |||
39 | Clipperz.PM.Components.Import.RoboFormImportComponent.superclass.constructor.call(this, anElement, args); | ||
40 | |||
41 | this.render(); | ||
42 | |||
43 | return this; | ||
44 | } | ||
45 | |||
46 | //============================================================================= | ||
47 | |||
48 | YAHOO.extendX(Clipperz.PM.Components.Import.RoboFormImportComponent, Clipperz.PM.Components.Import.GenericImportComponent, { | ||
49 | |||
50 | 'toString': function() { | ||
51 | return "Clipperz.PM.Components.Import.RoboFormImportComponent component"; | ||
52 | }, | ||
53 | |||
54 | //------------------------------------------------------------------------- | ||
55 | |||
56 | 'render': function() { | ||
57 | //MochiKit.Logging.logDebug(">>> Import.RoboFormImportComponent.render"); | ||
58 | this.domHelper().append(this.element(), {tag:'div', cls:'roboFormImportWizard', children:[ | ||
59 | {tag:'h3', htmlString:Clipperz.PM.Strings['RoboForm_ImportWizard_Title']}, | ||
60 | {tag:'div', cls:'importSteps', id:this.getId('importSteps')}, | ||
61 | {tag:'div', cls:'importStepBlocks', children:[ | ||
62 | {tag:'div', cls:'step_0', id:this.getId('step_0'), children:[ | ||
63 | {tag:'div', children:[ | ||
64 | {tag:'div', cls:'importOptionsDescription', htmlString:Clipperz.PM.Strings['importOptions_roboForm_description']}, | ||
65 | {tag:'div', cls:'importOptionsParameters', children:[]}, | ||
66 | this.textAreaConfig() | ||
67 | ]} | ||
68 | ]}, | ||
69 | {tag:'div', cls:'step_1', id:this.getId('step_1'), children:[ | ||
70 | {tag:'div', children:[ | ||
71 | {tag:'div', id:this.getId('previewDiv'), html:"preview"} | ||
72 | ]} | ||
73 | ]}, | ||
74 | {tag:'div', cls:'step_2', id:this.getId('step_2'), children:[ | ||
75 | {tag:'div', children:[ | ||
76 | {tag:'h4', html:"done"} | ||
77 | ]} | ||
78 | ]} | ||
79 | ]}, | ||
80 | {tag:'div', cls:'importOptionsButtons', children:[ | ||
81 | {tag:'table', children:[ | ||
82 | {tag:'tbody', children:[ | ||
83 | {tag:'tr', children:[ | ||
84 | {tag:'td', html:' '}, | ||
85 | {tag:'td', children:[ | ||
86 | {tag:'div', id:this.getId('backActionButton')} | ||
87 | ]}, | ||
88 | {tag:'td', html:' '}, | ||
89 | {tag:'td', children:[ | ||
90 | {tag:'div', id:this.getId('nextActionButton')} | ||
91 | ]}, | ||
92 | {tag:'td', html:' '} | ||
93 | ]} | ||
94 | ]} | ||
95 | ]} | ||
96 | ]} | ||
97 | ]}); | ||
98 | |||
99 | this.updateSteps(); | ||
100 | |||
101 | this.setBackButton(new YAHOO.ext.Button(this.getDom('backActionButton'), {text:"back", handler:this.backAction, scope:this})); | ||
102 | this.setNextButton(new YAHOO.ext.Button(this.getDom('nextActionButton'), {text:"next", handler:this.nextAction, scope:this})); | ||
103 | |||
104 | this.getElement('step_0').setVisibilityMode(YAHOO.ext.Element.DISPLAY).show() | ||
105 | this.getElement('step_1').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); | ||
106 | this.getElement('step_2').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); | ||
107 | //MochiKit.Logging.logDebug("<<< Import.RoboFormImportComponent.render"); | ||
108 | }, | ||
109 | |||
110 | //------------------------------------------------------------------------- | ||
111 | |||
112 | 'nextAction': function() { | ||
113 | switch (this.currentStep()) { | ||
114 | case 0: //-> 1 | ||
115 | this.previewValues(); | ||
116 | break; | ||
117 | case 1: //-> 2 | ||
118 | this.importValues(); | ||
119 | break; | ||
120 | } | ||
121 | }, | ||
122 | |||
123 | //------------------------------------------------------------------------- | ||
124 | |||
125 | 'deferredPreviewValues': function() { | ||
126 | var deferredResult; | ||
127 | |||
128 | // this.setFormValues(MochiKit.DOM.formContents(this.getDom('dataForm'))); | ||
129 | |||
130 | deferredResult = new MochiKit.Async.Deferred(); | ||
131 | deferredResult.addCallback(MochiKit.Base.bind(function(res) { | ||
132 | this.startProcessing(); | ||
133 | |||
134 | return res; | ||
135 | }, this)); | ||
136 | deferredResult.addCallback(MochiKit.Base.method(this, 'processRoboFormValues')); | ||
137 | deferredResult.addCallback(MochiKit.Base.method(this, 'setProcessedValues')); | ||
138 | deferredResult.addCallback(MochiKit.Base.method(this, 'previewRecordValues')); | ||
139 | deferredResult.addCallback(MochiKit.Base.bind(function(res) { | ||
140 | this.processingDone(); | ||
141 | this.getElement('step_0').hide(); | ||
142 | this.getElement('step_1').show(); | ||
143 | this.backButton().enable(); | ||
144 | |||
145 | return res; | ||
146 | }, this)); | ||
147 | // deferredResult.addErrback(MochiKit.Base.bind(function() { | ||
148 | // this.processingAborted(); | ||
149 | // }, this)) | ||
150 | deferredResult.callback(this.textAreaContent()); | ||
151 | |||
152 | return deferredResult; | ||
153 | }, | ||
154 | |||
155 | //------------------------------------------------------------------------- | ||
156 | |||
157 | 'processRoboFormValues': function(someData) { | ||
158 | var result; | ||
159 | |||
160 | if (someData.match(/^\<HTML\>\<HEAD\>\<TITLE\>RoboForm Passcards List /g)) { | ||
161 | result = this.processRoboFormPasscardsValues(someData); | ||
162 | } else if (someData.match(/\<HTML\>\<HEAD\>\<TITLE\>RoboForm Safenotes List /g)) { | ||
163 | result = this.processRoboFormSafenotesValues(someData); | ||
164 | } | ||
165 | |||
166 | return result; | ||
167 | }, | ||
168 | |||
169 | //......................................................................... | ||
170 | |||
171 | 'processRoboFormPasscardsValues': function(someData) { | ||
172 | var deferredResult; | ||
173 | |||
174 | deferredResult = new MochiKit.Async.Deferred(); | ||
175 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("RoboFormImportComponent.processRoboFormValues - 1: "/* + res*/); return res;}); | ||
176 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'parseImportData'); | ||
177 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("RoboFormImportComponent.processRoboFormValues - 2: "/* + res*/); return res;}); | ||
178 | deferredResult.addCallback(function(someData) { | ||
179 | var result; | ||
180 | var data; | ||
181 | |||
182 | data = someData.replace(/\r?\n/g, ""); | ||
183 | result = data.match(/\<TABLE width\=\"100\%\"\>.*?\<\/TABLE\>/g); | ||
184 | |||
185 | return result; | ||
186 | }); | ||
187 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("RoboFormImportComponent.processRoboFormValues - 3: "/* + res*/); return res;}); | ||
188 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("RoboFormImportComponent.processRoboFormValues - 3.1: " + res.length); return res;}); | ||
189 | deferredResult.addCallback(function(res) { | ||
190 | return Clipperz.NotificationCenter.deferredNotification(this, 'updatedProgressState', {steps:(res.length)}, res); | ||
191 | }) | ||
192 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("RoboFormImportComponent.processRoboFormValues - 4: "/* + res*/); return res;}); | ||
193 | deferredResult.addCallback(MochiKit.Base.bind(function(someRecordValues) { | ||
194 | var innerDeferredResult; | ||
195 | var records; | ||
196 | var i,c; | ||
197 | |||
198 | innerDeferredResult = new MochiKit.Async.Deferred(); | ||
199 | records = []; | ||
200 | |||
201 | c = someRecordValues.length; | ||
202 | for(i=0; i<c; i++) { | ||
203 | //innerDeferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("RoboFormImportComponent.processRoboFormValues __inner loop__ - 1: " + res); return res;}); | ||
204 | innerDeferredResult.addCallback(MochiKit.Async.wait, 0.2); | ||
205 | //innerDeferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("RoboFormImportComponent.processRoboFormValues __inner loop__ - 2: " + res); return res;}); | ||
206 | innerDeferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', {}); | ||
207 | //innerDeferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("RoboFormImportComponent.processRoboFormValues __inner loop__ - 3: " + res); return res;}); | ||
208 | innerDeferredResult.addCallback(MochiKit.Base.bind(function(someRecords, someData) { | ||
209 | var data; | ||
210 | var record; | ||
211 | var recordVersion; | ||
212 | var fields; | ||
213 | var ii, cc; | ||
214 | var hasNotes; | ||
215 | |||
216 | var caption; | ||
217 | var subcaption; | ||
218 | |||
219 | //MochiKit.Logging.logDebug("data: " + someData); | ||
220 | data = someData.replace(/\<WBR\>/g, ""); | ||
221 | hasNotes = false; | ||
222 | |||
223 | /\<TD class\=caption colSpan\=3\>(.*?)\<\/TD\>/.test(data); //<TD class=caption colSpan=3>110mb</TD> | ||
224 | caption = RegExp.$1; | ||
225 | //MochiKit.Logging.logDebug("caption: " + caption); | ||
226 | |||
227 | /\<TD class\=subcaption colSpan\=3\>(.*?)\<\/TD\>/.test(data); //<TD class=subcaption colSpan=3>110<WBR>mb.com</TD> | ||
228 | subcaption = RegExp.$1; | ||
229 | //MochiKit.Logging.logDebug("subcaption: " + subcaption); | ||
230 | |||
231 | record = new Clipperz.PM.DataModel.Record({user:this.user()}); | ||
232 | recordVersion = record.currentVersion() | ||
233 | |||
234 | record.setLabel(caption); | ||
235 | // record.setNotes(subcaption); | ||
236 | if (subcaption != null) { | ||
237 | var recordField; | ||
238 | |||
239 | recordField = new Clipperz.PM.DataModel.RecordField({ | ||
240 | recordVersion:recordVersion, | ||
241 | label: "url", | ||
242 | value: subcaption, | ||
243 | type: 'URL' | ||
244 | }); | ||
245 | recordVersion.addField(recordField); | ||
246 | } | ||
247 | |||
248 | fields = data.match(/\<TR\>.*?\<\/TR\>/g) || []; | ||
249 | cc = fields.length; | ||
250 | //MochiKit.Logging.logDebug("fields.length: " + cc); | ||
251 | for (ii=0; ii<cc; ii++) { | ||
252 | var recordField; | ||
253 | var fieldString; | ||
254 | var fieldName; | ||
255 | var fieldValue; | ||
256 | |||
257 | //MochiKit.Logging.logDebug("fieldString: " + fields[ii]); | ||
258 | fieldString = fields[ii]; | ||
259 | //MochiKit.Logging.logDebug("fieldString (cleaned): " + fieldString); | ||
260 | /\<TD class\=field vAlign\=top align\=left width\=\"40\%\"\>(.*?)\<\/TD\>/.test(fieldString); | ||
261 | fieldName = RegExp.$1; | ||
262 | |||
263 | /\<TD class\=wordbreakfield vAlign\=top align\=left width\=\"55\%\"\>(.*?)\<\/TD\>/.test(fieldString); | ||
264 | fieldValue = RegExp.$1; | ||
265 | |||
266 | if (fieldName == "Note$") { | ||
267 | record.setNotes(fieldValue); | ||
268 | hasNotes = true; | ||
269 | } else { | ||
270 | var fieldType; | ||
271 | |||
272 | if (((ii == 1) && (hasNotes == false)) || ((ii == 2) && (hasNotes == true))) { | ||
273 | fieldType = 'PWD'; | ||
274 | } else { | ||
275 | fieldType = 'TXT'; | ||
276 | } | ||
277 | |||
278 | recordField = new Clipperz.PM.DataModel.RecordField({ | ||
279 | recordVersion:recordVersion, | ||
280 | label: fieldName, | ||
281 | value: fieldValue, | ||
282 | type: fieldType | ||
283 | }); | ||
284 | recordVersion.addField(recordField); | ||
285 | } | ||
286 | } | ||
287 | |||
288 | someRecords.push(record); | ||
289 | |||
290 | return someRecords; | ||
291 | }, this), records, someRecordValues[i]); | ||
292 | } | ||
293 | //innerDeferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("RoboFormImportComponent.processRoboFormValues __inner loop__ - 4: " + res); return res;}); | ||
294 | innerDeferredResult.addCallback(MochiKit.Async.succeed, records); | ||
295 | //innerDeferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("RoboFormImportComponent.processRoboFormValues __inner loop__ - 5: " + res); return res;}); | ||
296 | innerDeferredResult.callback(); | ||
297 | |||
298 | return innerDeferredResult; | ||
299 | }, this)); | ||
300 | deferredResult.callback(someData); | ||
301 | |||
302 | return deferredResult; | ||
303 | }, | ||
304 | |||
305 | |||
306 | //......................................................................... | ||
307 | |||
308 | 'processRoboFormSafenotesValues': function(someData) { | ||
309 | var deferredResult; | ||
310 | |||
311 | deferredResult = new MochiKit.Async.Deferred(); | ||
312 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("RoboFormImportComponent.processRoboFormValues - 1: "/* + res*/); return res;}); | ||
313 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'parseImportData'); | ||
314 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("RoboFormImportComponent.processRoboFormValues - 2: "/* + res*/); return res;}); | ||
315 | deferredResult.addCallback(function(someData) { | ||
316 | var result; | ||
317 | var data; | ||
318 | |||
319 | data = someData.replace(/\r?\n/g, ""); | ||
320 | result = data.match(/\<TABLE width\=\"100\%\"\>.*?\<\/TABLE\>/g); | ||
321 | |||
322 | return result; | ||
323 | }); | ||
324 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("RoboFormImportComponent.processRoboFormValues - 3: "/* + res*/); return res;}); | ||
325 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("RoboFormImportComponent.processRoboFormValues - 3.1: " + res.length); return res;}); | ||
326 | deferredResult.addCallback(function(res) { | ||
327 | return Clipperz.NotificationCenter.deferredNotification(this, 'updatedProgressState', {steps:(res.length)}, res); | ||
328 | }) | ||
329 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("RoboFormImportComponent.processRoboFormValues - 4: "/* + res*/); return res;}); | ||
330 | deferredResult.addCallback(MochiKit.Base.bind(function(someRecordValues) { | ||
331 | var innerDeferredResult; | ||
332 | var records; | ||
333 | var i,c; | ||
334 | |||
335 | innerDeferredResult = new MochiKit.Async.Deferred(); | ||
336 | records = []; | ||
337 | |||
338 | c = someRecordValues.length; | ||
339 | for(i=0; i<c; i++) { | ||
340 | //innerDeferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("RoboFormImportComponent.processRoboFormValues __inner loop__ - 1: " + res); return res;}); | ||
341 | innerDeferredResult.addCallback(MochiKit.Async.wait, 0.2); | ||
342 | //innerDeferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("RoboFormImportComponent.processRoboFormValues __inner loop__ - 2: " + res); return res;}); | ||
343 | innerDeferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', {}); | ||
344 | //innerDeferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("RoboFormImportComponent.processRoboFormValues __inner loop__ - 3: " + res); return res;}); | ||
345 | innerDeferredResult.addCallback(MochiKit.Base.bind(function(someRecords, someData) { | ||
346 | var data; | ||
347 | var record; | ||
348 | var recordVersion; | ||
349 | |||
350 | var caption; | ||
351 | var wordbreakfield; | ||
352 | |||
353 | //MochiKit.Logging.logDebug("data: " + someData); | ||
354 | data = someData.replace(/\<WBR\>/g, ""); | ||
355 | hasNotes = false; | ||
356 | |||
357 | /\<TD class\=caption colSpan\=3\>(.*?)\<\/TD\>/.test(data); //<TD class=caption colSpan=3>110mb</TD> | ||
358 | caption = RegExp.$1; | ||
359 | //MochiKit.Logging.logDebug("caption: " + caption); | ||
360 | |||
361 | /\<TD class\=wordbreakfield vAlign=top align\=left width\=\"\1\0\0\%\"\>(.*?)\<\/TD\>/.test(data); //<TD class=wordbreakfield vAlign=top align=left width="100%">7759500</TD> | ||
362 | wordbreakfield = RegExp.$1; | ||
363 | //MochiKit.Logging.logDebug("subcaption: " + subcaption); | ||
364 | |||
365 | record = new Clipperz.PM.DataModel.Record({user:this.user()}); | ||
366 | recordVersion = record.currentVersion() | ||
367 | |||
368 | record.setLabel(caption); | ||
369 | record.setNotes(wordbreakfield); | ||
370 | |||
371 | someRecords.push(record); | ||
372 | |||
373 | return someRecords; | ||
374 | }, this), records, someRecordValues[i]); | ||
375 | } | ||
376 | //innerDeferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("RoboFormImportComponent.processRoboFormValues __inner loop__ - 4: " + res); return res;}); | ||
377 | innerDeferredResult.addCallback(MochiKit.Async.succeed, records); | ||
378 | //innerDeferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("RoboFormImportComponent.processRoboFormValues __inner loop__ - 5: " + res); return res;}); | ||
379 | innerDeferredResult.callback(); | ||
380 | |||
381 | return innerDeferredResult; | ||
382 | }, this)); | ||
383 | deferredResult.callback(someData); | ||
384 | |||
385 | return deferredResult; | ||
386 | }, | ||
387 | |||
388 | |||
389 | //------------------------------------------------------------------------- | ||
390 | __syntaxFix__: "syntax fix" | ||
391 | }); | ||
392 | |||
diff --git a/frontend/beta/js/Clipperz/PM/Components/MessageBox.js b/frontend/beta/js/Clipperz/PM/Components/MessageBox.js new file mode 100644 index 0000000..d2bc09a --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/MessageBox.js | |||
@@ -0,0 +1,224 @@ | |||
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 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | ||
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | ||
31 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } | ||
32 | |||
33 | |||
34 | |||
35 | Clipperz.PM.Components.MessageBoxImplementation = function() { | ||
36 | this._step = 0; | ||
37 | this._steps = 0; | ||
38 | |||
39 | return this; | ||
40 | }; | ||
41 | |||
42 | //YAHOO.extendX(Clipperz.PM.Components.MessageBoxImplementation, Clipperz.PM.Components.BaseComponent, { | ||
43 | Clipperz.PM.Components.MessageBoxImplementation.prototype = MochiKit.Base.update(null, { | ||
44 | |||
45 | 'toString': function() { | ||
46 | return "Clipperz.PM.Components.MessageBox"; | ||
47 | }, | ||
48 | |||
49 | //----------------------------------------------------- | ||
50 | |||
51 | 'step': function() { | ||
52 | return this._step; | ||
53 | }, | ||
54 | |||
55 | 'setStep': function(aValue) { | ||
56 | if (aValue == 'next') { | ||
57 | this._step = this._step + 1; | ||
58 | } else { | ||
59 | this._step = aValue; | ||
60 | } | ||
61 | |||
62 | if (this._step > this.steps()) { | ||
63 | //MochiKit.Logging.logDebug("overstepping: " + this._step + " (" + this.steps() + ")"); | ||
64 | this._step = this.steps(); | ||
65 | } | ||
66 | }, | ||
67 | |||
68 | //----------------------------------------------------- | ||
69 | |||
70 | 'steps': function() { | ||
71 | return this._steps; | ||
72 | }, | ||
73 | |||
74 | 'setSteps': function(aValue) { | ||
75 | if (aValue.constructor == String) { | ||
76 | if (aValue.charAt(0) == '+') { | ||
77 | this._steps += aValue.substring(1)*1; | ||
78 | } else if (aValue.charAt(0) == '-') { | ||
79 | this._steps -= aValue.substring(1)*1; | ||
80 | } else { | ||
81 | this._steps = aValue.substring(1)*1; | ||
82 | } | ||
83 | } else { | ||
84 | this._steps = aValue; | ||
85 | } | ||
86 | }, | ||
87 | |||
88 | //----------------------------------------------------- | ||
89 | |||
90 | 'deferredShow': function(aConfiguration, anAnimationTargetElement, aValue) { | ||
91 | this.show(aConfiguration, anAnimationTargetElement); | ||
92 | |||
93 | return aValue; | ||
94 | }, | ||
95 | |||
96 | 'show': function(aConfiguration, anAnimationTargetElement) { | ||
97 | varmessageBoxConfiguration; | ||
98 | |||
99 | messageBoxConfiguration = MochiKit.Base.clone(aConfiguration); | ||
100 | messageBoxConfiguration.msg = messageBoxConfiguration.text; | ||
101 | messageBoxConfiguration.animEl = anAnimationTargetElement; | ||
102 | messageBoxConfiguration.progress = messageBoxConfiguration.showProgressBar; | ||
103 | messageBoxConfiguration.closable = messageBoxConfiguration.showCloseButton; | ||
104 | this.setSteps(aConfiguration.steps || 0); | ||
105 | this.setStep(aConfiguration.step || 0); | ||
106 | delete messageBoxConfiguration.buttons; | ||
107 | |||
108 | Clipperz.YUI.MessageBox.show(messageBoxConfiguration); | ||
109 | }, | ||
110 | |||
111 | //----------------------------------------------------- | ||
112 | |||
113 | 'update': function(someValues) { | ||
114 | //MochiKit.Logging.logDebug(">>> MessageBox.update"); | ||
115 | if (someValues.title) { | ||
116 | Clipperz.YUI.MessageBox.getDialog().setTitle(someValues.title); | ||
117 | }; | ||
118 | |||
119 | if (someValues.text) { | ||
120 | Clipperz.YUI.MessageBox.updateText(someValues.text); | ||
121 | }; | ||
122 | |||
123 | if (typeof(someValues.showProgressBar) != 'undefined') { | ||
124 | Clipperz.YUI.MessageBox.progressElement().setDisplayed(someValues.showProgressBar); | ||
125 | Clipperz.YUI.MessageBox.updateProgress(0); | ||
126 | }; | ||
127 | |||
128 | if (typeof(someValues.steps) != 'undefined') { | ||
129 | this.setSteps(someValues.steps); | ||
130 | }; | ||
131 | |||
132 | if (typeof(someValues.step) != 'undefined') { | ||
133 | this.setStep(someValues.step); | ||
134 | } else { | ||
135 | this.setStep('next'); | ||
136 | } | ||
137 | Clipperz.YUI.MessageBox.updateProgress(this.step() / this.steps()); | ||
138 | |||
139 | |||
140 | if (typeof(someValues.fn) != 'undefined') { | ||
141 | Clipperz.YUI.MessageBox.opt().fn = someValues.fn; | ||
142 | }; | ||
143 | |||
144 | if (typeof(someValues.scope) != 'undefined') { | ||
145 | Clipperz.YUI.MessageBox.opt().scope = someValues.scope; | ||
146 | }; | ||
147 | |||
148 | if (someValues.buttons) { | ||
149 | Clipperz.YUI.MessageBox.updateButtons(someValues.buttons); | ||
150 | }; | ||
151 | |||
152 | // if (someValues.title) { | ||
153 | // Clipperz.YUI.MessageBox.getDialog().setTitle(someValues.title + " [" + this.step() + " / " + this.steps() + "]"); | ||
154 | // }; | ||
155 | |||
156 | //MochiKit.Logging.logDebug("--- MessageBox.update - step: " + this.step() + " / " + this.steps() + " - " + someValues.text); | ||
157 | //MochiKit.Logging.logDebug("<<< MessageBox.update"); | ||
158 | }, | ||
159 | |||
160 | //----------------------------------------------------- | ||
161 | |||
162 | 'hide': function(anAnimationTargetElement) { | ||
163 | if (anAnimationTargetElement) { | ||
164 | Clipperz.YUI.MessageBox.getDialog().animateTarget = anAnimationTargetElement; | ||
165 | } | ||
166 | |||
167 | Clipperz.YUI.MessageBox.hide(); | ||
168 | }, | ||
169 | |||
170 | //----------------------------------------------------- | ||
171 | __syntaxFix__: '__syntaxFix__' | ||
172 | }); | ||
173 | |||
174 | |||
175 | //########################################################## | ||
176 | |||
177 | _clipperz_pm_components_messageBox = null; | ||
178 | |||
179 | Clipperz.PM.Components.MessageBox = function() { | ||
180 | if (_clipperz_pm_components_messageBox == null) { | ||
181 | _clipperz_pm_components_messageBox = new Clipperz.PM.Components.MessageBoxImplementation(); | ||
182 | } | ||
183 | |||
184 | return _clipperz_pm_components_messageBox; | ||
185 | } | ||
186 | |||
187 | //--------------------------------------------------------- | ||
188 | |||
189 | Clipperz.PM.Components.MessageBox.showProgressPanel = function(aCallback, anErrback, anActivationItem) { | ||
190 | var deferredResult; | ||
191 | |||
192 | deferredResult = new MochiKit.Async.Deferred(); | ||
193 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Clipperz.PM.Components.MessageBox.showProgressPanel - 0: " + res); return res;}); | ||
194 | deferredResult.addCallback(MochiKit.Base.method(Clipperz.PM.Components.MessageBox(), 'deferredShow'), | ||
195 | { | ||
196 | title: "", | ||
197 | text: "", | ||
198 | width:240, | ||
199 | showProgressBar:true, | ||
200 | showCloseButton:false, | ||
201 | fn:MochiKit.Base.method(deferredResult, 'cancel'), | ||
202 | scope:this, | ||
203 | buttons:{ | ||
204 | //'ok':Clipperz.PM.Strings['loginMessagePanelInitialButtonLabel'] | ||
205 | } | ||
206 | }, | ||
207 | anActivationItem | ||
208 | ); | ||
209 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Clipperz.PM.Components.MessageBox.showProgressPanel - 1: " + res); return res;}); | ||
210 | deferredResult.addCallback(aCallback); | ||
211 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Clipperz.PM.Components.MessageBox.showProgressPanel - 2: " + res); return res;}); | ||
212 | deferredResult.addCallback(MochiKit.Async.wait, 0.5); | ||
213 | deferredResult.addCallback(function(res) { | ||
214 | Clipperz.PM.Components.MessageBox().hide(YAHOO.ext.Element.get(anActivationItem)); | ||
215 | return res; | ||
216 | }); | ||
217 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Clipperz.PM.Components.MessageBox.showProgressPanel - 3: " + res); return res;}); | ||
218 | deferredResult.addErrback(anErrback); | ||
219 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Clipperz.PM.Components.MessageBox.showProgressPanel - 4: " + res); return res;}); | ||
220 | deferredResult.callback(); | ||
221 | |||
222 | return deferredResult; | ||
223 | }; | ||
224 | |||
diff --git a/frontend/beta/js/Clipperz/PM/Components/OTP/MainComponent.js b/frontend/beta/js/Clipperz/PM/Components/OTP/MainComponent.js new file mode 100644 index 0000000..9d191f6 --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/OTP/MainComponent.js | |||
@@ -0,0 +1,490 @@ | |||
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 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | ||
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | ||
31 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } | ||
32 | if (typeof(Clipperz.PM.Components.OTP) == 'undefined') { Clipperz.PM.Components.OTP = {}; } | ||
33 | |||
34 | //############################################################################# | ||
35 | |||
36 | Clipperz.PM.Components.OTP.MainComponent = function(anElement, args) { | ||
37 | args = args || {}; | ||
38 | |||
39 | //MochiKit.Logging.logDebug("new OTP.MainComponent"); | ||
40 | Clipperz.PM.Components.OTP.MainComponent.superclass.constructor.call(this, anElement, args); | ||
41 | |||
42 | this._user = args.user; | ||
43 | this._shouldRender = true; | ||
44 | |||
45 | this._deleteButton = null; | ||
46 | this._printButton = null; | ||
47 | |||
48 | Clipperz.NotificationCenter.register(null, 'tabSelected', this, 'tabSelectedHandler'); | ||
49 | //Clipperz.NotificationCenter.register(null, 'oneTimePasswordAdded', this, 'render'); | ||
50 | |||
51 | return this; | ||
52 | } | ||
53 | |||
54 | //============================================================================= | ||
55 | |||
56 | YAHOO.extendX(Clipperz.PM.Components.OTP.MainComponent, Clipperz.PM.Components.BaseComponent, { | ||
57 | |||
58 | 'toString': function() { | ||
59 | return "Clipperz.PM.Components.OTP.MainComponent component"; | ||
60 | }, | ||
61 | |||
62 | //------------------------------------------------------------------------- | ||
63 | |||
64 | 'render': function() { | ||
65 | //MochiKit.Logging.logDebug("### OTP.MainComponent.render"); | ||
66 | Clipperz.NotificationCenter.unregister(this); | ||
67 | MochiKit.Signal.disconnectAllTo(this); | ||
68 | |||
69 | if (Clipperz.PM.Proxy.defaultProxy.isReadOnly()) { | ||
70 | this.element().update(""); | ||
71 | this.domHelper().append(this.element(), {tag:'div', cls:'oneTimePasswordReadOnlyMessage', htmlString:Clipperz.PM.Strings['oneTimePasswordReadOnlyMessage']}); | ||
72 | } else { | ||
73 | var deferredResult; | ||
74 | |||
75 | deferredResult = new MochiKit.Async.Deferred(); | ||
76 | |||
77 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("OTP.MainComponent.render - 1: " + res); return res;}); | ||
78 | deferredResult.addCallback(MochiKit.Base.bind(function() { | ||
79 | this.element().update(""); | ||
80 | Clipperz.YUI.DomHelper.append(this.element(), {tag:'div', htmlString:Clipperz.PM.Strings['oneTimePasswordLoadingMessage']}); | ||
81 | }, this)); | ||
82 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("OTP.MainComponent.render - 2: " + res); return res;}); | ||
83 | deferredResult.addCallback(MochiKit.Base.method(this.user(), 'loadOneTimePasswords')); | ||
84 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("OTP.MainComponent.render - 3: " + res); return res;}); | ||
85 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("OTP.MainComponent.render - 3.1: " + Clipperz.Base.serializeJSON(res.serializedData())); return res;}); | ||
86 | deferredResult.addCallback(MochiKit.Base.bind(function(aResult) { | ||
87 | vartbodyElement; | ||
88 | varoneTimePasswordReferenceKeys; | ||
89 | var imageExtension; | ||
90 | var isThereAnyActiveOneTimePassword; | ||
91 | |||
92 | isThereAnyActiveOneTimePassword = false; | ||
93 | |||
94 | this.element().update(""); | ||
95 | Clipperz.YUI.DomHelper.append(this.element(), {tag:'div', id:'oneTimePasswordList', children:[ | ||
96 | {tag:'div', id:'oneTimePasswords_header', children:[ | ||
97 | {tag:'table', width:'100%', children:[ | ||
98 | {tag:'tbody', children:[ | ||
99 | {tag:'tr', children:[ | ||
100 | {tag:'td', width:'10%', children:[ | ||
101 | {tag:'div', id:this.getId('createNewOneTimePasswordButton')} | ||
102 | ]}, | ||
103 | {tag:'td', width:'40%', children:[ | ||
104 | {tag:'div', id:this.getId('deleteSelectedOneTimePasswordButton')} | ||
105 | ]}, | ||
106 | {tag:'td', width:'50%', align:'right', children:[ | ||
107 | {tag:'div', id:this.getId('printOneTimePasswordButton')} | ||
108 | ]} | ||
109 | ]} | ||
110 | ]} | ||
111 | ]}, | ||
112 | {tag:'div', children:[ | ||
113 | {tag:'ul', children:[ | ||
114 | {tag:'li', children:[ | ||
115 | {tag:'span', htmlString:Clipperz.PM.Strings['oneTimePasswordSelectionLink_selectLabel']} | ||
116 | ]}, | ||
117 | {tag:'li', children:[ | ||
118 | {tag:'a', href:'#', id:this.getId('selectAllOneTimePasswords_link'), htmlString:Clipperz.PM.Strings['oneTimePasswordSelectionLink_all']} | ||
119 | ]}, | ||
120 | {tag:'li', children:[ | ||
121 | {tag:'a', href:'#', id:this.getId('selectNoneOneTimePasswords_link'), htmlString:Clipperz.PM.Strings['oneTimePasswordSelectionLink_none']} | ||
122 | ]}, | ||
123 | {tag:'li', children:[ | ||
124 | {tag:'a', href:'#', id:this.getId('selectUsedOneTimePasswords_link'), htmlString:Clipperz.PM.Strings['oneTimePasswordSelectionLink_used']} | ||
125 | ]}, | ||
126 | {tag:'li', children:[ | ||
127 | {tag:'a', href:'#', id:this.getId('selectUnusedOneTimePasswords_link'), htmlString:Clipperz.PM.Strings['oneTimePasswordSelectionLink_unused']} | ||
128 | ]} | ||
129 | ]} | ||
130 | ]} | ||
131 | ]}, | ||
132 | {tag:'form', id:this.getId('oneTimePasswords_form'), children:[ | ||
133 | {tag:'table', cls:'oneTimePassword', cellspacing:'0', cellpadding:'2', children:[ | ||
134 | {tag:'tbody', id:this.getId('oneTimePasswords_tbody'), children:[ | ||
135 | ]} | ||
136 | ]} | ||
137 | ]} | ||
138 | ]}); | ||
139 | |||
140 | imageExtension = (Clipperz_IEisBroken == true) ? 'gif': 'png'; | ||
141 | |||
142 | tbodyElement = this.getElement('oneTimePasswords_tbody'); | ||
143 | oneTimePasswordReferenceKeys = MochiKit.Base.keys(this.user().oneTimePasswordManager().oneTimePasswords()).reverse(); | ||
144 | c = oneTimePasswordReferenceKeys.length; | ||
145 | if (c>0) { | ||
146 | for (i=0; i<c; i++) { | ||
147 | var otpReference; | ||
148 | var currentOTP; | ||
149 | var loginSessionInfoConfig; | ||
150 | |||
151 | imageExtension = (Clipperz_IEisBroken == true) ? 'gif': 'png'; | ||
152 | |||
153 | otpReference = oneTimePasswordReferenceKeys[i]; | ||
154 | currentOTP = this.user().oneTimePasswordManager().oneTimePasswords()[otpReference]; | ||
155 | |||
156 | switch (currentOTP.status()) { | ||
157 | case 'USED': | ||
158 | var loginSessionInfo; | ||
159 | |||
160 | loginSessionInfo = currentOTP.connectionInfo(); | ||
161 | try { | ||
162 | var ip; | ||
163 | |||
164 | ip = (currentOTP.connectionInfo()['ip'].match(/^\d{1,3}(.\d{1,3}){3}$/)) ? currentOTP.connectionInfo()['ip'] : Clipperz.PM.Strings['unknown_ip']; | ||
165 | |||
166 | loginSessionInfoConfig = [ | ||
167 | {tag:'div', cls:'oneTimePassword_usageDateDescription', children:[ | ||
168 | {tag:'span', cls:'value', html:Clipperz.PM.Date.getElapsedTimeDescription(currentOTP.usageDate())} | ||
169 | ]}, | ||
170 | {tag:'div', cls:'oneTimePassword_usageDetails', children:[ | ||
171 | {tag:'img', cls:'flag', title:Clipperz.PM.Strings['countries'][ loginSessionInfo['country']], src:Clipperz.PM.Strings['icons_baseUrl'] + "/flags/" + loginSessionInfo['country'].toLowerCase() + "." + imageExtension, width:'32', height:'32'}, | ||
172 | {tag:'img', cls:'browser', title:Clipperz.PM.Strings['browsers'][ loginSessionInfo['browser']], src:Clipperz.PM.Strings['icons_baseUrl'] + "/browsers/" + loginSessionInfo['browser'].toLowerCase() + "." + imageExtension, width:'32', height:'32'}, | ||
173 | {tag:'img', cls:'operatingSystem', title:Clipperz.PM.Strings['operatingSystems'][loginSessionInfo['operatingSystem']], src:Clipperz.PM.Strings['icons_baseUrl'] + "/operatingSystems/" + loginSessionInfo['operatingSystem'].toLowerCase() + "." + imageExtension, width:'32', height:'32'} | ||
174 | ]}, | ||
175 | {tag:'div', cls:'oneTimePassword_usageDate', html:Clipperz.PM.Date.formatDateWithTemplate(currentOTP.usageDate(), Clipperz.PM.Strings['fullDate_format'])}, | ||
176 | {tag:'div', cls:'oneTimePassword_IP', children:[ | ||
177 | {tag:'span', cls:'oneTimePassword_IPLabel', htmlString:Clipperz.PM.Strings['loginHistoryIPLabel']}, | ||
178 | {tag:'span', cls:'oneTimePassword_IPValue', html:ip} | ||
179 | ]} | ||
180 | ]; | ||
181 | } catch(exception) { | ||
182 | MochiKit.Logging.logWarning("an error occured while showing the One Time Password session details"); | ||
183 | loginSessionInfoConfig = []; | ||
184 | } | ||
185 | break; | ||
186 | case 'DISABLED': | ||
187 | loginSessionInfoConfig = [ | ||
188 | {tag:'span', cls:'disabledOneTimePassword', htmlString:Clipperz.PM.Strings['disabledOneTimePassword_warning']} | ||
189 | ]; | ||
190 | break; | ||
191 | case 'ACTIVE': | ||
192 | default: | ||
193 | loginSessionInfoConfig = []; | ||
194 | break; | ||
195 | } | ||
196 | |||
197 | |||
198 | if (currentOTP.isExpired() == false) { | ||
199 | isThereAnyActiveOneTimePassword = true; | ||
200 | }; | ||
201 | |||
202 | |||
203 | this.domHelper().append(tbodyElement, {tag:'tr', cls:(currentOTP.isExpired() ? 'oneTimePassword_used': 'oneTimePassword_new'), children:[ | ||
204 | {tag:'td', valign:'top', children:[ | ||
205 | {tag:'input', type:'checkbox', cls:'otpCheckbox', name:currentOTP.reference()} | ||
206 | ]}, | ||
207 | {tag:'td', valign:'top', children:[ | ||
208 | {tag:'span', cls:'oneTimePassword_value', html:currentOTP.password()} | ||
209 | ]}, | ||
210 | {tag:'td', valign:'top', children:[ | ||
211 | {tag:'div', cls:'oneTimePassword_usageStats', children:loginSessionInfoConfig} | ||
212 | ]} | ||
213 | ]}); | ||
214 | } | ||
215 | } else { | ||
216 | this.domHelper().append(tbodyElement, {tag:'tr', children:[ | ||
217 | {tag:'td', children:[ | ||
218 | {tag:'div', cls:'oneTimePassword_noPasswordPresent', htmlString:Clipperz.PM.Strings['oneTimePasswordNoPasswordAvailable']} | ||
219 | ]} | ||
220 | ]}); | ||
221 | } | ||
222 | |||
223 | new YAHOO.ext.Button(this.getDom('createNewOneTimePasswordButton'), {text:Clipperz.PM.Strings['createNewOTPButtonLabel'], handler:this.createNewOneTimePassword, scope:this}); | ||
224 | this.setDeleteButton(new YAHOO.ext.Button(this.getDom('deleteSelectedOneTimePasswordButton'), {text:Clipperz.PM.Strings['deleteOTPButtonLabel'], handler:this.deleteSelectedOneTimePasswords, scope:this})); | ||
225 | this.setPrintButton(new YAHOO.ext.Button(this.getDom('printOneTimePasswordButton'), {text:Clipperz.PM.Strings['printOTPButtonLabel'], handler:this.printOneTimePasswords, scope:this})); | ||
226 | |||
227 | MochiKit.Signal.connect(this.getId('selectAllOneTimePasswords_link'),'onclick', this, 'selectAllOneTimePasswords'); | ||
228 | MochiKit.Signal.connect(this.getId('selectNoneOneTimePasswords_link'),'onclick', this, 'selectNoneOneTimePasswords'); | ||
229 | MochiKit.Signal.connect(this.getId('selectUsedOneTimePasswords_link'),'onclick', this, 'selectUsedOneTimePasswords'); | ||
230 | MochiKit.Signal.connect(this.getId('selectUnusedOneTimePasswords_link'),'onclick', this, 'selectUnusedOneTimePasswords'); | ||
231 | |||
232 | MochiKit.Base.map(MochiKit.Base.bind(function(aCheckbox) { | ||
233 | MochiKit.Signal.connect(aCheckbox, 'onclick', this, 'handleCheckboxClick'); | ||
234 | }, this), this.oneTimePasswordCheckboxes()); | ||
235 | |||
236 | this.updateDeleteButtonStatus(); | ||
237 | |||
238 | if (isThereAnyActiveOneTimePassword == true) { | ||
239 | this.printButton().enable(); | ||
240 | } else { | ||
241 | this.printButton().disable(); | ||
242 | } | ||
243 | |||
244 | // Clipperz.NotificationCenter.register(null, 'oneTimePasswordAdded', this, 'render'); | ||
245 | Clipperz.NotificationCenter.register(null, 'oneTimePassword_saveChanges_done', this, 'render'); | ||
246 | |||
247 | }, this)); | ||
248 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("OTP.MainComponent.render - 4: " + res); return res;}); | ||
249 | |||
250 | deferredResult.callback(); | ||
251 | } | ||
252 | }, | ||
253 | |||
254 | //------------------------------------------------------------------------- | ||
255 | |||
256 | 'printOneTimePasswords': function() { | ||
257 | var newWindow; | ||
258 | var activeOneTimePasswords; | ||
259 | |||
260 | //MochiKit.Logging.logDebug(">>> printAllData"); | ||
261 | newWindow = window.open("", ""); | ||
262 | newWindow.document.write( | ||
263 | "<html>" + | ||
264 | "<header>" + | ||
265 | "<title>Clipperz One Time Password</title>" + | ||
266 | "<style>" + | ||
267 | "div.oneTimePassword_print h2 {" + | ||
268 | "font-family: monospace;" + | ||
269 | "font-weight: normal;" + | ||
270 | "padding: 10px 20px;" + | ||
271 | "}" + | ||
272 | "</style>" + | ||
273 | "" + | ||
274 | "<!--[if IE]>" + | ||
275 | "<style>" + | ||
276 | "</style>" + | ||
277 | "<![endif]-->" + | ||
278 | "" + | ||
279 | "</header>" + | ||
280 | "<body>" + | ||
281 | "</body>" + | ||
282 | "</html>" | ||
283 | ); | ||
284 | |||
285 | activeOneTimePasswords = MochiKit.Base.filter(function(aOneTimePassword) {return (aOneTimePassword.isExpired() == false)}, MochiKit.Base.values(this.user().oneTimePasswordManager().oneTimePasswords()).reverse()); | ||
286 | |||
287 | MochiKit.Iter.forEach(activeOneTimePasswords, MochiKit.Base.partial(function(aWindow, aOneTimePassword) { | ||
288 | MochiKit.DOM.withWindow(aWindow, MochiKit.Base.partial(function(aOneTimePassword) { | ||
289 | var newBlock; | ||
290 | |||
291 | newBlock = MochiKit.DOM.DIV({'class': 'oneTimePassword_print'}, | ||
292 | MochiKit.DOM.H2(null, aOneTimePassword.password()) | ||
293 | ); | ||
294 | MochiKit.DOM.appendChildNodes(MochiKit.DOM.currentDocument().body, newBlock); | ||
295 | |||
296 | }, aOneTimePassword)); | ||
297 | }, newWindow)); | ||
298 | }, | ||
299 | |||
300 | //------------------------------------------------------------------------- | ||
301 | |||
302 | 'generateRandomBase32OTPValue': function(aButton) { | ||
303 | var randomValue; | ||
304 | varresult; | ||
305 | |||
306 | randomValue = Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(160/8); | ||
307 | result = randomValue.toBase32String(); | ||
308 | result = result.replace(/.{4}\B/g, '$&' + ' '); | ||
309 | result = result.replace(/(.{4} ){2}/g, '$&' + '- '); | ||
310 | |||
311 | return result; | ||
312 | }, | ||
313 | |||
314 | //------------------------------------------------------------------------- | ||
315 | |||
316 | 'createNewOneTimePassword': function() { | ||
317 | var newOneTimePassword; | ||
318 | var password; | ||
319 | |||
320 | password = this.generateRandomBase32OTPValue(); | ||
321 | newOneTimePassword = new Clipperz.PM.DataModel.OneTimePassword({ | ||
322 | user:this.user(), | ||
323 | password:password | ||
324 | }); | ||
325 | this.user().oneTimePasswordManager().addOneTimePassword(newOneTimePassword); | ||
326 | Clipperz.PM.Components.MessageBox.showProgressPanel(MochiKit.Base.method(newOneTimePassword, 'saveChanges'), null, this.getDom('createNewOneTimePasswordButton')); | ||
327 | }, | ||
328 | |||
329 | //------------------------------------------------------------------------- | ||
330 | |||
331 | 'oneTimePasswordCheckboxes': function() { | ||
332 | return MochiKit.DOM.getElementsByTagAndClassName('input', 'otpCheckbox', this.getId('oneTimePasswords_tbody')); | ||
333 | }, | ||
334 | |||
335 | 'checkedOneTimePasswordCheckboxes': function() { | ||
336 | return MochiKit.Base.filter(function(aCheckbox) {return (aCheckbox.checked == true)}, this.oneTimePasswordCheckboxes()); | ||
337 | }, | ||
338 | |||
339 | //------------------------------------------------------------------------- | ||
340 | |||
341 | 'selectAllOneTimePasswords': function(anEvent) { | ||
342 | var checkboxes; | ||
343 | var i,c; | ||
344 | |||
345 | anEvent.stop(); | ||
346 | checkboxes = this.oneTimePasswordCheckboxes(); | ||
347 | c = checkboxes.length; | ||
348 | for (i=0; i<c; i++) { | ||
349 | checkboxes[i].checked = true; | ||
350 | } | ||
351 | |||
352 | this.updateDeleteButtonStatus(); | ||
353 | }, | ||
354 | |||
355 | 'selectNoneOneTimePasswords': function(anEvent) { | ||
356 | var checkboxes; | ||
357 | var i,c; | ||
358 | |||
359 | anEvent.stop(); | ||
360 | checkboxes = this.oneTimePasswordCheckboxes(); | ||
361 | c = checkboxes.length; | ||
362 | for (i=0; i<c; i++) { | ||
363 | checkboxes[i].checked = false; | ||
364 | } | ||
365 | |||
366 | this.updateDeleteButtonStatus(); | ||
367 | }, | ||
368 | |||
369 | 'selectUsedOneTimePasswords': function(anEvent) { | ||
370 | var checkboxes; | ||
371 | var oneTimePasswordManager; | ||
372 | var i,c; | ||
373 | |||
374 | anEvent.stop(); | ||
375 | oneTimePasswordManager = this.user().oneTimePasswordManager(); | ||
376 | checkboxes = this.oneTimePasswordCheckboxes(); | ||
377 | c = checkboxes.length; | ||
378 | for (i=0; i<c; i++) { | ||
379 | var matchingOneTimePassword; | ||
380 | |||
381 | matchingOneTimePassword = oneTimePasswordManager.oneTimePasswordWithReference(checkboxes[i].name); | ||
382 | checkboxes[i].checked = matchingOneTimePassword.isExpired(); | ||
383 | } | ||
384 | |||
385 | this.updateDeleteButtonStatus(); | ||
386 | }, | ||
387 | |||
388 | 'selectUnusedOneTimePasswords': function(anEvent) { | ||
389 | var checkboxes; | ||
390 | var oneTimePasswordManager; | ||
391 | var i,c; | ||
392 | |||
393 | anEvent.stop(); | ||
394 | oneTimePasswordManager = this.user().oneTimePasswordManager(); | ||
395 | checkboxes = this.oneTimePasswordCheckboxes(); | ||
396 | c = checkboxes.length; | ||
397 | for (i=0; i<c; i++) { | ||
398 | var matchingOneTimePassword; | ||
399 | |||
400 | matchingOneTimePassword = oneTimePasswordManager.oneTimePasswordWithReference(checkboxes[i].name); | ||
401 | checkboxes[i].checked = !matchingOneTimePassword.isExpired(); | ||
402 | } | ||
403 | |||
404 | this.updateDeleteButtonStatus(); | ||
405 | }, | ||
406 | |||
407 | //------------------------------------------------------------------------- | ||
408 | |||
409 | 'handleCheckboxClick': function(anEvent) { | ||
410 | this.updateDeleteButtonStatus(); | ||
411 | }, | ||
412 | |||
413 | //------------------------------------------------------------------------- | ||
414 | |||
415 | 'deleteSelectedOneTimePasswords': function() { | ||
416 | var deferredResult; | ||
417 | var otpToDelete; | ||
418 | var i,c; | ||
419 | |||
420 | otpToDelete = this.checkedOneTimePasswordCheckboxes(); | ||
421 | c = otpToDelete.length; | ||
422 | for (i=0; i<c; i++) { | ||
423 | //MochiKit.Logging.logDebug("otp to delete: " + otpToDelete[i].name); | ||
424 | this.user().oneTimePasswordManager().deleteOneTimePasswordWithReference(otpToDelete[i].name); | ||
425 | }; | ||
426 | |||
427 | deferredResult = new MochiKit.Async.Deferred(); | ||
428 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("ActiveOTPPanel.deleteSelectedOneTimePasswords - 0: " + res); return res;}); | ||
429 | deferredResult.addCallback(Clipperz.PM.Components.MessageBox.showProgressPanel, MochiKit.Base.method(this.user().oneTimePasswordManager(), 'saveChanges'), null, null); | ||
430 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("ActiveOTPPanel.deleteSelectedOneTimePasswords - 1: " + res); return res;}); | ||
431 | deferredResult.addCallback(MochiKit.Base.method(this, 'render')); | ||
432 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("ActiveOTPPanel.deleteSelectedOneTimePasswords - 2: " + res); return res;}); | ||
433 | deferredResult.callback(); | ||
434 | }, | ||
435 | |||
436 | //------------------------------------------------------------------------- | ||
437 | |||
438 | 'user': function() { | ||
439 | return this._user; | ||
440 | }, | ||
441 | |||
442 | //------------------------------------------------------------------------- | ||
443 | |||
444 | 'shouldRender': function() { | ||
445 | return this._shouldRender; | ||
446 | }, | ||
447 | |||
448 | 'setShouldRender': function(aValue) { | ||
449 | this._shouldRender = aValue; | ||
450 | }, | ||
451 | |||
452 | 'tabSelectedHandler': function(anEvent) { | ||
453 | if ((this.shouldRender()) && (anEvent.source().selectedTab() == 'manageOTPTab')) { | ||
454 | this.render(); | ||
455 | this.setShouldRender(false); | ||
456 | } | ||
457 | }, | ||
458 | |||
459 | //------------------------------------------------------------------------- | ||
460 | |||
461 | 'deleteButton': function() { | ||
462 | return this._deleteButton; | ||
463 | }, | ||
464 | |||
465 | 'setDeleteButton': function(aValue) { | ||
466 | this._deleteButton = aValue; | ||
467 | }, | ||
468 | |||
469 | 'updateDeleteButtonStatus': function() { | ||
470 | if (this.checkedOneTimePasswordCheckboxes().length > 0) { | ||
471 | this.deleteButton().enable(); | ||
472 | } else { | ||
473 | this.deleteButton().disable(); | ||
474 | } | ||
475 | }, | ||
476 | |||
477 | //------------------------------------------------------------------------- | ||
478 | |||
479 | 'printButton': function() { | ||
480 | return this._printButton; | ||
481 | }, | ||
482 | |||
483 | 'setPrintButton': function(aValue) { | ||
484 | this._printButton = aValue; | ||
485 | }, | ||
486 | |||
487 | //------------------------------------------------------------------------- | ||
488 | __syntaxFix__: "syntax fix" | ||
489 | }); | ||
490 | |||
diff --git a/frontend/beta/js/Clipperz/PM/Components/Panels/AccountPanel.js b/frontend/beta/js/Clipperz/PM/Components/Panels/AccountPanel.js new file mode 100644 index 0000000..6b467d0 --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/Panels/AccountPanel.js | |||
@@ -0,0 +1,784 @@ | |||
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 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | ||
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | ||
31 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } | ||
32 | if (typeof(Clipperz.PM.Components.Panels) == 'undefined') { Clipperz.PM.Components.Panels = {}; } | ||
33 | |||
34 | //############################################################################# | ||
35 | |||
36 | Clipperz.PM.Components.Panels.AccountPanel = function(anElement, args) { | ||
37 | //MochiKit.Logging.logDebug(">>> new AccountPanel"); | ||
38 | args = args || {}; | ||
39 | |||
40 | Clipperz.PM.Components.Panels.AccountPanel.superclass.constructor.call(this, anElement, args); | ||
41 | |||
42 | Clipperz.NotificationCenter.register(null, 'setupDone', this, 'render'); | ||
43 | |||
44 | this._shouldLoadLoginHistory = true; | ||
45 | |||
46 | //this.render(); | ||
47 | //MochiKit.Logging.logDebug("<<< new AccountPanel"); | ||
48 | |||
49 | return this; | ||
50 | } | ||
51 | |||
52 | //============================================================================= | ||
53 | |||
54 | YAHOO.extendX(Clipperz.PM.Components.Panels.AccountPanel, Clipperz.PM.Components.Panels.BasePanel, { | ||
55 | |||
56 | 'toString': function() { | ||
57 | return "Clipperz.PM.Components.AccountPanel component"; | ||
58 | }, | ||
59 | |||
60 | //------------------------------------------------------------------------- | ||
61 | |||
62 | 'render': function() { | ||
63 | var errorMessageActor; | ||
64 | varchangePasswordButton; | ||
65 | var deleteAccountButton; | ||
66 | |||
67 | try { | ||
68 | //MochiKit.Logging.logDebug(">>> AccountPanel.render"); | ||
69 | Clipperz.NotificationCenter.unregister(this); | ||
70 | MochiKit.Signal.disconnectAllTo(this); | ||
71 | |||
72 | this.element().update(""); | ||
73 | Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'table', border:'0', cellspacing:'0', cellpadding:'0', children:[ | ||
74 | {tag:'tbody', children:[ | ||
75 | {tag:'tr', children:[ | ||
76 | {tag:'td', valign:'top', width:'200', children:[ | ||
77 | {tag:'ul', id:"accountSubMenu", cls:'subMenu', children:[ | ||
78 | {tag:'li', id:'changePassphraseTab', htmlString:Clipperz.PM.Strings['changePasswordTabLabel']}, | ||
79 | {tag:'li', id:'manageOTPTab', htmlString:Clipperz.PM.Strings['manageOTPTabLabel']}, | ||
80 | {tag:'li', id:'accountPreferencesTab', htmlString:Clipperz.PM.Strings['accountPreferencesLabel']}, | ||
81 | {tag:'li', id:'loginHistoryTab', htmlString:Clipperz.PM.Strings['accountLoginHistoryLabel']}, | ||
82 | {tag:'li', id:'deleteAccountTab', htmlString:Clipperz.PM.Strings['deleteAccountTabLabel']} | ||
83 | // {tag:'li', id:'paidAccountTab'), htmlString:Clipperz.PM.Strings['paidAccountTabLabel']} | ||
84 | ]} | ||
85 | ]}, | ||
86 | {tag:'td', valign:'top', children:[ | ||
87 | {tag:'ul', cls:'clipperzTabPanels', children:[ | ||
88 | {tag:'li', id:this.getId('changePassphrasePanel'), children:[ | ||
89 | {tag:'div', cls:'clipperzSubPanel', children:[ | ||
90 | {tag:'h5', htmlString:Clipperz.PM.Strings['changePasswordTabTitle']}, | ||
91 | {tag:'div', cls:'panelBody', id:'changePassphraseBlock', children:[ | ||
92 | {tag:'form', id:this.getId('changePassphraseForm'), children:[ | ||
93 | {tag:'h5', cls:'errorMessage', id:this.getId('changePassphrase_errorMessage')}, | ||
94 | {tag:'table', cls:'panelBody', children:[ | ||
95 | {tag:'tr', children:[ | ||
96 | {tag:'td', children:[ | ||
97 | {tag:'span', cls:'formLabel', htmlString:Clipperz.PM.Strings['changePasswordFormUsernameLabel']} | ||
98 | ]}, | ||
99 | {tag:'td', children:[ | ||
100 | {tag:'input', type:'text', name:'username', id:this.getId('changePassphrase_username')} | ||
101 | ]} | ||
102 | ]}, | ||
103 | {tag:'tr', children:[ | ||
104 | {tag:'td', children:[ | ||
105 | {tag:'span', cls:'formLabel', htmlString:Clipperz.PM.Strings['changePasswordFormOldPassphraseLabel']} | ||
106 | ]}, | ||
107 | {tag:'td', children:[ | ||
108 | {tag:'input', type:'password', name:'oldPassphrase', id:this.getId('changePassphrase_oldPassphrase')} | ||
109 | ]} | ||
110 | ]}, | ||
111 | {tag:'tr', children:[ | ||
112 | {tag:'td', children:[ | ||
113 | {tag:'span', cls:'formLabel', htmlString:Clipperz.PM.Strings['changePasswordFormNewPassphraseLabel']} | ||
114 | ]}, | ||
115 | {tag:'td', children:[ | ||
116 | {tag:'input', type:'password', name:'newPassphrase', id:this.getId('changePassphrase_newPassphrase')} | ||
117 | ]} | ||
118 | ]}, | ||
119 | {tag:'tr', children:[ | ||
120 | {tag:'td', children:[ | ||
121 | {tag:'span', cls:'formLabel', htmlString:Clipperz.PM.Strings['changePasswordFormRetypePassphraseLabel']} | ||
122 | ]}, | ||
123 | {tag:'td', children:[ | ||
124 | {tag:'input', type:'password', name:'renewPassphrase', id:this.getId('changePassphrase_renewPassphrase')} | ||
125 | ]} | ||
126 | ]}, | ||
127 | {tag:'tr', children:[ | ||
128 | {tag:'td', align:'right', children:[ | ||
129 | {tag:'input', type:'checkbox', id:this.getId('changePassphrase_safetyCheck')} | ||
130 | ]}, | ||
131 | {tag:'td', children:[ | ||
132 | {tag:'span', htmlString:Clipperz.PM.Strings['changePasswordFormSafetyCheckboxLabel']} | ||
133 | ]} | ||
134 | ]} | ||
135 | ]}, | ||
136 | {tag:'div', cls:'clipperzSubPanelButtonBox', children:[ | ||
137 | {tag:'div', id:this.getId('changePassphraseButton')} | ||
138 | ]} | ||
139 | ]} | ||
140 | ]} | ||
141 | ]} | ||
142 | ]}, | ||
143 | {tag:'li', id:this.getId('manageOTPPanel'), children:[ | ||
144 | {tag:'div', cls:'clipperzSubPanel', children:[ | ||
145 | {tag:'h5', htmlString:Clipperz.PM.Strings['manageOTPTabTitle']}, | ||
146 | {tag:'div', cls:'panelDescription', htmlString:Clipperz.PM.Strings['manageOTPTabDescription']}, | ||
147 | {tag:'div', id:'OTPComponent'} | ||
148 | ]} | ||
149 | ]}, | ||
150 | {tag:'li', id:this.getId('accountPreferencesPanel'), children:[ | ||
151 | {tag:'div', cls:'clipperzSubPanel', children:[ | ||
152 | {tag:'h5', htmlString:Clipperz.PM.Strings['accountPreferencesTabTitle']}, | ||
153 | {tag:'div', cls:'panelBody', id:this.getId('preferencesPanelBody')} | ||
154 | ]} | ||
155 | ]}, | ||
156 | {tag:'li', id:this.getId('loginHistoryAccountPanel'), children:[ | ||
157 | {tag:'div', cls:'clipperzSubPanel', children:[ | ||
158 | {tag:'h5', htmlString:Clipperz.PM.Strings['loginHistoryTabTitle']}, | ||
159 | {tag:'div', cls:'panelBody', id:'loginHistoryAccountBlock'} | ||
160 | ]} | ||
161 | ]}, | ||
162 | {tag:'li', id:this.getId('deleteAccountPanel'), children:[ | ||
163 | {tag:'div', cls:'clipperzSubPanel', children:[ | ||
164 | {tag:'h5', htmlString:Clipperz.PM.Strings['deleteAccountTabTitle']}, | ||
165 | |||
166 | {tag:'div', cls:'panelBody', id:'deleteAccountBlock', children:[ | ||
167 | {tag:'form', id:this.getId('deleteAccountForm'), children:[ | ||
168 | {tag:'h5', cls:'errorMessage', id:this.getId('deleteAccount_errorMessage')}, | ||
169 | {tag:'table', cls:'panelBody', children:[ | ||
170 | {tag:'tr', children:[ | ||
171 | {tag:'td', children:[ | ||
172 | {tag:'span', cls:'formLabel', htmlString:Clipperz.PM.Strings['deleteAccountFormUsernameLabel']} | ||
173 | ]}, | ||
174 | {tag:'td', children:[ | ||
175 | {tag:'input', type:'text', name:'username', id:this.getId('deleteAccount_username')} | ||
176 | ]} | ||
177 | ]}, | ||
178 | {tag:'tr', children:[ | ||
179 | {tag:'td', children:[ | ||
180 | {tag:'span', cls:'formLabel', htmlString:Clipperz.PM.Strings['deleteAccountFormPassphraseLabel']} | ||
181 | ]}, | ||
182 | {tag:'td', children:[ | ||
183 | {tag:'input', type:'password', name:'passphrase', id:this.getId('deleteAccount_passphrase')} | ||
184 | ]} | ||
185 | ]}, | ||
186 | {tag:'tr', children:[ | ||
187 | {tag:'td', align:'right', children:[ | ||
188 | {tag:'input', type:'checkbox', id:this.getId('deleteAccount_safetyCheck')} | ||
189 | ]}, | ||
190 | {tag:'td', children:[ | ||
191 | {tag:'span', htmlString:Clipperz.PM.Strings['deleteAccountFormSafetyCheckboxLabel']} | ||
192 | ]} | ||
193 | ]} | ||
194 | ]}, | ||
195 | {tag:'div', cls:'clipperzSubPanelButtonBox', children:[ | ||
196 | {tag:'div', id:this.getId('deleteAccountButton')} | ||
197 | ]} | ||
198 | ]} | ||
199 | ]} | ||
200 | ]} | ||
201 | ]} | ||
202 | /* | ||
203 | {tag:'li', id:this.getId('paidAccountPanel'), children:[ | ||
204 | {tag:'div', cls:'clipperzSubPanel', children:[ | ||
205 | {tag:'h5', htmlString:Clipperz.PM.Strings['upgradeAccountTabTitle']}, | ||
206 | {tag:'div', htmlString:Clipperz.PM.Strings['comingSoon']} | ||
207 | ]} | ||
208 | ]} | ||
209 | */ | ||
210 | ]} | ||
211 | ]} | ||
212 | ]} | ||
213 | ]} | ||
214 | ]}); | ||
215 | |||
216 | //MochiKit.Logging.logDebug("--- AccountPanel.render - 1"); | ||
217 | MochiKit.Signal.connect(this.getId('changePassphraseForm'), 'onkeydown', this, 'onkeydown'); | ||
218 | errorMessageActor = this.getActor('changePassphrase_errorMessage'); | ||
219 | errorMessageActor.setVisibilityMode(YAHOO.ext.Element.DISPLAY); | ||
220 | errorMessageActor.update("---"); | ||
221 | errorMessageActor.hide(); | ||
222 | changePasswordButton = new YAHOO.ext.Button(this.getDom('changePassphraseButton'), {text:Clipperz.PM.Strings['changePasswordFormSubmitLabel'], handler:this.doChangePassphrase, scope:this}); | ||
223 | |||
224 | //MochiKit.Logging.logDebug("--- AccountPanel.render - 2"); | ||
225 | |||
226 | MochiKit.Signal.connect(this.getId('deleteAccountForm'), 'onkeydown', this, 'onkeydown'); | ||
227 | errorMessageActor = this.getActor('deleteAccount_errorMessage'); | ||
228 | errorMessageActor.setVisibilityMode(YAHOO.ext.Element.DISPLAY); | ||
229 | errorMessageActor.update(Clipperz.PM.Strings['deleteAccountFormEmptyErrorMessage']); | ||
230 | errorMessageActor.hide(); | ||
231 | deleteAccountButton = new YAHOO.ext.Button(this.getDom('deleteAccountButton'), {text:Clipperz.PM.Strings['deleteAccountFormSubmitLabel'], handler:this.doDeleteAccount, scope:this}); | ||
232 | //MochiKit.Logging.logDebug("--- AccountPanel.render - 5"); | ||
233 | |||
234 | if (Clipperz.PM.Proxy.defaultProxy.isReadOnly()) { | ||
235 | this.getElement('changePassphraseForm').addClass('read-only'); | ||
236 | // this.getElement('accountPreferencesForm').addClass('read-only'); | ||
237 | this.getElement('deleteAccountForm').addClass('read-only'); | ||
238 | changePasswordButton.disable(); | ||
239 | deleteAccountButton.disable(); | ||
240 | } | ||
241 | //MochiKit.Logging.logDebug("--- AccountPanel.render - 6"); | ||
242 | |||
243 | new Clipperz.PM.Components.PasswordEntropyDisplay(this.getElement('changePassphrase_oldPassphrase')); | ||
244 | new Clipperz.PM.Components.PasswordEntropyDisplay(this.getElement('changePassphrase_newPassphrase')); | ||
245 | |||
246 | new Clipperz.PM.Components.OTP.MainComponent(YAHOO.ext.Element.get('OTPComponent'), {user:this.user()}); | ||
247 | |||
248 | this.tabPanelController().setUp(); | ||
249 | Clipperz.NotificationCenter.register(null, 'tabSelected', this, 'tabSelectedHandler'); | ||
250 | Clipperz.NotificationCenter.register(null, 'updatedPreferences', this, 'renderPreferences'); | ||
251 | Clipperz.NotificationCenter.register(null, 'switchLanguage', this, 'switchLanguageHandler'); | ||
252 | //MochiKit.Logging.logDebug("<<< AccountPanel.render"); | ||
253 | |||
254 | } catch(exception) { | ||
255 | MochiKit.Logging.logError("### " + exception); | ||
256 | throw exception; | ||
257 | } | ||
258 | }, | ||
259 | |||
260 | //------------------------------------------------------------------------- | ||
261 | |||
262 | 'tabPanelController': function() { | ||
263 | if (this._tabPanelController == null) { | ||
264 | var tabPanelControllerConfig; | ||
265 | |||
266 | tabPanelControllerConfig = {} | ||
267 | tabPanelControllerConfig['changePassphraseTab'] = this.getId('changePassphrasePanel'); | ||
268 | tabPanelControllerConfig['manageOTPTab'] = this.getId('manageOTPPanel'); | ||
269 | tabPanelControllerConfig['accountPreferencesTab'] = this.getId('accountPreferencesPanel'); | ||
270 | tabPanelControllerConfig['loginHistoryTab'] = this.getId('loginHistoryAccountPanel'); | ||
271 | tabPanelControllerConfig['deleteAccountTab'] = this.getId('deleteAccountPanel'); | ||
272 | // tabPanelControllerConfig['paidAccountTab'] = this.getId('paidAccountPanel'); | ||
273 | |||
274 | this._tabPanelController = new Clipperz.PM.Components.TabPanel.TabPanelController({ | ||
275 | name:'accountTabPanel', | ||
276 | config:tabPanelControllerConfig, | ||
277 | selectedTab:'changePassphraseTab' | ||
278 | }); | ||
279 | } | ||
280 | |||
281 | return this._tabPanelController; | ||
282 | }, | ||
283 | |||
284 | //------------------------------------------------------------------------- | ||
285 | |||
286 | 'doChangePassphrase': function() { | ||
287 | if (Clipperz.PM.Proxy.defaultProxy.isReadOnly() == false) { | ||
288 | varusername; | ||
289 | varoldPassphrase; | ||
290 | var newPassphrase; | ||
291 | var renewPassphrase; | ||
292 | var safetyCheck; | ||
293 | varareThereAnyErrors; | ||
294 | var errorMessageActor; | ||
295 | |||
296 | errorMessageActor = this.getActor('changePassphrase_errorMessage'); | ||
297 | |||
298 | areThereAnyErrors = false; | ||
299 | username = this.getDom('changePassphrase_username').value; | ||
300 | oldPassphrase= this.getDom('changePassphrase_oldPassphrase').value; | ||
301 | newPassphrase= this.getDom('changePassphrase_newPassphrase').value; | ||
302 | renewPassphrase= this.getDom('changePassphrase_renewPassphrase').value; | ||
303 | safetyCheck = this.getDom('changePassphrase_safetyCheck').checked; | ||
304 | |||
305 | if (this.user().username() != username) { | ||
306 | this.showFormErrorMessageAnimation(errorMessageActor, Clipperz.PM.Strings['changePasswordFormWrongUsernameWarning']); | ||
307 | this.getElement('changePassphrase_username').focus().dom.select(); | ||
308 | areThereAnyErrors = true; | ||
309 | } else if (this.user().passphrase() != oldPassphrase) { | ||
310 | this.showFormErrorMessageAnimation(errorMessageActor, Clipperz.PM.Strings['changePasswordFormWrongPassphraseWarning']); | ||
311 | this.getElement('changePassphrase_oldPassphrase').focus().dom.select(); | ||
312 | areThereAnyErrors = true; | ||
313 | } else if (newPassphrase != renewPassphrase) { | ||
314 | this.showFormErrorMessageAnimation(errorMessageActor, Clipperz.PM.Strings['changePasswordFormWrongRetypePassphraseWarning']); | ||
315 | this.getElement('changePassphrase_renewPassphrase').focus().dom.select(); | ||
316 | areThereAnyErrors = true; | ||
317 | } else if (safetyCheck != true) { | ||
318 | this.showFormErrorMessageAnimation(errorMessageActor, Clipperz.PM.Strings['changePasswordFormSafetyCheckWarning']); | ||
319 | this.getElement('changePassphrase_safetyCheck').focus(); | ||
320 | areThereAnyErrors = true; | ||
321 | } | ||
322 | |||
323 | if (areThereAnyErrors == false) { | ||
324 | errorMessageActor.hide(); | ||
325 | this.doChangePassphraseWithUsernameAndPassphrase(username, newPassphrase); | ||
326 | } | ||
327 | } | ||
328 | }, | ||
329 | |||
330 | //------------------------------------------------------------------------- | ||
331 | |||
332 | 'doChangePassphraseWithUsernameAndPassphrase': function(anUsername, aPassphrase) { | ||
333 | var deferredResult; | ||
334 | |||
335 | //MochiKit.Logging.logDebug(">>> AccountPanel.doChangePassphraseWithUsernameAndPassphrase - this.user: " + this.user()); | ||
336 | deferredResult = new MochiKit.Async.Deferred(); | ||
337 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug(" AccountPanel.doChangePassphraseWithUsernameAndPassphrase 1: " + res); return res;}); | ||
338 | deferredResult.addCallback(MochiKit.Base.method(Clipperz.PM.Components.MessageBox(), 'deferredShow'), | ||
339 | { | ||
340 | title:Clipperz.PM.Strings['changePasswordFormProgressDialogTitle'], | ||
341 | text:Clipperz.PM.Strings['changePasswordFormProgressDialogEmptyText'], | ||
342 | width:240, | ||
343 | showProgressBar:true, | ||
344 | showCloseButton:false, | ||
345 | steps:4 | ||
346 | }, | ||
347 | this.getDom('changePassphraseButton') | ||
348 | ); | ||
349 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug(" AccountPanel.doChangePassphraseWithUsernameAndPassphrase 2: " + res); return res;}); | ||
350 | deferredResult.addCallback(MochiKit.Base.method(this.user(), 'changeCredentials'), anUsername, aPassphrase); | ||
351 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug(" AccountPanel.doChangePassphraseWithUsernameAndPassphrase 3: " + res); return res;}); | ||
352 | deferredResult.addCallback(function() { | ||
353 | Clipperz.PM.Components.MessageBox().update({ | ||
354 | title:Clipperz.PM.Strings['changePasswordFormProgressDialogConnectedMessageTitle'], | ||
355 | text:Clipperz.PM.Strings['changePasswordFormProgressDialogConnectedMessageText'], | ||
356 | /*showProgressBar:false,*/ | ||
357 | step:'next' | ||
358 | }); | ||
359 | }); | ||
360 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug(" AccountPanel.doChangePassphraseWithUsernameAndPassphrase 4: " + res); return res;}); | ||
361 | deferredResult.addCallback(MochiKit.Async.wait, 1); | ||
362 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug(" AccountPanel.doChangePassphraseWithUsernameAndPassphrase 5: " + res); return res;}); | ||
363 | deferredResult.addCallback(function(anAccountPanel, res) { | ||
364 | Clipperz.PM.Components.MessageBox().hide(YAHOO.ext.Element.get('main')); | ||
365 | |||
366 | anAccountPanel.getDom('changePassphrase_username').value = ""; | ||
367 | anAccountPanel.getDom('changePassphrase_oldPassphrase').value = ""; | ||
368 | anAccountPanel.getElement('changePassphrase_oldPassphrase').focus(); | ||
369 | anAccountPanel.getDom('changePassphrase_newPassphrase').value = ""; | ||
370 | anAccountPanel.getElement('changePassphrase_newPassphrase').focus(); | ||
371 | anAccountPanel.getDom('changePassphrase_renewPassphrase').value = ""; | ||
372 | anAccountPanel.getDom('changePassphrase_safetyCheck').checked = false; | ||
373 | |||
374 | anAccountPanel.getElement('changePassphrase_username').focus(); | ||
375 | return res; | ||
376 | }, this); | ||
377 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug(" AccountPanel.doChangePassphraseWithUsernameAndPassphrase 6: " + res); return res;}); | ||
378 | deferredResult.addErrback(function() { | ||
379 | Clipperz.PM.Components.MessageBox().update({ | ||
380 | title:Clipperz.PM.Strings['changePasswordFormProgressDialogErrorMessageTitle'], | ||
381 | text:Clipperz.PM.Strings['changePasswordFormProgressDialogErrorMessageText'], | ||
382 | buttons:{'ok':"close"} | ||
383 | }); | ||
384 | }); | ||
385 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug(" AccountPanel.doChangePassphraseWithUsernameAndPassphrase 7: " + res); return res;}); | ||
386 | deferredResult.callback(); | ||
387 | |||
388 | //MochiKit.Logging.logDebug("<<< AccountPanel.doChangePassphraseWithUsernameAndPassphrase"); | ||
389 | }, | ||
390 | |||
391 | //------------------------------------------------------------------------- | ||
392 | |||
393 | 'doDeleteAccount': function() { | ||
394 | if (Clipperz.PM.Proxy.defaultProxy.isReadOnly() == false) { | ||
395 | varusername; | ||
396 | varpassphrase; | ||
397 | var safetyCheck; | ||
398 | varareThereAnyErrors; | ||
399 | var errorMessageActor; | ||
400 | |||
401 | errorMessageActor = this.getActor('deleteAccount_errorMessage'); | ||
402 | |||
403 | areThereAnyErrors = false; | ||
404 | username = this.getDom('deleteAccount_username').value; | ||
405 | passphrase= this.getDom('deleteAccount_passphrase').value; | ||
406 | safetyCheck = this.getDom('deleteAccount_safetyCheck').checked; | ||
407 | |||
408 | if (this.user().username() != username) { | ||
409 | this.showFormErrorMessageAnimation(errorMessageActor, Clipperz.PM.Strings['deleteAccountFormWrongUsernameWarning']); | ||
410 | this.getElement('deleteAccount_username').focus().dom.select(); | ||
411 | areThereAnyErrors = true; | ||
412 | } else if (this.user().passphrase() != passphrase) { | ||
413 | this.showFormErrorMessageAnimation(errorMessageActor, Clipperz.PM.Strings['deleteAccountFormWrongPassphraseWarning']); | ||
414 | this.getElement('deleteAccount_passphrase').focus().dom.select(); | ||
415 | areThereAnyErrors = true; | ||
416 | } else if (safetyCheck != true) { | ||
417 | this.showFormErrorMessageAnimation(errorMessageActor, Clipperz.PM.Strings['deleteAccountFormSafetyCheckWarning']); | ||
418 | this.getElement('deleteAccount_safetyCheck').focus(); | ||
419 | areThereAnyErrors = true; | ||
420 | } | ||
421 | |||
422 | if (areThereAnyErrors == false) { | ||
423 | var deferred; | ||
424 | |||
425 | deferred = new MochiKit.Async.Deferred(); | ||
426 | errorMessageActor.hide(); | ||
427 | |||
428 | deferred.addCallback(function() { | ||
429 | var deferredResult; | ||
430 | |||
431 | //TODO: if the form is submitted with the return key, the confirmation dialog is skipped!? | ||
432 | deferredResult = new MochiKit.Async.Deferred(); | ||
433 | Clipperz.PM.Components.MessageBox().deferredShow({ | ||
434 | title:Clipperz.PM.Strings['accountPanelDeletingAccountPanelConfirmationTitle'], | ||
435 | text:Clipperz.PM.Strings['accountPanelDeleteAccountPanelConfirmationText'], | ||
436 | width:240, | ||
437 | showProgressBar:false, | ||
438 | showCloseButton:false, | ||
439 | buttons:{ | ||
440 | 'yes':Clipperz.PM.Strings['accountPanelDeleteAccountPanelConfirmButtonLabel'], | ||
441 | 'no':Clipperz.PM.Strings['accountPanelDeleteAccountPanelDenyButtonLabel'] | ||
442 | }, | ||
443 | fn:MochiKit.Base.partial(function(aDeferred, aResult) { | ||
444 | if (aResult == 'yes') { | ||
445 | aDeferred.callback(aResult); | ||
446 | } else { | ||
447 | aDeferred.errback(aResult); | ||
448 | } | ||
449 | }, deferredResult) | ||
450 | }); | ||
451 | |||
452 | return deferredResult; | ||
453 | }); | ||
454 | deferred.addCallback(MochiKit.Base.method(Clipperz.PM.Components.MessageBox(), 'deferredShow'), | ||
455 | { | ||
456 | title:Clipperz.PM.Strings['accountPanelDeletingAccountPanelProgressTitle'], | ||
457 | text:Clipperz.PM.Strings['accountPanelDeletingAccountPanelProgressText'], | ||
458 | width:240, | ||
459 | showProgressBar:true, | ||
460 | showCloseButton:false | ||
461 | } | ||
462 | ); | ||
463 | deferred.addCallback(MochiKit.Base.method(this.user(), 'deleteAccountAction')); | ||
464 | deferred.addCallback(Clipperz.PM.exit, 'accountDeleted.html'); | ||
465 | deferred.addErrback(function(res) { | ||
466 | alert(res); | ||
467 | }) | ||
468 | deferred.callback(); | ||
469 | } | ||
470 | } | ||
471 | }, | ||
472 | |||
473 | //------------------------------------------------------------------------- | ||
474 | |||
475 | 'showFormErrorMessageAnimation': function(anActor, anErrorMessage, aCallback) { | ||
476 | anActor.update(anErrorMessage); | ||
477 | anActor.show(true); | ||
478 | anActor.play(aCallback); | ||
479 | }, | ||
480 | |||
481 | //------------------------------------------------------------------------- | ||
482 | |||
483 | 'onkeydown': function(anEvent) { | ||
484 | //MochiKit.Logging.logDebug(">>> onkeydown - " + anEvent.src().id); | ||
485 | if (anEvent.key().code == 13) { | ||
486 | anEvent.stop(); | ||
487 | |||
488 | if (anEvent.src() == this.getDom('changePassphraseForm')) { | ||
489 | this.doChangePassphrase(); | ||
490 | } else if (anEvent.src() == this.getDom('deleteAccountForm')) { | ||
491 | this.doDeleteAccount(); | ||
492 | } else { | ||
493 | } | ||
494 | |||
495 | } | ||
496 | }, | ||
497 | |||
498 | //------------------------------------------------------------------------- | ||
499 | |||
500 | 'selectSelectedLanguageOption': function() { | ||
501 | varuserSelectedLanguage; | ||
502 | |||
503 | userSelectedLanguage = this.user().preferences().preferredLanguage() || "default"; | ||
504 | MochiKit.Base.filter(function(anOption) {return (anOption.value == userSelectedLanguage)}, this.getDom('languageSelector').childNodes)[0].selected = true; | ||
505 | }, | ||
506 | |||
507 | //------------------------------------------------------------------------- | ||
508 | |||
509 | 'doSaveUserPreferences': function() { | ||
510 | var selectedLanguage; | ||
511 | var showDonationReminderDialog; | ||
512 | // var disableUnsecureFaviconLoadingForIE; | ||
513 | |||
514 | //MochiKit.Logging.logDebug(">>> AccountPanel.doSaveUserPreferences"); | ||
515 | selectedLanguage = this.getDom('languageSelector').value; | ||
516 | if (selectedLanguage == "default") { | ||
517 | selectedLanguage = null; | ||
518 | } | ||
519 | this.user().preferences().setPreferredLanguage(selectedLanguage); | ||
520 | |||
521 | showDonationReminderDialog = this.getDom('showDonationReminderCheckbox').checked; | ||
522 | this.user().preferences().setShouldShowDonationPanel(showDonationReminderDialog); | ||
523 | |||
524 | // disableUnsecureFaviconLoadingForIE = this.getDom('disableFaviconForIECheckbox').checked; | ||
525 | // this.user().preferences().setDisableUnsecureFaviconLoadingForIE(disableUnsecureFaviconLoadingForIE); | ||
526 | |||
527 | this.user().preferences().saveChanges(this.getDom('saveUserPreferences')); | ||
528 | }, | ||
529 | |||
530 | 'doCancelUserPreferences': function() { | ||
531 | this.renderPreferences(); | ||
532 | }, | ||
533 | |||
534 | //'switchLanguage': function(anEvent) { | ||
535 | // Clipperz.PM.Strings.Languages.setSelectedLanguage(anEvent.src().value); | ||
536 | //}, | ||
537 | |||
538 | //------------------------------------------------------------------------- | ||
539 | |||
540 | 'renderLoginHistory': function() { | ||
541 | var element; | ||
542 | |||
543 | //MochiKit.Logging.logDebug(">>> AccountPanel.renderLoginHistory"); | ||
544 | element = YAHOO.ext.Element.get('loginHistoryAccountBlock'); | ||
545 | |||
546 | if (Clipperz.PM.Proxy.defaultProxy.isReadOnly()) { | ||
547 | element.update(""); | ||
548 | this.domHelper().append(element, {tag:'div', cls:'loginHistoryReadOnlyMessage', htmlString:Clipperz.PM.Strings['loginHistoryReadOnlyMessage']}); | ||
549 | } else { | ||
550 | var deferredResult; | ||
551 | |||
552 | deferredResult = new MochiKit.Async.Deferred(); | ||
553 | deferredResult.addCallback(MochiKit.Base.bind(function(anElement) { | ||
554 | anElement.update(""); | ||
555 | Clipperz.YUI.DomHelper.append(anElement, {tag:'div', cls:'loadingMessage', htmlString:Clipperz.PM.Strings['loginHistoryLoadingMessage']}); | ||
556 | }, this), element); | ||
557 | deferredResult.addCallback(MochiKit.Base.method(this.user(), 'loadLoginHistory')); | ||
558 | deferredResult.addCallback(MochiKit.Base.bind(function(anElement, aResult) { | ||
559 | var loginListItems; | ||
560 | var tBodyElement; | ||
561 | var imageExtension; | ||
562 | var now; | ||
563 | var i, c; | ||
564 | |||
565 | loginListItems = aResult; | ||
566 | //MochiKit.Logging.logDebug("=== loginListItems: " + Clipperz.Base.serializeJSON(loginListItems)); | ||
567 | imageExtension = (Clipperz_IEisBroken == true) ? 'gif': 'png'; | ||
568 | |||
569 | now = new Date(); | ||
570 | anElement.update(""); | ||
571 | Clipperz.YUI.DomHelper.append(anElement, {tag:'div', cls:'panelDescription', htmlString:Clipperz.PM.Strings['loginHistoryLoadedMessage']}); | ||
572 | Clipperz.YUI.DomHelper.append(anElement, {tag:'table', id:'loginHistoryTable', cellspacing:'0', cellpadding:'2', border:'0', children:[ | ||
573 | {tag:'tbody', id:this.getId('loginHistoryTBody'), children:[]} | ||
574 | ]}); | ||
575 | //# Clipperz.YUI.DomHelper.append(anElement, {tag:'div', id:'loginHistoryFooter', children:[ | ||
576 | Clipperz.YUI.DomHelper.append(anElement, {tag:'div', cls:'clipperzSubPanelButtonBox', children:[ | ||
577 | {tag:'div', id:this.getId('reloadHistoryButton')} | ||
578 | ]}); | ||
579 | |||
580 | new YAHOO.ext.Button(this.getDom('reloadHistoryButton'), {text:Clipperz.PM.Strings['loginHistoryReloadButtonLabel'], handler:this.reloadHistory, scope:this}); | ||
581 | |||
582 | tBodyElement = this.getElement('loginHistoryTBody'); | ||
583 | c = loginListItems.length; | ||
584 | for (i=0; i<c; i++) { | ||
585 | var ip; | ||
586 | var date; | ||
587 | var mainText; | ||
588 | |||
589 | date = Clipperz.PM.Date.parseDateWithUTCFormat(loginListItems[i]['date']); | ||
590 | |||
591 | if (loginListItems[i]['isCurrent'] === true) { | ||
592 | mainText ={tag:'div', cls:'currentSession', htmlString:Clipperz.PM.Strings['loginHistoryCurrentSessionText']} | ||
593 | } else { | ||
594 | mainText = {tag:'div', cls:'elapsedTime', html:Clipperz.PM.Date.getElapsedTimeDescription(date)} | ||
595 | } | ||
596 | |||
597 | if (loginListItems[i]['connectionType'] == "ONE_TIME_PASSPHRASE") { | ||
598 | optionalInfo = [ | ||
599 | {tag:'span', html:"OTP"} | ||
600 | ]; | ||
601 | } else { | ||
602 | optionalInfo = []; | ||
603 | } | ||
604 | |||
605 | ip = (loginListItems[i]['ip'].match(/^\d{1,3}(.\d{1,3}){3}$/)) ? loginListItems[i]['ip'] : Clipperz.PM.Strings['unknown_ip']; | ||
606 | Clipperz.YUI.DomHelper.append(tBodyElement, {tag:'tr', children:[ | ||
607 | {tag:'td', cls:'loginHistoryValues', valign:'top', children:[ | ||
608 | mainText, | ||
609 | {tag:'div', cls:'fullDate', html:Clipperz.PM.Date.formatDateWithTemplate(date, Clipperz.PM.Strings['fullDate_format'])}, | ||
610 | {tag:'div', cls:'loginHistoryIP', children:[ | ||
611 | {tag:'span', cls:'loginHistoryIPLabel', htmlString:Clipperz.PM.Strings['loginHistoryIPLabel']}, | ||
612 | {tag:'span', cls:'loginHistoryIPValue', html:ip} | ||
613 | ]} | ||
614 | ]}, | ||
615 | {tag:'td', cls:'loginHistoryCountry', valign:'top', children:optionalInfo}, | ||
616 | {tag:'td', cls:'loginHistoryCountry', valign:'top', align:'center', children:[ | ||
617 | {tag:'img', title:Clipperz.PM.Strings['countries'][loginListItems[i]['country']], cls:'flag', src:Clipperz.PM.Strings['icons_baseUrl'] + "/flags/" + loginListItems[i]['country'].toLowerCase() + "." + imageExtension, width:'32', height:'32'} | ||
618 | // {tag:'span', cls:'label', htmlString:Clipperz.PM.Strings['countries'][loginListItems[i]['country']]} | ||
619 | ]}, | ||
620 | {tag:'td', cls:'loginHistoryBrowser', valign:'top', align:'center', children:[ | ||
621 | {tag:'img', title:Clipperz.PM.Strings['browsers'][loginListItems[i]['browser']], cls:'browser', src:Clipperz.PM.Strings['icons_baseUrl'] + "/browsers/" + loginListItems[i]['browser'].toLowerCase() + "." + imageExtension, width:'32', height:'32'} | ||
622 | // {tag:'span', cls:'label', htmlString:Clipperz.PM.Strings['browsers'][loginListItems[i]['browser']]} | ||
623 | ]}, | ||
624 | {tag:'td', cls:'loginHistoryOperatingSystem', valign:'top', align:'center', children:[ | ||
625 | {tag:'img', title:Clipperz.PM.Strings['operatingSystems'][loginListItems[i]['operatingSystem']], cls:'operatingSystem', src:Clipperz.PM.Strings['icons_baseUrl'] + "/operatingSystems/" + loginListItems[i]['operatingSystem'].toLowerCase() + "." + imageExtension, width:'32', height:'32'} | ||
626 | // {tag:'span', cls:'label', htmlString:Clipperz.PM.Strings['operatingSystems'][loginListItems[i]['operatingSystem']]} | ||
627 | ]} | ||
628 | ]}); | ||
629 | } | ||
630 | |||
631 | Clipperz.Style.applyZebraStylesToTable('loginHistoryTable'); | ||
632 | }, this), element); | ||
633 | |||
634 | deferredResult.callback(); | ||
635 | } | ||
636 | //MochiKit.Logging.logDebug("<<< AccountPanel.renderLoginHistory"); | ||
637 | }, | ||
638 | |||
639 | //------------------------------------------------------------------------- | ||
640 | |||
641 | 'renderPreferences': function() { | ||
642 | var saveUserPreferencesButton; | ||
643 | var cancelUserPreferencesButton; | ||
644 | var preferencedPanelBodyElement; | ||
645 | |||
646 | preferencedPanelBodyElement = this.getElement('preferencesPanelBody'); | ||
647 | |||
648 | preferencedPanelBodyElement.update(""); | ||
649 | Clipperz.YUI.DomHelper.append(preferencedPanelBodyElement, | ||
650 | {tag:'form', id:this.getId('accountPreferencesForm'), children:[ | ||
651 | {tag:'table', cls:'panelBody', children:[ | ||
652 | {tag:'tr', cls:'openPreferenceBlock', children:[ | ||
653 | {tag:'td', children:[ | ||
654 | {tag:'div', cls:'preferenceBlockTitle', htmlString:Clipperz.PM.Strings['accountPreferencesLanguageTitle']}, | ||
655 | {tag:'div', cls:'panelDescription', htmlString:Clipperz.PM.Strings['accountPreferencesLanguageDescription']}, | ||
656 | {tag:'div', cls:'panelDescription', children:[ | ||
657 | {tag:'select', | ||
658 | id:this.getId('languageSelector'), | ||
659 | children:MochiKit.Base.concat([{tag:'option', value:"default", html:"---"}], Clipperz.PM.Strings['loginPanelSwitchLanguageSelectOptions']) | ||
660 | } | ||
661 | ]} | ||
662 | ]} | ||
663 | ]}, | ||
664 | {tag:'tr', cls:'openPreferenceBlock', children:[ | ||
665 | {tag:'td', children:[ | ||
666 | {tag:'div', cls:'preferenceBlockTitle', htmlString:Clipperz.PM.Strings['showDonationReminderPanelTitle']}, | ||
667 | {tag:'table', cellpadding:'0', cellspacing:'0', children:[ | ||
668 | {tag:'tbody', children:[ | ||
669 | {tag:'tr', children:[ | ||
670 | {tag:'td', valign:'top', children:[ | ||
671 | {tag:'div', cls:'panelDescription', children:[ | ||
672 | {tag:'input', type:'checkbox', id:this.getId('showDonationReminderCheckbox')} | ||
673 | ]} | ||
674 | ]}, | ||
675 | {tag:'td', valign:'top', children:[ | ||
676 | {tag:'div', cls:'panelDescription', htmlString:Clipperz.PM.Strings['showDonationReminderPanelDescription']} | ||
677 | ]} | ||
678 | ]} | ||
679 | ]} | ||
680 | ]} | ||
681 | ]} | ||
682 | ]}//, | ||
683 | /* | ||
684 | {tag:'tr', cls:'openPreferenceBlock', children:[ | ||
685 | {tag:'td', children:[ | ||
686 | {tag:'div', cls:'preferenceBlockTitle', htmlString:Clipperz.PM.Strings['disableFaviconForIETitle']}, | ||
687 | {tag:'table', cellpadding:'0', cellspacing:'0', children:[ | ||
688 | {tag:'tbody', children:[ | ||
689 | {tag:'tr', children:[ | ||
690 | {tag:'td', valign:'top', children:[ | ||
691 | {tag:'div', cls:'panelDescription', children:[ | ||
692 | {tag:'input', type:'checkbox', id:this.getId('disableFaviconForIECheckbox')} | ||
693 | ]} | ||
694 | ]}, | ||
695 | {tag:'td', valign:'top', children:[ | ||
696 | {tag:'div', cls:'panelDescription', children:Clipperz.PM.Strings['disableFaviconForIEDescriptionConfig']} | ||
697 | ]} | ||
698 | ]} | ||
699 | ]} | ||
700 | ]} | ||
701 | ]} | ||
702 | ]}, | ||
703 | */ | ||
704 | // {tag:'tr', cls:'openPreferenceBlock', children:[ | ||
705 | // {tag:'td', children:[ | ||
706 | // {tag:'div', cls:'preferenceBlockTitle', htmlString:Clipperz.PM.Strings['accountPreferencesInterfaceTitle']}, | ||
707 | // {tag:'div', cls:'panelDescription', children:Clipperz.PM.Strings['accountPreferencesInterfaceDescriptionConfig']} | ||
708 | // ]} | ||
709 | // ]} | ||
710 | ]}, | ||
711 | {tag:'div', cls:'clipperzSubPanelButtonBox', children:[ | ||
712 | {tag:'table', border:'0', cellspacing:'0', cellpadding:'0', children:[ | ||
713 | {tag:'tbody', children:[ | ||
714 | {tag:'tr', children:[ | ||
715 | {tag:'td', width:'100', align:'right', cls:'newRecordPanelButtonTD', children:[ | ||
716 | {tag:'div', id:this.getId('saveUserPreferences')} | ||
717 | ]}, | ||
718 | {tag:'td', width:'10', html:" "}, | ||
719 | {tag:'td', cls:'newRecordPanelButtonTD', children:[ | ||
720 | {tag:'div', id:this.getId('cancelUserPreferences')} | ||
721 | ]} | ||
722 | ]} | ||
723 | ]} | ||
724 | ]} | ||
725 | ]} | ||
726 | ]} | ||
727 | ); | ||
728 | |||
729 | this.selectSelectedLanguageOption(); | ||
730 | if (this.user().preferences().shouldShowDonationPanel()) { | ||
731 | this.getDom('showDonationReminderCheckbox').checked = true; | ||
732 | } | ||
733 | // if (this.user().preferences().disableUnsecureFaviconLoadingForIE()) { | ||
734 | // this.getDom('disableFaviconForIECheckbox').checked = true; | ||
735 | // } | ||
736 | |||
737 | //MochiKit.Logging.logDebug("--- AccountPanel.render - 3"); | ||
738 | //# saveUserPreferencesButton = new YAHOO.ext.Button(this.getDom('saveUserPreferences'), {text:Clipperz.PM.Strings['saveUserPreferencesFormSubmitLabel'], handler:this.doSaveUserPreferences, scope:this}); | ||
739 | saveUserPreferencesButton = new YAHOO.ext.Button(this.getDom('saveUserPreferences'), {text:'-----------------', handler:this.doSaveUserPreferences, scope:this}); | ||
740 | saveUserPreferencesButton.setText(Clipperz.PM.Strings['saveUserPreferencesFormSubmitLabel']); | ||
741 | //# cancelUserPreferencesButton = new YAHOO.ext.Button(this.getDom('cancelUserPreferences'), {text:Clipperz.PM.Strings['cancelUserPreferencesFormSubmitLabel'], handler:this.doCancelUserPreferences, scope:this}); | ||
742 | cancelUserPreferencesButton = new YAHOO.ext.Button(this.getDom('cancelUserPreferences'), {text:'-----------------', handler:this.doCancelUserPreferences, scope:this}); | ||
743 | cancelUserPreferencesButton.setText(Clipperz.PM.Strings['cancelUserPreferencesFormSubmitLabel']); | ||
744 | //MochiKit.Logging.logDebug("--- AccountPanel.render - 4"); | ||
745 | |||
746 | if (Clipperz.PM.Proxy.defaultProxy.isReadOnly()) { | ||
747 | this.getElement('accountPreferencesForm').addClass('read-only'); | ||
748 | saveUserPreferencesButton.disable(); | ||
749 | cancelUserPreferencesButton.disable(); | ||
750 | } | ||
751 | |||
752 | }, | ||
753 | |||
754 | //------------------------------------------------------------------------- | ||
755 | |||
756 | 'reloadHistory': function() { | ||
757 | this.setShouldLoadLoginHistory(true); | ||
758 | this.renderLoginHistory(); | ||
759 | }, | ||
760 | |||
761 | 'shouldLoadLoginHistory': function() { | ||
762 | return this._shouldLoadLoginHistory; | ||
763 | }, | ||
764 | |||
765 | 'setShouldLoadLoginHistory': function(aValue) { | ||
766 | this._shouldLoadLoginHistory = aValue; | ||
767 | }, | ||
768 | |||
769 | 'tabSelectedHandler': function(anEvent) { | ||
770 | if (anEvent.parameters() == 'accountPreferencesTab') { | ||
771 | this.renderPreferences(); | ||
772 | } | ||
773 | |||
774 | if ((this.shouldLoadLoginHistory()) && (anEvent.parameters() == 'loginHistoryTab')) { | ||
775 | this.renderLoginHistory(); | ||
776 | this.setShouldLoadLoginHistory(false); | ||
777 | } | ||
778 | }, | ||
779 | |||
780 | //------------------------------------------------------------------------- | ||
781 | __syntaxFix__: "syntax fix" | ||
782 | |||
783 | }); | ||
784 | |||
diff --git a/frontend/beta/js/Clipperz/PM/Components/Panels/BasePanel.js b/frontend/beta/js/Clipperz/PM/Components/Panels/BasePanel.js new file mode 100644 index 0000000..bf60f45 --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/Panels/BasePanel.js | |||
@@ -0,0 +1,96 @@ | |||
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 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | ||
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | ||
31 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } | ||
32 | if (typeof(Clipperz.PM.Components.Panels) == 'undefined') { Clipperz.PM.Components.Panels = {}; } | ||
33 | |||
34 | //var _Clipperz_PM_Components_Panels_base_id_ = 0; | ||
35 | |||
36 | //############################################################################# | ||
37 | |||
38 | Clipperz.PM.Components.Panels.BasePanel = function(anElement, args) { | ||
39 | args = args || {}; | ||
40 | |||
41 | Clipperz.PM.Components.Panels.BasePanel.superclass.constructor.call(this, anElement, args); | ||
42 | |||
43 | this._user = args.user || null; | ||
44 | this._delegate = args.delegate || null; | ||
45 | this._tabPanelController = null; | ||
46 | //Clipperz.NotificationCenter.register(null, 'switchLanguage', this, 'switchLanguageHandler'); | ||
47 | |||
48 | //this._ids = {}; | ||
49 | |||
50 | return this; | ||
51 | } | ||
52 | |||
53 | //============================================================================= | ||
54 | |||
55 | YAHOO.extendX(Clipperz.PM.Components.Panels.BasePanel, Clipperz.PM.Components.BaseComponent, { | ||
56 | |||
57 | 'toString': function() { | ||
58 | return "Clipperz.PM.Components.Panels.BasePanel component"; | ||
59 | }, | ||
60 | |||
61 | //------------------------------------------------------------------------- | ||
62 | |||
63 | 'user': function() { | ||
64 | return this._user; | ||
65 | }, | ||
66 | |||
67 | 'setUser': function(aValue) { | ||
68 | this._user = aValue; | ||
69 | }, | ||
70 | |||
71 | //------------------------------------------------------------------------- | ||
72 | |||
73 | 'delegate': function() { | ||
74 | return this._delegate; | ||
75 | }, | ||
76 | |||
77 | 'setDelegate': function(aValue) { | ||
78 | this._delegate = aValue; | ||
79 | }, | ||
80 | |||
81 | //------------------------------------------------------------------------- | ||
82 | |||
83 | 'tabPanelController': function() { | ||
84 | return this._tabPanelController; | ||
85 | }, | ||
86 | |||
87 | 'switchLanguageHandler': function() { | ||
88 | //MochiKit.Logging.logDebug(">>> BasePanel.switchLanguageHandler [" + this.toString() + "]"); | ||
89 | this.render(); | ||
90 | //MochiKit.Logging.logDebug("<<< BasePanel.switchLanguageHandler [" + this.toString() + "]"); | ||
91 | }, | ||
92 | |||
93 | //------------------------------------------------------------------------- | ||
94 | __syntaxFix__: "syntax fix" | ||
95 | |||
96 | }); | ||
diff --git a/frontend/beta/js/Clipperz/PM/Components/Panels/ContactsPanel.js b/frontend/beta/js/Clipperz/PM/Components/Panels/ContactsPanel.js new file mode 100644 index 0000000..f0eb9c8 --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/Panels/ContactsPanel.js | |||
@@ -0,0 +1,105 @@ | |||
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 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | ||
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | ||
31 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } | ||
32 | if (typeof(Clipperz.PM.Components.Panels) == 'undefined') { Clipperz.PM.Components.Panels = {}; } | ||
33 | |||
34 | //############################################################################# | ||
35 | |||
36 | Clipperz.PM.Components.Panels.ContactsPanel = function(anElement, args) { | ||
37 | args = args || {}; | ||
38 | |||
39 | Clipperz.PM.Components.Panels.ContactsPanel.superclass.constructor.call(this, anElement, args); | ||
40 | |||
41 | this.render(); | ||
42 | |||
43 | return this; | ||
44 | } | ||
45 | |||
46 | //============================================================================= | ||
47 | |||
48 | YAHOO.extendX(Clipperz.PM.Components.Panels.ContactsPanel, Clipperz.PM.Components.Panels.BasePanel, { | ||
49 | |||
50 | 'toString': function() { | ||
51 | return "Clipperz.PM.Components.ContactsPanel component"; | ||
52 | }, | ||
53 | |||
54 | //------------------------------------------------------------------------- | ||
55 | |||
56 | 'render': function() { | ||
57 | // var tabPanelControllerConfig; | ||
58 | |||
59 | Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'table', border:'0', cellspacing:'0', cellpadding:'0', children:[ | ||
60 | {tag:'tbody', children:[ | ||
61 | {tag:'tr', children:[ | ||
62 | {tag:'td', valign:'top', width:'200', children:[ | ||
63 | {tag:'ul', id:"dataSubMenu", cls:'subMenu', children:[ | ||
64 | {tag:'li', id:this.getId('contacts'), htmlString:Clipperz.PM.Strings['contactsTabLabel']}, | ||
65 | ]} | ||
66 | ]}, | ||
67 | {tag:'td', valign:'top', children:[ | ||
68 | {tag:'ul', cls:'clipperzTabPanels', children:[ | ||
69 | {tag:'li', id:this.getId('contactsPanel'), children:[ | ||
70 | {tag:'div', cls:'clipperzSubPanel', children:[ | ||
71 | {tag:'h5', htmlString:Clipperz.PM.Strings['contactsTabTitle']}, | ||
72 | {tag:'div', htmlString:Clipperz.PM.Strings['comingSoon']} | ||
73 | ]} | ||
74 | ]} | ||
75 | ]} | ||
76 | ]} | ||
77 | ]} | ||
78 | ]} | ||
79 | ]}); | ||
80 | |||
81 | // tabPanelControllerConfig = {} | ||
82 | // tabPanelControllerConfig[this.getId('contacts')] = this.getId('contactsPanel'); | ||
83 | // new Clipperz.PM.Components.TabPanel.TabPanelController({ config:tabPanelControllerConfig, selectedTab:this.getId('contacts') }); | ||
84 | this.tabPanelController().setUp(); | ||
85 | }, | ||
86 | |||
87 | //------------------------------------------------------------------------- | ||
88 | |||
89 | 'tabPanelController': function() { | ||
90 | if (this._tabPanelController == null) { | ||
91 | var tabPanelControllerConfig; | ||
92 | |||
93 | tabPanelControllerConfig = {} | ||
94 | tabPanelControllerConfig[this.getId('contacts')] = this.getId('contactsPanel'); | ||
95 | this._tabPanelController = new Clipperz.PM.Components.TabPanel.TabPanelController({ config:tabPanelControllerConfig, selectedTab:this.getId('contacts') }); | ||
96 | } | ||
97 | |||
98 | return this._tabPanelController; | ||
99 | }, | ||
100 | |||
101 | //------------------------------------------------------------------------- | ||
102 | __syntaxFix__: "syntax fix" | ||
103 | |||
104 | }); | ||
105 | |||
diff --git a/frontend/beta/js/Clipperz/PM/Components/Panels/DataPanel.js b/frontend/beta/js/Clipperz/PM/Components/Panels/DataPanel.js new file mode 100644 index 0000000..759903f --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/Panels/DataPanel.js | |||
@@ -0,0 +1,486 @@ | |||
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 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | ||
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | ||
31 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } | ||
32 | if (typeof(Clipperz.PM.Components.Panels) == 'undefined') { Clipperz.PM.Components.Panels = {}; } | ||
33 | |||
34 | //############################################################################# | ||
35 | |||
36 | Clipperz.PM.Components.Panels.DataPanel = function(anElement, args) { | ||
37 | args = args || {}; | ||
38 | |||
39 | Clipperz.PM.Components.Panels.DataPanel.superclass.constructor.call(this, anElement, args); | ||
40 | |||
41 | this._progressWidth = 400; | ||
42 | |||
43 | |||
44 | this.render(); | ||
45 | |||
46 | return this; | ||
47 | } | ||
48 | |||
49 | //============================================================================= | ||
50 | |||
51 | YAHOO.extendX(Clipperz.PM.Components.Panels.DataPanel, Clipperz.PM.Components.Panels.BasePanel, { | ||
52 | |||
53 | 'toString': function() { | ||
54 | return "Clipperz.PM.Components.DataPanel component"; | ||
55 | }, | ||
56 | |||
57 | //------------------------------------------------------------------------- | ||
58 | |||
59 | 'render': function() { | ||
60 | MochiKit.Signal.disconnectAllTo(this); | ||
61 | Clipperz.NotificationCenter.unregister(this); | ||
62 | this.element().update(""); | ||
63 | |||
64 | Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'table', border:'0', cellspacing:'0', cellpadding:'0', children:[ | ||
65 | {tag:'tbody', children:[ | ||
66 | {tag:'tr', children:[ | ||
67 | {tag:'td', valign:'top', width:'200', children:[ | ||
68 | {tag:'ul', id:"dataSubMenu", cls:'subMenu', children:[ | ||
69 | {tag:'li', id:'offlineCopyTab', htmlString:Clipperz.PM.Strings['offlineCopyTabLabel']}, | ||
70 | {tag:'li', id:'sharingTab', htmlString:Clipperz.PM.Strings['sharingTabLabel']}, | ||
71 | {tag:'li', id:'importTab', htmlString:Clipperz.PM.Strings['importTabLabel']}, | ||
72 | {tag:'li', id:'printingTab', htmlString:Clipperz.PM.Strings['printingTabLabel']} | ||
73 | ]} | ||
74 | ]}, | ||
75 | {tag:'td', valign:'top', children:[ | ||
76 | {tag:'ul', cls:'clipperzTabPanels', children:[ | ||
77 | {tag:'li', id:this.getId('offlineCopyPanel'), children:[ | ||
78 | {tag:'div', cls:'clipperzSubPanel', children:[ | ||
79 | {tag:'h5', htmlString:Clipperz.PM.Strings['offlineCopyTabTitle']}, | ||
80 | {tag:'div', cls:'panelDescription', htmlString:Clipperz.PM.Strings['offlineCopyTabDescription']}, | ||
81 | {tag:'div', id:this.getId('offlineCopyLinkBox'), children:[ | ||
82 | {tag:'a', id:'offlineCopyLink', href:'#', htmlString:Clipperz.PM.Strings['offlineCopyDownloadLinkLabel']} | ||
83 | ]}, | ||
84 | {tag:'div', id:this.getId('offlineCopyLinkBox_read-only'), children:[ | ||
85 | {tag:'span', cls:'read-only', htmlString:Clipperz.PM.Strings['offlineCopyDownloadLinkLabel']} | ||
86 | ]} | ||
87 | ]} | ||
88 | ]}, | ||
89 | {tag:'li', id:this.getId('sharingPanel'), children:[ | ||
90 | {tag:'div', cls:'clipperzSubPanel', children:[ | ||
91 | {tag:'h5', htmlString:Clipperz.PM.Strings['sharingTabTitle']}, | ||
92 | {tag:'div', cls:'panelDescription', htmlString:Clipperz.PM.Strings['sharingTabDescription']} | ||
93 | ]} | ||
94 | ]}, | ||
95 | {tag:'li', id:this.getId('importPanel'), children:[ | ||
96 | {tag:'div', cls:'clipperzSubPanel', children:[ | ||
97 | {tag:'div', id:this.getId('importPanelMainComponent')} | ||
98 | ]} | ||
99 | ]}, | ||
100 | {tag:'li', id:this.getId('printingPanel'), children:[ | ||
101 | {tag:'div', cls:'clipperzSubPanel', children:[ | ||
102 | {tag:'h5', htmlString:Clipperz.PM.Strings['printingTabTitle']}, | ||
103 | |||
104 | {tag:'div', cls:'panelDescription', htmlString:Clipperz.PM.Strings['printingTabDescription']}, | ||
105 | {tag:'div', id:this.getId('printingLinkBox'), children:[ | ||
106 | {tag:'a', id:'printingLink', href:'#', htmlString:Clipperz.PM.Strings['printingLinkLabel']} | ||
107 | ]}, | ||
108 | |||
109 | {tag:'hr'}, | ||
110 | |||
111 | {tag:'div', cls:'panelDescription', htmlString:Clipperz.PM.Strings['exportTabDescription']}, | ||
112 | {tag:'div', id:this.getId('exportLinkBox'), children:[ | ||
113 | {tag:'a', id:'exportLink', href:'#', htmlString:Clipperz.PM.Strings['exportLinkLabel']} | ||
114 | ]} | ||
115 | ]} | ||
116 | ]} | ||
117 | ]} | ||
118 | ]} | ||
119 | ]} | ||
120 | ]} | ||
121 | ]}); | ||
122 | |||
123 | this.tabPanelController().setUp(); | ||
124 | |||
125 | if (Clipperz.PM.Proxy.defaultProxy.isReadOnly()) { | ||
126 | this.getElement('offlineCopyLinkBox').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); | ||
127 | } else { | ||
128 | this.getElement('offlineCopyLinkBox_read-only').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); | ||
129 | MochiKit.Signal.connect('offlineCopyLink', 'onclick', this, 'downloadOfflineCopy'); | ||
130 | } | ||
131 | |||
132 | new Clipperz.PM.Components.Import.MainComponent(this.getElement('importPanelMainComponent'), {user:this.user()}); | ||
133 | |||
134 | MochiKit.Signal.connect('printingLink', 'onclick', this, 'printAllData'); | ||
135 | MochiKit.Signal.connect('exportLink', 'onclick', this, 'exportAllData'); | ||
136 | |||
137 | Clipperz.NotificationCenter.register(null, 'switchLanguage', this, 'switchLanguageHandler'); | ||
138 | }, | ||
139 | |||
140 | //------------------------------------------------------------------------- | ||
141 | |||
142 | 'tabPanelController': function() { | ||
143 | if (this._tabPanelController == null) { | ||
144 | var tabPanelControllerConfig; | ||
145 | |||
146 | tabPanelControllerConfig = {} | ||
147 | tabPanelControllerConfig['offlineCopyTab'] = this.getId('offlineCopyPanel'); | ||
148 | tabPanelControllerConfig['sharingTab'] = this.getId('sharingPanel'); | ||
149 | tabPanelControllerConfig['importTab'] = this.getId('importPanel'); | ||
150 | tabPanelControllerConfig['printingTab'] = this.getId('printingPanel'); | ||
151 | this._tabPanelController = new Clipperz.PM.Components.TabPanel.TabPanelController({ | ||
152 | name: 'dataTabPanel', | ||
153 | config:tabPanelControllerConfig, | ||
154 | selectedTab:'offlineCopyTab' | ||
155 | }); | ||
156 | } | ||
157 | |||
158 | return this._tabPanelController; | ||
159 | }, | ||
160 | |||
161 | //------------------------------------------------------------------------- | ||
162 | |||
163 | 'downloadOfflineCopy': function(anEvent) { | ||
164 | var downloadHref; | ||
165 | |||
166 | downloadHref = window.location.href.replace(/\/[^\/]*$/,'') + Clipperz_dumpUrl; | ||
167 | |||
168 | if (Clipperz_IEisBroken == true) { | ||
169 | window.open(downloadHref, ""); | ||
170 | } else { | ||
171 | vardeferredResult; | ||
172 | var newWindow; | ||
173 | |||
174 | newWindow = window.open("", ""); | ||
175 | |||
176 | anEvent.preventDefault(); | ||
177 | |||
178 | deferredResult = new MochiKit.Async.Deferred(); | ||
179 | deferredResult.addCallback(MochiKit.Base.method(this.user().connection(), 'message'), 'echo', {'echo':"echo"}); | ||
180 | deferredResult.addCallback(function(aWindow) { | ||
181 | aWindow.location.href = downloadHref; | ||
182 | }, newWindow); | ||
183 | deferredResult.callback(); | ||
184 | } | ||
185 | }, | ||
186 | |||
187 | //------------------------------------------------------------------------- | ||
188 | |||
189 | 'compareRecords': function(a, b) { | ||
190 | return MochiKit.Base.compare(a.label().toLowerCase(), b.label().toLowerCase()); | ||
191 | }, | ||
192 | |||
193 | 'logo': function() { | ||
194 | var result; | ||
195 | |||
196 | if (Clipperz_IEisBroken == true) { | ||
197 | if (Clipperz.PM.Proxy.defaultProxy.isReadOnly()) { | ||
198 | result = "<span><span class=\"clipperzLogoSpan\">clipper</span><span class=\"clipperzLoggoZSpan\">z</span></span>"; | ||
199 | } else { | ||
200 | result = "<img src=\"./images/exportLogo.png\" />"; | ||
201 | } | ||
202 | } else { | ||
203 | result = "<img src=\"data:image/png;charset=utf-8;base64,iVBORw0KGgoAAAANSUhEUgAAANYAAABOCAIAAADTtH9XAAANIWlDQ1BJQ0MgUHJvZmlsZQAAeJyV13k0lG8bB/BrFsYyZhhjDyO77LKHLJFItmwp2bdhJiZRypIUIkso2iiSFC0kEtWPLCHJkq2oyJI9kmXeP6R6f+f9ve95rz+ecz3385xz389zzud7nxsAr+FKpZKRABAQSAuyNjEgOTg6kTBdgAJewAEzaLi6B1P1LS3N4R9roRMQAADtcq5UKvmf3/uPhQtycHQCQMgCANF7vd8OAES39d4WAIhHaFQaAMIHAIjuPq4eAIhwAJANsrU2BEAUAADOe70vBwCc23pfDwC4EHdvGgCiG4CREOjhGwiAmQBg1PXwDHYHwMkCgIdHsHsAAC4ZACwCAigeALgPACDlTg2iAeCZAEDOwdGJtL7kffEAW/kAmMx+jx1JByjNAZDa/XtM9BEAtytAbuLvsTlrQAAAgrs12EtFGQAAEFgDAIYBOn1OAgCTCrCaQqcv59Lpq9cBUH0ANWT3w0EhP/8XAtEM8L/u17/5Z6EQAEgAhBgiH3kUFY4OZzjBGImJZjrJbMRcy3Ka9Qw2ju0srozdhyOFkMKZSjzPlc6dzpPJW8tPEcjelC14WaiedFgkd/N10VbxYxL5km3SJ2Rub+mUi5a/o9CjdFr5vsp71bNqZeqDmklaFdrDOmm6T/XG9DMMnhtO7sgyrjOZNb26q9FsYXeuRcue15avrdqsV2wL93bYddp3OXQ7offdc+7b339gwOX9wQ9uWPfHHp88P3sNe4/4fPEd9eciPwv4GjhJmaJOH5oJmg2ep80f/haycGQx9HvY0tEfx1bCV46vRkhHdkQjTiJjUKfQsQynGc9g4pjimRNYzrImYpPYzuGS8SnsqRxphPOc6cQMrkzuCzwXebP4svkvCVzedEXwqtA14RxSrsj1zTdE88TyxW9KFkjekiqUvi1ze7yIfEf2rlyxQoniPaX7Sg+UH24tVS1TK1t4FFKu/lijQqtS+8m2qm1PdZ6uVUfU6D3b/lz/hcFfhrXo2pi6HS+N600aTBtNm1iaEl6ZNZu3WLTiWs+9tmyzemPdTmhPfWvTYdu5t4u7K7Pb/p1Dj1Mvf292n3O/88D+90Lvr35wGTw4JDKU+9Htk/tnj2Hx4fwRry/eoz5j0mOF434T/l/Jk3KTd6cCpykz1Fml2ftzQfPB32gLqgtliyHfQ5fCfoQtay1XrhxbDV/TWXtKpwMgRJE45DSqCX2bIY0xHOPNZMtsyLKVVRIrycaL48HzsvNycBEkOKWIGlzm3Ad4gnmT+Ir5mwRGBTmF1IS9SRdEXooixHTED0nck5ySlpIhb6mUQ8nrK6QoDipLq8Ru7VKTUadq1GrxaIdue6XLrUfZ/txAzPCYUZuxkEnozirTJTMlc8/d6RZtljgrE+tQmzzbt3Ys9tsdDjledqrbN7Vf+MAel6MHc11r3UY9uDz1vBy8T/hc863x6/dfCuAM3EIxovocCg9KDs6llR6uD+k9Mha6cBR1jCOcdFz2hGrE9kizqD3R+04ejPE8RY6lnQ46ExkXGX8yIe5samJCUta5i8mZKSmpl9JSz2ekX8goyLx54e7Fgqzb2cWXnlx+cqX26qtrbTntue3X22/05n3KH7k5VPD51lThzO2posk7s3enisdLJu6N3B98MPSwp7StrOFRTfmjx8UVlypTn0RWBTzdV21Ws+2ZzHPC86UXH/5qrH1Yl/YyqN6mQa1RoJHe1PPqYXN8i1OraOvw6wdtx9/saMe197+91uHXqdK52tXcnfZuf490z1xvRV90v9kAcWDg/a0PwYPaQ+ihxo/nPx34LPl5YrhiJOrLrlGu0f6xG+PkCdWJta8Nk6lT+6bFpidmHsyGz5nME+a7v+UtUBY1v6O+v1xK+bFvWXT560rZauSaKZ2bTgeAk4hQ5FGUNqoCfZxBj6GaMQpzismYqZY5luU0azx2F7aJLRGXiE9i38PeypFMSOVMI6Zx2XK95c7gyeC9wJfFny2QvemSoLNgv9BV4WukHJGczTmi18VuiOdJ5EvelCqQviXjKzO2pVC2SO6O/F2FYsUSpXvK91UebH2oWqZWpl6mEarxXbNCq0K7ctsTnSrdE7pretXba/SfGTw3fGEUswO9o9a4zuTlznrThl2NZgnmWPNXu5stWva0WiZbsVu1Wb+xabd9u7fTLsOe277LodvxnVPPvmxnAee+/f0H3rt8OPjBNcdNxG3I/aPHJ8/PXvneEusJ4jfmf5ssS574txSZ+5Ui5WEaYUtHfxxbDl85vnpiLYIeBdHIX0mCOYOJY4priN+VwHoWm4hNYjuHT2ZP4fiVJdyZPBd4f2bJpj+zJHfouvsN0TyxfImbEhtpUiR7R+6u/B9ZolK6tUz1kXq5+mONCs1K7SfaVdue6lbr/pEjO+qMXxrXmzTsbDRtMnsV0rK51eK1ZZvlG6v24x0ynXZd9t3RPQq9Tn2xAyrv4wZVh85+8hjWHkkZ9R33+0qeoszEzzstnFtKWLWm0wHW9z4AAEY1gIwtAHZZADa5ALFbACRdALgLACzZAGw1AckgBEgdKiB26WzsH4AAdhAEeTAARwiGZCiB7wgSwgwRiihAtCBGkHikCTIKWYVcQemgolB1qBW0CNoRnY/+xmDMcIqhmGGK0YQxh3EYw4VxxlQxYZg0mWKYxpm1mCnMNSxyLJEs5aw41ijWd1giNhD7hW0H20m2QZwr7jkehffCT7BbsWewr3LEccwStAh5nOqceZxTRBfiIpcvVxn3Fu6XPF68GN5CPnG+I3zz/JcFTATmNl0TFBMMF0IIlQr7kURIPSLnN2/eHCmKF20VSxHfK8EvMSR5W8pQ6pa0gQyHzOCWB7Kn5ZzlVRSwCiOKfynlKkereGw1UZVV41RbUR/WyNTEadZolWjnbDuvc0Y3Qu/I9kP6ZANfQx8jnx3+xoEmtJ3HTGN2nTPLNr+1u9yiYU+f5Yw1xkbIVmOvjR3VPsnhruNrpzln3v26B7xckg9Wun5x5/Ew8QzzKvLl9bP0jyfXBiIp+tSoQy+CGWlmh1NDxcIoR5+Esxx3OlEUQY+yjUGeco59dIYz7lB8W2J60lKyS0pdmsL5rMzgCx+zbLJrr9y9Jp5z+TpPPvvNpFu4wnN3MosFS27clys1Kmsrd308U8XztKjG4AWtFl9XVL+rKb5ZrqXtdUh7XQe1S6C7vk+iv/t9/KDep6Jhjy/Coz1f7aa4p7tms+ZdFieWSpcj6Lx0OgAggQV4QBr0wAEOQzqUwwACg1BEuCCSENWIOaQM0gWZhXyLwqN2o86imtFs6D3odHQvA4nBl6GE4TujIeM5xncYccxhzAsmApMHUzkzK7Mz810WNMsBloesLKzurNVYLiwV28wmw5bINoEzxxXj2fAUfCf7dvYbHDiOEI5egjHhHieJM5VzjRhM/MrlxzXGTeae5aHxLPAe5UPwneXn5y8U0BSo22S3aVQwUohPqEzYSniMFCsiIVK/OVCUR/SpmLs4VvyZRKCksOQbqThpA+lVmcot4bI6soty1fJnFGwVRRSnlKqVU1T8thqpCqkuq3WoP9a4rBml5a1tv01HR0FXRI+wHa2P0p81mDGcMhrfMWw8ZzK+89supBnRnGe3koXunj2W1lb+1mE22bb3976y67VfcSQ6KeyzcD60/+KBWpcRV2Y3RXcfjyzPaq9pH2lfT79M/44AgcC9lGzqlyCp4BBaQ4jgkeDQxqOix5LCx044RtRHqUXnxRBOJZ0mnMmI503ITlRNakn2TPmRlpiunvH5wpUsv0t7r0hfY8iZuP48r/TmxVuxt93vOBcb39N4sLVU/pHcY6lK8SqpasVnei921lq9JDccakppvtb6pG2gnd4p3K3T49GXMFDxYeIj32eDkcjRgvFPk/zTXrNX5ocXpZYCl8vWEHQ6ADACOwiCAThCMpTAmw37G+7X1aPxaEf0NwZjhqyf3tcwzkzCTDFM48y2zDUsciyXWHGsUayL2EDsFzYPnCvuI94LP8EezL7KEUfgJuRxqnM2El2Ii1zJv0xb8M3/9GwphBAq/WnZal3yT8ch0gZ/Gv4t+KffN5o1WiW/7f6W+89u/5ta70FfXj/Lv6sN6fm72+jCP+WeVf4tN4Nxw+5lzQ29N9I2/BYRNgQ/KN8wXHlyXfGzng3HDaNN8a/+as5oaXsd8kawva6D2lnSFdtd3xPSJ9HvP2D0Pn5Qb+j0R7dPRZ8Xhtu/CI/6j5mOS01gvtpN5k/FTnvP7JyVmWOdm5x//e3BQsai7eLE95glgx+SP4aXI1Z4V66scqzGrC6u3aAn0OkA6+clAABgMaSQKUEkc0Oj//Ow978qgHx4Yw4kAGA9A/faAAABAKR8aaa2AEAEAC0wBAqQgQJBQAJzMASjn1cSuP964guwfpYDAGBkB7hkDwBQ/f1Y5N/npXmG0gAADCnUsCBfbx8aSZ9KJXuSDCkB1MM0zyBZkmmgu7wsSVlRURUA4F93RgACxGzQPQAAAAlwSFlzAAALEwAACxMBAJqcGAAAC25JREFUeJztnHlUE9cex38JYY2JGhQ14Hae1BSXKoK4C0UtbtRqRUWlomi1NK5Y6tKKQpG2qK0pWo8oPp+ix+rRFlCPyxEVV9TXpx7klOdxKQFERQ1CWMLM+wMfDZk7k5nJMsHez8k/+d3f/d1fJt+5d+6SiEiSBAxGOMRCJ4D5u4MliBEYLEGMwGAJYgQGSxAjMFiCGIHBEsQIDJYgRmCwBDECgyWIERgsQYzAYAliBAZLECMwWIIYgcESxAgMliBGYLAEMQKDJYgRGCxBjMBgCWIEBksQIzASoRN4w+93X25YpWkl8zCyifr37bDsy5mcfDAtDkeRYFFRmVZbbmKsrixeBjM5+WBaHI4yEJNg/ufMbHwwLQ5HkSDmb0uLl6BM1kroFDAW0ZIkqNfXU43FJU/snwnGijjKdIQNUTP6hoelmhjdXEWCJIOxFi1JgiIRtFW4Cp0Fxsq0pIEY81ZitV5QV0nmZOUfz877o/CBkZlQqbpMmDB0TJh/a4UHbWV2NBBQ/PiFi4uzkU3k7ka2UTSbkehr4GnZC2cjt/q6ui7d2gKIAOB5heHg/tyjR85W6l43JRkYqPpkTlhAUA+RmHZYt1FYJNoS/bEjl86culqi/etJVy53DwsLipg+onO39szVmVMFgCfl9ds0x07kXGh8HxTos3VHPAmkqP4uiC0YZ5ze4VFJZPn/CxaX1EVFrqv669LTYUhPX9HHvwey7NDRe5sSt5kYO3s7H87a3PT2n5m3t6XuNPGRy+tO5+4wtiDdzp5Z79FW8WF4crm2lCHFz2PHzZ43Fllko7AmXLqiXRqbYm5sMqSlqQMG+9EVI1PNyV7bTtmhpg6mTjHNtvE6G8iHkp+6s0mSFnUDj3HV0oE4OeXklAkrWOgPACQxMT9GRyYBSfBry93dmWr0UXZg4/bgYfWAAWpmoQDAT2nHRwerkRnaKGwTBgImTkxebl5/ACCJjd2++FPTmRlzqq1kHroqGDGINlsnEaKWHbBIgtMjt/56KIdTlYLCJ0EDFvBWIZXKSjbqh5iYb13YBdTpYHTIEpatWytsTR0MCjAvZWOu5T/6eOIXrN2JoiJd8HC1Ay4f8Jfg0hUHHxQW8arqHj3za97t2gGdDhZ/utFuYQkShg5SO3EP+KdWv3rFD+x8xTExKcL0cubgKcF7RdVXzl2iKw0J6bciLnLs+BF0DgWFr67k3uDXtOXI5a5zosctip3aybsTnc+1/JJnHBe9eYddHneQblYYGKj6LHby8rjZdDHPnrtfdPc+pzzpaCARK/92gOeMeMa0eOTEKXx8/zUb5v5/4gXrEqfuz7ylSc2gen6dsOt0bgC/1i3AkJX9jZdS0fhmzrwRryrh/ZFq5FVYGafJyEyyddjyCkDezEGBXX9IWyaWvOkcp0UOLC6p/2jCcmqfMSsq8dqtPezybIa3dzsSxFptuUzmAQASUTdQmx5EMkICUA0aH8aQfHo0PhJ8XNKA1F9oiO+axLnGFhHArEj/1/r6jLR9Js46HQkkASJ7LkwaLl3eLHFzNza1lsG1G5qgAIRcCgpfNNTVObmYfdizKOyqVbuoEUNDfJM3LTYx+iidcy9rQoZQn+dkL8sr2ngpzOX5hs7erXfsivf0kqEKmZZ7nh+f5MlQrK5imYAJfBSwadMvKHNt8iY10j9qdhBq4cf55dOXPFrnzfa0hSZCaUQihqPZW1A1xKdy8mwattYAd/J/pzjUJ6d+jmxL6gbhEROo9j27s8zm2Uj4+D6Hs5Jo9MeELi/S8/4F2mJ1OQDPdV8+EryIGjji46Y0rXya4OECfQPfk8ulMqMXAOHqbs/dtlr/wX3pyrooJa5yxImbQ7/k2jTsvUId9ZLFRAczDA6fxX5ANR44dAlYHKaUyw1rEheYdaNSdS9B/u8DtMULbzN3n8xwHoiratB1RocFMdRK3xHDtSHrEhriR3eHNKJe8klqYpqdw2ZlX6Ea0zMudvTp+bxCh6pB3ClATpKcSEODSGLm20zfGc/sgISoyJKeWU9bPPM3cO7DI2wTnCX4SkeiLnm9rK3ckjxszfBhtH1VIyNHqlITTY0FhcUAJIPILAx75dJNVCVxUuJu5rAUJM/Kn7enrNI3R9/VtyvHsAD1d8T7w2lLx34HiomcYzaH80AskSC/DwOIHHDV0xh+8x4XMLOBaVFYpRnRcMBZYmbVz0/VkbnDpkKCFn6mv8f6z4AeKzkFRML5Crq7Ih46eHw8O+PX27LdT9uElbZCzGNsRGVlNSd/EqprGZZglO/BsExLcwIAHhKsrEIMxAWF5WwehwXkZn6BA4YtK31mrUwMBjMLy5EzRrOPRgDxTCN1oyt2bwNTqBN5nljrsJYYSNLhx2ImDAa02cIPxSNsUKDyx+2rDAYOtzRBgCutXvhQlu6pZCiOeW7FtjhLsJUUee2cn5U+bUf/ZLNFc/FgxiETY0rytJCwYVwT4EfmgbOTI5mOS2VlXaca/VRK5gcMC8OGhAZlUPbZgwa+KxKDs4tg9/OTI/2UevolW3WVdU86c44llwKyx9+39yRDrb0U/QFAn76+XFvnzZ9aPVFXx+Dwc9q/UGYzJ3osDDsqtB+1bGvaMeZGCQJqa0jjV4PBaiePKvIiO5T8h7ZYXcx7CZoOPnL+YHwo1Xjg0HVDjR7pX1IOqE0ug6dXGx6t80WckriHruzClTLkNtyCBZNsGrZbF1eUdmSPih4xNBkQoB4xZLHxK2zUInN5sqL6v98rGJag5+cDeFulIWP4SHDZMuQXIx46ZBF1UlJvgAlhiI27zt5SkcSuv0X6NefOiaPnqfbScmJl7DeoGobBIxC9lBXDSsQQirqfI6al6GkmsEtXZFJXXzYkzDebp1mIiiyPE/QHEOdeBDebHCvhMx3xUkA3le9DxGFBWZD/or171/Ts1RlEQBCQe+HhquWbkAtW69cLsF+SkHj4+MmbSRsXNv6QpaYG9u2/vDMNfd+HhviCmNX1sSTsV2smncs5S/GSBI+Mnxs9Jnr+OBc3JwAgCLh6rXhJ7LeoPqN28Eh/NnkyQAJZtT+caef48RmoRD5UNGfgDvM+zeE5I965c/Ho4chDCc5RUd+ZrS6XG3r5q/g1bSHX8x+MGcVqn2rdhoV2CCt1g+nRHx/MOEz13J1xanfGKWMLcsxKSZ5jlQNH6Ll7Ewx7dMYM3M51aOWZulwKSZt5r4wTJ05uNu8lKAlfTXGVWvm5my7sMvVI5GkGNvip2oaEDbE4LyHhf/eMDu6SmraaR8Xs7ATk6SYbw2HOOCNi4NiPgu0Z9nzuxvb0Z63pkMshI5Nd5+TAWNSBDx/cKfvM1gbW/n6qDpevbm6vRB7sYbMMxn+pLCV5RvYZDRvPL+I+XPrlbDuHFQFkZ62eH8vhjxInju9/OldjxX1Rof5Yw9JniPYK0Y1bmm3pazt6M+24v6vq9Fv2+ozMtU4u6N30jh0RCzQmu/hsfOh4UVHZXgF51zWTI8LofAID/3Hu/PdTIkexCWiLsDHzBuVe1syKnsS8MTItYnje5S1rmx9QN8YddRATaTTGzLMgWzjfElb4KXsTBAFlZdVFf2hfvdC5uruVasu9vT1VKh+fLgp7ns9H/io+Pm5c0zYGSUJpafWd2w9q9TXV+jpPhZRNkjYKS0dVFfnwwVNt8dMafTUJkhq9vnt3r3d6erdRuDn4iRCuWLP3FYtBqfRQKpv2PHpZMbgVEYka87RyetYNK5WKevX26tXbyyrRHBn8t0YYgcESxAgMliBGYLAEMQKDJYgRmLdQgno90wE+RwuLaUn/Nc2S4UN8n0a8LzXain1dVeMf2Nsxw2KsuTSNwfDgLRyIMS0LLEGMwGAJYgQGSxAjMFiCGIHBEsQIDJYgRmCwBDECgyWIERgsQYzAYAliBOZ/jys2NWyvP3gAAAAASUVORK5CYIIK\" />"; | ||
204 | } | ||
205 | |||
206 | return result; | ||
207 | }, | ||
208 | |||
209 | 'progressWidth': function() { | ||
210 | return this._progressWidth; | ||
211 | }, | ||
212 | |||
213 | 'updateProgress': function(aProgressComponent, aPercentage) { | ||
214 | |||
215 | |||
216 | }, | ||
217 | |||
218 | //------------------------------------------------------------------------- | ||
219 | |||
220 | 'printAllData': function(anEvent) { | ||
221 | var newWindow; | ||
222 | var allRecords; | ||
223 | |||
224 | //MochiKit.Logging.logDebug(">>> printAllData"); | ||
225 | newWindow = window.open("", ""); | ||
226 | newWindow.document.write( | ||
227 | "<html>" + | ||
228 | "<header>" + | ||
229 | "<title>Clipperz export data</title>" + | ||
230 | "<style>" + | ||
231 | "#exportedData {" + | ||
232 | " width: 600px;"+ | ||
233 | "}" + | ||
234 | ".ext-mb-progress-wrap {" + | ||
235 | "border:1px solid #6593cf;" + | ||
236 | "margin-bottom: 10px;" + | ||
237 | "width: " + this.progressWidth() + "px;" + | ||
238 | "}" + | ||
239 | ".ext-mb-progress {" + | ||
240 | "height:18px;" + | ||
241 | "background:transparent url(./images/default/basic-dialog/progress2.gif) repeat-x 1px 1px;" + | ||
242 | "}" + | ||
243 | ".ext-mb-progress-bar {" + | ||
244 | "height:18px;" + | ||
245 | "overflow:hidden;" + | ||
246 | "width:0;" + | ||
247 | "background:#8bb8f3;" + | ||
248 | "}" + | ||
249 | "body {" + | ||
250 | "font-family: sans-serif;" + | ||
251 | "}" + | ||
252 | "div#logo {" + | ||
253 | "border-bottom: 1px dotted #aaaaaa;" + | ||
254 | "margin-bottom: 15px;" + | ||
255 | "}" + | ||
256 | "div.recordBlock h2 {" + | ||
257 | "font-size: 14pt;" + | ||
258 | "margin: 0px;" + | ||
259 | "padding: 0px;" + | ||
260 | "border: 0px;" + | ||
261 | "color: #666666;" + | ||
262 | "}" + | ||
263 | "div.recordBlock div.recordNotes p {" + | ||
264 | "margin: 0px;" + | ||
265 | "padding: 0px;" + | ||
266 | "border: 0px;" + | ||
267 | "color: #aaaaaa;" + | ||
268 | "font-size: 10pt;" + | ||
269 | "line-height: 18pt;" + | ||
270 | "border-left: 1px solid #aaaaaa;" + | ||
271 | "padding-left: 10px;" + | ||
272 | "}" + | ||
273 | "div.recordBlock dl {" + | ||
274 | "margin: 0px;" + | ||
275 | "padding: 0px;" + | ||
276 | "border: 0px;" + | ||
277 | "color: #999999;" + | ||
278 | "padding-bottom: 10px;" + | ||
279 | "border-bottom: 1px dotted #aaaaaa;" + | ||
280 | "margin-top: 10px;" + | ||
281 | "margin-bottom: 15px;" + | ||
282 | "}" + | ||
283 | "div.recordBlock dl dt {" + | ||
284 | "display: block;" + | ||
285 | "float: left;" + | ||
286 | "min-width: 100px;" + | ||
287 | "white-space: nowrap;" + | ||
288 | "overflow: hidden;" + | ||
289 | "margin-right: 10px;" + | ||
290 | "font-size: 10pt;" + | ||
291 | "line-height: 18pt;" + | ||
292 | "}" + | ||
293 | "div.recordBlock dl dd {" + | ||
294 | "color: #666666;" + | ||
295 | "font-size: 10pt;" + | ||
296 | "line-height: 18pt;" + | ||
297 | "}" + | ||
298 | "" + | ||
299 | "</style>" + | ||
300 | "" + | ||
301 | "<!--[if IE]>" + | ||
302 | "<style>" + | ||
303 | "div.recordBlock dl dt {" + | ||
304 | "width: 100px;" + | ||
305 | "}" + | ||
306 | "</style>" + | ||
307 | "<![endif]-->" + | ||
308 | "" + | ||
309 | "</header>" + | ||
310 | "<body>" + | ||
311 | "<div id=\"logo\">" + this.logo() + | ||
312 | "<div id=\"progressWrapper\"><div class=\"ext-mb-progress-wrap\"><div class=\"ext-mb-progress\"><div id=\"progress\" class=\"ext-mb-progress-bar\"> </div></div></div></div>" + | ||
313 | " </div>" + | ||
314 | "</body>" + | ||
315 | "</html>" | ||
316 | ); | ||
317 | |||
318 | anEvent.preventDefault(); | ||
319 | |||
320 | allRecords = MochiKit.Base.values(this.user().records()); | ||
321 | allRecords.sort(this.compareRecords); | ||
322 | |||
323 | /* | ||
324 | deferredResult = new MochiKit.Async.Deferred(); | ||
325 | MochiKit.Iter.forEach(allRecords, MochiKit.Base.partial(function(aDeferredResult, aWindow, aRecord) { | ||
326 | var printerRecord; | ||
327 | |||
328 | printerRecord = new Clipperz.PM.Components.Printing.Record({record:aRecord}); | ||
329 | aDeferredResult.addCallback(MochiKit.Base.method(printerRecord, 'deferredDrawToWindow', aWindow)); | ||
330 | }, deferredResult, newWindow)); | ||
331 | deferredResult.callback(); | ||
332 | |||
333 | return deferredResult; | ||
334 | */ | ||
335 | |||
336 | MochiKit.DOM.withWindow(newWindow, MochiKit.Base.bind(function(someRecords) { | ||
337 | var currentWindow; | ||
338 | vardeferredResult; | ||
339 | var progressBar; | ||
340 | var progressWrapper; | ||
341 | var i, c; | ||
342 | |||
343 | currentWindow = MochiKit.DOM.currentWindow(); | ||
344 | progressBar = MochiKit.DOM.getElement('progress'); | ||
345 | progressWrapper = MochiKit.DOM.getElement('progressWrapper'); | ||
346 | |||
347 | deferredResult = new MochiKit.Async.Deferred(); | ||
348 | c = someRecords.length; | ||
349 | for (i=0; i<c; i++) { | ||
350 | deferredResult.addCallback(function(aWindow, aRecord) { | ||
351 | var printerRecord; | ||
352 | |||
353 | printerRecord = new Clipperz.PM.Components.Printing.Record({record:aRecord}); | ||
354 | return printerRecord.deferredDrawToWindow(aWindow); | ||
355 | }, currentWindow, someRecords[i]) | ||
356 | deferredResult.addCallback(MochiKit.Base.bind(function(aProgressBar, aProgress) { | ||
357 | MochiKit.Style.setElementDimensions(aProgressBar, {w:aProgress * this.progressWidth()}); | ||
358 | }, this, progressBar, ((i+1)/c))); | ||
359 | deferredResult.addCallback(MochiKit.Async.wait, 0.2); | ||
360 | } | ||
361 | |||
362 | deferredResult.addCallback(function(aWindow, aProgressWrapper) { | ||
363 | MochiKit.DOM.replaceChildNodes(aProgressWrapper); | ||
364 | MochiKit.Style.hideElement(aProgressWrapper); | ||
365 | aWindow.stop(); | ||
366 | }, currentWindow, progressWrapper); | ||
367 | |||
368 | |||
369 | deferredResult.callback(); | ||
370 | }, this, allRecords)); | ||
371 | }, | ||
372 | |||
373 | //------------------------------------------------------------------------- | ||
374 | |||
375 | 'exportAllData': function(anEvent) { | ||
376 | // vardeferredResult; | ||
377 | var newWindow; | ||
378 | var allRecords; | ||
379 | |||
380 | //MochiKit.Logging.logDebug(">>> printAllData"); | ||
381 | newWindow = window.open("", ""); | ||
382 | newWindow.document.write( | ||
383 | "<html>" + | ||
384 | "<header>" + | ||
385 | "<title>Clipperz export data</title>" + | ||
386 | "<style>" + | ||
387 | "#exportedData {" + | ||
388 | " width: 600px;"+ | ||
389 | "}" + | ||
390 | ".ext-mb-progress-wrap {" + | ||
391 | "margin-top:4px;" + | ||
392 | "margin-bottom: 10px;" + | ||
393 | "border:1px solid #6593cf;" + | ||
394 | "width: " + this.progressWidth() + "px;" + | ||
395 | "}" + | ||
396 | ".ext-mb-progress {" + | ||
397 | "height:18px;" + | ||
398 | "background:transparent url(./images/default/basic-dialog/progress2.gif) repeat-x 1px 1px;" + | ||
399 | "}" + | ||
400 | ".ext-mb-progress-bar {" + | ||
401 | "height:18px;" + | ||
402 | "overflow:hidden;" + | ||
403 | "width:0;" + | ||
404 | "background:#8bb8f3;" + | ||
405 | "}" + | ||
406 | "</style>" + | ||
407 | "" + | ||
408 | "<!--[if IE]>" + | ||
409 | "<style>" + | ||
410 | "</style>" + | ||
411 | "<![endif]-->" + | ||
412 | "" + | ||
413 | "</header>" + | ||
414 | "<body>" + | ||
415 | "<div id=\"logo\">" + this.logo() + "</div>" + | ||
416 | "<div id=\"progressWrapper\">" + | ||
417 | " <div class=\"description\">" + Clipperz.PM.Strings['exportDataInProgressDescription'] + "</div>" + | ||
418 | " <div class=\"ext-mb-progress-wrap\"><div class=\"ext-mb-progress\"><div id=\"progress\" class=\"ext-mb-progress-bar\"> </div></div></div>" + | ||
419 | "</div>" + | ||
420 | "<div id=\"textareaWrapper\">" + | ||
421 | " <div class=\"description\">" + Clipperz.PM.Strings['exportDataDescription'] + "</div>" + | ||
422 | " <textarea id=\"exportedData\" cols=\"80\" rows=\"20\">[</textarea>" + | ||
423 | "</div>" + | ||
424 | "</body>" + | ||
425 | "</html>" | ||
426 | ); | ||
427 | |||
428 | anEvent.preventDefault(); | ||
429 | |||
430 | allRecords = MochiKit.Base.values(this.user().records()); | ||
431 | allRecords.sort(this.compareRecords); | ||
432 | |||
433 | MochiKit.DOM.withWindow(newWindow, MochiKit.Base.bind(function(someRecords) { | ||
434 | var currentWindow; | ||
435 | vardeferredResult; | ||
436 | var textareaWrapper; | ||
437 | vartextarea; | ||
438 | var progressBar; | ||
439 | var progressWrapper; | ||
440 | var i, c; | ||
441 | |||
442 | currentWindow = MochiKit.DOM.currentWindow(); | ||
443 | textarea = MochiKit.DOM.getElement('exportedData'); | ||
444 | textareaWrapper = MochiKit.DOM.getElement('textareaWrapper'); | ||
445 | MochiKit.Style.hideElement(textareaWrapper); | ||
446 | progressBar = MochiKit.DOM.getElement('progress'); | ||
447 | progressWrapper = MochiKit.DOM.getElement('progressWrapper'); | ||
448 | |||
449 | deferredResult = new MochiKit.Async.Deferred(); | ||
450 | |||
451 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("exportAllData - 1: " + res); return res;}); | ||
452 | c = someRecords.length; | ||
453 | for (i=0; i<c; i++) { | ||
454 | deferredResult.addCallback(MochiKit.Base.method(someRecords[i], 'deferredData')); | ||
455 | deferredResult.addCallback(MochiKit.Base.method(someRecords[i], 'exportedData')); | ||
456 | deferredResult.addCallback(MochiKit.Base.bind(function(aTextarea, aProgressBar, aProgress, someRecordExportedData) { | ||
457 | aTextarea.value = aTextarea.value + "\n" + someRecordExportedData + ","; | ||
458 | MochiKit.Style.setElementDimensions(aProgressBar, {w:aProgress * this.progressWidth()}); | ||
459 | }, this, textarea, progressBar, ((i+1)/c))); | ||
460 | deferredResult.addCallback(MochiKit.Async.wait, 0.2); | ||
461 | } | ||
462 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("exportAllData - 2: " + res); return res;}); | ||
463 | deferredResult.addCallback(function(aTextareaWrapper, aTextarea, aProgressWrapper) { | ||
464 | aTextarea.value = aTextarea.value.slice(0, -1) + "\n]"; | ||
465 | // MochiKit.DOM.replaceChildNodes(aProgressWrapper); | ||
466 | MochiKit.Style.hideElement(aProgressWrapper); | ||
467 | MochiKit.Style.showElement(aTextareaWrapper); | ||
468 | aTextarea.focus(); | ||
469 | aTextarea.select(); | ||
470 | }, textareaWrapper, textarea, progressWrapper); | ||
471 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("exportAllData - 3: " + res); return res;}); | ||
472 | deferredResult.addBoth(function(aWindow) { | ||
473 | aWindow.stop(); | ||
474 | }, currentWindow); | ||
475 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("exportAllData - 4: " + res); return res;}); | ||
476 | |||
477 | deferredResult.callback(); | ||
478 | }, this, allRecords)); | ||
479 | }, | ||
480 | |||
481 | //------------------------------------------------------------------------- | ||
482 | |||
483 | __syntaxFix__: "syntax fix" | ||
484 | |||
485 | }); | ||
486 | |||
diff --git a/frontend/beta/js/Clipperz/PM/Components/Panels/LoginPanel.js b/frontend/beta/js/Clipperz/PM/Components/Panels/LoginPanel.js new file mode 100644 index 0000000..84b2475 --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/Panels/LoginPanel.js | |||
@@ -0,0 +1,1114 @@ | |||
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 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | ||
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | ||
31 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } | ||
32 | if (typeof(Clipperz.PM.Components.Panels) == 'undefined') { Clipperz.PM.Components.Panels = {}; } | ||
33 | |||
34 | |||
35 | Clipperz.PM.Components.Panels.LoginPanel = function(anElement, args) { | ||
36 | args = args || {}; | ||
37 | |||
38 | Clipperz.PM.Components.Panels.LoginPanel.superclass.constructor.call(this, anElement, args); | ||
39 | |||
40 | this._showLoginFormAnimator = null; | ||
41 | this._showRegistrationFormAnimator = null; | ||
42 | this._shouldShowRegistrationAlert = true; | ||
43 | |||
44 | this._visibleForm = null; | ||
45 | //this._isPassphraseVisible = true; | ||
46 | |||
47 | Clipperz.NotificationCenter.register(null, 'switchLanguage', this, 'switchLanguageHandler'); | ||
48 | |||
49 | this.render(); | ||
50 | |||
51 | return this; | ||
52 | } | ||
53 | |||
54 | //============================================================================= | ||
55 | |||
56 | //MochiKit.Base.update(Clipperz.PM.Components.Panels.LoginPanel.prototype, { | ||
57 | YAHOO.extendX(Clipperz.PM.Components.Panels.LoginPanel, Clipperz.PM.Components.Panels.BasePanel, { | ||
58 | |||
59 | 'toString': function() { | ||
60 | return "Clipperz.PM.Components.LoginPanel component"; | ||
61 | }, | ||
62 | |||
63 | //------------------------------------------------------------------------- | ||
64 | |||
65 | 'render': function() { | ||
66 | var result; | ||
67 | varlayout; | ||
68 | var registerButton; | ||
69 | |||
70 | MochiKit.Signal.disconnectAllTo(this); | ||
71 | this.element().update(""); | ||
72 | |||
73 | //MochiKit.Logging.logDebug(">>> LoginPanel.initPanel"); | ||
74 | Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'div', id:this.getId('baseDiv'), cls:'LoginPanel', children:[ | ||
75 | {tag:'table', children:[ | ||
76 | {tag:'thead'}, | ||
77 | {tag:'tbody', children:[ | ||
78 | {tag:'tr', children:[ | ||
79 | {tag:'td', valign:'top', children:[ | ||
80 | {tag:'div', cls:'clipperzServiceDescription', htmlString:Clipperz.PM.Strings['clipperzServiceDescription']} | ||
81 | ]}, | ||
82 | {tag:'td', valign:'top', align:'right', children:[ | ||
83 | {tag:'div', id:this.getId('forms'), cls:'clipperzLoginForm', children:[ | ||
84 | {tag:'div', id:this.getId('loginForm'), cls:'loginForm', children:[ | ||
85 | {tag:'div', cls:'loginFormHeaderBox', children:[{tag:'h3', htmlString:Clipperz.PM.Strings['loginFormTitle']}]}, | ||
86 | {tag:'form', id:this.getId('loginForm_form'), autocomplete:'off', children:[ | ||
87 | |||
88 | {tag:'table', cls:'formLayout', children:[ | ||
89 | {tag:'thead'}, | ||
90 | {tag:'tbody', children:[ | ||
91 | {tag:'tr', cls:'formFieldTR', children:[ | ||
92 | {tag:'td', width:'90', htmlString:Clipperz.PM.Strings['loginFormUsernameLabel']}, | ||
93 | {tag:'td', children:[ | ||
94 | {tag:'input', id:this.getId('login_username'), cls:'loginFormField', type:'text', name:'username'} | ||
95 | ]} | ||
96 | ]}, | ||
97 | {tag:'tr', cls:'formFieldTR', children:[ | ||
98 | {tag:'td', htmlString:Clipperz.PM.Strings['loginFormPassphraseLabel']}, | ||
99 | {tag:'td', children:[ | ||
100 | {tag:'div', id:this.getId('passphraseDIV'), children:[ | ||
101 | {tag:'input', id:this.getId('login_passphrase'), cls:'loginFormField', type:'password', name:'passphrase'} | ||
102 | ]}, | ||
103 | {tag:'div', cls:'oneTimePassword', id:this.getId('oneTimePasswordDIV'), children:[ | ||
104 | {tag:'input', type:'text', id:this.getId('oneTimePassword_1'), name:'passphrase'}, | ||
105 | {tag:'span', html:'-'}, | ||
106 | {tag:'input', type:'text', id:this.getId('oneTimePassword_2'), name:'passphrase'}, | ||
107 | {tag:'span', html:'-'}, | ||
108 | {tag:'input', type:'text', id:this.getId('oneTimePassword_3'), name:'passphrase'}, | ||
109 | {tag:'span', html:'-'}, | ||
110 | {tag:'input', type:'text', id:this.getId('oneTimePassword_4'), name:'passphrase'} | ||
111 | ]} | ||
112 | ]} | ||
113 | ]}, | ||
114 | {tag:'tr', cls:'formFieldTR', id:this.getId('passwordTypeChooserTR'), children:[ | ||
115 | {tag:'td', valign:'top', align:'right', children:[ | ||
116 | {tag:'input', type:'checkbox', cls:'passwordTypeCheckbox', id:this.getId('useOneTimePasswordCheckbox')} | ||
117 | ]}, | ||
118 | {tag:'td', children:[ | ||
119 | {tag:'div', cls:'passwordTypeChooser', children:[ | ||
120 | {tag:'h4', htmlString:Clipperz.PM.Strings['loginFormOneTimePasswordCheckboxLabel']}, | ||
121 | {tag:'span', htmlString:Clipperz.PM.Strings['loginFormOneTimePasswordCheckboxDescription']} | ||
122 | ]} | ||
123 | ]} | ||
124 | ]}, | ||
125 | {tag:'tr', children:[ | ||
126 | {tag:'td'}, | ||
127 | {tag:'td', children:[ | ||
128 | {tag:'div', id:this.getId('login_submit')} | ||
129 | ]} | ||
130 | ]} | ||
131 | ]}, | ||
132 | {tag:'tfoot'} | ||
133 | ]} | ||
134 | ]}, | ||
135 | |||
136 | {tag:'div', cls:'loginFormFooterBox', children:[ | ||
137 | {tag:'ul', children:[ | ||
138 | {tag:'li', id:this.getId('showRegistrationLI'), children:[ | ||
139 | {tag:'span', htmlString:Clipperz.PM.Strings['loginFormDontHaveAnAccountLabel']}, | ||
140 | {tag:'a', href:'.', id:this.getId('showRegistration'), cls:'clipperzActionLink', htmlString:Clipperz.PM.Strings['loginFormCreateOneLabel']} | ||
141 | ]}, | ||
142 | {tag:'li', children:[ | ||
143 | {tag:'span', htmlString:Clipperz.PM.Strings['loginFormForgotYourCredentialsLabel']}, | ||
144 | {tag:'a', href:Clipperz.PM.Strings['loginFormAarghThatsBadUrl'], target:'Clipperz_Help', htmlString:Clipperz.PM.Strings['loginFormAarghThatsBadLabel']} | ||
145 | ]}, | ||
146 | {tag:'li', children:[ | ||
147 | {tag:'span', htmlString:Clipperz.PM.Strings['loginFormAfraidOfMaliciousScriptsLabel']}, | ||
148 | {tag:'a', href:Clipperz.PM.Strings['loginFormVerifyTheCodeUrl'], target:'Clipperz_Help', htmlString:Clipperz.PM.Strings['loginFormVerifyTheCodeLabel']} | ||
149 | ]} | ||
150 | ]} | ||
151 | ]} | ||
152 | ]}, | ||
153 | |||
154 | |||
155 | |||
156 | {tag:'div', id:this.getId('registrationForm'), cls:'registrationForm', children:[ | ||
157 | {tag:'div', cls:'loginFormHeaderBox', children:[{tag:'h3', htmlString:Clipperz.PM.Strings['registrationFormTitle']}]}, | ||
158 | {tag:'form', id:this.getId('registrationForm_form'), children:[ | ||
159 | {tag:'h5', cls:'errorMessage', id:this.getId('registration_errorMessage')}, | ||
160 | {tag:'table', cls:'formLayout', children:[ | ||
161 | {tag:'thead'}, | ||
162 | {tag:'tbody', children:[ | ||
163 | {tag:'tr', cls:'formFieldTR', children:[ | ||
164 | {tag:'td', width:'90', htmlString:Clipperz.PM.Strings['registrationFormUsernameLabel']}, | ||
165 | {tag:'td', children:[ | ||
166 | {tag:'input', id:this.getId('registration_username'), cls:'loginFormField', type:'text', name:'username'} | ||
167 | ]} | ||
168 | ]}, | ||
169 | {tag:'tr', cls:'formFieldTR', children:[ | ||
170 | {tag:'td', htmlString:Clipperz.PM.Strings['registrationFormPassphraseLabel']}, | ||
171 | {tag:'td', children:[ | ||
172 | {tag:'input', id:this.getId('registration_passphrase'), cls:'loginFormField', type:'password', name:'passphrase'} | ||
173 | ]} | ||
174 | ]}, | ||
175 | {tag:'tr', cls:'formFieldTR', children:[ | ||
176 | {tag:'td', htmlString:Clipperz.PM.Strings['registrationFormRetypePassphraseLabel']}, | ||
177 | {tag:'td', children:[ | ||
178 | {tag:'input', id:this.getId('registration_repassphrase'), cls:'loginFormField', type:'password', name:'repeat-passphrase'} | ||
179 | ]} | ||
180 | ]}, | ||
181 | {tag:'tr', cls:'formFieldTR', children:[ | ||
182 | {tag:'td', align:'right', valign:'top', children:[ | ||
183 | {tag:'input', id:this.getId('registration_check'), type:'checkbox', name:'safetyCheck'} | ||
184 | ]}, | ||
185 | {tag:'td', children:[ | ||
186 | {tag:'span', htmlString:Clipperz.PM.Strings['registrationFormSafetyCheckLabel']} | ||
187 | ]} | ||
188 | ]}, | ||
189 | {tag:'tr', cls:'formFieldTR', children:[ | ||
190 | {tag:'td', align:'right', valign:'top', children:[ | ||
191 | {tag:'input', id:this.getId('registration_termsOfServiceCheck'), type:'checkbox', name:'termsOfServiceCheck'} | ||
192 | ]}, | ||
193 | {tag:'td', children:[ | ||
194 | {tag:'span', htmlString:Clipperz.PM.Strings['registrationFormTermsOfServiceCheckLabel']} | ||
195 | ]} | ||
196 | ]}, | ||
197 | // {tag:'tr', cls:'formFieldTR', children:[ | ||
198 | // {tag:'td', htmlString:Clipperz.PM.Strings['registrationFormInvitationCodeLabel']}, | ||
199 | // {tag:'td', children:[ | ||
200 | // {tag:'input', id:this.getId('registration_invitationCode'), type:'text', size:'30', name:'invitationCode'} | ||
201 | // ]} | ||
202 | // ]}, | ||
203 | {tag:'tr', children:[ | ||
204 | {tag:'td'}, | ||
205 | {tag:'td', children:[ | ||
206 | {tag:'div', id:this.getId('registration_submit')} | ||
207 | ]} | ||
208 | ]} | ||
209 | ]}, | ||
210 | {tag:'tfoot'} | ||
211 | ]} | ||
212 | ]}, | ||
213 | {tag:'div', cls:'loginFormFooterBox', children:[ | ||
214 | {tag:'ul', children:[ | ||
215 | {tag:'li', children:[ | ||
216 | {tag:'span', htmlString:Clipperz.PM.Strings['registrationFormDoYouAlreadyHaveAnAccountLabel']}, | ||
217 | {tag:'a', href:'.', id:this.getId('showLogin'), cls:'clipperzActionLink', htmlString:Clipperz.PM.Strings['registrationFormSimplyLoginLabel']} | ||
218 | ]} | ||
219 | ]} | ||
220 | ]} | ||
221 | ]} | ||
222 | ]}, | ||
223 | {tag:'div', cls:'loginPanelSwitchLanguageBox', children:[ | ||
224 | {tag:'div', cls:'loginPanelSwitchLanguageDescription', htmlString:Clipperz.PM.Strings['loginPanelSwithLanguageDescription']}, | ||
225 | {tag:'div', cls:'loginPanelSwitchLanguageSelect', children:[ | ||
226 | {tag:'select', id:this.getId('languageSelector'), children:Clipperz.PM.Strings['loginPanelSwitchLanguageSelectOptions']} | ||
227 | ]} | ||
228 | ]}, | ||
229 | {tag:'div', cls:'browserCompatibilityBox', htmlString:Clipperz.PM.Strings['browserCompatibilityDescription']} | ||
230 | ]} | ||
231 | ]} | ||
232 | ]} | ||
233 | ]} | ||
234 | ]}); | ||
235 | |||
236 | MochiKit.Signal.connect(this.getId('loginForm_form'), 'onsubmit', function(e){e.stop();}); | ||
237 | MochiKit.Signal.connect(this.getId('registrationForm_form'), 'onsubmit', function(e){e.stop();}); | ||
238 | |||
239 | MochiKit.Signal.connect(this.getId('showRegistration'), 'onclick', this, 'showRegistrationFormEventHandler'); | ||
240 | MochiKit.Signal.connect(this.getId('showLogin'), 'onclick', this, 'showLoginFormEventHandler'); | ||
241 | |||
242 | new YAHOO.ext.Button(this.getId('login_submit'), {text:Clipperz.PM.Strings['loginFormButtonLabel'], handler:this.doLogin, scope:this, minWidth:0}); | ||
243 | registerButton = new YAHOO.ext.Button(this.getId('registration_submit'), {text:Clipperz.PM.Strings['registrationFormButtonLabel'], handler:this.doRegister, scope:this, minWidth:0}) | ||
244 | |||
245 | if (Clipperz.PM.Proxy.defaultProxy.isReadOnly()) { | ||
246 | // this.getElement('showRegistrationLI').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); | ||
247 | this.getElement('registrationForm_form').addClass('read-only'); | ||
248 | registerButton.disable(); | ||
249 | this.getElement('passwordTypeChooserTR').addClass('read-only'); | ||
250 | this.getDom('useOneTimePasswordCheckbox').disabled = true; | ||
251 | } | ||
252 | |||
253 | MochiKit.Signal.connect(this.getId('loginForm'), 'onkeydown', this, 'onkeydown'); | ||
254 | MochiKit.Signal.connect(this.getId('registrationForm'), 'onkeydown', this, 'onkeydown'); | ||
255 | // MochiKit.Signal.connect(this.getId('useOneTimePasswordCheckbox'), 'onchange', this, 'renderPasswordField'); | ||
256 | MochiKit.Signal.connect(this.getId('useOneTimePasswordCheckbox'), 'onclick', this, 'renderPasswordField'); | ||
257 | this.renderPasswordField(); | ||
258 | |||
259 | this.selectSelectedLanguageOption(); | ||
260 | MochiKit.Signal.connect(this.getId('languageSelector'), 'onchange', this, 'switchLanguage'); | ||
261 | |||
262 | MochiKit.Signal.connect(this.getId('oneTimePassword_1'), 'onkeypress', this, 'handleOneTimePasswordFieldKeyPress'); | ||
263 | MochiKit.Signal.connect(this.getId('oneTimePassword_2'), 'onkeypress', this, 'handleOneTimePasswordFieldKeyPress'); | ||
264 | MochiKit.Signal.connect(this.getId('oneTimePassword_3'), 'onkeypress', this, 'handleOneTimePasswordFieldKeyPress'); | ||
265 | MochiKit.Signal.connect(this.getId('oneTimePassword_4'), 'onkeypress', this, 'handleOneTimePasswordFieldKeyPress'); | ||
266 | |||
267 | MochiKit.Signal.connect(this.getId('oneTimePassword_1'), 'onkeyup', this, 'handleOneTimePasswordFieldKeyUp'); | ||
268 | MochiKit.Signal.connect(this.getId('oneTimePassword_2'), 'onkeyup', this, 'handleOneTimePasswordFieldKeyUp'); | ||
269 | MochiKit.Signal.connect(this.getId('oneTimePassword_3'), 'onkeyup', this, 'handleOneTimePasswordFieldKeyUp'); | ||
270 | MochiKit.Signal.connect(this.getId('oneTimePassword_4'), 'onkeyup', this, 'handleOneTimePasswordFieldKeyUp'); | ||
271 | |||
272 | new Clipperz.PM.Components.PasswordEntropyDisplay(this.getElement('login_passphrase')); | ||
273 | new Clipperz.PM.Components.PasswordEntropyDisplay(this.getElement('registration_passphrase')); | ||
274 | //MochiKit.Logging.logDebug("<<< LoginPanel.initPanel"); | ||
275 | |||
276 | return result; | ||
277 | }, | ||
278 | |||
279 | //------------------------------------------------------------------------- | ||
280 | |||
281 | 'renderPasswordField': function() { | ||
282 | if (this.getDom('useOneTimePasswordCheckbox').checked == false) { | ||
283 | this.getElement('oneTimePasswordDIV').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(false); | ||
284 | this.getElement('passphraseDIV').setVisibilityMode(YAHOO.ext.Element.DISPLAY).show(false); | ||
285 | this.getElement('login_passphrase').focus(); | ||
286 | } else { | ||
287 | this.getElement('passphraseDIV').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); | ||
288 | this.getElement('oneTimePasswordDIV').setVisibilityMode(YAHOO.ext.Element.DISPLAY).show(); | ||
289 | this.getElement('oneTimePassword_1').focus(); | ||
290 | } | ||
291 | |||
292 | }, | ||
293 | |||
294 | //......................................................................... | ||
295 | |||
296 | 'handleOneTimePasswordFieldKeyPress': function(anEvent) { | ||
297 | if (anEvent.key().string == '-') { | ||
298 | switch (anEvent.src().id) { | ||
299 | case this.getId('oneTimePassword_1'): | ||
300 | this.getElement('oneTimePassword_2').focus(); | ||
301 | break; | ||
302 | case this.getId('oneTimePassword_2'): | ||
303 | this.getElement('oneTimePassword_3').focus(); | ||
304 | break; | ||
305 | case this.getId('oneTimePassword_3'): | ||
306 | this.getElement('oneTimePassword_4').focus(); | ||
307 | break; | ||
308 | } | ||
309 | |||
310 | anEvent.stop(); | ||
311 | } | ||
312 | }, | ||
313 | |||
314 | /* | ||
315 | var ctrl = document.getElementById("txtTargetText"); | ||
316 | var saveText = ctrl.value; | ||
317 | ctrl.focus(); | ||
318 | |||
319 | var range = document.selection.createRange(); | ||
320 | var specialchar = String.fromCharCode(1); | ||
321 | range.text = specialchar; | ||
322 | var pos = ctrl.value.indexOf(specialchar); | ||
323 | ctrl.value = saveText; | ||
324 | range = ctrl.createTextRange(); | ||
325 | range.move('character', pos); | ||
326 | range.select(); | ||
327 | range.text = | ||
328 | document.getElementById("txtSourceText").value; | ||
329 | document.getElementById("txtTargetText").focus(); | ||
330 | window.event.returnValue = false; | ||
331 | */ | ||
332 | |||
333 | 'handleOneTimePasswordFieldKeyUp': function(anEvent) { | ||
334 | varfield; | ||
335 | varfieldValue; | ||
336 | var key; | ||
337 | |||
338 | //console.log("keyUp", anEvent); | ||
339 | field = anEvent.src(); | ||
340 | fieldValue = field.value; | ||
341 | key = anEvent.key(); | ||
342 | |||
343 | // &&(key.string != 'KEY_TAB') | ||
344 | // &&(key.string != 'KEY_SHIFT') | ||
345 | // &&(key.string != 'KEY_BACKSPACE') | ||
346 | // &&(key.string != 'KEY_DELETE') | ||
347 | // &&(key.string.indexOf('KEY_ARROW') != 0) | ||
348 | |||
349 | |||
350 | if ((fieldValue.replace(/\s/g, '').length == 8) && (key.string == 'KEY_SPACEBAR')) { | ||
351 | // field.value = Clipperz.Base.trim(fieldValue).replace(/.{4}/g, '$&' + ' '); | ||
352 | |||
353 | switch (field.id) { | ||
354 | case this.getId('oneTimePassword_1'): | ||
355 | this.getElement('oneTimePassword_2').focus(); | ||
356 | break; | ||
357 | case this.getId('oneTimePassword_2'): | ||
358 | this.getElement('oneTimePassword_3').focus(); | ||
359 | break; | ||
360 | case this.getId('oneTimePassword_3'): | ||
361 | this.getElement('oneTimePassword_4').focus(); | ||
362 | break; | ||
363 | } | ||
364 | // } else if (fieldValue.replace(/\s/g, '').length > 8) { | ||
365 | } | ||
366 | |||
367 | //MochiKit.Logging.logDebug("-- fieldValue: " + fieldValue); | ||
368 | }, | ||
369 | |||
370 | //......................................................................... | ||
371 | |||
372 | 'doLogin': function() { | ||
373 | //MochiKit.Logging.logDebug(">>> LoginPanel.doLogin"); | ||
374 | if (this.checkLoginForm()) { | ||
375 | if (this.getDom('useOneTimePasswordCheckbox').checked == false) { | ||
376 | this.doLoginWithUsernameAndPassphrase(this.getDom('login_username').value, this.getDom('login_passphrase').value); | ||
377 | } else { | ||
378 | varoneTimePasswordValue; | ||
379 | |||
380 | oneTimePasswordValue = this.getDom('oneTimePassword_1').value + this.getDom('oneTimePassword_2').value + this.getDom('oneTimePassword_3').value + this.getDom('oneTimePassword_4').value; | ||
381 | this.doLoginWithUsernameAndOneTimePassword(this.getDom('login_username').value, oneTimePasswordValue); | ||
382 | } | ||
383 | } | ||
384 | //MochiKit.Logging.logDebug("<<< LoginPanel.doLogin"); | ||
385 | }, | ||
386 | |||
387 | //......................................................................... | ||
388 | |||
389 | 'doLoginWithUsernameAndPassphrase': function(anUsername, aPassphrase) { | ||
390 | var deferredResult; | ||
391 | var user; | ||
392 | var loginPanel; | ||
393 | |||
394 | //MochiKit.Logging.logDebug(">>> LoginPanel.doLoginWithUsernameAndPassphrase"); | ||
395 | user = new Clipperz.PM.DataModel.User({username:anUsername, passphrase:aPassphrase}); | ||
396 | loginPanel = this; | ||
397 | |||
398 | deferredResult = new MochiKit.Async.Deferred(); | ||
399 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("0 - LoginPanel.doLogin - 0: "/* + res*/); return res;}); | ||
400 | //deferredResult.addErrback(function(res) {MochiKit.Logging.logDebug("ERROR: " + res); return res;}); | ||
401 | deferredResult.addCallback(MochiKit.Base.method(Clipperz.PM.Components.MessageBox(), 'deferredShow'), | ||
402 | { | ||
403 | title: "", | ||
404 | text: "", | ||
405 | width:240, | ||
406 | showProgressBar:true, | ||
407 | showCloseButton:false, | ||
408 | fn:MochiKit.Base.method(deferredResult, 'cancel'), | ||
409 | scope:this | ||
410 | }, | ||
411 | this.getDom('login_submit') | ||
412 | ); | ||
413 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("1 - LoginPanel.doLogin - 1: "/* + res*/); return res;}); | ||
414 | //deferredResult.addErrback(function(res) {MochiKit.Logging.logDebug("ERROR: " + res); return res;}); | ||
415 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'login_start'); | ||
416 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("2 - LoginPanel.doLogin - 2: "/* + res*/); return res;}); | ||
417 | //deferredResult.addErrback(function(res) {MochiKit.Logging.logDebug("ERROR: " + res); return res;}); | ||
418 | deferredResult.addCallback(MochiKit.Base.method(user, 'connect')); | ||
419 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("3 - LoginPanel.doLogin - 3: "/* + res*/); return res;}); | ||
420 | //deferredResult.addErrback(function(res) {MochiKit.Logging.logDebug("ERROR: " + res); return res;}); | ||
421 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'connection_done'); | ||
422 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("4 - LoginPanel.doLogin - 4: "/* + res*/); return res;}); | ||
423 | //deferredResult.addErrback(function(res) {MochiKit.Logging.logDebug("ERROR: " + res); return res;}); | ||
424 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'connection_loadingUserData'); | ||
425 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("5 - LoginPanel.doLogin - 5: "/* + res*/); return res;}); | ||
426 | //deferredResult.addErrback(function(res) {MochiKit.Logging.logDebug("ERROR: " + res); return res;}); | ||
427 | deferredResult.addCallback(MochiKit.Base.method(user, 'loadPreferences')); | ||
428 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("6 - LoginPanel.doLogin - 6: "/* + res*/); return res;}); | ||
429 | //deferredResult.addErrback(function(res) {MochiKit.Logging.logDebug("ERROR: " + res); return res;}); | ||
430 | deferredResult.addCallback(MochiKit.Base.method(user, 'loadRecords')); | ||
431 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("7 - LoginPanel.doLogin - 7: "/* + res*/); return res;}); | ||
432 | //deferredResult.addErrback(function(res) {MochiKit.Logging.logDebug("ERROR: " + res); return res;}); | ||
433 | deferredResult.addCallback(MochiKit.Base.method(user, 'loadDirectLogins')); | ||
434 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("8 - LoginPanel.doLogin - 8: "/* + res*/); return res;}); | ||
435 | //deferredResult.addErrback(function(res) {MochiKit.Logging.logDebug("ERROR: " + res); return res;}); | ||
436 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'login_connected'); | ||
437 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("9 - LoginPanel.doLogin - 9: "/* + res*/); return res;}); | ||
438 | //deferredResult.addErrback(function(res) {MochiKit.Logging.logDebug("ERROR: " + res); return res;}); | ||
439 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, user, 'setupDone', null); | ||
440 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("10 - LoginPanel.doLogin - 10: "/* + res*/); return res;}); | ||
441 | //deferredResult.addErrback(function(res) {MochiKit.Logging.logDebug("ERROR: " + res); return res;}); | ||
442 | |||
443 | deferredResult.addCallback(MochiKit.Async.wait, 0.5); | ||
444 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("11 - LoginPanel.doLogin - 11: "/* + res*/); return res;}); | ||
445 | //deferredResult.addErrback(function(res) {MochiKit.Logging.logDebug("ERROR: " + res); return res;}); | ||
446 | |||
447 | deferredResult.addCallback(function(res) { | ||
448 | Clipperz.PM.Components.MessageBox().hide(YAHOO.ext.Element.get('main')); | ||
449 | return res; | ||
450 | }); | ||
451 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("12 - LoginPanel.doLogin - 12: "/* + res*/); return res;}); | ||
452 | //deferredResult.addErrback(function(res) {MochiKit.Logging.logDebug("ERROR: " + res); return res;}); | ||
453 | |||
454 | deferredResult.addErrback(MochiKit.Base.bind(function() { | ||
455 | Clipperz.PM.Components.MessageBox().update({ | ||
456 | title:Clipperz.PM.Strings['loginMessagePanelFailureTitle'], | ||
457 | text:Clipperz.PM.Strings['loginMessagePanelFailureText'], | ||
458 | showProgressBar:false, | ||
459 | buttons:{'ok':Clipperz.PM.Strings['loginMessagePanelFailureButtonLabel']}, | ||
460 | fn:MochiKit.Base.bind(function() { | ||
461 | this.getElement('login_passphrase').focus(); | ||
462 | this.getElement('login_passphrase').dom.select(); | ||
463 | }, this), | ||
464 | scope:this | ||
465 | }); | ||
466 | }, this)); | ||
467 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("13 - LoginPanel.doLogin - 13: "/* + res*/); return res;}); | ||
468 | //deferredResult.addErrback(function(res) {MochiKit.Logging.logDebug("ERROR: " + res); return res;}); | ||
469 | |||
470 | deferredResult.callback("token"); | ||
471 | //MochiKit.Logging.logDebug("<<< LoginPanel.doLoginWithUsernameAndPassphrase"); | ||
472 | |||
473 | return deferredResult; | ||
474 | }, | ||
475 | |||
476 | //......................................................................... | ||
477 | |||
478 | 'doLoginWithUsernameAndOneTimePassword': function(anUsername, aOneTimePassword) { | ||
479 | var deferredResult; | ||
480 | var loginPanel; | ||
481 | var oneTimePassword; | ||
482 | |||
483 | oneTimePassword = Clipperz.PM.DataModel.OneTimePassword.normalizedOneTimePassword(aOneTimePassword); | ||
484 | |||
485 | //MochiKit.Logging.logDebug(">>> LoginPanel.doLoginWithUsernameAndPassphrase"); | ||
486 | deferredResult = new MochiKit.Async.Deferred(); | ||
487 | deferredResult.addCallback(MochiKit.Base.method(Clipperz.PM.Components.MessageBox(), 'deferredShow'), | ||
488 | { | ||
489 | title: "", | ||
490 | text: "", | ||
491 | width:240, | ||
492 | showProgressBar:true, | ||
493 | showCloseButton:false, | ||
494 | fn:MochiKit.Base.method(deferredResult, 'cancel'), | ||
495 | scope:this, | ||
496 | steps:7, | ||
497 | buttons:{ | ||
498 | //'ok':Clipperz.PM.Strings['loginMessagePanelInitialButtonLabel'] | ||
499 | } | ||
500 | }, | ||
501 | this.getDom('login_submit') | ||
502 | ); | ||
503 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'OTP_login_start'); | ||
504 | deferredResult.addCallback(function(anUsername, aOneTimePassword) { | ||
505 | var args; | ||
506 | |||
507 | args = { | ||
508 | 'message': 'oneTimePassword', | ||
509 | 'version': Clipperz.PM.Crypto.communicationProtocol.currentVersion, | ||
510 | 'parameters': { | ||
511 | 'oneTimePasswordKey': Clipperz.PM.DataModel.OneTimePassword.computeKeyWithUsernameAndPassword(anUsername, aOneTimePassword), | ||
512 | 'oneTimePasswordKeyChecksum': Clipperz.PM.DataModel.OneTimePassword.computeKeyChecksumWithUsernameAndPassword(anUsername, aOneTimePassword) | ||
513 | } | ||
514 | } | ||
515 | |||
516 | return args; | ||
517 | }, anUsername, oneTimePassword); | ||
518 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'OTP_login_loadingOTP'); | ||
519 | deferredResult.addCallback(MochiKit.Base.method(Clipperz.PM.Proxy.defaultProxy, 'handshake')); | ||
520 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'OTP_login_extractingPassphrase'); | ||
521 | deferredResult.addCallback(function(aResult) { | ||
522 | return Clipperz.PM.Crypto.deferredDecrypt(oneTimePassword, aResult['data'], aResult['version']); | ||
523 | }); | ||
524 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("LoginPanel.otpLogin - 4: " + res); return res;}); | ||
525 | deferredResult.addCallback(function(aResult) { | ||
526 | //MochiKit.Logging.logDebug("aResult") | ||
527 | return (new Clipperz.ByteArray().appendBase64String(aResult['passphrase'])).asString(); | ||
528 | }); | ||
529 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("LoginPanel.otpLogin - 5: " + res); return res;}); | ||
530 | deferredResult.addCallbacks( | ||
531 | MochiKit.Base.method(this, 'doLoginWithUsernameAndPassphrase', anUsername), | ||
532 | MochiKit.Base.bind(function(aLoginPanel) { | ||
533 | Clipperz.PM.Components.MessageBox().update({ | ||
534 | title:Clipperz.PM.Strings['loginMessagePanelFailureTitle'], | ||
535 | text:Clipperz.PM.Strings['loginMessagePanelFailureText'], | ||
536 | showProgressBar:false, | ||
537 | buttons:{'ok':Clipperz.PM.Strings['loginMessagePanelFailureButtonLabel']}, | ||
538 | fn:MochiKit.Base.bind(function() { | ||
539 | this.getElement('oneTimePassword_1').focus(); | ||
540 | }, this), | ||
541 | scope:aLoginPanel | ||
542 | }); | ||
543 | }, this) | ||
544 | ); | ||
545 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("LoginPanel.otpLogin - 6: " + res); return res;}); | ||
546 | deferredResult.callback("token"); | ||
547 | //MochiKit.Logging.logDebug("<<< LoginPanel.doLoginWithUsernameAndPassphrase"); | ||
548 | |||
549 | return deferredResult; | ||
550 | }, | ||
551 | |||
552 | //......................................................................... | ||
553 | |||
554 | 'checkLoginForm': function() { | ||
555 | var result; | ||
556 | var username | ||
557 | |||
558 | result = true; | ||
559 | |||
560 | //MochiKit.Logging.logDebug(">>> checkLoginForm"); | ||
561 | username = Clipperz.Base.trim(this.getDom('login_username').value); | ||
562 | if (username == "") { | ||
563 | this.getElement('login_username').focus(); | ||
564 | result = false; | ||
565 | } else { | ||
566 | if (this.getDom('useOneTimePasswordCheckbox').checked == false) { | ||
567 | varpassphrase; | ||
568 | |||
569 | passphrase = Clipperz.Base.trim(this.getDom('login_passphrase').value); | ||
570 | |||
571 | if (passphrase == "") { | ||
572 | this.getElement('login_passphrase').focus(); | ||
573 | result = false; | ||
574 | } | ||
575 | } else { | ||
576 | if (Clipperz.Base.trim(this.getDom('oneTimePassword_1').value) == "") { | ||
577 | this.getElement('oneTimePassword_1').focus(); | ||
578 | result = false; | ||
579 | } else if (Clipperz.Base.trim(this.getDom('oneTimePassword_2').value) == "") { | ||
580 | this.getElement('oneTimePassword_2').focus(); | ||
581 | result = false; | ||
582 | } else if (Clipperz.Base.trim(this.getDom('oneTimePassword_3').value) == "") { | ||
583 | this.getElement('oneTimePassword_3').focus(); | ||
584 | result = false; | ||
585 | } else if (Clipperz.Base.trim(this.getDom('oneTimePassword_4').value) == "") { | ||
586 | this.getElement('oneTimePassword_4').focus(); | ||
587 | result = false; | ||
588 | } | ||
589 | } | ||
590 | } | ||
591 | //MochiKit.Logging.logDebug("<<< checkLoginForm - " + result); | ||
592 | |||
593 | return result; | ||
594 | }, | ||
595 | |||
596 | //......................................................................... | ||
597 | |||
598 | 'doRegister': function(anEvent) { | ||
599 | if ((Clipperz.PM.Proxy.defaultProxy.isReadOnly() == false) && (this.checkRegistrationForm())) { | ||
600 | this.doRegistrationWithUsernameAndPassphrase(this.getDom('registration_username').value, this.getDom('registration_passphrase').value /*, this.getDom('registration_invitationCode').value*/); | ||
601 | } | ||
602 | }, | ||
603 | |||
604 | //......................................................................... | ||
605 | |||
606 | 'checkRegistrationForm': function() { | ||
607 | var result; | ||
608 | var username | ||
609 | varpassphrase; | ||
610 | varrePassphrase; | ||
611 | varsafetyCheck; | ||
612 | vartermsOfServiceCheck; | ||
613 | // varinvitationCode; | ||
614 | |||
615 | username = this.getDom('registration_username').value; | ||
616 | passphrase = this.getDom('registration_passphrase').value; | ||
617 | rePassphrase = this.getDom('registration_repassphrase').value; | ||
618 | safetyCheck = this.getDom('registration_check').checked; | ||
619 | termsOfServiceCheck = this.getDom('registration_termsOfServiceCheck').checked; | ||
620 | // invitationCode = this.getDom('registration_invitationCode').value; | ||
621 | |||
622 | if ((username != "") && (passphrase != "") && (rePassphrase != "") /*&& (invitationCode != "")*/) { | ||
623 | if (passphrase != rePassphrase) { | ||
624 | //show alert that the passphrase and rePassphrase should be equal | ||
625 | //MochiKit.Logging.logDebug("WARNING: passphrase != rePassphrase"); | ||
626 | this.showRegistrationFormErrorMessageAnimation(Clipperz.PM.Strings['registrationFormWarningMessageNotMatchingPassphrases']); | ||
627 | this.getElement('registration_repassphrase').focus().dom.select(); | ||
628 | // this.getElement('registration_repassphrase').select(); | ||
629 | result = false; | ||
630 | } else if (safetyCheck != true) { | ||
631 | //show alert that the safetyCheck should be checed | ||
632 | //MochiKit.Logging.logDebug("WARNING: safetyCheck not checked"); | ||
633 | this.showRegistrationFormErrorMessageAnimation(Clipperz.PM.Strings['registrationFormWarningMessageSafetyCheckNotSelected']); | ||
634 | this.getElement('registration_check').focus(); | ||
635 | result = false; | ||
636 | } else if (termsOfServiceCheck != true) { | ||
637 | this.showRegistrationFormErrorMessageAnimation(Clipperz.PM.Strings['registrationFormWarningMessageTermsOfServiceCheckNotSelected']); | ||
638 | this.getElement('registration_termsOfServiceCheck').focus(); | ||
639 | } else { | ||
640 | result = true; | ||
641 | } | ||
642 | } else { | ||
643 | if (username == "") { | ||
644 | this.getElement('registration_username').focus(); | ||
645 | } else if (passphrase == "") { | ||
646 | this.getElement('registration_passphrase').focus(); | ||
647 | } else if (rePassphrase == "") { | ||
648 | this.getElement('registration_repassphrase').focus(); | ||
649 | // } else if (invitationCode == "") { | ||
650 | // this.showRegistrationFormErrorMessageAnimation(Clipperz.PM.Strings['registrationFormWarningMessageInvitationCodeMissing']); | ||
651 | // this.getElement('registration_invitationCode').focus(); | ||
652 | } | ||
653 | |||
654 | result = false; | ||
655 | } | ||
656 | |||
657 | if (result === true) { | ||
658 | this.getActor('registration_errorMessage').hide(); | ||
659 | } | ||
660 | |||
661 | return result; | ||
662 | }, | ||
663 | |||
664 | //......................................................................... | ||
665 | |||
666 | 'showRegistrationFormErrorMessageAnimation': function(anErrorMessage, aCallback) { | ||
667 | varerrorMessageActor; | ||
668 | |||
669 | errorMessageActor = this.getActor('registration_errorMessage'); | ||
670 | errorMessageActor.update(anErrorMessage); | ||
671 | errorMessageActor.show(true); | ||
672 | errorMessageActor.play(aCallback); | ||
673 | }, | ||
674 | |||
675 | //......................................................................... | ||
676 | |||
677 | 'doRegistrationWithUsernameAndPassphrase': function(anUsername, aPassphrase /*, anInvitationCode */) { | ||
678 | var deferredResult; | ||
679 | var user; | ||
680 | var loginPanel; | ||
681 | |||
682 | //MochiKit.Logging.logDebug(">>> LoginPanel.doRegistrationWithUsernameAndPassphrase"); | ||
683 | user = new Clipperz.PM.DataModel.User({username:anUsername, passphrase:aPassphrase}); | ||
684 | //MochiKit.Logging.logDebug("--- LoginPanel.doRegistrationWithUsernameAndPassphrase - 1"); | ||
685 | loginPanel = this; | ||
686 | //MochiKit.Logging.logDebug("--- LoginPanel.doRegistrationWithUsernameAndPassphrase - 2"); | ||
687 | |||
688 | deferredResult = new MochiKit.Async.Deferred(); | ||
689 | //MochiKit.Logging.logDebug("--- LoginPanel.doRegistrationWithUsernameAndPassphrase - 3"); | ||
690 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("LoginPanel.doRegistrationWithUsernameAndPassphrase - 1: " + res); return res;}); | ||
691 | deferredResult.addCallback(MochiKit.Base.method(Clipperz.PM.Components.MessageBox(), 'deferredShow'), | ||
692 | { | ||
693 | title:Clipperz.PM.Strings['registrationMessagePanelInitialTitle'], | ||
694 | text: Clipperz.PM.Strings['registrationMessagePanelInitialText'], | ||
695 | width:240, | ||
696 | showProgressBar:true, | ||
697 | showCloseButton:false, | ||
698 | fn:MochiKit.Base.method(deferredResult, 'cancel'), | ||
699 | scope:this, | ||
700 | steps:9, | ||
701 | buttons:{ | ||
702 | 'ok':Clipperz.PM.Strings['registrationMessagePanelInitialButtonLabel'] | ||
703 | } | ||
704 | }, | ||
705 | this.getDom('registration_submit') | ||
706 | ); | ||
707 | //MochiKit.Logging.logDebug("--- LoginPanel.doRegistrationWithUsernameAndPassphrase - 4"); | ||
708 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("LoginPanel.doRegistrationWithUsernameAndPassphrase - 2: " + res); return res;}); | ||
709 | deferredResult.addCallback(MochiKit.Base.method(user, 'register'), /*anInvitationCode*/ "VeryBraveBetaTester"); | ||
710 | //MochiKit.Logging.logDebug("--- LoginPanel.doRegistrationWithUsernameAndPassphrase - 5"); | ||
711 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("LoginPanel.doRegistrationWithUsernameAndPassphrase - 3: " + res); return res;}); | ||
712 | deferredResult.addCallback(function(res) { | ||
713 | Clipperz.PM.Components.MessageBox().update({ | ||
714 | title:Clipperz.PM.Strings['registrationMessagePanelRegistrationDoneTitle'], | ||
715 | text:Clipperz.PM.Strings['registrationMessagePanelRegistrationDoneText'], | ||
716 | step:'next' | ||
717 | }); | ||
718 | return res; | ||
719 | }); | ||
720 | //MochiKit.Logging.logDebug("--- LoginPanel.doRegistrationWithUsernameAndPassphrase - 6"); | ||
721 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("LoginPanel.doRegistrationWithUsernameAndPassphrase - 5: " + res); return res;}); | ||
722 | deferredResult.addCallback(MochiKit.Async.wait, 1); | ||
723 | //MochiKit.Logging.logDebug("--- LoginPanel.doRegistrationWithUsernameAndPassphrase - 7"); | ||
724 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("LoginPanel.doRegistrationWithUsernameAndPassphrase - 6: " + res); return res;}); | ||
725 | deferredResult.addCallback(MochiKit.Base.method(user, 'connect')); | ||
726 | //MochiKit.Logging.logDebug("--- LoginPanel.doRegistrationWithUsernameAndPassphrase - 8"); | ||
727 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("LoginPanel.doRegistrationWithUsernameAndPassphrase - 7: " + res); return res;}); | ||
728 | deferredResult.addCallback(MochiKit.Async.wait, 1); | ||
729 | //MochiKit.Logging.logDebug("--- LoginPanel.doRegistrationWithUsernameAndPassphrase - 9"); | ||
730 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("LoginPanel.doRegistrationWithUsernameAndPassphrase - 8: " + res); return res;}); | ||
731 | deferredResult.addCallback(function(res) { | ||
732 | Clipperz.PM.Components.MessageBox().hide(YAHOO.ext.Element.get('main')); | ||
733 | return res; | ||
734 | }); | ||
735 | deferredResult.addCallback(MochiKit.Base.method(this, 'showRegistrationSplashScreen'), user); | ||
736 | //MochiKit.Logging.logDebug("--- LoginPanel.doRegistrationWithUsernameAndPassphrase - 10"); | ||
737 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("LoginPanel.doRegistrationWithUsernameAndPassphrase - 9: " + res); return res;}); | ||
738 | deferredResult.addErrback(function(anError) { | ||
739 | Clipperz.PM.Components.MessageBox().update({ | ||
740 | title:Clipperz.PM.Strings['registrationMessagePanelFailureTitle'], | ||
741 | text:anError.message, | ||
742 | showProgressBar:false, | ||
743 | buttons:{'ok':Clipperz.PM.Strings['registrationMessagePanelFailureButtonLabel']}}); | ||
744 | return anError; | ||
745 | }); | ||
746 | //MochiKit.Logging.logDebug("--- LoginPanel.doRegistrationWithUsernameAndPassphrase - 11"); | ||
747 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("LoginPanel.doRegistrationWithUsernameAndPassphrase - 10: " + res); return res;}); | ||
748 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, user, 'setupDone', null); | ||
749 | deferredResult.callback("token"); | ||
750 | //MochiKit.Logging.logDebug("--- LoginPanel.doRegistrationWithUsernameAndPassphrase - 12"); | ||
751 | |||
752 | return deferredResult; | ||
753 | }, | ||
754 | |||
755 | //------------------------------------------------------------------------- | ||
756 | |||
757 | 'showRegistrationSplashScreen': function(anUser) { | ||
758 | var deferredResult; | ||
759 | var alertElement; | ||
760 | varalertDialog; | ||
761 | var closeButton; | ||
762 | var closeFunction; | ||
763 | |||
764 | deferredResult = new MochiKit.Async.Deferred(); | ||
765 | |||
766 | //MochiKit.Logging.logDebug(">>> Main.showRegistrationSplashScreen"); | ||
767 | alertElement = Clipperz.YUI.DomHelper.append(document.body, {tag:'div', id:'registrationSplash', children:[ | ||
768 | {tag:'div', cls:'ydlg-hd', htmlString:Clipperz.PM.Strings['registrationSplashPanelTitle']}, | ||
769 | {tag:'div', cls:'ydlg-bd', children:[ | ||
770 | {tag:'div', cls:'alert-message', id:'splashMessage', children:[ | ||
771 | {tag:'div', htmlString:Clipperz.PM.Strings['registrationSplashPanelDescription']}, | ||
772 | {tag:'table', border:'0', cellpadding:'5', children:[ | ||
773 | {tag:'tbody', children:[ | ||
774 | {tag:'tr', children:[ | ||
775 | {tag:'td', valign:'top', children:[ | ||
776 | {tag:'span', cls:'label', htmlString:Clipperz.PM.Strings['registrationSplashPanelUsernameLabel']} | ||
777 | ]}, | ||
778 | {tag:'td', valign:'top', children:[ | ||
779 | {tag:'span', cls:'value', html:Clipperz.Base.escapeHTML(anUser.username())} | ||
780 | ]} | ||
781 | ]}, | ||
782 | {tag:'tr', children:[ | ||
783 | {tag:'td', valign:'top', children:[ | ||
784 | {tag:'span', cls:'label', htmlString:Clipperz.PM.Strings['registrationSplashPanelPassphraseLabel']} | ||
785 | ]}, | ||
786 | {tag:'td', valign:'top', children:[ | ||
787 | {tag:'div', id:this.getId('showPassphraseDiv'), children:[ | ||
788 | {tag:'span', cls:'value', html:Clipperz.Base.escapeHTML(anUser.passphrase())} | ||
789 | ]}, | ||
790 | {tag:'div', id:this.getId('hidePassphraseDiv'), cls:'Clipperz_recordFieldData', children:[ | ||
791 | {tag:'input', id:this.getId('passwordField'), type:'text', cls:'scrambledField', title:Clipperz.PM.Strings['recordDetailPasswordFieldTooltipLabel'], value:"anUser.passphrase()"} | ||
792 | ]} | ||
793 | ]} | ||
794 | ]}, | ||
795 | {tag:'tr', children:[ | ||
796 | {tag:'td'}, | ||
797 | {tag:'td', valign:'top', children:[ | ||
798 | // {tag:'a', href:"#", id:this.getId('togglePassphraseVisibility'), htmlString:Clipperz.PM.Strings['registrationSplashPanelShowPassphraseButtonLabel']} | ||
799 | {tag:'input', type:'checkbox', id:this.getId('showPassphraseCheckbox')}, | ||
800 | {tag:'span', cls:'activeText', id:this.getId('showPassphraseText'), htmlString:Clipperz.PM.Strings['registrationSplashPanelShowPassphraseButtonLabel']} | ||
801 | ]} | ||
802 | ]} | ||
803 | ]} | ||
804 | ]} | ||
805 | ]} | ||
806 | ]}, | ||
807 | {tag:'div', cls:'ydlg-ft'} | ||
808 | ]}, true); | ||
809 | //MochiKit.Logging.logDebug("--- Main.showRegistrationSplashScreen - 1"); | ||
810 | |||
811 | this.getElement('passwordField').dom.value = anUser.passphrase(); | ||
812 | this.getElement('passwordField').wrap({tag:'div', cls:'passwordBackground'}).setStyle('background-position', "0px -" + Math.min(128, Clipperz.PM.Crypto.passwordEntropy(anUser.passphrase())) + "px").setStyle('width', '71px'); | ||
813 | MochiKit.Signal.connect(this.getId('showPassphraseCheckbox'), 'onclick', this, 'togglePassphraseVisibility'); | ||
814 | MochiKit.Signal.connect(this.getId('showPassphraseText'), 'onclick', this, 'togglePassphraseCheckbox'); | ||
815 | //MochiKit.Logging.logDebug("--- Main.showRegistrationSplashScreen - 1.1"); | ||
816 | |||
817 | this.getElement('showPassphraseDiv').setVisibilityMode(YAHOO.ext.Element.DISPLAY); | ||
818 | this.getElement('hidePassphraseDiv').setVisibilityMode(YAHOO.ext.Element.DISPLAY); | ||
819 | //MochiKit.Logging.logDebug("--- Main.showRegistrationSplashScreen - 1.1.1"); | ||
820 | this.togglePassphraseVisibility(); | ||
821 | //MochiKit.Logging.logDebug("--- Main.showRegistrationSplashScreen - 1.2"); | ||
822 | |||
823 | alertDialog = new YAHOO.ext.BasicDialog( | ||
824 | alertElement, { | ||
825 | closable:false, | ||
826 | modal:true, | ||
827 | autoTabs:false, | ||
828 | resizable:false, | ||
829 | fixedcenter:true, | ||
830 | constraintoviewport:false, | ||
831 | width:450, | ||
832 | height:220, | ||
833 | shadow:true, | ||
834 | minWidth:300, | ||
835 | minHeight:300 | ||
836 | } | ||
837 | ); | ||
838 | //MochiKit.Logging.logDebug("--- Main.showRegistrationSplashScreen - 2"); | ||
839 | |||
840 | closeFunction = deferredResult.callback; | ||
841 | //MochiKit.Logging.logDebug("--- Main.showRegistrationSplashScreen - 3"); | ||
842 | alertDialog.addKeyListener(27, closeFunction); | ||
843 | //MochiKit.Logging.logDebug("--- Main.showRegistrationSplashScreen - 4"); | ||
844 | closeButton = alertDialog.addButton(Clipperz.PM.Strings['splashAlertCloseButtonLabel'], closeFunction, deferredResult); | ||
845 | //MochiKit.Logging.logDebug("--- Main.showRegistrationSplashScreen - 5"); | ||
846 | alertDialog.setDefaultButton(closeButton); | ||
847 | //MochiKit.Logging.logDebug("--- Main.showRegistrationSplashScreen - 6"); | ||
848 | alertDialog.show('main'); | ||
849 | //MochiKit.Logging.logDebug("--- Main.showRegistrationSplashScreen - 7"); | ||
850 | |||
851 | deferredResult.addBoth(MochiKit.Base.method(alertDialog, 'hide')); | ||
852 | deferredResult.addCallback(MochiKit.Signal.disconnectAllTo, this) | ||
853 | //MochiKit.Logging.logDebug("--- Main.showRegistrationSplashScreen - 8"); | ||
854 | deferredResult.addCallback(MochiKit.Async.succeed); | ||
855 | //MochiKit.Logging.logDebug("<<< Main.showRegistrationSplashScreen"); | ||
856 | |||
857 | return deferredResult; | ||
858 | }, | ||
859 | |||
860 | //------------------------------------------------------------------------- | ||
861 | |||
862 | 'showLoginFormEventHandler': function(anEvent) { | ||
863 | anEvent.stop(); | ||
864 | this.showLoginForm(true); | ||
865 | }, | ||
866 | |||
867 | 'showLoginForm': function(shouldAnimate) { | ||
868 | if (shouldAnimate) { | ||
869 | this.showLoginFormAnimator().play(); | ||
870 | } else { | ||
871 | this.hideRegistrationForm(false); | ||
872 | this.getActor('loginForm').show(false); | ||
873 | this.getElement('login_username').focus(); | ||
874 | } | ||
875 | this.setVisibleForm('login'); | ||
876 | }, | ||
877 | |||
878 | 'showLoginFormAnimator': function() { | ||
879 | if (this._showLoginFormAnimator == null) { | ||
880 | var animator; | ||
881 | varloginFormActor; | ||
882 | var registrationFormActor; | ||
883 | var usernameFieldActor; | ||
884 | |||
885 | animator = new YAHOO.ext.Animator(); | ||
886 | loginFormActor = this.getActor('loginForm', animator); | ||
887 | loginFormActor.setVisibilityMode(YAHOO.ext.Element.DISPLAY); | ||
888 | registrationFormActor = this.getActor('registrationForm', animator); | ||
889 | registrationFormActor.setVisibilityMode(YAHOO.ext.Element.DISPLAY); | ||
890 | usernameFieldActor = this.getActor('login_username', animator); | ||
891 | |||
892 | animator.startCapture(); | ||
893 | registrationFormActor.hide(true); | ||
894 | loginFormActor.show(true); | ||
895 | usernameFieldActor.focus(); | ||
896 | animator.stopCapture(); | ||
897 | |||
898 | this._showLoginFormAnimator = animator; | ||
899 | } | ||
900 | |||
901 | return this._showLoginFormAnimator; | ||
902 | }, | ||
903 | |||
904 | |||
905 | 'hideLoginForm': function(shouldAnimate) { | ||
906 | var loginFormActor; | ||
907 | |||
908 | loginFormActor = this.getActor('loginForm'); | ||
909 | loginFormActor.setVisibilityMode(YAHOO.ext.Element.DISPLAY); | ||
910 | loginFormActor.hide(shouldAnimate); | ||
911 | }, | ||
912 | |||
913 | //------------------------------------------------------------------------- | ||
914 | |||
915 | 'showRegistrationFormEventHandler': function(anEvent) { | ||
916 | anEvent.stop(); | ||
917 | this.showRegistrationForm(true); | ||
918 | }, | ||
919 | |||
920 | 'showRegistrationForm': function(shouldAnimate) { | ||
921 | if (shouldAnimate) { | ||
922 | this.showRegistrationFormAnimator().play(MochiKit.Base.bind(this.showRegistrationAlert, this)); | ||
923 | } else { | ||
924 | varerrorMessageActor; | ||
925 | |||
926 | this.hideLoginForm(shouldAnimate) | ||
927 | this.getActor('registrationForm').show(false); | ||
928 | this.getElement('registration_username').focus(); | ||
929 | |||
930 | errorMessageActor = this.getActor('registration_errorMessage'); | ||
931 | errorMessageActor.setVisibilityMode(YAHOO.ext.Element.DISPLAY); | ||
932 | errorMessageActor.update("---"); | ||
933 | errorMessageActor.hide(); | ||
934 | |||
935 | this.showRegistrationAlert(); | ||
936 | } | ||
937 | this.setVisibleForm('registration'); | ||
938 | }, | ||
939 | |||
940 | 'showRegistrationFormAnimator': function() { | ||
941 | if (this._showRegistrationFormAnimator == null) { | ||
942 | var animator; | ||
943 | varloginFormActor; | ||
944 | var registrationFormActor; | ||
945 | var usernameFieldActor; | ||
946 | varerrorMessageActor; | ||
947 | |||
948 | animator = new YAHOO.ext.Animator(); | ||
949 | loginFormActor = this.getActor('loginForm', animator); | ||
950 | loginFormActor.setVisibilityMode(YAHOO.ext.Element.DISPLAY); | ||
951 | registrationFormActor = this.getActor('registrationForm', animator); | ||
952 | registrationFormActor.setVisibilityMode(YAHOO.ext.Element.DISPLAY); | ||
953 | usernameFieldActor = this.getActor('registration_username', animator); | ||
954 | errorMessageActor = this.getActor('registration_errorMessage', animator); | ||
955 | errorMessageActor.setVisibilityMode(YAHOO.ext.Element.DISPLAY); | ||
956 | |||
957 | animator.startCapture(); | ||
958 | loginFormActor.hide(true); | ||
959 | errorMessageActor.update("---"); | ||
960 | errorMessageActor.hide(); | ||
961 | registrationFormActor.show(true); | ||
962 | usernameFieldActor.focus(); | ||
963 | animator.stopCapture(); | ||
964 | |||
965 | this._showRegistrationFormAnimator = animator; | ||
966 | } | ||
967 | |||
968 | return this._showRegistrationFormAnimator; | ||
969 | }, | ||
970 | |||
971 | 'hideRegistrationForm': function(shouldAnimate) { | ||
972 | var registrationFormActor; | ||
973 | |||
974 | registrationFormActor = this.getActor('registrationForm'); | ||
975 | registrationFormActor.setVisibilityMode(YAHOO.ext.Element.DISPLAY); | ||
976 | registrationFormActor.hide(shouldAnimate); | ||
977 | }, | ||
978 | |||
979 | //------------------------------------------------------------------------- | ||
980 | |||
981 | 'shouldShowRegistrationAlert': function() { | ||
982 | return this._shouldShowRegistrationAlert; | ||
983 | }, | ||
984 | |||
985 | 'showRegistrationAlert': function() { | ||
986 | if ((this.shouldShowRegistrationAlert()) && (Clipperz.PM.Proxy.defaultProxy.isReadOnly() == false)) { | ||
987 | var alertElement; | ||
988 | varalertDialog; | ||
989 | var closeButton; | ||
990 | var closeFunction; | ||
991 | |||
992 | alertElement = Clipperz.YUI.DomHelper.append(document.body, {tag:'div', id:'alert', children:[ | ||
993 | {tag:'div', cls:'ydlg-hd', htmlString:Clipperz.PM.Strings['splashAlertTitle']}, | ||
994 | {tag:'div', cls:'ydlg-bd', children:[ | ||
995 | {tag:'div', cls:'alert-message', id:'splashMessage', htmlString:Clipperz.PM.Strings['splashAlertText']} | ||
996 | ]}, | ||
997 | {tag:'div', cls:'ydlg-ft'} | ||
998 | ]}, true); | ||
999 | |||
1000 | alertDialog = new YAHOO.ext.BasicDialog( | ||
1001 | alertElement, { | ||
1002 | closable:false, | ||
1003 | modal:true, | ||
1004 | autoTabs:false, | ||
1005 | resizable:false, | ||
1006 | fixedcenter:true, | ||
1007 | constraintoviewport:false, | ||
1008 | width:450, | ||
1009 | height:320, | ||
1010 | shadow:true, | ||
1011 | minWidth:300, | ||
1012 | minHeight:300 | ||
1013 | } | ||
1014 | ); | ||
1015 | |||
1016 | closeFunction = MochiKit.Base.partial(MochiKit.Base.bind(this.closeResigrationAlert, this), alertDialog); | ||
1017 | alertDialog.addKeyListener(27, closeFunction); | ||
1018 | closeButton = alertDialog.addButton(Clipperz.PM.Strings['splashAlertCloseButtonLabel'], closeFunction, this); | ||
1019 | alertDialog.setDefaultButton(closeButton); | ||
1020 | alertDialog.show('main'); | ||
1021 | |||
1022 | this._shouldShowRegistrationAlert = false; | ||
1023 | } | ||
1024 | }, | ||
1025 | |||
1026 | 'closeResigrationAlert': function(anAlertDialog) { | ||
1027 | anAlertDialog.hide(MochiKit.Base.bind(function() {anAlertDialog.destroy(true); this.focusOnVisibleForm();}, this)); | ||
1028 | }, | ||
1029 | |||
1030 | //------------------------------------------------------------------------- | ||
1031 | |||
1032 | 'onkeydown': function(anEvent) { | ||
1033 | //MochiKit.Logging.logDebug(">>> onkeydown - " + anEvent.src().id); | ||
1034 | if (anEvent.key().code == 13) { | ||
1035 | if (anEvent.src() == this.getDom('loginForm')) { | ||
1036 | this.doLogin(); | ||
1037 | } else if (anEvent.src() == this.getDom('registrationForm')) { | ||
1038 | this.doRegister(); | ||
1039 | } else { | ||
1040 | } | ||
1041 | |||
1042 | anEvent.stop(); | ||
1043 | } | ||
1044 | }, | ||
1045 | |||
1046 | //------------------------------------------------------------------------- | ||
1047 | |||
1048 | 'visibleForm': function() { | ||
1049 | return this._visibleForm; | ||
1050 | }, | ||
1051 | |||
1052 | 'setVisibleForm': function(aValue) { | ||
1053 | this._visibleForm = aValue; | ||
1054 | }, | ||
1055 | |||
1056 | //------------------------------------------------------------------------- | ||
1057 | |||
1058 | 'focusOnVisibleForm': function() { | ||
1059 | if (this.visibleForm() == 'registration') { | ||
1060 | this.getElement('registration_username').focus(); | ||
1061 | } else { | ||
1062 | this.getElement('login_username').focus(); | ||
1063 | } | ||
1064 | }, | ||
1065 | |||
1066 | //------------------------------------------------------------------------- | ||
1067 | |||
1068 | 'show': function() { | ||
1069 | if (this.visibleForm() == 'registration') { | ||
1070 | this.showRegistrationForm(false); | ||
1071 | } else { | ||
1072 | this.showLoginForm(false); | ||
1073 | } | ||
1074 | }, | ||
1075 | |||
1076 | //------------------------------------------------------------------------- | ||
1077 | |||
1078 | 'switchLanguage': function(anEvent) { | ||
1079 | Clipperz.PM.Strings.Languages.setSelectedLanguage(anEvent.src().value); | ||
1080 | }, | ||
1081 | |||
1082 | //------------------------------------------------------------------------- | ||
1083 | |||
1084 | 'selectSelectedLanguageOption': function() { | ||
1085 | Clipperz.DOM.selectOptionMatchingValue(this.getDom('languageSelector'), Clipperz.PM.Strings.selectedLanguage, true); | ||
1086 | }, | ||
1087 | |||
1088 | //------------------------------------------------------------------------- | ||
1089 | |||
1090 | 'switchLanguageHandler': function() { | ||
1091 | this.render(); | ||
1092 | this.show(); | ||
1093 | }, | ||
1094 | |||
1095 | //------------------------------------------------------------------------- | ||
1096 | |||
1097 | 'togglePassphraseCheckbox': function(anEvent) { | ||
1098 | this.getDom('showPassphraseCheckbox').click(); | ||
1099 | }, | ||
1100 | |||
1101 | 'togglePassphraseVisibility': function(anEvent) { | ||
1102 | if (this.getDom('showPassphraseCheckbox').checked == true) { | ||
1103 | this.getElement('showPassphraseDiv').show(); | ||
1104 | this.getElement('hidePassphraseDiv').hide(); | ||
1105 | } else { | ||
1106 | this.getElement('showPassphraseDiv').hide(); | ||
1107 | this.getElement('hidePassphraseDiv').show(); | ||
1108 | } | ||
1109 | }, | ||
1110 | |||
1111 | //------------------------------------------------------------------------- | ||
1112 | __syntaxFix__: "syntax fix" | ||
1113 | |||
1114 | }); | ||
diff --git a/frontend/beta/js/Clipperz/PM/Components/Panels/LogoutPanel.js b/frontend/beta/js/Clipperz/PM/Components/Panels/LogoutPanel.js new file mode 100644 index 0000000..d7abfd6 --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/Panels/LogoutPanel.js | |||
@@ -0,0 +1,73 @@ | |||
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 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | ||
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | ||
31 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } | ||
32 | if (typeof(Clipperz.PM.Components.Panels) == 'undefined') { Clipperz.PM.Components.Panels = {}; } | ||
33 | |||
34 | //############################################################################# | ||
35 | |||
36 | Clipperz.PM.Components.Panels.LogoutPanel = function(args) { | ||
37 | args = args || {}; | ||
38 | |||
39 | Clipperz.PM.Components.Panels.LogoutPanel.superclass.constructor.call(this, args); | ||
40 | |||
41 | return this; | ||
42 | } | ||
43 | |||
44 | //============================================================================= | ||
45 | |||
46 | YAHOO.extendX(Clipperz.PM.Components.Panels.LogoutPanel, Clipperz.PM.Components.Panels.BasePanel, { | ||
47 | |||
48 | 'toString': function() { | ||
49 | return "Clipperz.PM.Components.LogoutPanel component"; | ||
50 | }, | ||
51 | |||
52 | //------------------------------------------------------------------------- | ||
53 | |||
54 | 'initPanel': function() { | ||
55 | var result; | ||
56 | varlayout; | ||
57 | |||
58 | result = new YAHOO.ext.ContentPanel(this.getId('panel'), {title:'logout', closable:false, autoCreate:true}); | ||
59 | |||
60 | Clipperz.YUI.DomHelper.append(result.getEl().dom, | ||
61 | {tag:'div', children:[ | ||
62 | {tag:'h2', html:'Logout panel'} | ||
63 | ]} | ||
64 | ); | ||
65 | |||
66 | return result; | ||
67 | }, | ||
68 | |||
69 | //------------------------------------------------------------------------- | ||
70 | __syntaxFix__: "syntax fix" | ||
71 | |||
72 | }); | ||
73 | |||
diff --git a/frontend/beta/js/Clipperz/PM/Components/Panels/MainPanel.js b/frontend/beta/js/Clipperz/PM/Components/Panels/MainPanel.js new file mode 100644 index 0000000..e2036d0 --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/Panels/MainPanel.js | |||
@@ -0,0 +1,906 @@ | |||
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 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | ||
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | ||
31 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } | ||
32 | if (typeof(Clipperz.PM.Components.Panels) == 'undefined') { Clipperz.PM.Components.Panels = {}; } | ||
33 | |||
34 | //############################################################################# | ||
35 | |||
36 | Clipperz.PM.Components.Panels.MainPanel = function(anElement, args) { | ||
37 | args = args || {}; | ||
38 | |||
39 | Clipperz.PM.Components.Panels.MainPanel.superclass.constructor.call(this, anElement, args); | ||
40 | |||
41 | this._recordListDataModel = null; | ||
42 | this._selectedRecord = null; | ||
43 | this._recordDetailComponent = null; | ||
44 | this._recordListGrid = null; | ||
45 | |||
46 | this._directLinkItemTemplate = null; | ||
47 | this._recordItemTemplate = null; | ||
48 | |||
49 | this._addNewRecordButton = null; | ||
50 | this._deleteRecordButton = null; | ||
51 | |||
52 | this._creationWizard = null; | ||
53 | |||
54 | Clipperz.NotificationCenter.register(null, 'selectAndEnterEditMode', this, 'selectRecordAndEnterEditModeHandler'); | ||
55 | |||
56 | Clipperz.NotificationCenter.register(null, 'recordAdded', this, 'recordAddedHandler'); | ||
57 | Clipperz.NotificationCenter.register(null, 'recordUpdated', this, 'recordUpdatedHandler'); | ||
58 | Clipperz.NotificationCenter.register(null, 'recordRemoved', this, 'recordRemovedHandler'); | ||
59 | |||
60 | Clipperz.NotificationCenter.register(null, 'directLoginAdded', this, 'directLoginAddedHandler'); | ||
61 | Clipperz.NotificationCenter.register(null, 'directLoginUpdated', this, 'directLoginUpdatedHandler'); | ||
62 | Clipperz.NotificationCenter.register(null, 'directLoginRemoved', this, 'directLoginRemovedHandler'); | ||
63 | |||
64 | Clipperz.NotificationCenter.register(null, 'accountLocked', this, 'accountLockedHandler'); | ||
65 | |||
66 | MochiKit.Signal.connect(MochiKit.DOM.currentWindow(), 'onresize', this, 'resizeModalMask'); | ||
67 | this.render(); | ||
68 | |||
69 | return this; | ||
70 | } | ||
71 | |||
72 | //============================================================================= | ||
73 | |||
74 | YAHOO.extendX(Clipperz.PM.Components.Panels.MainPanel, Clipperz.PM.Components.Panels.BasePanel, { | ||
75 | |||
76 | 'toString': function() { | ||
77 | return "Clipperz.PM.Components.Panels.MainPanel component"; | ||
78 | }, | ||
79 | |||
80 | //------------------------------------------------------------------------- | ||
81 | |||
82 | 'render': function() { | ||
83 | this.element().update(""); | ||
84 | Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'table', id:'mainPanelTABLE', border:'0', cellspacing:'0', cellpadding:'0', children:[ | ||
85 | {tag:'tbody', children:[ | ||
86 | {tag:'tr', children:[ | ||
87 | {tag:'td', width:'15', children:[ | ||
88 | {tag:'div', cls:'mainPanelMinHeightDiv'} | ||
89 | ]}, | ||
90 | {tag:'td', valign:'top', id:'directLoginsTD', width:'200', children:[ | ||
91 | {tag:'div', id:'directLoginsBlock', children:[ | ||
92 | {tag:'div', cls:'directLoginsBlockHeaderBox', children:[{tag:'h3', id:'directLoginTitle', htmlString:Clipperz.PM.Strings['mainPanelDirectLoginBlockLabel']}]}, | ||
93 | {tag:'div', id:'directLoginsDescription', htmlString:Clipperz.PM.Strings['mainPanelDirectLoginBlockDescription']}, | ||
94 | {tag:'ul', id:'directLogins'} | ||
95 | ]} | ||
96 | ]}, | ||
97 | {tag:'td', width:'15', children:[ | ||
98 | {tag:'div', cls:'mainPanelMinHeightDiv'} | ||
99 | ]}, | ||
100 | {tag:'td', valign:'top', children:[ | ||
101 | {tag:'div', id:'mainContent', children:[ | ||
102 | {tag:'div', id:'recordListBlockHeader'}, | ||
103 | {tag:'div', id:'recordListAndDetailBlock', children:[ | ||
104 | {tag:'table', id:'recordListAndDetailBlockTABLE', border:'0', cellspacing:'0', cellpadding:'0', children:[ | ||
105 | {tag:'tbody', children:[ | ||
106 | {tag:'tr', children:[ | ||
107 | {tag:'td', valign:'top', width:'250', children:[ | ||
108 | {tag:'div', id:'recordListBlock', children:[ | ||
109 | {tag:'div', id:'recordListFilterHeader'}, | ||
110 | {tag:'ul', id:'records'} | ||
111 | ]} | ||
112 | ]}, | ||
113 | {tag:'td', id:'recordDetailSeparatorTD', rowspan:'2', valign:'top', bgcolor:'#ddddff', html:' '}, | ||
114 | {tag:'td', valign:'top', children:[ | ||
115 | {tag:'div', id:'recordDetailMainBlock', children:[ | ||
116 | {tag:'div', id:'recordTitleTopBlock'}, | ||
117 | {tag:'div', id:'recordDetailBlock', children:[ | ||
118 | {tag:'div', id:'recordDetail'} | ||
119 | ]} | ||
120 | ]}, | ||
121 | {tag:'div', id:'recordCreationWizardMainBlock', children:[ | ||
122 | {tag:'div', id:'recordCreationWizard', html:"WIZARD"} | ||
123 | ]} | ||
124 | ]} | ||
125 | ]}, | ||
126 | {tag:'tr', children:[ | ||
127 | {tag:'td', id:'cardBoxLowerLeftTD', html:' '}, | ||
128 | {tag:'td', id:'cardBoxLowerRightTD', html:' '} | ||
129 | ]} | ||
130 | ]} | ||
131 | ]} | ||
132 | ]} | ||
133 | ]} | ||
134 | ]}, | ||
135 | {tag:'td', width:'15', html:" "} | ||
136 | ]} | ||
137 | ]} | ||
138 | ]}); | ||
139 | |||
140 | this.renderRecordListBlockHeader(); | ||
141 | // this.renderRecordListFilterHeader(); | ||
142 | |||
143 | YAHOO.ext.Element.get('directLogins').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); | ||
144 | |||
145 | this.recordDetailComponent(); | ||
146 | |||
147 | YAHOO.ext.Element.get('recordDetailMainBlock').setVisibilityMode(YAHOO.ext.Element.DISPLAY).show(); | ||
148 | YAHOO.ext.Element.get('recordCreationWizardMainBlock').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); | ||
149 | }, | ||
150 | |||
151 | //------------------------------------------------------------------------- | ||
152 | |||
153 | 'addNewRecordButton': function() { | ||
154 | return this._addNewRecordButton; | ||
155 | }, | ||
156 | |||
157 | 'setAddNewRecordButton': function(aValue) { | ||
158 | this._addNewRecordButton = aValue; | ||
159 | }, | ||
160 | |||
161 | 'deleteRecordButton': function() { | ||
162 | return this._deleteRecordButton; | ||
163 | }, | ||
164 | |||
165 | 'setDeleteRecordButton': function(aValue) { | ||
166 | this._deleteRecordButton = aValue; | ||
167 | }, | ||
168 | |||
169 | //------------------------------------------------------------------------- | ||
170 | |||
171 | 'addNewRecord': function(anEvent) { | ||
172 | var deferredResult; | ||
173 | // var currentNumberOfRecords; | ||
174 | |||
175 | deferredResult = new MochiKit.Async.Deferred(); | ||
176 | |||
177 | // currentNumberOfRecords = MochiKit.Base.keys(this.user().records()).length; | ||
178 | /* | ||
179 | // if ((this.user().preferences().shouldShowDonationPanel()) && (currentNumberOfRecords > 0) && ((currentNumberOfRecords%10) == 0)) { | ||
180 | // if (true) { | ||
181 | if ((this.user().preferences().shouldShowDonationPanel()) && (currentNumberOfRecords >= 5)) { | ||
182 | deferredResult.addCallback(Clipperz.PM.showDonationSplashScreen, this.user(), 'recordListAddRecordButton'); | ||
183 | } | ||
184 | */ | ||
185 | deferredResult.addCallback(MochiKit.Base.bind(function() { | ||
186 | var currentlySelectedRecord; | ||
187 | |||
188 | currentlySelecedRecord = this.selectedRecord(); | ||
189 | this.setSelectedRecord(null); | ||
190 | |||
191 | YAHOO.ext.Element.get('recordDetailMainBlock').hide(); | ||
192 | YAHOO.ext.Element.get('recordCreationWizardMainBlock').show(); | ||
193 | this.setCreationWizard(new Clipperz.PM.Components.RecordDetail.CreationWizard(YAHOO.ext.Element.get('recordCreationWizardMainBlock'), {previouslySelectedRecord:currentlySelecedRecord, mainComponent:this})); | ||
194 | |||
195 | this.enterModalView(); | ||
196 | }, this)); | ||
197 | |||
198 | deferredResult.callback(); | ||
199 | }, | ||
200 | |||
201 | //------------------------------------------------------------------------- | ||
202 | |||
203 | 'creationWizard': function() { | ||
204 | return this._creationWizard; | ||
205 | }, | ||
206 | |||
207 | 'setCreationWizard': function(aValue) { | ||
208 | this._creationWizard = aValue; | ||
209 | }, | ||
210 | |||
211 | //------------------------------------------------------------------------- | ||
212 | |||
213 | 'exitWizard': function(aSelectedRecord, shouldEnterEditMode) { | ||
214 | //MochiKit.Logging.logDebug(">>> MainPanel.exitWizard - " + aSelectedRecord) | ||
215 | YAHOO.ext.Element.get('recordCreationWizardMainBlock').hide(); | ||
216 | YAHOO.ext.Element.get('recordDetailMainBlock').show(); | ||
217 | |||
218 | if (shouldEnterEditMode == true) { | ||
219 | this.selectRecordAndEnterEditMode(aSelectedRecord); | ||
220 | } else { | ||
221 | this.setSelectedRecord(aSelectedRecord); | ||
222 | this.exitModalView(); | ||
223 | } | ||
224 | |||
225 | this.creationWizard().remove(); | ||
226 | this.setCreationWizard(null); | ||
227 | //MochiKit.Logging.logDebug("<<< MainPanel.exitWizard"); | ||
228 | }, | ||
229 | |||
230 | //------------------------------------------------------------------------- | ||
231 | |||
232 | 'selectRecordAndEnterEditMode': function(aRecord) { | ||
233 | this.setSelectedRecord(aRecord); | ||
234 | this.recordDetailComponent().setEditMode('EDIT'); | ||
235 | }, | ||
236 | |||
237 | 'selectRecordAndEnterEditModeHandler': function(anEvent) { | ||
238 | this.selectRecordAndEnterEditMode(anEvent.source()); | ||
239 | }, | ||
240 | |||
241 | //------------------------------------------------------------------------- | ||
242 | |||
243 | 'resizeModalMask': function() { | ||
244 | //MochiKit.Logging.logDebug(">>> MainPanel.resizeModalMask"); | ||
245 | MochiKit.Style.setElementDimensions('recordDetailEditModeHeaderMask', {w:MochiKit.Style.getElementDimensions('mainDiv').w, h:119}); | ||
246 | |||
247 | MochiKit.Style.setElementDimensions('recordDetailEditModeVerticalMask', {w:511, h:MochiKit.Style.getElementDimensions('mainDiv').h - 119}); | ||
248 | //MochiKit.Logging.logDebug("<<< MainPanel.resizeModalMask"); | ||
249 | }, | ||
250 | |||
251 | //------------------------------------------------------------------------- | ||
252 | |||
253 | 'enterModalView': function() { | ||
254 | if (this.user().preferences().useSafeEditMode()) { | ||
255 | var headerMaskElement; | ||
256 | var verticalMaskElement; | ||
257 | |||
258 | this.resizeModalMask(); | ||
259 | |||
260 | headerMaskElement = YAHOO.ext.Element.get('recordDetailEditModeHeaderMask'); | ||
261 | headerMaskElement.show(); | ||
262 | headerMaskElement.mask(); | ||
263 | |||
264 | verticalMaskElement = YAHOO.ext.Element.get('recordDetailEditModeVerticalMask'); | ||
265 | verticalMaskElement.show(); | ||
266 | verticalMaskElement.mask(); | ||
267 | } | ||
268 | }, | ||
269 | |||
270 | //------------------------------------------------------------------------- | ||
271 | |||
272 | 'exitModalView': function() { | ||
273 | if (this.user().preferences().useSafeEditMode()) { | ||
274 | var headerMaskElement; | ||
275 | var verticalMaskElement; | ||
276 | |||
277 | headerMaskElement = YAHOO.ext.Element.get('recordDetailEditModeHeaderMask'); | ||
278 | headerMaskElement.unmask(); | ||
279 | headerMaskElement.hide(); | ||
280 | |||
281 | verticalMaskElement = YAHOO.ext.Element.get('recordDetailEditModeVerticalMask'); | ||
282 | verticalMaskElement.unmask(); | ||
283 | verticalMaskElement.hide(); | ||
284 | } | ||
285 | }, | ||
286 | |||
287 | //------------------------------------------------------------------------- | ||
288 | |||
289 | 'removeSelectedRecord': function() { | ||
290 | var selectedRecordReferences; | ||
291 | |||
292 | //MochiKit.Logging.logDebug(">>> MainPanel.removeSelectedRecord"); | ||
293 | if (this.selectedRecord() != null) { | ||
294 | selectedRecordReferences = [this.selectedRecord().reference()]; | ||
295 | } else { | ||
296 | selectedRecordReferences = []; | ||
297 | } | ||
298 | |||
299 | if (selectedRecordReferences.length > 0 ) { | ||
300 | varrecordReference; | ||
301 | varrecords; | ||
302 | var deferred; | ||
303 | |||
304 | records = []; | ||
305 | for (recordReference in selectedRecordReferences) { | ||
306 | var record; | ||
307 | |||
308 | //MochiKit.Logging.logDebug("### MainPanel.removeSelectedRecord - recordReference: " + selectedRecordReferences[recordReference]); | ||
309 | record = this.user().records()[selectedRecordReferences[recordReference]]; | ||
310 | //MochiKit.Logging.logDebug("### MainPanel.removeSelectedRecord - record: " + record); | ||
311 | records.push(record); | ||
312 | } | ||
313 | //MochiKit.Logging.logDebug("### MainPanel.removeSelectedRecord - records.length: " + records.length); | ||
314 | |||
315 | deferred = new MochiKit.Async.Deferred(); | ||
316 | //MochiKit.Logging.logDebug("--- MainPanel.removeSelectedRecord - 1:"); | ||
317 | //deferred.addBoth(function(res) {MochiKit.Logging.logDebug("MainPanel.removeSelectedRecord - 1: " + res); return res;}); | ||
318 | //MochiKit.Logging.logDebug("--- MainPanel.removeSelectedRecord - 2:"); | ||
319 | deferred.addCallback(function() { | ||
320 | var deferredResult; | ||
321 | |||
322 | deferredResult = new MochiKit.Async.Deferred(); | ||
323 | Clipperz.PM.Components.MessageBox().deferredShow({ | ||
324 | title:Clipperz.PM.Strings['mainPanelDeletingRecordPanelConfirmationTitle'], | ||
325 | text:Clipperz.PM.Strings['mainPanelDeleteRecordPanelConfirmationText'], | ||
326 | width:240, | ||
327 | showProgressBar:false, | ||
328 | showCloseButton:false, | ||
329 | buttons:{ | ||
330 | 'yes':Clipperz.PM.Strings['mainPanelDeleteRecordPanelConfirmButtonLabel'], | ||
331 | 'no':Clipperz.PM.Strings['mainPanelDeleteRecordPanelDenyButtonLabel'] | ||
332 | }, | ||
333 | fn:MochiKit.Base.partial(function(aDeferred, aResult) { | ||
334 | if (aResult == 'yes') { | ||
335 | aDeferred.callback(aResult); | ||
336 | } else { | ||
337 | aDeferred.errback(aResult); | ||
338 | } | ||
339 | }, deferredResult) | ||
340 | }, 'recordListRemoveRecordButton'); | ||
341 | |||
342 | return deferredResult; | ||
343 | }); | ||
344 | //MochiKit.Logging.logDebug("--- MainPanel.removeSelectedRecord - 3:"); | ||
345 | //deferred.addBoth(function(res) {MochiKit.Logging.logDebug("MainPanel.removeSelectedRecord - 2: " + res); return res;}); | ||
346 | //MochiKit.Logging.logDebug("--- MainPanel.removeSelectedRecord - 4:"); | ||
347 | //deferred.addBoth(function(res) {MochiKit.Logging.logDebug("MainPanel.removeSelectedRecord - 3: " + res); return res;}); | ||
348 | deferred.addCallback(MochiKit.Base.method(Clipperz.PM.Components.MessageBox(), 'deferredShow'), | ||
349 | { | ||
350 | title:Clipperz.PM.Strings['mainPanelDeletingRecordPanelInitialTitle'], | ||
351 | text:Clipperz.PM.Strings['mainPanelDeletingRecordPanelInitialText'], | ||
352 | width:240, | ||
353 | showProgressBar:true, | ||
354 | showCloseButton:false, | ||
355 | steps:5 | ||
356 | } | ||
357 | ); | ||
358 | //MochiKit.Logging.logDebug("--- MainPanel.removeSelectedRecord - 5:"); | ||
359 | //deferred.addBoth(function(res) {MochiKit.Logging.logDebug("MainPanel.removeSelectedRecord - 4: " + res); return res;}); | ||
360 | deferred.addCallback(MochiKit.Base.method(this.user(), 'deleteRecordsAction'), records); | ||
361 | //MochiKit.Logging.logDebug("--- MainPanel.removeSelectedRecord - 6:"); | ||
362 | //deferred.addBoth(function(res) {MochiKit.Logging.logDebug("MainPanel.removeSelectedRecord - 5: " + res); return res;}); | ||
363 | //MochiKit.Logging.logDebug("--- MainPanel.removeSelectedRecord - 7:"); | ||
364 | //deferred.addBoth(function(res) {MochiKit.Logging.logDebug("MainPanel.removeSelectedRecord - 6: " + res); return res;}); | ||
365 | deferred.addCallback(function() { | ||
366 | Clipperz.PM.Components.MessageBox().update({ | ||
367 | title:null, | ||
368 | text:Clipperz.PM.Strings['mainPanelDeletingRecordPanelCompletedText'], | ||
369 | step:'next', | ||
370 | buttons:{} | ||
371 | }); | ||
372 | }); | ||
373 | //MochiKit.Logging.logDebug("--- MainPanel.removeSelectedRecord - 8:"); | ||
374 | //deferred.addBoth(function(res) {MochiKit.Logging.logDebug("MainPanel.removeSelectedRecord - 7: " + res); return res;}); | ||
375 | deferred.addCallback(MochiKit.Async.wait, 1); | ||
376 | //MochiKit.Logging.logDebug("--- MainPanel.removeSelectedRecord - 9:"); | ||
377 | //deferred.addBoth(function(res) {MochiKit.Logging.logDebug("MainPanel.removeSelectedRecord - 8: " + res); return res;}); | ||
378 | deferred.addCallback(function(res) { | ||
379 | Clipperz.PM.Components.MessageBox().hide(YAHOO.ext.Element.get('main')); | ||
380 | return res; | ||
381 | }); | ||
382 | //MochiKit.Logging.logDebug("--- MainPanel.removeSelectedRecord - 10:"); | ||
383 | //deferred.addBoth(function(res) {MochiKit.Logging.logDebug("MainPanel.removeSelectedRecord - 9: " + res); return res;}); | ||
384 | deferred.callback(); | ||
385 | } else { | ||
386 | //MochiKit.Logging.logDebug("+++ MainPanel.removeSelectedRecord - nothing selected"); | ||
387 | } | ||
388 | }, | ||
389 | |||
390 | //------------------------------------------------------------------------- | ||
391 | |||
392 | 'recordDetailComponent': function() { | ||
393 | //MochiKit.Logging.logDebug(">>> MainPanel.recordDetailComponent"); | ||
394 | if (this._recordDetailComponent == null) { | ||
395 | //MochiKit.Logging.logDebug("--- MainPanel.recordDetailComponent - 1"); | ||
396 | //MochiKit.Logging.logDebug("--- MainPanel.recordDetailComponent - 1 - user: " + this.user()); | ||
397 | this._recordDetailComponent = new Clipperz.PM.Components.RecordDetail.MainComponent( | ||
398 | YAHOO.ext.Element.get('recordDetail'), | ||
399 | {user:this.user(), mainPanel:this} | ||
400 | ); | ||
401 | } | ||
402 | |||
403 | //MochiKit.Logging.logDebug("<<< MainPanel.recordDetailComponent"); | ||
404 | |||
405 | return this._recordDetailComponent; | ||
406 | }, | ||
407 | |||
408 | //------------------------------------------------------------------------- | ||
409 | |||
410 | 'selectedRecord': function() { | ||
411 | return this._selectedRecord; | ||
412 | }, | ||
413 | |||
414 | 'setSelectedRecord': function(aValue) { | ||
415 | // this.hideNewRecordPanel(); | ||
416 | //MochiKit.Logging.logDebug(">>> MainPanel.setSelectedRecord"); | ||
417 | if (aValue != this._selectedRecord) { | ||
418 | //MochiKit.Logging.logDebug("--- MainPanel.setSelectedRecord - 1"); | ||
419 | this._selectedRecord = aValue; | ||
420 | //MochiKit.Logging.logDebug("--- MainPanel.setSelectedRecord - 2"); | ||
421 | this.redrawRecordItems(); | ||
422 | //MochiKit.Logging.logDebug("--- MainPanel.setSelectedRecord - 3"); | ||
423 | this.recordDetailComponent().setRecord(aValue); | ||
424 | //MochiKit.Logging.logDebug("--- MainPanel.setSelectedRecord - 4"); | ||
425 | } | ||
426 | |||
427 | if ((aValue == null) || (Clipperz.PM.Proxy.defaultProxy.isReadOnly())) { | ||
428 | this.deleteRecordButton().disable(); | ||
429 | } else { | ||
430 | this.deleteRecordButton().enable(); | ||
431 | } | ||
432 | //MochiKit.Logging.logDebug("<<< MainPanel.setSelectedRecord"); | ||
433 | }, | ||
434 | |||
435 | //------------------------------------------------------------------------- | ||
436 | |||
437 | 'recordAddedHandler': function(anEvent) { | ||
438 | //MochiKit.Logging.logDebug(">>> MainPanel.recordAddedHandler"); | ||
439 | this.recordDetailComponent(); | ||
440 | this.redrawRecordItems(); | ||
441 | //MochiKit.Logging.logDebug("<<< MainPanel.recordAddedHandler"); | ||
442 | }, | ||
443 | |||
444 | 'recordUpdatedHandler': function(anEvent) { | ||
445 | //MochiKit.Logging.logDebug(">>> MainPanel.recordUpdatedHandler"); | ||
446 | this.redrawRecordItems(); | ||
447 | //MochiKit.Logging.logDebug("<<< MainPanel.recordUpdatedHandler"); | ||
448 | }, | ||
449 | |||
450 | 'recordRemovedHandler': function(anEvent) { | ||
451 | //MochiKit.Logging.logDebug(">>> MainPanel.recordRemovedHandler"); | ||
452 | this.setSelectedRecord(null); | ||
453 | //MochiKit.Logging.logDebug("--- MainPanel.recordRemovedHandler - 1"); | ||
454 | this.redrawRecordItems(); | ||
455 | //MochiKit.Logging.logDebug("<<< MainPanel.recordRemovedHandler"); | ||
456 | }, | ||
457 | |||
458 | 'compareRecords': function(a, b) { | ||
459 | //MochiKit.Logging.logDebug("=== compareRecords: " + a.toString() + " - " + b.toString()); | ||
460 | return MochiKit.Base.compare(a.label().toLowerCase(), b.label().toLowerCase()); | ||
461 | }, | ||
462 | |||
463 | 'redrawRecordItems': function() { | ||
464 | var template; | ||
465 | var allRecords; | ||
466 | |||
467 | //MochiKit.Logging.logDebug(">>> MainPanel.redrawRecordItems"); | ||
468 | MochiKit.Iter.forEach(YAHOO.ext.Element.get('records').getChildrenByTagName('li'), function(aRecordElement) { | ||
469 | MochiKit.Signal.disconnectAll(aRecordElement.dom); | ||
470 | }) | ||
471 | //MochiKit.Logging.logDebug("--- MainPanel.redrawRecordItems - 1"); | ||
472 | YAHOO.ext.Element.get('records').update(""); | ||
473 | //MochiKit.Logging.logDebug("--- MainPanel.redrawRecordItems - 2"); | ||
474 | allRecords = MochiKit.Base.values(this.user().records()); | ||
475 | //MochiKit.Logging.logDebug("--- MainPanel.redrawRecordItems - 3"); | ||
476 | allRecords.sort(this.compareRecords); | ||
477 | //MochiKit.Logging.logDebug("--- MainPanel.redrawRecordItems - 4"); | ||
478 | template = this.recordItemTemplate(); | ||
479 | //MochiKit.Logging.logDebug("--- MainPanel.redrawRecordItems - 5"); | ||
480 | MochiKit.Iter.forEach(allRecords, MochiKit.Base.bind(function(aRecord) { | ||
481 | varrecordElement; | ||
482 | recordElement = template.append('records', { | ||
483 | recordTitle:aRecord.label(), | ||
484 | recordReference:aRecord.reference(), | ||
485 | cls:((aRecord == this.selectedRecord()) ? 'selected': '') | ||
486 | }, true); | ||
487 | //MochiKit.Logging.logDebug("--- MainPanel.redrawRecordItems - 6: " + recordElement.dom); | ||
488 | recordElement.addClassOnOver('hover'); | ||
489 | MochiKit.Signal.connect(recordElement.dom, 'onclick', this, 'selectRecord'); | ||
490 | }, this)); | ||
491 | //MochiKit.Logging.logDebug("<<< MainPanel.redrawRecordItems"); | ||
492 | }, | ||
493 | |||
494 | 'selectRecord': function(anEvent) { | ||
495 | //MochiKit.Logging.logDebug(">>> MainPanel.selectRecord"); | ||
496 | //MochiKit.Logging.logDebug("--- MainPanel.selectRecord !!! - ", this.user().records()[anEvent.src().id].label()); | ||
497 | this.setSelectedRecord(this.user().records()[anEvent.src().id]); | ||
498 | //MochiKit.Logging.logDebug("<<< MainPanel.selectRecord"); | ||
499 | }, | ||
500 | |||
501 | //------------------------------------------------------------------------- | ||
502 | |||
503 | 'directLoginAddedHandler': function(anEvent) { | ||
504 | //MochiKit.Logging.logDebug(">>> MainPanel.recordRemovedHandler"); | ||
505 | this.redrawDirectLoginItems(); | ||
506 | //MochiKit.Logging.logDebug("<<< MainPanel.recordRemovedHandler"); | ||
507 | }, | ||
508 | |||
509 | 'directLoginUpdatedHandler': function(anEvent) { | ||
510 | //MochiKit.Logging.logDebug(">>> MainPanel.directLoginUpdatedHandler"); | ||
511 | this.redrawDirectLoginItems(); | ||
512 | //MochiKit.Logging.logDebug("<<< MainPanel.directLoginUpdatedHandler"); | ||
513 | }, | ||
514 | |||
515 | 'directLoginRemovedHandler': function(anEvent) { | ||
516 | //MochiKit.Logging.logDebug(">>> MainPanel.directLoginRemovedHandler"); | ||
517 | this.redrawDirectLoginItems(); | ||
518 | //MochiKit.Logging.logDebug("<<< MainPanel.directLoginRemovedHandler"); | ||
519 | }, | ||
520 | |||
521 | 'compareDirectLogins': function(a, b) { | ||
522 | return MochiKit.Base.compare(a.label().toLowerCase(), b.label().toLowerCase()); | ||
523 | }, | ||
524 | |||
525 | 'redrawDirectLoginItems': function() { | ||
526 | var template; | ||
527 | var allDirectLogins; | ||
528 | |||
529 | //MochiKit.Logging.logDebug(">>> MainPanel.redrawDirectLoginItems"); | ||
530 | MochiKit.Iter.forEach(YAHOO.ext.Element.get('directLogins').getChildrenByTagName('li'), function(aDirectLoginElement) { | ||
531 | MochiKit.Signal.disconnectAll(aDirectLoginElement.dom); | ||
532 | //MochiKit.Logging.logDebug("disconnecting IMG " + aDirectLoginElement.getChildrenByTagName('img')[0].dom.src); | ||
533 | MochiKit.Signal.disconnectAll(aDirectLoginElement.getChildrenByTagName('img')[0].dom); | ||
534 | }) | ||
535 | //MochiKit.Logging.logDebug("--- MainPanel.redrawDirectLoginItems - 1"); | ||
536 | YAHOO.ext.Element.get('directLogins').update(""); | ||
537 | //MochiKit.Logging.logDebug("--- MainPanel.redrawDirectLoginItems - 2"); | ||
538 | allDirectLogins = MochiKit.Base.values(this.user().directLoginReferences()); | ||
539 | //MochiKit.Logging.logDebug("--- MainPanel.redrawDirectLoginItems - 3"); | ||
540 | allDirectLogins.sort(this.compareDirectLogins); | ||
541 | |||
542 | if (allDirectLogins.length == 0) { | ||
543 | YAHOO.ext.Element.get('directLoginsDescription').show(); | ||
544 | YAHOO.ext.Element.get('directLogins').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); | ||
545 | } else { | ||
546 | YAHOO.ext.Element.get('directLoginsDescription').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); | ||
547 | YAHOO.ext.Element.get('directLogins').show(); | ||
548 | } | ||
549 | //MochiKit.Logging.logDebug("--- MainPanel.redrawDirectLoginItems - 4"); | ||
550 | template = this.directLoginItemTemplate(); | ||
551 | //MochiKit.Logging.logDebug("--- MainPanel.redrawDirectLoginItems - 5"); | ||
552 | MochiKit.Iter.forEach(allDirectLogins, MochiKit.Base.bind(function(aDirectLogin) { | ||
553 | vardirectLoginElement; | ||
554 | varfaviconImageElementID; | ||
555 | |||
556 | faviconImageElementID = aDirectLogin.reference() + "_faviconIMG"; | ||
557 | directLoginElement = template.append('directLogins', { | ||
558 | elementID:faviconImageElementID, | ||
559 | faviconUrl:aDirectLogin.fixedFavicon(), | ||
560 | directLoginTitle:aDirectLogin.label(), | ||
561 | directLoginReference:aDirectLogin.reference() | ||
562 | }, true); | ||
563 | //MochiKit.Logging.logDebug("--- MainPanel.redrawDirectLoginItems - 6: " + recordElement.dom); | ||
564 | directLoginElement.addClassOnOver("hover"); | ||
565 | MochiKit.Signal.connect(directLoginElement.dom, 'onclick', this, 'handleDirectLoginClick'); | ||
566 | |||
567 | MochiKit.Signal.connect(faviconImageElementID, 'onload', this, 'handleLoadedFaviconImage'); | ||
568 | MochiKit.Signal.connect(faviconImageElementID, 'onerror', aDirectLogin, 'handleMissingFaviconImage'); | ||
569 | MochiKit.Signal.connect(faviconImageElementID, 'onabort', aDirectLogin, 'handleMissingFaviconImage'); | ||
570 | |||
571 | // YAHOO.ext.Element.get(faviconImageElementID).dom.src = aDirectLogin.fixedFavicon(); | ||
572 | }, this)); | ||
573 | //MochiKit.Logging.logDebug("<<< MainPanel.redrawDirectLoginItems"); | ||
574 | }, | ||
575 | |||
576 | //------------------------------------------------------------------------- | ||
577 | |||
578 | 'handleDirectLoginClick': function(anEvent) { | ||
579 | vardirectLoginReference; | ||
580 | //MochiKit.Logging.logDebug(">>> MainPanel.handleDirectLoginClick !!!"); | ||
581 | |||
582 | directLoginReference = this.user().directLoginReferences()[anEvent.src().id]; | ||
583 | if (anEvent.target().className == 'directLoginItemEditButton') { | ||
584 | this.editDirectLogin(directLoginReference); | ||
585 | } else { | ||
586 | this.openDirectLogin(directLoginReference); | ||
587 | } | ||
588 | //MochiKit.Logging.logDebug("<<< MainPanel.handleDirectLoginClick"); | ||
589 | }, | ||
590 | |||
591 | 'editDirectLogin': function(aDirectLoginReference) { | ||
592 | //MochiKit.Logging.logDebug("=== MainPanel.editDirectLogin - " + aDirectLoginReference.label()); | ||
593 | this.setSelectedRecord(aDirectLoginReference.record()); | ||
594 | }, | ||
595 | |||
596 | 'openDirectLogin': function(aDirectLoginReference) { | ||
597 | vardeferredResult; | ||
598 | varnewWindow; | ||
599 | |||
600 | //MochiKit.Logging.logDebug(">>> MainPanel.openDirectLogin - " + aDirectLoginReference.label()); | ||
601 | deferredResult = new MochiKit.Async.Deferred(); | ||
602 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("MainPanel.openDirectLogin - 1: " + res); return res;}); | ||
603 | deferredResult.addCallback(MochiKit.Base.method(aDirectLoginReference, 'setupJumpPageWindow')); | ||
604 | deferredResult.addCallback(MochiKit.Base.method(aDirectLoginReference, 'deferredDirectLogin')); | ||
605 | deferredResult.addCallback(function(aDirectLogin) { | ||
606 | aDirectLogin.runDirectLogin(newWindow); | ||
607 | }); | ||
608 | |||
609 | newWindow = window.open(Clipperz.PM.Strings['directLoginJumpPageUrl'], ""); | ||
610 | // MochiKit.Signal.connect(newWindow, 'onload', MochiKit.Base.method(deferredResult, 'callback', newWindow)) | ||
611 | // MochiKit.Signal.connect(newWindow, 'onload', MochiKit.Base.partial(alert, "done")); | ||
612 | deferredResult.callback(newWindow); | ||
613 | //MochiKit.Logging.logDebug("<<< MainPanel.openDirectLogin"); | ||
614 | }, | ||
615 | |||
616 | //------------------------------------------------------------------------- | ||
617 | |||
618 | 'handleLoadedFaviconImage': function(anEvent) { | ||
619 | //MochiKit.Logging.logDebug(">>> MainPanel.handleLoadedFaviconImage"); | ||
620 | MochiKit.Signal.disconnectAll(anEvent.src()) | ||
621 | //MochiKit.Logging.logDebug("<<< MainPanel.handleLoadedFaviconImage"); | ||
622 | }, | ||
623 | |||
624 | //------------------------------------------------------------------------- | ||
625 | |||
626 | 'recordItemTemplate': function() { | ||
627 | if (this._recordItemTemplate == null) { | ||
628 | this._recordItemTemplate = Clipperz.YUI.DomHelper.createTemplate({tag:'li', cls:'{cls}', id:'{recordReference}', children:[ | ||
629 | {tag:'span', html:'{recordTitle}'} | ||
630 | ]}); | ||
631 | this._recordItemTemplate.compile(); | ||
632 | } | ||
633 | |||
634 | return this._recordItemTemplate; | ||
635 | }, | ||
636 | |||
637 | 'directLoginItemTemplate': function() { | ||
638 | if (this._directLoginItemTemplate == null) { | ||
639 | this._directLoginItemTemplate = Clipperz.YUI.DomHelper.createTemplate({tag:'li', id:'{directLoginReference}', children:[ | ||
640 | {tag:'table', border:'0', cellpadding:'0', cellspacing:'0', children:[ | ||
641 | {tag:'tbody', children:[ | ||
642 | {tag:'tr', children:[ | ||
643 | {tag:'td', width:'20', align:'center', valign:'top', children:[ | ||
644 | {tag:'img', id:'{elementID}', src:'{faviconUrl}'} | ||
645 | ]}, | ||
646 | {tag:'td', valign:'top', children:[ | ||
647 | {tag:'a', cls:'directLoginItemTitle', html:'{directLoginTitle}'} | ||
648 | ]}, | ||
649 | {tag:'td', valign:'top', align:'right', children:[ | ||
650 | // {tag:'span', cls:'directLoginItemEditButton', htmlString:Clipperz.PM.Strings['directLinkReferenceShowButtonLabel']} | ||
651 | {tag:'a', cls:'directLoginItemEditButton', htmlString:Clipperz.PM.Strings['directLinkReferenceShowButtonLabel']} | ||
652 | ]} | ||
653 | ]} | ||
654 | ]} | ||
655 | ]} | ||
656 | ]}); | ||
657 | this._directLoginItemTemplate.compile(); | ||
658 | } | ||
659 | |||
660 | return this._directLoginItemTemplate; | ||
661 | }, | ||
662 | |||
663 | //------------------------------------------------------------------------- | ||
664 | /* | ||
665 | 'newRecordButton': function() { | ||
666 | return this._newRecordButton; | ||
667 | }, | ||
668 | |||
669 | 'setNewRecordButton': function(aValue) { | ||
670 | this._newRecordButton = aValue; | ||
671 | }, | ||
672 | |||
673 | 'newRecordCancelButton': function() { | ||
674 | return this._newRecordCancelButton; | ||
675 | }, | ||
676 | |||
677 | 'setNewRecordCancelButton': function(aValue) { | ||
678 | this._newRecordCancelButton = aValue; | ||
679 | }, | ||
680 | */ | ||
681 | //------------------------------------------------------------------------- | ||
682 | |||
683 | 'onkeydown': function(anEvent) { | ||
684 | //MochiKit.Logging.logDebug(">>> onkeydown - " + anEvent.src().id + ": " + anEvent.key().code); | ||
685 | switch (anEvent.src().id) { | ||
686 | /* | ||
687 | case this.getId('newRecordForm'): | ||
688 | if (anEvent.key().code == 13) { | ||
689 | this.newRecordButton().focus(); | ||
690 | // this.addNewRecord(); | ||
691 | } else if (anEvent.key().code == 27) { | ||
692 | this.newRecordCancelButton().focus(); | ||
693 | this.hideNewRecordPanel(true); | ||
694 | } | ||
695 | break; | ||
696 | */ | ||
697 | case "recordFilterSearchForm": | ||
698 | if (anEvent.key().code == 13) { | ||
699 | //MochiKit.Logging.logDebug("SEARCH"); | ||
700 | this.filterCardsWithName(YAHOO.ext.Element.get('recordFilterSearchValue').dom.value); | ||
701 | anEvent.event().stopPropagation(); | ||
702 | YAHOO.ext.Element.get('recordFilterSearchValue').focus(); | ||
703 | } else if (anEvent.key().code == 27) { | ||
704 | this.hideRecordFilterSearchPanel(true); | ||
705 | this.showRecordFilterAllPanel(); | ||
706 | } | ||
707 | break; | ||
708 | } | ||
709 | |||
710 | }, | ||
711 | |||
712 | //------------------------------------------------------------------------- | ||
713 | |||
714 | 'renderRecordListBlockHeader': function(){ | ||
715 | var recordListBlockHeaderElement; | ||
716 | |||
717 | recordListBlockHeaderElement = YAHOO.ext.Element.get('recordListBlockHeader'); | ||
718 | recordListBlockHeaderElement.update(""); | ||
719 | Clipperz.YUI.DomHelper.append(recordListBlockHeaderElement.dom, | ||
720 | {tag:'table', cls:'recordListBlockHeaderTABLE', border:'0', cellspacing:'0', cellpadding:'0', children:[ | ||
721 | {tag:'tbody', children:[ | ||
722 | {tag:'tr', children:[ | ||
723 | {tag:'td', /*width:'50%',*/ cls:'recordBlockTitleTD', children:[ | ||
724 | {tag:'h3', id:'recordBlockTitle', htmlString:Clipperz.PM.Strings['mainPanelRecordsBlockLabel']} | ||
725 | ]}, | ||
726 | {tag:'td', align:'right', children:[ | ||
727 | {tag:'table', id:'recordListButtonsTABLE', border:'0', cellspacing:'0', cellpadding:'0', children:[ | ||
728 | {tag:'tbody', children:[ | ||
729 | {tag:'tr', children:[ | ||
730 | {tag:'td', cls:'recordButtonTD', align:'right', children:[ | ||
731 | {tag:'div', cls:'recordButton', id:'recordListAddRecordButton'} | ||
732 | ]}, | ||
733 | {tag:'td', cls:'recordButtonTD', align:'left', children:[ | ||
734 | {tag:'div', cls:'recordButton', id:'recordListRemoveRecordButton'} | ||
735 | ]} | ||
736 | ]} | ||
737 | ]} | ||
738 | ]} | ||
739 | ]}, | ||
740 | {tag:'td', width:'15', html:" "} | ||
741 | ]} | ||
742 | ]} | ||
743 | ]} | ||
744 | ); | ||
745 | |||
746 | this.setAddNewRecordButton(new YAHOO.ext.Button('recordListAddRecordButton', {text:Clipperz.PM.Strings['mainPanelAddRecordButtonLabel'], handler:this.addNewRecord, scope:this})); | ||
747 | // this.setAddNewRecordButton(new YAHOO.ext.Button('recordListAddRecordButton', {text:Clipperz.PM.Strings['mainPanelAddRecordButtonLabel'], handler:this.showNewRecordPanel, scope:this})); | ||
748 | this.setDeleteRecordButton(new YAHOO.ext.Button('recordListRemoveRecordButton', {text:Clipperz.PM.Strings['mainPanelRemoveRecordButtonLabel'], handler:this.removeSelectedRecord, scope:this})); | ||
749 | |||
750 | |||
751 | if ((Clipperz.PM.Proxy.defaultProxy.isReadOnly()) || (this.selectedRecord() == null)) { | ||
752 | this.deleteRecordButton().disable(); | ||
753 | } | ||
754 | |||
755 | if (Clipperz.PM.Proxy.defaultProxy.isReadOnly()) { | ||
756 | this.addNewRecordButton().disable(); | ||
757 | } | ||
758 | |||
759 | }, | ||
760 | |||
761 | //------------------------------------------------------------------------- | ||
762 | |||
763 | 'renderRecordListFilterHeader': function(){ | ||
764 | var recordListFilterHeaderElement; | ||
765 | |||
766 | recordListFilterHeaderElement = YAHOO.ext.Element.get('recordListFilterHeader'); | ||
767 | recordListFilterHeaderElement.update(""); | ||
768 | Clipperz.YUI.DomHelper.append(recordListFilterHeaderElement.dom, | ||
769 | {tag:'div', id:'recordFiltersDIV', children:[ | ||
770 | {tag:'div', id:'recordFiltersTableWrapper', children:[ | ||
771 | {tag:'table', id:'recordFiltersTABLE', border:'0', cellspacing:'0', cellpadding:'0', children:[ | ||
772 | {tag:'tbody', children:[ | ||
773 | {tag:'tr', children:[ | ||
774 | {tag:'td', id:'recordFilterAllTD', children:[{tag:'div', children:[{tag:'a', id:'recordFilterAll', htmlString:Clipperz.PM.Strings['mainPanelRecordFilterBlockAllLabel']}]}]}, | ||
775 | {tag:'td', id:'recordFilterTagsTD', children:[{tag:'div', children:[{tag:'a', id:'recordFilterTags', htmlString:Clipperz.PM.Strings['mainPanelRecordFilterBlockTagsLabel']}]}]}, | ||
776 | {tag:'td', id:'recordFilterSearchTD', children:[{tag:'div', children:[{tag:'a', id:'recordFilterSearch', htmlString:Clipperz.PM.Strings['mainPanelRecordFilterBlockSearchLabel']}]}]} | ||
777 | ]} | ||
778 | ]} | ||
779 | ]} | ||
780 | ]}, | ||
781 | {tag:'div', id:'recordFiltersTagsPanel'}, | ||
782 | {tag:'div', id:'recordFiltersSearchPanel', children:[{tag:'div', id:'recordFiltersSearchInnerPanel', children:[{tag:'div', id:'recordFiltersSearchInnerInnerPanel', children:[ | ||
783 | {tag:'form', id:'recordFilterSearchForm', children:[ | ||
784 | {tag:'input', type:'text', name:'search', id:'recordFilterSearchValue'} | ||
785 | ]} | ||
786 | ]}]}]} | ||
787 | ]} | ||
788 | ); | ||
789 | |||
790 | /// YAHOO.ext.Element.get('recordFiltersSearchPanel').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); | ||
791 | this.showRecordFilterAllPanel(false); | ||
792 | |||
793 | MochiKit.Signal.connect('recordFilterSearchForm', 'onkeydown', this, 'onkeydown'); | ||
794 | MochiKit.Signal.connect('recordFilterSearchForm', 'onsubmit', this, 'onkeydown'); | ||
795 | |||
796 | MochiKit.Signal.connect('recordFilterAll', 'onclick', this, 'showRecordFilterAllPanel'); | ||
797 | MochiKit.Signal.connect('recordFilterTags', 'onclick', this, 'showRecordFilterTagsPanel'); | ||
798 | MochiKit.Signal.connect('recordFilterSearch', 'onclick', this, 'showRecordFilterSearchPanel'); | ||
799 | }, | ||
800 | |||
801 | //------------------------------------------------------------------------- | ||
802 | |||
803 | 'showRecordFilterAllPanel': function(shouldSlide) { | ||
804 | this.hideRecordFilterTagsPanel(shouldSlide); | ||
805 | this.hideRecordFilterSearchPanel(shouldSlide); | ||
806 | YAHOO.ext.Element.get('recordFilterAllTD').addClass('selectedTab'); | ||
807 | }, | ||
808 | |||
809 | 'hideRecordFilterAllPanel': function(shouldSlide) { | ||
810 | YAHOO.ext.Element.get('recordFilterAllTD').removeClass('selectedTab'); | ||
811 | }, | ||
812 | |||
813 | //------------------------------------------------------------------------- | ||
814 | |||
815 | 'showRecordFilterTagsPanel': function(shouldSlide) { | ||
816 | this.hideRecordFilterAllPanel(shouldSlide); | ||
817 | this.hideRecordFilterSearchPanel(shouldSlide); | ||
818 | YAHOO.ext.Element.get('recordFilterTagsTD').addClass('selectedTab'); | ||
819 | }, | ||
820 | |||
821 | 'hideRecordFilterTagsPanel': function(shouldSlide) { | ||
822 | YAHOO.ext.Element.get('recordFilterTagsTD').removeClass('selectedTab'); | ||
823 | }, | ||
824 | |||
825 | //------------------------------------------------------------------------- | ||
826 | |||
827 | 'showRecordFilterSearchPanel': function(shouldSlide) { | ||
828 | var searchPanelActor; | ||
829 | |||
830 | this.hideRecordFilterAllPanel(shouldSlide); | ||
831 | this.hideRecordFilterTagsPanel(shouldSlide); | ||
832 | YAHOO.ext.Element.get('recordFilterSearchTD').addClass('selectedTab'); | ||
833 | YAHOO.ext.Element.get('recordFilterSearchValue').dom.value = ""; | ||
834 | |||
835 | searchPanelActor = new YAHOO.ext.Actor('recordFiltersSearchPanel'); | ||
836 | |||
837 | searchPanelActor.startCapture(true); | ||
838 | searchPanelActor.slideShow('top', 54); | ||
839 | searchPanelActor.play(MochiKit.Base.bind(function() { | ||
840 | YAHOO.ext.Element.get('recordFilterSearchValue').focus(); | ||
841 | }, this)); | ||
842 | }, | ||
843 | |||
844 | 'hideRecordFilterSearchPanel': function(shouldSlide) { | ||
845 | var searchPanelActor; | ||
846 | varcallback; | ||
847 | |||
848 | YAHOO.ext.Element.get('recordFilterSearchTD').removeClass('selectedTab'); | ||
849 | |||
850 | searchPanelActor = new YAHOO.ext.Actor('recordFiltersSearchPanel'); | ||
851 | |||
852 | searchPanelActor.startCapture(true) | ||
853 | if (shouldSlide === false) { | ||
854 | searchPanelActor.hide(); | ||
855 | searchPanelActor.slideHide('top'); | ||
856 | searchPanelActor.show(); | ||
857 | } else { | ||
858 | searchPanelActor.slideHide('top'); | ||
859 | } | ||
860 | |||
861 | callback = MochiKit.Base.bind(function() { | ||
862 | }, this); | ||
863 | |||
864 | searchPanelActor.play(callback); | ||
865 | }, | ||
866 | |||
867 | //------------------------------------------------------------------------- | ||
868 | |||
869 | 'filterCardsWithName': function(aValue) { | ||
870 | MochiKit.Logging.logDebug(">>> filterCardsWithName: " + aValue); | ||
871 | |||
872 | MochiKit.Logging.logDebug("<<< filterCardsWithName"); | ||
873 | }, | ||
874 | |||
875 | 'accountLockedHandler': function() { | ||
876 | this.setSelectedRecord(null); | ||
877 | }, | ||
878 | |||
879 | //------------------------------------------------------------------------- | ||
880 | |||
881 | 'switchLanguageHandler': function() { | ||
882 | YAHOO.ext.Element.get('directLoginTitle').update(Clipperz.PM.Strings['mainPanelDirectLoginBlockLabel']); | ||
883 | YAHOO.ext.Element.get('directLoginsDescription').update(""); | ||
884 | MochiKit.Iter.forEach(Clipperz.PM.Strings['mainPanelDirectLoginBlockDescriptionConfig'], function(aConfigItem) { | ||
885 | Clipperz.YUI.DomHelper.append(YAHOO.ext.Element.get('directLoginsDescription').dom, aConfigItem); | ||
886 | }); | ||
887 | YAHOO.ext.Element.get('recordBlockTitle').update(Clipperz.PM.Strings['mainPanelRecordsBlockLabel']); | ||
888 | this.renderRecordListBlockHeader(); | ||
889 | // this.renderRecordListFilterHeader(); | ||
890 | |||
891 | // YAHOO.ext.Element.get('newRecordPanelTitleH2').update(Clipperz.PM.Strings['mainPanelNewRecordPanelTitle']); | ||
892 | // YAHOO.ext.Element.get('newRecordPanelTitleLabel').update(Clipperz.PM.Strings['mainPanelNewRecordPanelRecordTitleLabel']); | ||
893 | // YAHOO.ext.Element.get('newRecordPanelConfigLabel').update(""); | ||
894 | // MochiKit.Iter.forEach(Clipperz.PM.Strings['mainPanelNewRecordPanelRecordConfigConfig'], function(aConfigItem) { | ||
895 | // Clipperz.YUI.DomHelper.append(YAHOO.ext.Element.get('newRecordPanelConfigLabel').dom, aConfigItem); | ||
896 | // }); | ||
897 | // this.newRecordButton().setText(Clipperz.PM.Strings['mainPanelNewRecordPanelCreateButtonLabel']); | ||
898 | // this.newRecordCancelButton().setText(Clipperz.PM.Strings['mainPanelNewRecordPanelCancelButtonLabel']); | ||
899 | |||
900 | this.recordDetailComponent().render(); | ||
901 | }, | ||
902 | |||
903 | //------------------------------------------------------------------------- | ||
904 | __syntaxFix__: "syntax fix" | ||
905 | |||
906 | }); | ||
diff --git a/frontend/beta/js/Clipperz/PM/Components/Panels/ToolsPanel.js b/frontend/beta/js/Clipperz/PM/Components/Panels/ToolsPanel.js new file mode 100644 index 0000000..abd2621 --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/Panels/ToolsPanel.js | |||
@@ -0,0 +1,305 @@ | |||
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 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | ||
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | ||
31 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } | ||
32 | if (typeof(Clipperz.PM.Components.Panels) == 'undefined') { Clipperz.PM.Components.Panels = {}; } | ||
33 | |||
34 | //############################################################################# | ||
35 | |||
36 | Clipperz.PM.Components.Panels.ToolsPanel = function(anElement, args) { | ||
37 | args = args || {}; | ||
38 | |||
39 | Clipperz.PM.Components.Panels.ToolsPanel.superclass.constructor.call(this, anElement, args); | ||
40 | |||
41 | this._generateButtonElement = null; | ||
42 | this._needsRenderingUponTabSwitch = false; | ||
43 | |||
44 | this.render(); | ||
45 | |||
46 | return this; | ||
47 | } | ||
48 | |||
49 | //============================================================================= | ||
50 | |||
51 | YAHOO.extendX(Clipperz.PM.Components.Panels.ToolsPanel, Clipperz.PM.Components.Panels.BasePanel, { | ||
52 | |||
53 | 'toString': function() { | ||
54 | return "Clipperz.PM.Components.Panels.ToolsPanel component"; | ||
55 | }, | ||
56 | |||
57 | //------------------------------------------------------------------------- | ||
58 | |||
59 | 'render': function() { | ||
60 | var bookmarkletUrl; | ||
61 | |||
62 | //MochiKit.Logging.logDebug(">>> ToolsPanel.render"); | ||
63 | Clipperz.NotificationCenter.unregister(this); | ||
64 | MochiKit.Signal.disconnectAllTo(this); | ||
65 | |||
66 | if (Clipperz_IEisBroken == true) { | ||
67 | bookmarkletUrl = bookmarklet_ie; | ||
68 | } else { | ||
69 | bookmarkletUrl = bookmarklet; | ||
70 | } | ||
71 | |||
72 | this.element().update(""); | ||
73 | Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'table', border:'0', cellspacing:'0', cellpadding:'0', children:[ | ||
74 | {tag:'tbody', children:[ | ||
75 | {tag:'tr', children:[ | ||
76 | {tag:'td', valign:'top', width:'200', children:[ | ||
77 | {tag:'ul', id:"dataSubMenu", cls:'subMenu', children:[ | ||
78 | {tag:'li', id:this.getId('passwordGenerator'), htmlString:Clipperz.PM.Strings['passwordGeneratorTabLabel']}, | ||
79 | {tag:'li', id:this.getId('bookmarklet'), htmlString:Clipperz.PM.Strings['bookmarkletTabLabel']}, | ||
80 | {tag:'li', id:this.getId('compact'), htmlString:Clipperz.PM.Strings['compactTabLabel']}, | ||
81 | {tag:'li', id:this.getId('httpAuth'), htmlString:Clipperz.PM.Strings['httpAuthTabLabel']} | ||
82 | ]} | ||
83 | ]}, | ||
84 | {tag:'td', valign:'top', children:[ | ||
85 | {tag:'ul', cls:'clipperzTabPanels', children:[ | ||
86 | {tag:'li', id:this.getId('passwordGeneratorPanel'), children:[ | ||
87 | {tag:'div', cls:'clipperzSubPanel', children:[ | ||
88 | {tag:'h5', htmlString:Clipperz.PM.Strings['passwordGeneratorTabTitle']}, | ||
89 | {tag:'div', cls:'panelDescription', htmlString:Clipperz.PM.Strings['paswordGeneratorTabDescription']}, | ||
90 | |||
91 | //--------------------------------------------------- | ||
92 | {tag:'div', children:[ | ||
93 | {tag:'form', id:this.getId('passwordGeneratorForm'), cls:'passwordGenerator', children:[ | ||
94 | {tag:'input', type:'text', cls:'clipperz_passwordGenerator_password', id:this.getId('passwordField')}, | ||
95 | {tag:'table', children:[ | ||
96 | {tag:'tbody', children:[ | ||
97 | {tag:'tr', children:[ | ||
98 | {tag:'td', width:'20%', children:[ | ||
99 | {tag:'input', type:'checkbox', name:'lowercase', id:this.getId('lowercase'), checked:true}, | ||
100 | {tag:'span', htmlString:Clipperz.PM.Strings['passwordGeneratorLowercaseLabel']} | ||
101 | ]}, | ||
102 | {tag:'td', width:'20%', children:[ | ||
103 | {tag:'input', type:'checkbox', name:'uppercase', id:this.getId('uppercase'), checked:true}, | ||
104 | {tag:'span', htmlString:Clipperz.PM.Strings['passwordGeneratorUppercaseLabel']} | ||
105 | ]}, | ||
106 | {tag:'td', width:'20%', children:[ | ||
107 | {tag:'input', type:'checkbox', name:'numbers', id:this.getId('numbers'), checked:true}, | ||
108 | {tag:'span', htmlString:Clipperz.PM.Strings['passwordGeneratorNumberLabel']} | ||
109 | ]}, | ||
110 | {tag:'td', width:'20%', children:[ | ||
111 | {tag:'input', type:'checkbox', name:'symbols', id:this.getId('symbols'), checked:true}, | ||
112 | {tag:'span', htmlString:Clipperz.PM.Strings['passwordGeneratorSymbolLabel']} | ||
113 | ]}, | ||
114 | {tag:'td', width:'20%', children:[ | ||
115 | {tag:'span', cls:'passwordGeneratorLength', children:[ | ||
116 | {tag:'span', htmlString:Clipperz.PM.Strings['passwordGeneratorLengthLabel']}, | ||
117 | {tag:'span', id:this.getId('passwordLength'), cls:'passwordGeneratorLengthValue', html:'0'} | ||
118 | ]} | ||
119 | ]} | ||
120 | ]} | ||
121 | ]} | ||
122 | ]} | ||
123 | ]}, | ||
124 | {tag:'div', id:this.getId('generateRandomPassword')} | ||
125 | ]} | ||
126 | //--------------------------------------------------- | ||
127 | |||
128 | ]} | ||
129 | ]}, | ||
130 | {tag:'li', id:this.getId('bookmarkletPanel'), children:[ | ||
131 | {tag:'div', cls:'clipperzSubPanel', children:[ | ||
132 | {tag:'h5', htmlString:Clipperz.PM.Strings['bookmarkletTabTitle']}, | ||
133 | {tag:'div', cls:'panelDescription', htmlString:Clipperz.PM.Strings['bookmarkletTabDescription']}, | ||
134 | {tag:'a', href:bookmarkletUrl, cls:'bookmarkletLink', htmlString:Clipperz.PM.Strings['bookmarkletTabBookmarkletTitle']}, | ||
135 | {tag:'div', cls:'panelDescription', htmlString:Clipperz.PM.Strings['bookmarkletTabInstructions']} | ||
136 | ]} | ||
137 | ]}, | ||
138 | {tag:'li', id:this.getId('compactPanel'), children:[ | ||
139 | {tag:'div', cls:'clipperzSubPanel', children:[ | ||
140 | {tag:'h5', htmlString:Clipperz.PM.Strings['compactTabTitle']}, | ||
141 | {tag:'div', cls:'panelDescription', htmlString:Clipperz.PM.Strings['compactTabDescription']} | ||
142 | ]} | ||
143 | ]}, | ||
144 | {tag:'li', id:this.getId('httpAuthPanel'), children:[ | ||
145 | {tag:'div', cls:'clipperzSubPanel', children:[ | ||
146 | {tag:'h5', htmlString:Clipperz.PM.Strings['httpAuthTabTitle']}, | ||
147 | {tag:'div', cls:'panelDescription', htmlString:Clipperz.PM.Strings['httpAuthTabDescription']}, | ||
148 | {tag:'div', cls:'bookmarkletConfiguration', children:[Clipperz.PM.Strings['httpAuthBookmarkletConfiguration']]} | ||
149 | ]} | ||
150 | ]} | ||
151 | ]} | ||
152 | ]} | ||
153 | ]} | ||
154 | ]} | ||
155 | ]}); | ||
156 | |||
157 | new Clipperz.PM.Components.PasswordEntropyDisplay(this.getElement('passwordField')); | ||
158 | |||
159 | MochiKit.Signal.connect(this.getId('lowercase'), 'onclick', this, 'updatePasswordValue'); | ||
160 | MochiKit.Signal.connect(this.getId('uppercase'), 'onclick', this, 'updatePasswordValue'); | ||
161 | MochiKit.Signal.connect(this.getId('numbers'), 'onclick', this, 'updatePasswordValue'); | ||
162 | MochiKit.Signal.connect(this.getId('symbols'), 'onclick', this, 'updatePasswordValue'); | ||
163 | |||
164 | MochiKit.Signal.connect(this.getDom('passwordField'), 'onkeyup', this, 'updatePasswordLengthLabel'); | ||
165 | MochiKit.Signal.connect(this.getDom('passwordField'), 'onchange', this, 'updatePasswordLengthLabel'); | ||
166 | MochiKit.Signal.connect(this.getDom('passwordField'), 'onblur', this, 'updatePasswordLengthLabel'); | ||
167 | |||
168 | this.setGenerateButtonElement(new YAHOO.ext.Button(this.getDom('generateRandomPassword'), {text:Clipperz.PM.Strings['passwordGeneratorTabButtonLabel'], handler:this.updatePasswordValue, scope:this})); | ||
169 | |||
170 | this.setNeedsRenderingUponTabSwitch(false); | ||
171 | this.tabPanelController().setUp(); | ||
172 | Clipperz.NotificationCenter.register(null, 'tabSelected', this, 'tabSelectedHandler'); | ||
173 | Clipperz.NotificationCenter.register(null, 'switchLanguage', this, 'switchLanguageHandler'); | ||
174 | //MochiKit.Logging.logDebug("<<< ToolsPanel.render"); | ||
175 | }, | ||
176 | |||
177 | //------------------------------------------------------------------------- | ||
178 | |||
179 | 'needsRenderingUponTabSwitch': function() { | ||
180 | return this._needsRenderingUponTabSwitch; | ||
181 | }, | ||
182 | |||
183 | 'setNeedsRenderingUponTabSwitch': function(aValue) { | ||
184 | this._needsRenderingUponTabSwitch = aValue; | ||
185 | }, | ||
186 | |||
187 | 'tabSelectedHandler': function(anEvent) { | ||
188 | if (this.needsRenderingUponTabSwitch()) { | ||
189 | this.render(); | ||
190 | } | ||
191 | |||
192 | if (anEvent.parameters() == this.getId('httpAuth')) { | ||
193 | var textarea; | ||
194 | |||
195 | textarea = document.getElementById("httpAuthDefaultConfiguration"); | ||
196 | textarea.focus(); | ||
197 | textarea.select(); | ||
198 | } | ||
199 | }, | ||
200 | |||
201 | //------------------------------------------------------------------------- | ||
202 | |||
203 | 'tabPanelController': function() { | ||
204 | if (this._tabPanelController == null) { | ||
205 | var tabPanelControllerConfig; | ||
206 | |||
207 | tabPanelControllerConfig = {} | ||
208 | tabPanelControllerConfig[this.getId('passwordGenerator')] = this.getId('passwordGeneratorPanel'); | ||
209 | tabPanelControllerConfig[this.getId('bookmarklet')] = this.getId('bookmarkletPanel'); | ||
210 | tabPanelControllerConfig[this.getId('compact')] = this.getId('compactPanel'); | ||
211 | tabPanelControllerConfig[this.getId('httpAuth')] = this.getId('httpAuthPanel'); | ||
212 | this._tabPanelController = new Clipperz.PM.Components.TabPanel.TabPanelController({ config:tabPanelControllerConfig, selectedTab:this.getId('passwordGenerator') }); | ||
213 | } | ||
214 | |||
215 | return this._tabPanelController; | ||
216 | }, | ||
217 | |||
218 | //------------------------------------------------------------------------- | ||
219 | |||
220 | 'generateButtonElement': function() { | ||
221 | return this._generateButtonElement; | ||
222 | }, | ||
223 | |||
224 | 'setGenerateButtonElement': function(aValue) { | ||
225 | this._generateButtonElement = aValue; | ||
226 | }, | ||
227 | |||
228 | //------------------------------------------------------------------------- | ||
229 | |||
230 | 'updatePasswordValue': function(anEvent) { | ||
231 | varrandomBytes; | ||
232 | varrandomValue; | ||
233 | var charset; | ||
234 | var charsetBitSize; | ||
235 | var stringValue; | ||
236 | varblockIndex; | ||
237 | |||
238 | //MochiKit.Logging.logDebug(">>> updatePasswordValue"); | ||
239 | randomBytes = Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(50); | ||
240 | stringValue = ""; | ||
241 | blockIndex = 0; | ||
242 | |||
243 | charset = ""; | ||
244 | if (this.getDom('lowercase').checked) { | ||
245 | charset += Clipperz.PM.Strings['passwordGeneratorLowercaseCharset']; | ||
246 | } | ||
247 | if (this.getDom('uppercase').checked) { | ||
248 | charset += Clipperz.PM.Strings['passwordGeneratorUppercaseCharset']; | ||
249 | } | ||
250 | if (this.getDom('numbers').checked) { | ||
251 | charset += Clipperz.PM.Strings['passwordGeneratorNumberCharset']; | ||
252 | } | ||
253 | if (this.getDom('symbols').checked) { | ||
254 | charset += Clipperz.PM.Strings['passwordGeneratorSymbolCharset']; | ||
255 | } | ||
256 | |||
257 | charsetBitSize = 0; | ||
258 | while (Math.pow(2, charsetBitSize) < charset.length) { | ||
259 | charsetBitSize ++; | ||
260 | } | ||
261 | |||
262 | if (charsetBitSize > 0) { | ||
263 | while (Clipperz.PM.Crypto.passwordEntropy(stringValue) < 128) { | ||
264 | if (((blockIndex + 1)*charsetBitSize) > (randomBytes.length() * 8)) { | ||
265 | randomBytes = Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(50); | ||
266 | blockIndex = 0; | ||
267 | } | ||
268 | randomValue = randomBytes.bitBlockAtIndexWithSize(blockIndex*charsetBitSize, charsetBitSize); | ||
269 | if (randomValue < charset.length) { | ||
270 | stringValue += charset.charAt(randomValue); | ||
271 | } | ||
272 | |||
273 | blockIndex ++; | ||
274 | } | ||
275 | } else { | ||
276 | stringValue = ""; | ||
277 | } | ||
278 | |||
279 | this.getElement('passwordField').dom.focus() | ||
280 | this.getElement('passwordField').dom.value = stringValue; | ||
281 | |||
282 | |||
283 | if (anEvent.src) { | ||
284 | anEvent.src().focus(); | ||
285 | } else { | ||
286 | this.generateButtonElement().el.focus(); | ||
287 | } | ||
288 | |||
289 | this.setNeedsRenderingUponTabSwitch(true); | ||
290 | |||
291 | return false; | ||
292 | //MochiKit.Logging.logDebug("<<< updatePasswordValue"); | ||
293 | }, | ||
294 | |||
295 | //----------------------------------------------------- | ||
296 | |||
297 | 'updatePasswordLengthLabel': function() { | ||
298 | this.getElement('passwordLength').update(this.getDom('passwordField').value.length); | ||
299 | }, | ||
300 | |||
301 | //------------------------------------------------------------------------- | ||
302 | __syntaxFix__: "syntax fix" | ||
303 | |||
304 | }); | ||
305 | |||
diff --git a/frontend/beta/js/Clipperz/PM/Components/PasswordEntropyDisplay.js b/frontend/beta/js/Clipperz/PM/Components/PasswordEntropyDisplay.js new file mode 100644 index 0000000..530d2cb --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/PasswordEntropyDisplay.js | |||
@@ -0,0 +1,118 @@ | |||
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 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | ||
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | ||
31 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } | ||
32 | |||
33 | Clipperz.PM.Components.PasswordEntropyDisplay = function(anElement, args) { | ||
34 | args = args || {}; | ||
35 | |||
36 | //MochiKit.Logging.logDebug(">>> new TextFormField"); | ||
37 | Clipperz.PM.Components.PasswordEntropyDisplay.superclass.constructor.call(this, anElement, args); | ||
38 | |||
39 | this._wrapperElement = null; | ||
40 | this._entropyElement = null; | ||
41 | |||
42 | this.render(); | ||
43 | //MochiKit.Logging.logDebug("<<< new TextFormField"); | ||
44 | |||
45 | return this; | ||
46 | }; | ||
47 | |||
48 | YAHOO.extendX(Clipperz.PM.Components.PasswordEntropyDisplay, Clipperz.PM.Components.BaseComponent, { | ||
49 | |||
50 | 'toString': function() { | ||
51 | return "Clipperz.PM.Components.PasswordEntropyDisplay"; | ||
52 | }, | ||
53 | |||
54 | //----------------------------------------------------- | ||
55 | |||
56 | 'wrapperElement': function() { | ||
57 | return this._wrapperElement; | ||
58 | }, | ||
59 | |||
60 | 'setWrapperElement': function(aValue) { | ||
61 | this._wrapperElement = aValue; | ||
62 | }, | ||
63 | |||
64 | //----------------------------------------------------- | ||
65 | |||
66 | 'passwordElement': function() { | ||
67 | return this.element(); | ||
68 | }, | ||
69 | |||
70 | //----------------------------------------------------- | ||
71 | |||
72 | 'entropyElement': function() { | ||
73 | return this._entropyElement; | ||
74 | }, | ||
75 | |||
76 | 'setEntropyElement': function(aValue) { | ||
77 | this._entropyElement = aValue; | ||
78 | }, | ||
79 | |||
80 | //----------------------------------------------------- | ||
81 | |||
82 | 'render': function() { | ||
83 | MochiKit.Signal.disconnectAllTo(this); | ||
84 | |||
85 | this.setWrapperElement(this.element().wrap({tag:'div'})); | ||
86 | this.setEntropyElement(Clipperz.YUI.DomHelper.append(this.wrapperElement().dom, {tag:'div', cls:'passwordEntropy', html:" "}, true)); | ||
87 | |||
88 | // this.entropyElement().setWidth(this.passwordElement().getWidth()); | ||
89 | this.updateEntropyElement(); | ||
90 | |||
91 | MochiKit.Signal.connect(this.element().dom, 'onkeyup', this, 'updateEntropyElement'); | ||
92 | MochiKit.Signal.connect(this.element().dom, 'onchange', this, 'updateEntropyElement'); | ||
93 | MochiKit.Signal.connect(this.element().dom, 'onblur', this, 'updateEntropyElement'); | ||
94 | }, | ||
95 | |||
96 | //----------------------------------------------------- | ||
97 | |||
98 | 'computeEntropyForString': function(aValue) { | ||
99 | return Clipperz.PM.Crypto.passwordEntropy(aValue); | ||
100 | }, | ||
101 | |||
102 | //----------------------------------------------------- | ||
103 | |||
104 | 'updateEntropyElement': function(anEvent) { | ||
105 | //MochiKit.Logging.logDebug(">>> PasswordEntropyDisplay.updateEntropyElement"); | ||
106 | varmaxExtent; | ||
107 | varentropy; | ||
108 | |||
109 | entropy = Math.min(128, this.computeEntropyForString(this.passwordElement().dom.value)); | ||
110 | //MochiKit.Logging.logDebug("--- PasswordEntropyDisplay.updateEntropyElement - entropy: " + entropy); | ||
111 | this.entropyElement().setStyle('background-position', "0px " + -entropy + "px"); | ||
112 | this.entropyElement().setWidth(this.passwordElement().getWidth() * (entropy/128)); | ||
113 | //MochiKit.Logging.logDebug("<<< PasswordEntropyDisplay.updateEntropyElement"); | ||
114 | }, | ||
115 | |||
116 | //----------------------------------------------------- | ||
117 | __syntaxFix__: '__syntaxFix__' | ||
118 | }); | ||
diff --git a/frontend/beta/js/Clipperz/PM/Components/PasswordGenerator.js b/frontend/beta/js/Clipperz/PM/Components/PasswordGenerator.js new file mode 100644 index 0000000..8195f2e --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/PasswordGenerator.js | |||
@@ -0,0 +1,285 @@ | |||
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 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | ||
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | ||
31 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } | ||
32 | |||
33 | Clipperz.PM.Components.PasswordGenerator = function(anElement, aFieldValueComponent, args) { | ||
34 | args = args || {}; | ||
35 | |||
36 | //MochiKit.Logging.logDebug(">>> new TextFormField"); | ||
37 | Clipperz.PM.Components.PasswordGenerator.superclass.constructor.call(this, anElement, args); | ||
38 | |||
39 | this._fieldValueComponent = aFieldValueComponent; | ||
40 | this._panelButton = null; | ||
41 | this.render(); | ||
42 | //MochiKit.Logging.logDebug("<<< new TextFormField"); | ||
43 | |||
44 | return this; | ||
45 | }; | ||
46 | |||
47 | YAHOO.extendX(Clipperz.PM.Components.PasswordGenerator, Clipperz.PM.Components.BaseComponent, { | ||
48 | |||
49 | 'toString': function() { | ||
50 | return "Clipperz.PM.Components.PasswordGenerator"; | ||
51 | }, | ||
52 | |||
53 | //----------------------------------------------------- | ||
54 | |||
55 | 'fieldValueComponent': function() { | ||
56 | return this._fieldValueComponent; | ||
57 | }, | ||
58 | |||
59 | //----------------------------------------------------- | ||
60 | |||
61 | 'render': function() { | ||
62 | MochiKit.Signal.disconnectAllTo(this); | ||
63 | |||
64 | // this._panelButton = new YAHOO.ext.Button(this.element().dom, {text:Clipperz.PM.Strings['passwordGeneratorButtonLabel'], handler:this.openPasswordPanel, scope:this}); | ||
65 | MochiKit.Signal.connect(this.element().dom, 'onmouseenter', this, 'onMouseEnter'); | ||
66 | MochiKit.Signal.connect(this.element().dom, 'onmouseleave', this, 'onMouseLeave'); | ||
67 | MochiKit.Signal.connect(this.element().dom, 'onclick', this, 'openPasswordPanel'); | ||
68 | }, | ||
69 | |||
70 | //----------------------------------------------------- | ||
71 | |||
72 | 'onMouseEnter': function() { | ||
73 | this.element().addClass('hover'); | ||
74 | }, | ||
75 | |||
76 | 'onMouseLeave': function() { | ||
77 | this.element().removeClass('hover'); | ||
78 | }, | ||
79 | |||
80 | //----------------------------------------------------- | ||
81 | |||
82 | 'panelButton': function() { | ||
83 | return this._panelButton; | ||
84 | }, | ||
85 | |||
86 | //----------------------------------------------------- | ||
87 | |||
88 | 'openPasswordPanel': function() { | ||
89 | var passwordGeneratorElement; | ||
90 | var passwordGeneratorDialog; | ||
91 | var cancelButton; | ||
92 | var okButton; | ||
93 | var cancelFunction; | ||
94 | var okFunction; | ||
95 | |||
96 | //MochiKit.Logging.logDebug(">>> PasswordGenerator.openPasswordPanel"); | ||
97 | passwordGeneratorElement = Clipperz.YUI.DomHelper.append(document.body, {tag:'div', id:'passwordGenerator', children:[ | ||
98 | {tag:'div', cls:'ydlg-hd', htmlString:Clipperz.PM.Strings['passwordGeneratorPanelTitle']}, | ||
99 | {tag:'div', cls:'ydlg-bd', children:[ | ||
100 | {tag:'form', id:this.getId('passwordGeneratorForm'), cls:'passwordGenerator', children:[ | ||
101 | {tag:'input', type:'text', cls:'clipperz_passwordGenerator_password', id:this.getId('passwordField')}, | ||
102 | {tag:'table', children:[ | ||
103 | {tag:'tbody', children:[ | ||
104 | {tag:'tr', children:[ | ||
105 | {tag:'td', width:'20%', children:[ | ||
106 | {tag:'input', type:'checkbox', name:'lowercase', id:this.getId('lowercase'), checked:true}, | ||
107 | {tag:'span', htmlString:Clipperz.PM.Strings['passwordGeneratorLowercaseLabel']} | ||
108 | ]}, | ||
109 | {tag:'td', width:'20%', children:[ | ||
110 | {tag:'input', type:'checkbox', name:'uppercase', id:this.getId('uppercase'), checked:true}, | ||
111 | {tag:'span', htmlString:Clipperz.PM.Strings['passwordGeneratorUppercaseLabel']} | ||
112 | ]}, | ||
113 | {tag:'td', width:'20%', children:[ | ||
114 | {tag:'input', type:'checkbox', name:'numbers', id:this.getId('numbers'), checked:true}, | ||
115 | {tag:'span', htmlString:Clipperz.PM.Strings['passwordGeneratorNumberLabel']} | ||
116 | ]}, | ||
117 | {tag:'td', width:'20%', children:[ | ||
118 | {tag:'input', type:'checkbox', name:'symbols', id:this.getId('symbols'), checked:true}, | ||
119 | {tag:'span', htmlString:Clipperz.PM.Strings['passwordGeneratorSymbolLabel']} | ||
120 | ]}, | ||
121 | {tag:'td', width:'20%', children:[ | ||
122 | {tag:'span', cls:'passwordGeneratorLength', children:[ | ||
123 | {tag:'span', htmlString:Clipperz.PM.Strings['passwordGeneratorLengthLabel']}, | ||
124 | {tag:'span', id:this.getId('passwordLength'), cls:'passwordGeneratorLengthValue', html:'0'} | ||
125 | ]} | ||
126 | ]} | ||
127 | ]} | ||
128 | ]} | ||
129 | ]} | ||
130 | ]} | ||
131 | ]}, | ||
132 | {tag:'div', cls:'ydlg-ft'} | ||
133 | ]}, true); | ||
134 | |||
135 | new Clipperz.PM.Components.PasswordEntropyDisplay(this.getElement('passwordField')); | ||
136 | |||
137 | MochiKit.Signal.connect(this.getId('lowercase'), 'onclick', this, 'updatePasswordValue'); | ||
138 | MochiKit.Signal.connect(this.getId('uppercase'), 'onclick', this, 'updatePasswordValue'); | ||
139 | MochiKit.Signal.connect(this.getId('numbers'), 'onclick', this, 'updatePasswordValue'); | ||
140 | MochiKit.Signal.connect(this.getId('symbols'), 'onclick', this, 'updatePasswordValue'); | ||
141 | |||
142 | MochiKit.Signal.connect(this.getDom('passwordField'), 'onkeyup', this, 'updatePasswordLengthLabel'); | ||
143 | MochiKit.Signal.connect(this.getDom('passwordField'), 'onchange', this, 'updatePasswordLengthLabel'); | ||
144 | MochiKit.Signal.connect(this.getDom('passwordField'), 'onblur', this, 'updatePasswordLengthLabel'); | ||
145 | |||
146 | this.updatePasswordValue(); | ||
147 | |||
148 | passwordGeneratorDialog = new YAHOO.ext.BasicDialog( | ||
149 | passwordGeneratorElement, { | ||
150 | autoCreate:false, | ||
151 | closable:false, | ||
152 | modal:true, | ||
153 | autoTabs:false, | ||
154 | resizable:false, | ||
155 | fixedcenter:true, | ||
156 | constraintoviewport:false, | ||
157 | width:320, | ||
158 | height:130, | ||
159 | shadow:true, | ||
160 | minWidth:200, | ||
161 | minHeight:100 | ||
162 | } | ||
163 | ); | ||
164 | |||
165 | cancelFunction = MochiKit.Base.partial(MochiKit.Base.bind(this.cancelPasswordPanel, this), passwordGeneratorDialog); | ||
166 | passwordGeneratorDialog.addKeyListener(27, cancelFunction); | ||
167 | cancelButton = passwordGeneratorDialog.addButton(Clipperz.PM.Strings['passwordGeneratorPanelCancelLabel'], cancelFunction, this); | ||
168 | |||
169 | okFunction = MochiKit.Base.partial(MochiKit.Base.bind(this.okPasswordPanel, this), passwordGeneratorDialog); | ||
170 | passwordGeneratorDialog.addKeyListener([10, 13], okFunction); | ||
171 | okButton = passwordGeneratorDialog.addButton(Clipperz.PM.Strings['passwordGeneratorPanelOkLabel'], okFunction, this); | ||
172 | |||
173 | MochiKit.Signal.connect(this.getId('passwordGeneratorForm'), 'onsubmit', okFunction); | ||
174 | |||
175 | passwordGeneratorDialog.setDefaultButton(okButton); | ||
176 | |||
177 | this.fieldValueComponent().mainComponent().mainPanel().exitModalView(); | ||
178 | this.fieldValueComponent().mainComponent().scrollToTop(); | ||
179 | |||
180 | // passwordGeneratorDialog.show(this.panelButton().getEl()); | ||
181 | passwordGeneratorDialog.show(this.element()); | ||
182 | this.onMouseLeave(); | ||
183 | }, | ||
184 | |||
185 | //----------------------------------------------------- | ||
186 | |||
187 | 'cancelPasswordPanel': function(aPasswordGeneratorPanel) { | ||
188 | this.fieldValueComponent().mainComponent().mainPanel().enterModalView(); | ||
189 | aPasswordGeneratorPanel.hide(MochiKit.Base.bind(function() { | ||
190 | aPasswordGeneratorPanel.destroy(true); | ||
191 | MochiKit.Signal.disconnectAllTo(this); | ||
192 | }, this)); | ||
193 | }, | ||
194 | |||
195 | //----------------------------------------------------- | ||
196 | |||
197 | 'updatePasswordLengthLabel': function() { | ||
198 | this.getElement('passwordLength').update(this.getDom('passwordField').value.length); | ||
199 | }, | ||
200 | |||
201 | //----------------------------------------------------- | ||
202 | |||
203 | 'okPasswordPanel': function(aPasswordGeneratorPanel, anEvent) { | ||
204 | //MochiKit.Logging.logDebug(">>> PasswordGenerator.okPasswordPanel"); | ||
205 | |||
206 | if (anEvent.stop) { | ||
207 | anEvent.stop(); | ||
208 | } | ||
209 | |||
210 | this.fieldValueComponent().inputElement().dom.focus(); | ||
211 | this.fieldValueComponent().inputElement().dom.value = this.getElement('passwordField').dom.value; | ||
212 | this.getElement('passwordField').dom.focus(); | ||
213 | this.cancelPasswordPanel(aPasswordGeneratorPanel); | ||
214 | |||
215 | return false; | ||
216 | }, | ||
217 | |||
218 | //----------------------------------------------------- | ||
219 | |||
220 | 'updatePasswordValue': function(anEvent) { | ||
221 | varrandomBytes; | ||
222 | varrandomValue; | ||
223 | var charset; | ||
224 | var charsetBitSize; | ||
225 | var stringValue; | ||
226 | varblockIndex; | ||
227 | |||
228 | //MochiKit.Logging.logDebug(">>> updatePasswordValue"); | ||
229 | randomBytes = Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(50); | ||
230 | stringValue = ""; | ||
231 | blockIndex = 0; | ||
232 | |||
233 | charset = ""; | ||
234 | if (this.getDom('lowercase').checked) { | ||
235 | charset += Clipperz.PM.Strings['passwordGeneratorLowercaseCharset']; | ||
236 | } | ||
237 | if (this.getDom('uppercase').checked) { | ||
238 | charset += Clipperz.PM.Strings['passwordGeneratorUppercaseCharset']; | ||
239 | } | ||
240 | if (this.getDom('numbers').checked) { | ||
241 | charset += Clipperz.PM.Strings['passwordGeneratorNumberCharset']; | ||
242 | } | ||
243 | if (this.getDom('symbols').checked) { | ||
244 | charset += Clipperz.PM.Strings['passwordGeneratorSymbolCharset']; | ||
245 | } | ||
246 | |||
247 | charsetBitSize = 0; | ||
248 | while (Math.pow(2, charsetBitSize) < charset.length) { | ||
249 | charsetBitSize ++; | ||
250 | } | ||
251 | |||
252 | if (charsetBitSize > 0) { | ||
253 | while (Clipperz.PM.Crypto.passwordEntropy(stringValue) < 128) { | ||
254 | if (((blockIndex + 1)*charsetBitSize) > (randomBytes.length() * 8)) { | ||
255 | randomBytes = Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(50); | ||
256 | blockIndex = 0; | ||
257 | } | ||
258 | randomValue = randomBytes.bitBlockAtIndexWithSize(blockIndex*charsetBitSize, charsetBitSize); | ||
259 | if (randomValue < charset.length) { | ||
260 | stringValue += charset.charAt(randomValue); | ||
261 | } | ||
262 | |||
263 | blockIndex ++; | ||
264 | } | ||
265 | } else { | ||
266 | stringValue = ""; | ||
267 | } | ||
268 | |||
269 | this.getElement('passwordField').dom.focus() | ||
270 | this.getElement('passwordField').dom.value = stringValue; | ||
271 | |||
272 | |||
273 | if (anEvent) { | ||
274 | anEvent.src().focus(); | ||
275 | } else { | ||
276 | this.element().focus(); | ||
277 | } | ||
278 | |||
279 | return false; | ||
280 | //MochiKit.Logging.logDebug("<<< updatePasswordValue"); | ||
281 | }, | ||
282 | |||
283 | //----------------------------------------------------- | ||
284 | __syntaxFix__: '__syntaxFix__' | ||
285 | }); | ||
diff --git a/frontend/beta/js/Clipperz/PM/Components/Printing/Footer.js b/frontend/beta/js/Clipperz/PM/Components/Printing/Footer.js new file mode 100644 index 0000000..6bede3e --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/Printing/Footer.js | |||
@@ -0,0 +1,28 @@ | |||
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 | |||
diff --git a/frontend/beta/js/Clipperz/PM/Components/Printing/Header.js b/frontend/beta/js/Clipperz/PM/Components/Printing/Header.js new file mode 100644 index 0000000..6bede3e --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/Printing/Header.js | |||
@@ -0,0 +1,28 @@ | |||
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 | |||
diff --git a/frontend/beta/js/Clipperz/PM/Components/Printing/Record.js b/frontend/beta/js/Clipperz/PM/Components/Printing/Record.js new file mode 100644 index 0000000..910d4b1 --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/Printing/Record.js | |||
@@ -0,0 +1,95 @@ | |||
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 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | ||
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | ||
31 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } | ||
32 | if (typeof(Clipperz.PM.Components.Printing) == 'undefined') { Clipperz.PM.Components.Printing = {}; } | ||
33 | |||
34 | Clipperz.PM.Components.Printing.Record = function(args) { | ||
35 | args = args || {}; | ||
36 | |||
37 | this._record = args['record']; | ||
38 | |||
39 | return this; | ||
40 | } | ||
41 | |||
42 | MochiKit.Base.update(Clipperz.PM.Components.Printing.Record.prototype, { | ||
43 | |||
44 | 'record': function() { | ||
45 | return this._record; | ||
46 | }, | ||
47 | |||
48 | //------------------------------------------------------------------------- | ||
49 | |||
50 | 'deferredDrawToWindow': function(aWindow) { | ||
51 | vardeferredResult; | ||
52 | |||
53 | deferredResult = new MochiKit.Async.Deferred(); | ||
54 | deferredResult.addCallback(MochiKit.Base.method(this.record(), 'deferredData')); | ||
55 | deferredResult.addCallback(MochiKit.Base.method(this, 'appendToWindow', aWindow)); | ||
56 | deferredResult.callback(); | ||
57 | return deferredResult; | ||
58 | }, | ||
59 | |||
60 | //------------------------------------------------------------------------- | ||
61 | |||
62 | 'appendToWindow': function(aWindow) { | ||
63 | MochiKit.DOM.withWindow(aWindow, MochiKit.Base.bind(function() { | ||
64 | var newBlock; | ||
65 | var fields; | ||
66 | |||
67 | fields = MochiKit.Base.concat( | ||
68 | MochiKit.Base.map(MochiKit.Base.bind(function(aField) { | ||
69 | var result; | ||
70 | var dt, dd; | ||
71 | var label, value; | ||
72 | |||
73 | label = aField.label(); | ||
74 | value = aField.value(); | ||
75 | dt = MochiKit.DOM.createDOM('DT', null, label); | ||
76 | dd = MochiKit.DOM.createDOM('DD', null, value) | ||
77 | result = [dt, dd]; | ||
78 | |||
79 | return result | ||
80 | }, this), MochiKit.Base.values(this.record().currentVersion().fields())) | ||
81 | ); | ||
82 | |||
83 | newBlock = MochiKit.DOM.DIV({'class': 'recordBlock'}, | ||
84 | MochiKit.DOM.H2(null, this.record().label()), | ||
85 | MochiKit.DOM.DIV({'class': 'recordNotes'}, MochiKit.Base.map(MochiKit.Base.partial(MochiKit.DOM.P, null), this.record().notes().split("\n"))), | ||
86 | MochiKit.DOM.createDOM('DL', null, fields) | ||
87 | ); | ||
88 | MochiKit.DOM.appendChildNodes(MochiKit.DOM.currentDocument().body, newBlock); | ||
89 | |||
90 | }, this)); | ||
91 | }, | ||
92 | |||
93 | //------------------------------------------------------------------------- | ||
94 | __syntaxFix__: "syntax fix" | ||
95 | }); | ||
diff --git a/frontend/beta/js/Clipperz/PM/Components/RecordDetail/AbstractComponent.js b/frontend/beta/js/Clipperz/PM/Components/RecordDetail/AbstractComponent.js new file mode 100644 index 0000000..840d555 --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/RecordDetail/AbstractComponent.js | |||
@@ -0,0 +1,105 @@ | |||
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 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | ||
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | ||
31 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } | ||
32 | if (typeof(Clipperz.PM.Components.RecordDetail) == 'undefined') { Clipperz.PM.Components.RecordDetail = {}; } | ||
33 | |||
34 | //############################################################################# | ||
35 | |||
36 | Clipperz.PM.Components.RecordDetail.AbstractComponent = function(anElement, args) { | ||
37 | args = args || {}; | ||
38 | |||
39 | Clipperz.PM.Components.RecordDetail.AbstractComponent.superclass.constructor.call(this, args); | ||
40 | |||
41 | this._element = anElement; | ||
42 | this._mainComponent = args.mainComponent; | ||
43 | |||
44 | return this; | ||
45 | } | ||
46 | |||
47 | //============================================================================= | ||
48 | |||
49 | YAHOO.extendX(Clipperz.PM.Components.RecordDetail.AbstractComponent, Clipperz.PM.Components.BaseComponent, { | ||
50 | |||
51 | 'toString': function() { | ||
52 | return "Clipperz.PM.Components.RecordDetail.AbstractComponent"; | ||
53 | }, | ||
54 | |||
55 | //------------------------------------------------------------------------- | ||
56 | |||
57 | 'mainComponent': function() { | ||
58 | return this._mainComponent; | ||
59 | }, | ||
60 | |||
61 | //------------------------------------------------------------------------- | ||
62 | |||
63 | 'record': function() { | ||
64 | return this.mainComponent().record(); | ||
65 | }, | ||
66 | |||
67 | //------------------------------------------------------------------------- | ||
68 | |||
69 | 'editMode': function() { | ||
70 | return this.mainComponent().editMode(); | ||
71 | }, | ||
72 | |||
73 | //------------------------------------------------------------------------- | ||
74 | |||
75 | 'render': function() { | ||
76 | this.element().update(""); | ||
77 | this.update(); | ||
78 | }, | ||
79 | |||
80 | //------------------------------------------------------------------------- | ||
81 | |||
82 | 'update': function(anEvent) { | ||
83 | if (this.editMode() == 'EDIT') { | ||
84 | this.updateEditMode(); | ||
85 | } else if (this.editMode() == 'VIEW') { | ||
86 | this.updateViewMode(); | ||
87 | } | ||
88 | }, | ||
89 | |||
90 | //------------------------------------------------------------------------- | ||
91 | |||
92 | 'updateViewMode': function() {}, | ||
93 | 'updateEditMode': function() {}, | ||
94 | 'synchronizeComponentValues': function() {}, | ||
95 | |||
96 | //------------------------------------------------------------------------- | ||
97 | |||
98 | 'destroy': function() { | ||
99 | this.element().remove(); | ||
100 | }, | ||
101 | |||
102 | //------------------------------------------------------------------------- | ||
103 | __syntaxFix__: "syntax fix" | ||
104 | }); | ||
105 | |||
diff --git a/frontend/beta/js/Clipperz/PM/Components/RecordDetail/AbstractFieldSubComponent.js b/frontend/beta/js/Clipperz/PM/Components/RecordDetail/AbstractFieldSubComponent.js new file mode 100644 index 0000000..7596184 --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/RecordDetail/AbstractFieldSubComponent.js | |||
@@ -0,0 +1,77 @@ | |||
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 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | ||
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | ||
31 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } | ||
32 | if (typeof(Clipperz.PM.Components.RecordDetail) == 'undefined') { Clipperz.PM.Components.RecordDetail = {}; } | ||
33 | |||
34 | //############################################################################# | ||
35 | |||
36 | Clipperz.PM.Components.RecordDetail.AbstractFieldSubComponent = function(anElement, args) { | ||
37 | args = args || {}; | ||
38 | |||
39 | Clipperz.PM.Components.RecordDetail.AbstractFieldSubComponent.superclass.constructor.call(this, anElement, args); | ||
40 | |||
41 | this._fieldComponent = args.fieldComponent || null; | ||
42 | |||
43 | this.render(); | ||
44 | |||
45 | return this; | ||
46 | } | ||
47 | |||
48 | //============================================================================= | ||
49 | |||
50 | YAHOO.extendX(Clipperz.PM.Components.RecordDetail.AbstractFieldSubComponent, Clipperz.PM.Components.RecordDetail.AbstractComponent, { | ||
51 | |||
52 | 'toString': function() { | ||
53 | return "Clipperz.PM.Components.RecordDetail.AbstractFieldSubComponent"; | ||
54 | }, | ||
55 | |||
56 | //------------------------------------------------------------------------- | ||
57 | |||
58 | 'fieldComponent': function() { | ||
59 | return this._fieldComponent; | ||
60 | }, | ||
61 | |||
62 | //------------------------------------------------------------------------- | ||
63 | |||
64 | 'mainComponent': function() { | ||
65 | return this.fieldComponent().mainComponent(); | ||
66 | }, | ||
67 | |||
68 | //------------------------------------------------------------------------- | ||
69 | |||
70 | 'recordField': function() { | ||
71 | return this.fieldComponent().recordField(); | ||
72 | }, | ||
73 | |||
74 | //------------------------------------------------------------------------- | ||
75 | __syntaxFix__: "syntax fix" | ||
76 | }); | ||
77 | |||
diff --git a/frontend/beta/js/Clipperz/PM/Components/RecordDetail/CreationWizard.js b/frontend/beta/js/Clipperz/PM/Components/RecordDetail/CreationWizard.js new file mode 100644 index 0000000..a92285f --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/RecordDetail/CreationWizard.js | |||
@@ -0,0 +1,317 @@ | |||
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 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | ||
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | ||
31 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } | ||
32 | if (typeof(Clipperz.PM.Components.RecordDetail) == 'undefined') { Clipperz.PM.Components.RecordDetail = {}; } | ||
33 | |||
34 | //############################################################################# | ||
35 | |||
36 | Clipperz.PM.Components.RecordDetail.CreationWizard = function(anElement, args) { | ||
37 | args = args || {}; | ||
38 | |||
39 | Clipperz.PM.Components.RecordDetail.CreationWizard.superclass.constructor.call(this, anElement, args); | ||
40 | |||
41 | this._mainComponent = args.mainComponent; | ||
42 | this._previouslySelectedRecord = args.previouslySelectedRecord; | ||
43 | //MochiKit.Logging.logDebug("--- new CreationWizard - previouslySelectedRecord: " + args.previouslySelectedRecord); | ||
44 | this._createButton_header = null; | ||
45 | this._createButton_footer = null; | ||
46 | |||
47 | this._cancelButton_header = null; | ||
48 | this._cancelButton_footer = null; | ||
49 | |||
50 | this.render(); | ||
51 | |||
52 | return this; | ||
53 | } | ||
54 | |||
55 | //============================================================================= | ||
56 | |||
57 | YAHOO.extendX(Clipperz.PM.Components.RecordDetail.CreationWizard, Clipperz.PM.Components.BaseComponent, { | ||
58 | |||
59 | 'toString': function() { | ||
60 | return "Clipperz.PM.Components.RecordDetail.CreationWizard component"; | ||
61 | }, | ||
62 | |||
63 | //------------------------------------------------------------------------- | ||
64 | |||
65 | 'previouslySelectedRecord': function() { | ||
66 | return this._previouslySelectedRecord; | ||
67 | }, | ||
68 | |||
69 | //------------------------------------------------------------------------- | ||
70 | |||
71 | 'render': function() { | ||
72 | vartemplateListElement; | ||
73 | vartemplates; | ||
74 | |||
75 | this.element().update(""); | ||
76 | |||
77 | Clipperz.YUI.DomHelper.append(this.element().dom, | ||
78 | {tag:'form', cls:'recordDataFORM', id:this.getId('form'), children:[ | ||
79 | {tag:'div', id:'recordDetailDataBox', cls:'recordDetailDataBox', children:[ | ||
80 | {tag:'div', id:this.getId('wizardBox'), cls:'recordCreationWizard', children:[ | ||
81 | {tag:'div', id:this.getId('recordCreationWizardTitleBox'), cls:'recordCreationWizardTitleBox', htmlString:Clipperz.PM.Strings['newRecordWizardTitleBox']}, | ||
82 | {tag:'ul', id:this.getId('templateList'), cls:'radioList'} | ||
83 | ]} | ||
84 | ]} | ||
85 | ]} | ||
86 | ); | ||
87 | |||
88 | Clipperz.YUI.DomHelper.append(this.getDom('recordCreationWizardTitleBox'), {tag:'div', cls:'newRecordWizardHeader', children:[ | ||
89 | {tag:'table', width:'100%', cellpadding:'5', children:[ | ||
90 | {tag:'tbody', children:[ | ||
91 | {tag:'tr', children:[ | ||
92 | {tag:'td', width:'49%', align:'right', children:[ | ||
93 | {tag:'div', id:this.getId('cancelButton_header')} | ||
94 | ]}, | ||
95 | {tag:'td', width:'10', html:' '}, | ||
96 | {tag:'td', width:'49%', align:'left', children:[ | ||
97 | {tag:'div', id:this.getId('createButton_header')} | ||
98 | ]} | ||
99 | ]} | ||
100 | ]} | ||
101 | ]} | ||
102 | ]}); | ||
103 | |||
104 | templateListElement = this.getElement('templateList'); | ||
105 | templates = Clipperz.PM.Strings['recordTemplates']; | ||
106 | MochiKit.Iter.forEach(MochiKit.Base.keys(templates), MochiKit.Base.bind(function(aTemplateKey) { | ||
107 | Clipperz.YUI.DomHelper.append(templateListElement.dom, {tag:'li', children:[ | ||
108 | {tag:'table', children:[ | ||
109 | {tag:'tbody', children:[ | ||
110 | {tag:'tr', children:[ | ||
111 | {tag:'td', valign:'top', children:[ | ||
112 | {tag:'input', id:this.getId(aTemplateKey+"_radio"), type:'radio', name:'recordTemplate', value:"aTemplateKey"} | ||
113 | ]}, | ||
114 | {tag:'td', valign:'top', children:[ | ||
115 | {tag:'h4', id:this.getId(aTemplateKey+"_title"), html:templates[aTemplateKey]['title']}, | ||
116 | {tag:'div', cls:'templateDescription', htmlString:templates[aTemplateKey]['description']} | ||
117 | ]} | ||
118 | ]} | ||
119 | ]} | ||
120 | ]} | ||
121 | ]}); | ||
122 | this.getElement(aTemplateKey+"_radio").dom.value = aTemplateKey; | ||
123 | MochiKit.Signal.connect(this.getDom(aTemplateKey+"_title"), 'onclick', MochiKit.Base.partial(function(aRadioButton) {aRadioButton.click();}, this.getDom(aTemplateKey+"_radio"))); | ||
124 | }, this)); | ||
125 | |||
126 | Clipperz.YUI.DomHelper.append(templateListElement.dom, {tag:'li', children:[ | ||
127 | {tag:'table', children:[ | ||
128 | {tag:'tbody', children:[ | ||
129 | {tag:'tr', children:[ | ||
130 | {tag:'td', valign:'top', children:[ | ||
131 | {tag:'input', type:'radio', name:'recordTemplate', id:this.getId('bookmarkletRadioButton'), value:'BookmarkletConfigurationTemplate'} | ||
132 | ]}, | ||
133 | {tag:'td', valign:'top', children:[ | ||
134 | {tag:'h4', htmlString:Clipperz.PM.Strings['newRecordWizardBookmarkletConfigurationTitle']}, | ||
135 | {tag:'div', cls:'templateDescription', htmlString:Clipperz.PM.Strings['newRecordWizardBookmarkletConfigurationDescription']}, | ||
136 | {tag:'div', cls:'bookmarkletConfiguration', children:[ | ||
137 | // {tag:'span', htmlString:Clipperz.PM.Strings['newRecordWizardBookmarkletConfigurationLabel']}, | ||
138 | {tag:'div', htmlString:Clipperz.PM.Strings['recordDetailNewDirectLoginDescription']}, | ||
139 | {tag:'textarea', id:this.getId('bookmarkletConfiguration')} | ||
140 | ]} | ||
141 | ]} | ||
142 | ]} | ||
143 | ]} | ||
144 | ]} | ||
145 | ]}); | ||
146 | |||
147 | Clipperz.YUI.DomHelper.append(this.getDom('wizardBox'), {tag:'div', cls:'newRecordWizardFooter', children:[ | ||
148 | {tag:'table', width:'100%', cellpadding:'5', children:[ | ||
149 | {tag:'tbody', children:[ | ||
150 | {tag:'tr', children:[ | ||
151 | {tag:'td', width:'49%', align:'right', children:[ | ||
152 | {tag:'div', id:this.getId('cancelButton_footer')} | ||
153 | ]}, | ||
154 | {tag:'td', width:'10', html:' '}, | ||
155 | {tag:'td', width:'49%', align:'left', children:[ | ||
156 | {tag:'div', id:this.getId('createButton_footer')} | ||
157 | ]} | ||
158 | ]} | ||
159 | ]} | ||
160 | ]} | ||
161 | ]}); | ||
162 | |||
163 | this.setCreateButton_header(new YAHOO.ext.Button(this.getDom('createButton_header'), {text:Clipperz.PM.Strings['newRecordWizardCreateButtonLabel'], handler:this.createRecord, scope:this})); | ||
164 | this.setCreateButton_footer(new YAHOO.ext.Button(this.getDom('createButton_footer'), {text:Clipperz.PM.Strings['newRecordWizardCreateButtonLabel'], handler:this.createRecord, scope:this})); | ||
165 | |||
166 | this.setCancelButton_header(new YAHOO.ext.Button(this.getDom('cancelButton_header'), {text:Clipperz.PM.Strings['newRecordWizardCancelButtonLabel'], handler:this.exitWizard, scope:this})); | ||
167 | this.setCancelButton_footer(new YAHOO.ext.Button(this.getDom('cancelButton_footer'), {text:Clipperz.PM.Strings['newRecordWizardCancelButtonLabel'], handler:this.exitWizard, scope:this})); | ||
168 | |||
169 | this.createButton_header().disable(); | ||
170 | this.createButton_footer().disable(); | ||
171 | |||
172 | MochiKit.Iter.forEach(this.getElement('form').getChildrenByTagName('input'), MochiKit.Base.bind(function(anInput) { | ||
173 | // MochiKit.Signal.connect(anInput.dom, 'onchange', this, 'enableCreateButton'); | ||
174 | MochiKit.Signal.connect(anInput.dom, 'onclick', this, 'enableCreateButton'); //for Safari | ||
175 | },this)); | ||
176 | |||
177 | MochiKit.Signal.connect(this.getDom('bookmarkletConfiguration'), 'onkeyup', this, 'enableCreateButton'); | ||
178 | MochiKit.Signal.connect(this.getDom('bookmarkletConfiguration'), 'onkeydown', this, 'enableCreateButton'); //for Safari | ||
179 | }, | ||
180 | |||
181 | //------------------------------------------------------------------------- | ||
182 | |||
183 | 'createButton_header': function() { | ||
184 | return this._createButton_header; | ||
185 | }, | ||
186 | |||
187 | 'setCreateButton_header': function(aValue) { | ||
188 | this._createButton_header = aValue; | ||
189 | }, | ||
190 | |||
191 | //......................................................................... | ||
192 | |||
193 | 'createButton_footer': function() { | ||
194 | return this._createButton_footer; | ||
195 | }, | ||
196 | |||
197 | 'setCreateButton_footer': function(aValue) { | ||
198 | this._createButton_footer = aValue; | ||
199 | }, | ||
200 | |||
201 | |||
202 | //------------------------------------------------------------------------- | ||
203 | |||
204 | 'cancelButton_header': function() { | ||
205 | return this._cancelButton_header; | ||
206 | }, | ||
207 | |||
208 | 'setCancelButton_header': function(aValue) { | ||
209 | this._cancelButton_header = aValue; | ||
210 | }, | ||
211 | |||
212 | //......................................................................... | ||
213 | |||
214 | 'cancelButton_footer': function() { | ||
215 | return this._cancelButton_footer; | ||
216 | }, | ||
217 | |||
218 | 'setCancelButton_footer': function(aValue) { | ||
219 | this._cancelButton_footer = aValue; | ||
220 | }, | ||
221 | |||
222 | //------------------------------------------------------------------------- | ||
223 | |||
224 | 'enableCreateButton': function(anEvent, skipKeyDownCheck) { | ||
225 | //MochiKit.Logging.logDebug(">>> CreationWizard.enableCreateButton (" + anEvent.type() + ")"); | ||
226 | if ((anEvent.type() == "keydown") && (skipKeyDownCheck != true)) { | ||
227 | //MochiKit.Logging.logDebug("--- CreationWizard.enableCreateButton - handling 'keydown' event with a postponed execution of the check"); | ||
228 | MochiKit.Async.callLater(0.3, MochiKit.Base.method(this, 'enableCreateButton', anEvent, true)); | ||
229 | } else { | ||
230 | var shouldEnableCreateButton; | ||
231 | var isBookmarkletConfigurationEmpty; | ||
232 | |||
233 | //MochiKit.Logging.logDebug("--- CreationWizard.enableCreateButton - common execution"); | ||
234 | |||
235 | shouldEnableCreateButton = true; | ||
236 | |||
237 | isBookmarkletConfigurationEmpty = !/[^ \n]/.test(this.getDom('bookmarkletConfiguration').value); | ||
238 | //MochiKit.Logging.logDebug("--- CreationWizard.enableCreateButton - isBookmarkletConfigurationEmpty: " + isBookmarkletConfigurationEmpty); | ||
239 | |||
240 | if ((anEvent.src() == this.getDom('bookmarkletConfiguration')) && !isBookmarkletConfigurationEmpty) { | ||
241 | this.getDom('bookmarkletRadioButton').checked = true; | ||
242 | } | ||
243 | |||
244 | if ((this.getDom('bookmarkletRadioButton').checked) && isBookmarkletConfigurationEmpty) { | ||
245 | shouldEnableCreateButton = false; | ||
246 | } | ||
247 | |||
248 | if (shouldEnableCreateButton) { | ||
249 | //MochiKit.Logging.logDebug("--- CreationWizard.enableCreateButton - enabling button"); | ||
250 | this.createButton_header().enable(); | ||
251 | this.createButton_footer().enable(); | ||
252 | } else { | ||
253 | //MochiKit.Logging.logDebug("--- CreationWizard.enableCreateButton - disabling button"); | ||
254 | this.createButton_header().disable(); | ||
255 | this.createButton_footer().disable(); | ||
256 | } | ||
257 | } | ||
258 | //MochiKit.Logging.logDebug("<<< CreationWizard.enableCreateButton"); | ||
259 | }, | ||
260 | |||
261 | //------------------------------------------------------------------------- | ||
262 | |||
263 | 'createRecord': function() { | ||
264 | varselectedTemplateKey; | ||
265 | varnewRecord; | ||
266 | |||
267 | selectedTemplateKey = MochiKit.Base.filter(function(aCheckBoxElement) { | ||
268 | return aCheckBoxElement.dom.checked; | ||
269 | },this.getElement('form').getChildrenByTagName('input'))[0].dom.value; | ||
270 | |||
271 | //MochiKit.Logging.logDebug("--- CreationWizard.createRecord - selectedTemplateKey: " + selectedTemplateKey); | ||
272 | if (selectedTemplateKey == 'BookmarkletConfigurationTemplate') { | ||
273 | var bookmarkletConfiguration; | ||
274 | |||
275 | this.mainComponent().exitModalView(); | ||
276 | bookmarkletConfiguration = Clipperz.PM.BookmarkletProcessor.checkBookmarkletConfiguration(this.getDom('bookmarkletConfiguration').value, this.getDom('createButton'), MochiKit.Base.method(this.mainComponent(), 'enterModalView')); | ||
277 | this.mainComponent().enterModalView(); | ||
278 | newRecord = Clipperz.PM.BookmarkletProcessor.createRecordFromBookmarkletConfiguration(this.mainComponent().user(), bookmarkletConfiguration); | ||
279 | } else { | ||
280 | varfieldsConfigurations; | ||
281 | |||
282 | newRecord = this.mainComponent().user().addNewRecord(); | ||
283 | newRecord.setLabel(Clipperz.PM.Strings['recordTemplates'][selectedTemplateKey]['title']); | ||
284 | |||
285 | fieldsConfigurations = Clipperz.PM.Strings['recordTemplates'][selectedTemplateKey]['fields']; | ||
286 | |||
287 | MochiKit.Iter.forEach(fieldsConfigurations, MochiKit.Base.partial(function(aRecord, aFieldConfiguration) { | ||
288 | var newField; | ||
289 | |||
290 | newField = new Clipperz.PM.DataModel.RecordField({recordVersion:aRecord.currentVersion()}); | ||
291 | newField.setLabel(aFieldConfiguration['label']); | ||
292 | newField.setType(aFieldConfiguration['type']); | ||
293 | aRecord.currentVersion().addField(newField); | ||
294 | }, newRecord)); | ||
295 | } | ||
296 | |||
297 | this.mainComponent().exitWizard(newRecord, true); | ||
298 | }, | ||
299 | |||
300 | //------------------------------------------------------------------------- | ||
301 | |||
302 | 'exitWizard': function() { | ||
303 | //MochiKit.Logging.logDebug(">>> CreationWizard.exitWizard - " + this.previouslySelectedRecord()); | ||
304 | this.mainComponent().exitWizard(this.previouslySelectedRecord()); | ||
305 | //MochiKit.Logging.logDebug("<<< CreationWizard.exitWizard"); | ||
306 | }, | ||
307 | |||
308 | //------------------------------------------------------------------------- | ||
309 | |||
310 | 'mainComponent': function() { | ||
311 | return this._mainComponent; | ||
312 | }, | ||
313 | |||
314 | //------------------------------------------------------------------------- | ||
315 | __syntaxFix__: "syntax fix" | ||
316 | }); | ||
317 | |||
diff --git a/frontend/beta/js/Clipperz/PM/Components/RecordDetail/DirectLoginBindingComponent.js b/frontend/beta/js/Clipperz/PM/Components/RecordDetail/DirectLoginBindingComponent.js new file mode 100644 index 0000000..6171a4e --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/RecordDetail/DirectLoginBindingComponent.js | |||
@@ -0,0 +1,174 @@ | |||
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 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | ||
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | ||
31 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } | ||
32 | if (typeof(Clipperz.PM.Components.RecordDetail) == 'undefined') { Clipperz.PM.Components.RecordDetail = {}; } | ||
33 | |||
34 | //############################################################################# | ||
35 | |||
36 | Clipperz.PM.Components.RecordDetail.DirectLoginBindingComponent = function(anElement, args) { | ||
37 | //MochiKit.Logging.logDebug(">>> new DirectLoginBindingComponent"); | ||
38 | args = args || {}; | ||
39 | |||
40 | Clipperz.PM.Components.RecordDetail.DirectLoginBindingComponent.superclass.constructor.call(this, anElement, args); | ||
41 | |||
42 | this._directLoginBinding = args.directLoginBinding || null; | ||
43 | this.render(); | ||
44 | |||
45 | Clipperz.NotificationCenter.register(this.record(), 'addNewRecordField',this, 'syncAndUpdateEditMode'); | ||
46 | Clipperz.NotificationCenter.register(this.record(), 'removedField', this, 'syncAndUpdateEditMode'); | ||
47 | Clipperz.NotificationCenter.register(this.record(), 'updatedFieldLabel',this, 'syncAndUpdateEditMode'); | ||
48 | //MochiKit.Logging.logDebug("<<< new DirectLoginBindingComponent"); | ||
49 | |||
50 | return this; | ||
51 | } | ||
52 | |||
53 | //============================================================================= | ||
54 | |||
55 | YAHOO.extendX(Clipperz.PM.Components.RecordDetail.DirectLoginBindingComponent, Clipperz.PM.Components.RecordDetail.AbstractComponent, { | ||
56 | |||
57 | 'toString': function() { | ||
58 | return "Clipperz.PM.Components.RecordDetail.DirectLoginBindingComponent component"; | ||
59 | }, | ||
60 | |||
61 | //------------------------------------------------------------------------- | ||
62 | |||
63 | 'directLoginBinding': function() { | ||
64 | return this._directLoginBinding; | ||
65 | }, | ||
66 | |||
67 | //------------------------------------------------------------------------- | ||
68 | |||
69 | 'render': function() { | ||
70 | // Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'span', style:'font-weight:bold;', html:this.directLoginBinding().key()}) | ||
71 | // Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'span', html:this.directLoginBinding().value()}) | ||
72 | //MochiKit.Logging.logDebug(">>> DirectLoginBindingComponent.render"); | ||
73 | Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'td', cls:'directLoginBindingLabelTD', children:[ | ||
74 | {tag:'span', html:this.directLoginBinding().key()} | ||
75 | ]}); | ||
76 | //MochiKit.Logging.logDebug("--- DirectLoginBindingComponent.render - 1"); | ||
77 | Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'td', cls:'directLoginBindingValueTD', children:[ | ||
78 | {tag:'div', id:this.getId('editModeBox'), children:[ | ||
79 | {tag:'select', id:this.getId('select'), children:this.recordFieldOptions()} | ||
80 | ]}, | ||
81 | {tag:'div', id:this.getId('viewModeBox'), children:[ | ||
82 | {tag:'span', id:this.getId('viewValue'), html:""} | ||
83 | ]} | ||
84 | ]}); | ||
85 | //MochiKit.Logging.logDebug("--- DirectLoginBindingComponent.render - 2"); | ||
86 | this.getElement('editModeBox').setVisibilityMode(YAHOO.ext.Element.DISPLAY); | ||
87 | this.getElement('viewModeBox').setVisibilityMode(YAHOO.ext.Element.DISPLAY); | ||
88 | |||
89 | this.update(); | ||
90 | //MochiKit.Logging.logDebug("<<< DirectLoginBindingComponent.render"); | ||
91 | }, | ||
92 | |||
93 | //------------------------------------------------------------------------- | ||
94 | |||
95 | 'recordFieldOptions': function() { | ||
96 | varresult; | ||
97 | var option; | ||
98 | varrecordFieldKey; | ||
99 | varrecordFields; | ||
100 | |||
101 | //MochiKit.Logging.logDebug(">>> DirectLoginBindingComponent.recordFieldOptions"); | ||
102 | recordFields = this.directLoginBinding().directLogin().record().currentVersion().fields(); | ||
103 | result = []; | ||
104 | option = {tag:'option', value:null, html:'---'}; | ||
105 | result.push(option); | ||
106 | for (recordFieldKey in recordFields) { | ||
107 | //TODO: remove the value: field and replace it with element.dom.value = <some value> | ||
108 | option = {tag:'option', value:recordFieldKey, html:recordFields[recordFieldKey].label()} | ||
109 | if (recordFieldKey == this.directLoginBinding().fieldKey()) { | ||
110 | option['selected'] = true; | ||
111 | } | ||
112 | result.push(option); | ||
113 | } | ||
114 | //MochiKit.Logging.logDebug("<<< DirectLoginBindingComponent.recordFieldOptions"); | ||
115 | |||
116 | return result; | ||
117 | }, | ||
118 | |||
119 | //------------------------------------------------------------------------- | ||
120 | |||
121 | 'syncAndUpdateEditMode': function() { | ||
122 | this.synchronizeComponentValues(); | ||
123 | this.updateEditMode(); | ||
124 | }, | ||
125 | |||
126 | 'updateEditMode': function() { | ||
127 | varselectElementBox; | ||
128 | |||
129 | //MochiKit.Logging.logDebug(">>> DirectLoginBindingComponent.updateEditMode"); | ||
130 | this.getElement('viewModeBox').hide(); | ||
131 | |||
132 | selectElementBox = this.getElement('editModeBox'); | ||
133 | selectElementBox.update(""); | ||
134 | |||
135 | Clipperz.YUI.DomHelper.append(selectElementBox.dom, {tag:'select', id:this.getId('select'), children:this.recordFieldOptions()}); | ||
136 | |||
137 | /* | ||
138 | selectElement = this.getElement('select'); | ||
139 | |||
140 | selectElement.update(""); | ||
141 | MochiKit.Iter.forEach(this.recordFieldOptions(), function(anOption) { | ||
142 | Clipperz.YUI.DomHelper.append(selectElement.dom, anOption); | ||
143 | }); | ||
144 | */ | ||
145 | |||
146 | |||
147 | this.getElement('editModeBox').show(); | ||
148 | //MochiKit.Logging.logDebug("<<< DirectLoginBindingComponent.updateEditMode"); | ||
149 | }, | ||
150 | |||
151 | //------------------------------------------------------------------------- | ||
152 | |||
153 | 'updateViewMode': function() { | ||
154 | //MochiKit.Logging.logDebug(">>> DirectLoginBindingComponent.updateViewMode"); | ||
155 | this.getElement('editModeBox').hide(); | ||
156 | this.getElement('viewModeBox').show(); | ||
157 | |||
158 | this.getElement('viewValue').update(this.directLoginBinding().field().label()); | ||
159 | //MochiKit.Logging.logDebug("<<< DirectLoginBindingComponent.updateViewMode"); | ||
160 | }, | ||
161 | |||
162 | //------------------------------------------------------------------------- | ||
163 | |||
164 | 'synchronizeComponentValues': function() { | ||
165 | //MochiKit.Logging.logDebug(">>> DirectLoginBindingComponent.synchronizeComponentValues") | ||
166 | //MochiKit.Logging.logDebug("--- DirectLoginBindingComponent.synchronizeComponentValues - 1 - " + this.getId('select')); | ||
167 | this.directLoginBinding().setFieldKey(this.getDom('select').value); | ||
168 | //MochiKit.Logging.logDebug("<<< DirectLoginBindingComponent.synchronizeComponentValues"); | ||
169 | }, | ||
170 | |||
171 | //------------------------------------------------------------------------- | ||
172 | __syntaxFix__: "syntax fix" | ||
173 | }); | ||
174 | |||
diff --git a/frontend/beta/js/Clipperz/PM/Components/RecordDetail/DirectLoginComponent.js b/frontend/beta/js/Clipperz/PM/Components/RecordDetail/DirectLoginComponent.js new file mode 100644 index 0000000..7638f00 --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/RecordDetail/DirectLoginComponent.js | |||
@@ -0,0 +1,362 @@ | |||
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 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | ||
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | ||
31 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } | ||
32 | if (typeof(Clipperz.PM.Components.RecordDetail) == 'undefined') { Clipperz.PM.Components.RecordDetail = {}; } | ||
33 | |||
34 | //############################################################################# | ||
35 | |||
36 | Clipperz.PM.Components.RecordDetail.DirectLoginComponent = function(anElement, args) { | ||
37 | args = args || {}; | ||
38 | |||
39 | Clipperz.PM.Components.RecordDetail.DirectLoginComponent.superclass.constructor.call(this, anElement, args); | ||
40 | |||
41 | this._directLogin = args.directLogin || null; | ||
42 | //this._titleElement = null; | ||
43 | this._structureElement = null; | ||
44 | this._removeButton = null; | ||
45 | this._directLoginBindingComponents = null; | ||
46 | this._collapser = null; | ||
47 | |||
48 | this.mainComponent().addEditComponent(this); | ||
49 | this.render(); | ||
50 | |||
51 | return this; | ||
52 | } | ||
53 | |||
54 | //============================================================================= | ||
55 | |||
56 | YAHOO.extendX(Clipperz.PM.Components.RecordDetail.DirectLoginComponent, Clipperz.PM.Components.RecordDetail.AbstractComponent, { | ||
57 | |||
58 | 'toString': function() { | ||
59 | return "Clipperz.PM.Components.RecordDetail.DirectLoginComponent component"; | ||
60 | }, | ||
61 | |||
62 | //------------------------------------------------------------------------- | ||
63 | |||
64 | 'directLogin': function() { | ||
65 | return this._directLogin; | ||
66 | }, | ||
67 | |||
68 | 'directLoginBindingComponents': function() { | ||
69 | return this._directLoginBindingComponents; | ||
70 | }, | ||
71 | |||
72 | //------------------------------------------------------------------------- | ||
73 | |||
74 | 'removeDirectLogin': function() { | ||
75 | //MochiKit.Logging.logDebug(">>> DirectLoginComponent.removeDirectLogin"); | ||
76 | this.mainComponent().synchronizeComponentValues(); | ||
77 | this.directLogin().remove(); | ||
78 | this.mainComponent().removeEditComponent(this); | ||
79 | this.mainComponent().render(); | ||
80 | //MochiKit.Logging.logDebug("<<< DirectLoginComponent.removeDirectLogin"); | ||
81 | }, | ||
82 | |||
83 | //------------------------------------------------------------------------- | ||
84 | /* | ||
85 | 'formDataValue': function() { | ||
86 | return Clipperz.Base.serializeJSON(this.directLogin().formData()); | ||
87 | }, | ||
88 | |||
89 | 'setFormDataValue': function(aValue) { | ||
90 | |||
91 | }, | ||
92 | */ | ||
93 | //------------------------------------------------------------------------- | ||
94 | |||
95 | 'removeButton': function() { | ||
96 | return this._removeButton; | ||
97 | }, | ||
98 | |||
99 | 'setRemoveButton': function(aValue) { | ||
100 | this._removeButton = aValue; | ||
101 | }, | ||
102 | |||
103 | //------------------------------------------------------------------------- | ||
104 | /* | ||
105 | 'titleElement': function() { | ||
106 | return this._titleElement; | ||
107 | }, | ||
108 | |||
109 | 'setTitleElement': function(aValue) { | ||
110 | this._titleElement = aValue; | ||
111 | }, | ||
112 | */ | ||
113 | //------------------------------------------------------------------------- | ||
114 | |||
115 | 'structureElement': function() { | ||
116 | return this._structureElement; | ||
117 | }, | ||
118 | |||
119 | 'setStructureElement': function(aValue) { | ||
120 | this._structureElement = aValue; | ||
121 | }, | ||
122 | |||
123 | //------------------------------------------------------------------------- | ||
124 | |||
125 | 'render': function() { | ||
126 | //MochiKit.Logging.logDebug(">>> DirectLoginComponent.render"); | ||
127 | try { | ||
128 | this.element().update(""); | ||
129 | Clipperz.YUI.DomHelper.append(this.element().dom, | ||
130 | {tag:'li', children:[ | ||
131 | {tag:'table', width:'100%', border:'0', cellpadding:'0', cellspacing:'0', children:[ | ||
132 | {tag:'tbody', children:[ | ||
133 | {tag:'tr', children:[ | ||
134 | {tag:'td', rowspan:'2', width:'30', valign:'top', html:' ', children:[ | ||
135 | {tag:'div', id:this.getId('removeDirectLogin'), children:[ | ||
136 | {tag:'div', id:this.getId('removeDirectLoginButton')} | ||
137 | ]}, | ||
138 | {tag:'div', id:this.getId('collapseLink'), cls:'directLoginCollapseLink'} | ||
139 | ]}, | ||
140 | {tag:'td', valign:'top', children:[ | ||
141 | {tag:'table', width:'100%', border:'0', cellpadding:'0', cellspacing:'0', children:[ | ||
142 | {tag:'tbody', children:[ | ||
143 | {tag:'tr', children:[ | ||
144 | {tag:'td', width:'20', valign:'top', children:[ | ||
145 | {tag:'a', href:'#', id:this.getId('directLogin'), children:[ | ||
146 | {tag:'img', id:this.getId('faviconImage'), width:'16', height:'16', src:this.directLogin().fixedFavicon()} | ||
147 | ]} | ||
148 | ]}, | ||
149 | {tag:'td', valign:'top', children:[ | ||
150 | {tag:'div', cls:'directLoginDetailTitle', children:[ | ||
151 | {tag:'div', id:this.getId('titleViewBox'), children:[ | ||
152 | {tag:'a', href:'#', id:this.getId('titleLink')} | ||
153 | ]}, | ||
154 | {tag:'div', id:this.getId('titleEditBox'), children:[ | ||
155 | {tag:'input', type:'text', id:this.getId('titleInput')} | ||
156 | ]} | ||
157 | ]} | ||
158 | ]} | ||
159 | ]} | ||
160 | ]} | ||
161 | ]} | ||
162 | ]} | ||
163 | ]}, | ||
164 | {tag:'tr', children:[ | ||
165 | {tag:'td', /*colspan:'2',*/ children:[ | ||
166 | {tag:'div', id:this.getId('details'), children:[ | ||
167 | {tag:'table', cls:'directLoginBindings', border:'0', cellpadding:'0', cellspacing:'0', children:[ | ||
168 | {tag:'tbody', id:this.getId('tbodyBindings'), children:[]} | ||
169 | ]} | ||
170 | ]} | ||
171 | ]} | ||
172 | ]} | ||
173 | ]} | ||
174 | ]} | ||
175 | ]} | ||
176 | ); | ||
177 | |||
178 | MochiKit.Signal.connect(this.getId('faviconImage'), 'onload', this, 'handleLoadedFaviconImage'); | ||
179 | MochiKit.Signal.connect(this.getId('faviconImage'), 'onerror', this.directLogin(), 'handleMissingFaviconImage'); | ||
180 | MochiKit.Signal.connect(this.getId('faviconImage'), 'onabort', this.directLogin(), 'handleMissingFaviconImage'); | ||
181 | |||
182 | this.getElement('removeDirectLogin').setVisibilityMode(YAHOO.ext.Element.DISPLAY); | ||
183 | //MochiKit.Logging.logDebug("--- DirectLoginComponent.render - 1"); | ||
184 | this.getElement('collapseLink').addClassOnOver('hover'); | ||
185 | this._collapser = new Clipperz.YUI.Collapser(this.getElement('collapseLink'), this.getElement('details'), true); | ||
186 | //MochiKit.Logging.logDebug("--- DirectLoginComponent.render - 2"); | ||
187 | MochiKit.Signal.connect(this.getId('directLogin'), 'onclick', this, 'runDirectLogin'); | ||
188 | // this.getElement('directLogin').on('click', this.runDirectLogin, this, false); | ||
189 | //MochiKit.Logging.logDebug("--- DirectLoginComponent.render - 3"); | ||
190 | // this.setTitleElement(new Clipperz.PM.Components.TextFormField(this.getElement('title'), { | ||
191 | // editMode:this.editMode(), | ||
192 | // value:this.directLogin().label() | ||
193 | // })); | ||
194 | this.getElement('titleViewBox').setVisibilityMode(YAHOO.ext.Element.DISPLAY); | ||
195 | this.getElement('titleEditBox').setVisibilityMode(YAHOO.ext.Element.DISPLAY); | ||
196 | //- this.getElement('titleLink').on('click', this.runDirectLogin, this, false); | ||
197 | MochiKit.Signal.connect(this.getId('titleLink'), 'onclick', this, 'runDirectLogin'); | ||
198 | |||
199 | //MochiKit.Logging.logDebug("--- DirectLoginComponent.render - 4"); | ||
200 | //- this.setStructureElement(new Clipperz.PM.Components.TextFormField(this.getElement('formStructure'), { | ||
201 | //- editMode:this.editMode(), | ||
202 | //- value:this.formDataValue(), multiline:true | ||
203 | //- })); | ||
204 | //MochiKit.Logging.logDebug("--- DirectLoginComponent.render - 5"); | ||
205 | { | ||
206 | varbindingKey; | ||
207 | var valueName; | ||
208 | var inputsRequiringAdditionalValues; | ||
209 | var bindingsElement; | ||
210 | var i,c; | ||
211 | |||
212 | //MochiKit.Logging.logDebug("--- DirectLoginComponent.render - 6"); | ||
213 | this._directLoginBindingComponents = []; | ||
214 | //MochiKit.Logging.logDebug("--- DirectLoginComponent.render - 7"); | ||
215 | bindingsElement = this.getElement('tbodyBindings'); | ||
216 | //MochiKit.Logging.logDebug("--- DirectLoginComponent.render - 8"); | ||
217 | for (bindingKey in this.directLogin().bindings()) { | ||
218 | try { | ||
219 | var directLoginBindingElement; | ||
220 | var directLoginBindingComponent; | ||
221 | |||
222 | //MochiKit.Logging.logDebug("--- DirectLoginComponent.render - 9"); | ||
223 | directLoginBindingElement = Clipperz.YUI.DomHelper.append(bindingsElement.dom, {tag:'tr'}, true); | ||
224 | //MochiKit.Logging.logDebug("--- DirectLoginComponent.render - 10"); | ||
225 | directLoginBindingComponent =new Clipperz.PM.Components.RecordDetail.DirectLoginBindingComponent(directLoginBindingElement, { | ||
226 | mainComponent:this, | ||
227 | directLoginBinding:this.directLogin().bindings()[bindingKey] | ||
228 | }); | ||
229 | //MochiKit.Logging.logDebug("--- DirectLoginComponent.render - 11"); | ||
230 | this._directLoginBindingComponents.push(directLoginBindingComponent); | ||
231 | } catch (e) { | ||
232 | MochiKit.Logging.logError("Error while rendering a DirectLoginBindingComponent - " + e); | ||
233 | } | ||
234 | //MochiKit.Logging.logDebug("--- DirectLoginComponent.render - 12"); | ||
235 | } | ||
236 | //MochiKit.Logging.logDebug("--- DirectLoginComponent.render - 13"); | ||
237 | |||
238 | inputsRequiringAdditionalValues = this.directLogin().inputsRequiringAdditionalValues(); | ||
239 | //MochiKit.Logging.logDebug("--- DirectLoginComponent.render - 13.1"); | ||
240 | for (valueName in inputsRequiringAdditionalValues) { | ||
241 | //- Clipperz.YUI.DomHelper.append(bindingsElement.dom, {tag:'tr', children:[ | ||
242 | //- {tag:'td', html:valueName}, | ||
243 | //- {tag:'td', children:inputsRequiringAdditionalValues[valueName].inputElementConfiguration()} | ||
244 | //- ]}, true) | ||
245 | var directLoginValueElement; | ||
246 | var directLoginValueComponent; | ||
247 | |||
248 | //MochiKit.Logging.logDebug("--- DirectLoginComponent.render - 13.2"); | ||
249 | directLoginValueElement = Clipperz.YUI.DomHelper.append(bindingsElement.dom, {tag:'tr'}, true); | ||
250 | //MochiKit.Logging.logDebug("--- DirectLoginComponent.render - 13.3"); | ||
251 | directLoginValueComponent =new Clipperz.PM.Components.RecordDetail.DirectLoginValueComponent(directLoginValueElement, { | ||
252 | mainComponent:this, | ||
253 | directLoginInputValue:inputsRequiringAdditionalValues[valueName] | ||
254 | }); | ||
255 | //MochiKit.Logging.logDebug("--- DirectLoginComponent.render - 13.4"); | ||
256 | this._directLoginBindingComponents.push(directLoginValueComponent); | ||
257 | //MochiKit.Logging.logDebug("--- DirectLoginComponent.render - 13.5"); | ||
258 | } | ||
259 | //MochiKit.Logging.logDebug("--- DirectLoginComponent.render - 13.6"); | ||
260 | } | ||
261 | //MochiKit.Logging.logDebug("--- DirectLoginComponent.render - 14"); | ||
262 | this.setRemoveButton(new YAHOO.ext.Button(this.getDom('removeDirectLoginButton'), {text:Clipperz.PM.Strings['recordDetailDeleteDirectLoginButtonLabel'], handler:this.removeDirectLogin, scope:this})); | ||
263 | //MochiKit.Logging.logDebug("--- DirectLoginComponent.render - 15"); | ||
264 | this.update(); | ||
265 | } catch (e) { | ||
266 | MochiKit.Logging.logError("Error while rendering a DirectLoginComponent - " + e); | ||
267 | } | ||
268 | //MochiKit.Logging.logDebug("<<< DirectLoginComponent.render"); | ||
269 | }, | ||
270 | |||
271 | //------------------------------------------------------------------------- | ||
272 | |||
273 | 'collapser': function() { | ||
274 | return this._collapser; | ||
275 | }, | ||
276 | |||
277 | //------------------------------------------------------------------------- | ||
278 | |||
279 | 'handleLoadedFaviconImage': function(anEvent) { | ||
280 | MochiKit.Signal.disconnectAll(anEvent.src()) | ||
281 | }, | ||
282 | |||
283 | //------------------------------------------------------------------------- | ||
284 | |||
285 | 'update': function() { | ||
286 | var i,c; | ||
287 | var bindingComponents; | ||
288 | |||
289 | //MochiKit.Logging.logDebug(">>> DirectLoginComponent.update"); | ||
290 | bindingComponents = this.directLoginBindingComponents(); | ||
291 | c = bindingComponents.length; | ||
292 | for (i=0; i<c; i++) { | ||
293 | bindingComponents[i].update(); | ||
294 | } | ||
295 | |||
296 | Clipperz.PM.Components.RecordDetail.DirectLoginComponent.superclass.update.call(this); | ||
297 | //MochiKit.Logging.logDebug("<<< DirectLoginComponent.update"); | ||
298 | }, | ||
299 | |||
300 | //------------------------------------------------------------------------- | ||
301 | |||
302 | 'updateEditMode': function() { | ||
303 | // this.element().update(""); | ||
304 | // Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'div', style:'border:4px solid red; padding:10px;', children:[ | ||
305 | // {tag:'div', style:'font-weight:bold;', html:this.directLogin().label()}, | ||
306 | // {tag:'div', style:'border:1px solid #aaaaaa;', html:Clipperz.Base.serializeJSON(this.directLogin().formData())}, | ||
307 | // {tag:'div', style:'border:1px solid #aaaaaa;', html:Clipperz.Base.serializeJSON(this.directLogin().bindings())} | ||
308 | // ]}); | ||
309 | |||
310 | this.getElement('titleEditBox').show(); | ||
311 | this.getElement('titleViewBox').hide(); | ||
312 | |||
313 | this.getDom('titleInput').value = this.directLogin().label(); | ||
314 | |||
315 | //MochiKit.Logging.logDebug(">>> DirectLoginComponent.updateEditMode"); | ||
316 | this.collapser().expand(); | ||
317 | this.getElement('collapseLink').hide(); | ||
318 | this.getElement('removeDirectLogin').show(); | ||
319 | // this.removeButton().show(); | ||
320 | //MochiKit.Logging.logDebug("<<< DirectLoginComponent.updateEditMode"); | ||
321 | }, | ||
322 | |||
323 | //------------------------------------------------------------------------- | ||
324 | |||
325 | 'updateViewMode': function() { | ||
326 | //MochiKit.Logging.logDebug(">>> DirectLoginComponent.updateViewMode"); | ||
327 | this.getElement('titleEditBox').hide(); | ||
328 | this.getElement('titleViewBox').show(); | ||
329 | this.getElement('titleLink').update(this.directLogin().label()); | ||
330 | |||
331 | this.getElement('collapseLink').show(); | ||
332 | this.getElement('removeDirectLogin').hide(); | ||
333 | // this.removeButton().hide(); | ||
334 | //MochiKit.Logging.logDebug("<<< DirectLoginComponent.updateViewMode"); | ||
335 | }, | ||
336 | |||
337 | //------------------------------------------------------------------------- | ||
338 | |||
339 | 'synchronizeComponentValues': function() { | ||
340 | //MochiKit.Logging.logDebug(">>> DirectLoginComponent.syncronizeComponentValues"); | ||
341 | this.directLogin().setLabel(this.getDom('titleInput').value); | ||
342 | // this.setFormDataValue(this.structureElement().value()); | ||
343 | |||
344 | MochiKit.Iter.forEach(this.directLoginBindingComponents(), MochiKit.Base.methodcaller('synchronizeComponentValues')); | ||
345 | //MochiKit.Logging.logDebug("<<< DirectLoginComponent.syncronizeComponentValues"); | ||
346 | }, | ||
347 | |||
348 | //------------------------------------------------------------------------- | ||
349 | |||
350 | 'runDirectLogin': function(anEvent) { | ||
351 | //MochiKit.Logging.logDebug("--- DirectLoginComponent.runDirectLogin - 1"); | ||
352 | //MochiKit.Logging.logDebug("--- DirectLoginComponent.runDirectLogin - 1 anEvent: " + anEvent); | ||
353 | anEvent.stop(); | ||
354 | //MochiKit.Logging.logDebug("--- DirectLoginComponent.runDirectLogin - 2"); | ||
355 | this.directLogin().runDirectLogin(); | ||
356 | //MochiKit.Logging.logDebug("--- DirectLoginComponent.runDirectLogin - 3"); | ||
357 | }, | ||
358 | |||
359 | //------------------------------------------------------------------------- | ||
360 | __syntaxFix__: "syntax fix" | ||
361 | }); | ||
362 | |||
diff --git a/frontend/beta/js/Clipperz/PM/Components/RecordDetail/DirectLoginValueComponent.js b/frontend/beta/js/Clipperz/PM/Components/RecordDetail/DirectLoginValueComponent.js new file mode 100644 index 0000000..e70229b --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/RecordDetail/DirectLoginValueComponent.js | |||
@@ -0,0 +1,257 @@ | |||
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 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | ||
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | ||
31 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } | ||
32 | if (typeof(Clipperz.PM.Components.RecordDetail) == 'undefined') { Clipperz.PM.Components.RecordDetail = {}; } | ||
33 | |||
34 | //############################################################################# | ||
35 | |||
36 | Clipperz.PM.Components.RecordDetail.DirectLoginValueComponent = function(anElement, args) { | ||
37 | //MochiKit.Logging.logDebug(">>> new DirectLoginValueComponent"); | ||
38 | args = args || {}; | ||
39 | |||
40 | Clipperz.PM.Components.RecordDetail.DirectLoginValueComponent.superclass.constructor.call(this, anElement, args); | ||
41 | |||
42 | this._directLoginInputValue = args.directLoginInputValue || null; | ||
43 | this._value = this.directLoginInputValue().directLogin().formValues()[this.directLoginInputValue().name()]; | ||
44 | |||
45 | this.render(); | ||
46 | //MochiKit.Logging.logDebug("<<< new DirectLoginValueComponent - record: " + this.record()); | ||
47 | |||
48 | return this; | ||
49 | } | ||
50 | |||
51 | //============================================================================= | ||
52 | |||
53 | YAHOO.extendX(Clipperz.PM.Components.RecordDetail.DirectLoginValueComponent, Clipperz.PM.Components.RecordDetail.AbstractComponent, { | ||
54 | |||
55 | 'toString': function() { | ||
56 | return "Clipperz.PM.Components.RecordDetail.DirectLoginValueComponent component - " + this.directLoginInputValue().name(); | ||
57 | }, | ||
58 | |||
59 | //------------------------------------------------------------------------- | ||
60 | |||
61 | 'directLoginInputValue': function() { | ||
62 | return this._directLoginInputValue; | ||
63 | }, | ||
64 | |||
65 | //------------------------------------------------------------------------- | ||
66 | |||
67 | 'render': function() { | ||
68 | //MochiKit.Logging.logDebug(">>> DirectLoginValueComponent.render"); | ||
69 | Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'td', cls:'directLoginDataLabelTD', children:[ | ||
70 | {tag:'span', html:this.directLoginInputValue().name()} | ||
71 | ]}); | ||
72 | //MochiKit.Logging.logDebug("--- DirectLoginValueComponent.render - 1"); | ||
73 | Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'td', cls:'directLoginDataValueTD', children:[ | ||
74 | {tag:'span', id:this.getId('inputElement')} | ||
75 | ]}); | ||
76 | //MochiKit.Logging.logDebug("--- DirectLoginValueComponent.render - 2"); | ||
77 | this.update(); | ||
78 | //MochiKit.Logging.logDebug("<<< DirectLoginValueComponent.render"); | ||
79 | }, | ||
80 | |||
81 | //------------------------------------------------------------------------- | ||
82 | |||
83 | 'inputElementConfiguration': function() { | ||
84 | var result; | ||
85 | var currentValue; | ||
86 | |||
87 | //MochiKit.Logging.logDebug(">>> DirectLoginValueComponent.inputElementConfiguration - " + this.directLoginInputValue().name()); | ||
88 | result = []; | ||
89 | currentValue = this.value(); | ||
90 | |||
91 | switch (this.directLoginInputValue().type()) { | ||
92 | case 'checkbox': | ||
93 | var checkbox; | ||
94 | //{"type":"checkbox", "name":"rememberUsernameChk", "value":"checkbox"} | ||
95 | checkbox = {tag:'input', id:this.getId('checkbox'), type:'checkbox'} | ||
96 | if (currentValue == true) { | ||
97 | checkbox.checked = true; | ||
98 | } | ||
99 | result.push(checkbox); | ||
100 | break; | ||
101 | |||
102 | case 'select': | ||
103 | var input; | ||
104 | //{"type":"select", "name":"DOMAIN", "options":[{"selected":true, "label":"@tin.it", "value":"tin.it"}, {"selected":false, "label":"@virgilio.it", "value":"virgilio.it"}]} | ||
105 | input = {tag:'select', id:this.getId('select'), name:this.directLoginInputValue().name(), children:[]}; | ||
106 | input.children.push({tag:'option', value:null, html:"---"}); | ||
107 | MochiKit.Iter.forEach(this.directLoginInputValue().args()['options'], function(anOption) { | ||
108 | var option; | ||
109 | |||
110 | //TODO: remove the value: field and replace it with element.dom.value = <some value> | ||
111 | option = {tag:'option', value:anOption['value'], html:anOption['label']} | ||
112 | if (currentValue == anOption['value']) { | ||
113 | option.selected = true; | ||
114 | } | ||
115 | input.children.push(option); | ||
116 | }) | ||
117 | result.push(input); | ||
118 | break; | ||
119 | |||
120 | case 'radio': | ||
121 | var name; | ||
122 | var radioBox; | ||
123 | |||
124 | //MochiKit.Logging.logDebug("--- DirectLoginValueComponent.inputElementConfiguration - 3"); | ||
125 | name = this.getId(this.directLoginInputValue().name()); | ||
126 | radioBox = {tag:'div', id:this.getId('radioBox'), children:[]}; | ||
127 | result.push(radioBox); | ||
128 | //MochiKit.Logging.logDebug("--- DirectLoginValueComponent.inputElementConfiguration - 3.1 - options.length: " + this.directLoginInputValue().args()['options'].length); | ||
129 | //{"name":"dominio", "type":"radio", "options":[{"value":"@alice.it", "checked":true}, {"value":"@tin.it", "checked":false}, {"value":"@virgilio.it", "checked":false}, {"value":"@tim.it", "checked":false}]} | ||
130 | |||
131 | MochiKit.Iter.forEach(this.directLoginInputValue().args()['options'], function(anOption) { | ||
132 | varradio; | ||
133 | |||
134 | //MochiKit.Logging.logDebug("--- DirectLoginValueComponent.inputElementConfiguration - 3.1.1"); | ||
135 | //TODO: remove the value: field and replace it with element.dom.value = <some value> | ||
136 | radio = {tag:'input', type:'radio', name:name, value:anOption['value']}; | ||
137 | //MochiKit.Logging.logDebug("--- DirectLoginValueComponent.inputElementConfiguration - 3.1.2"); | ||
138 | if (currentValue == anOption['value']) { | ||
139 | //MochiKit.Logging.logDebug("--- DirectLoginValueComponent.inputElementConfiguration - 3.1.3"); | ||
140 | radio.checked = true; | ||
141 | //MochiKit.Logging.logDebug("--- DirectLoginValueComponent.inputElementConfiguration - 3.1.4"); | ||
142 | } | ||
143 | //MochiKit.Logging.logDebug("--- DirectLoginValueComponent.inputElementConfiguration - 3.1.5"); | ||
144 | radioBox.children.push({tag:'div', children:[ radio, {tag:'span', html:anOption['value']} ]}) | ||
145 | //MochiKit.Logging.logDebug("--- DirectLoginValueComponent.inputElementConfiguration - 3.1.6"); | ||
146 | }) | ||
147 | //MochiKit.Logging.logDebug("--- DirectLoginValueComponent.inputElementConfiguration - 3.2"); | ||
148 | break; | ||
149 | } | ||
150 | //MochiKit.Logging.logDebug("<<< DirectLoginValueComponent.inputElementConfiguration"); | ||
151 | |||
152 | return result; | ||
153 | }, | ||
154 | |||
155 | //------------------------------------------------------------------------- | ||
156 | |||
157 | 'inputValue': function() { | ||
158 | var result; | ||
159 | |||
160 | switch (this.directLoginInputValue().type()) { | ||
161 | case 'checkbox': | ||
162 | result = this.getDom('checkbox').checked; | ||
163 | break; | ||
164 | case 'select': | ||
165 | result = this.getDom('select').value; | ||
166 | break; | ||
167 | case 'radio': | ||
168 | var checkedRadioButtons; | ||
169 | |||
170 | checkedRadioButtons = MochiKit.Base.filter(function(aRadioButton) { return aRadioButton.dom.checked }, | ||
171 | this.getElement('radioBox').getChildrenByTagName('input')); | ||
172 | |||
173 | if (checkedRadioButtons.length == 0) { | ||
174 | result = null; | ||
175 | } else { | ||
176 | result = checkedRadioButtons[0].dom.value; | ||
177 | } | ||
178 | break; | ||
179 | } | ||
180 | |||
181 | return result; | ||
182 | }, | ||
183 | |||
184 | //------------------------------------------------------------------------- | ||
185 | |||
186 | 'value': function() { | ||
187 | return this._value; | ||
188 | }, | ||
189 | |||
190 | 'setValue': function(aValue) { | ||
191 | this._value = aValue; | ||
192 | }, | ||
193 | |||
194 | //------------------------------------------------------------------------- | ||
195 | |||
196 | 'updateEditMode': function() { | ||
197 | //MochiKit.Logging.logDebug(">>> DirectLoginValueComponent.updateEditMode - " + this); | ||
198 | this.getElement('inputElement').update(""); | ||
199 | //MochiKit.Logging.logDebug("--- DirectLoginValueComponent.updateEditMode - 1"); | ||
200 | Clipperz.YUI.DomHelper.append(this.getDom('inputElement'), {tag:'div', children:this.inputElementConfiguration()}); | ||
201 | //MochiKit.Logging.logDebug("<<< DirectLoginValueComponent.updateEditMode"); | ||
202 | }, | ||
203 | |||
204 | //------------------------------------------------------------------------- | ||
205 | |||
206 | 'updateViewMode': function() { | ||
207 | //MochiKit.Logging.logDebug(">>> DirectLoginValueComponent.updateViewMode"); | ||
208 | // this.getElement('inputElement').update(this.directLoginInputValue().value()); | ||
209 | |||
210 | this.getElement('inputElement').update(""); | ||
211 | |||
212 | switch (this.directLoginInputValue().type()) { | ||
213 | case 'checkbox': | ||
214 | if (this.value() == true) { | ||
215 | this.getElement('inputElement').update(Clipperz.PM.Strings['directLoginConfigurationCheckBoxFieldSelectedValue']); | ||
216 | } else { | ||
217 | this.getElement('inputElement').update(Clipperz.PM.Strings['directLoginConfigurationCheckBoxFieldNotSelectedValue']) | ||
218 | } | ||
219 | break; | ||
220 | case 'select': | ||
221 | var displayedValue; | ||
222 | var selectedOptions; | ||
223 | var currentValue; | ||
224 | |||
225 | currentValue = this.value(); | ||
226 | selectedOptions = MochiKit.Base.filter(function(anOption) { return (anOption['value'] == currentValue); }, | ||
227 | this.directLoginInputValue().args()['options']); | ||
228 | if (selectedOptions.length == 0) { | ||
229 | displayedValue = "---"; | ||
230 | } else { | ||
231 | //MochiKit.Logging.logDebug("+++ " + Clipperz.Base.serializeJSON(selectedOptions)); | ||
232 | //MochiKit.Logging.logDebug("*** " + Clipperz.Base.serializeJSON(selectedOptions[0])); | ||
233 | displayedValue = selectedOptions[0]['label']; | ||
234 | } | ||
235 | this.getElement('inputElement').update(displayedValue); | ||
236 | break; | ||
237 | case 'radio': | ||
238 | this.getElement('inputElement').update(this.value()); | ||
239 | break; | ||
240 | } | ||
241 | //MochiKit.Logging.logDebug("<<< DirectLoginValueComponent.updateViewMode"); | ||
242 | }, | ||
243 | |||
244 | //------------------------------------------------------------------------- | ||
245 | |||
246 | 'synchronizeComponentValues': function() { | ||
247 | //MochiKit.Logging.logDebug(">>> DirectLoginValueComponent.synchronizeComponentValues"); | ||
248 | //MochiKit.Logging.logDebug("--- DirectLoginValueComponent.synchronizeComponentValues - 1; value: " + this.inputValue()); | ||
249 | this.setValue(this.inputValue()); | ||
250 | this.directLoginInputValue().directLogin().formValues()[this.directLoginInputValue().name()] = this.value(); | ||
251 | //MochiKit.Logging.logDebug("<<< DirectLoginValueComponent.synchronizeComponentValues"); | ||
252 | }, | ||
253 | |||
254 | //------------------------------------------------------------------------- | ||
255 | __syntaxFix__: "syntax fix" | ||
256 | }); | ||
257 | |||
diff --git a/frontend/beta/js/Clipperz/PM/Components/RecordDetail/DirectLoginsComponent.js b/frontend/beta/js/Clipperz/PM/Components/RecordDetail/DirectLoginsComponent.js new file mode 100644 index 0000000..3292a95 --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/RecordDetail/DirectLoginsComponent.js | |||
@@ -0,0 +1,199 @@ | |||
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 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | ||
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | ||
31 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } | ||
32 | if (typeof(Clipperz.PM.Components.RecordDetail) == 'undefined') { Clipperz.PM.Components.RecordDetail = {}; } | ||
33 | |||
34 | //############################################################################# | ||
35 | |||
36 | Clipperz.PM.Components.RecordDetail.DirectLoginsComponent = function(anElement, args) { | ||
37 | //MochiKit.Logging.logDebug(">>> new Clipperz.PM.Components.RecordDetail.DirectLoginsComponent"); | ||
38 | args = args || {}; | ||
39 | |||
40 | //MochiKit.Logging.logDebug("--- new Clipperz.PM.Components.RecordDetail.DirectLoginsComponent - 0"); | ||
41 | Clipperz.PM.Components.RecordDetail.DirectLoginsComponent.superclass.constructor.call(this, anElement, args); | ||
42 | //MochiKit.Logging.logDebug("--- new Clipperz.PM.Components.RecordDetail.DirectLoginsComponent - 1"); | ||
43 | |||
44 | this._addDirectLoginButton = null; | ||
45 | |||
46 | //MochiKit.Logging.logDebug("--- new Clipperz.PM.Components.RecordDetail.DirectLoginsComponent - 2"); | ||
47 | this.mainComponent().addEditComponent(this); | ||
48 | //MochiKit.Logging.logDebug("--- new Clipperz.PM.Components.RecordDetail.DirectLoginsComponent - 3"); | ||
49 | this.render(); | ||
50 | //MochiKit.Logging.logDebug("<<< new Clipperz.PM.Components.RecordDetail.DirectLoginsComponent"); | ||
51 | |||
52 | return this; | ||
53 | } | ||
54 | |||
55 | //============================================================================= | ||
56 | |||
57 | YAHOO.extendX(Clipperz.PM.Components.RecordDetail.DirectLoginsComponent, Clipperz.PM.Components.RecordDetail.AbstractComponent, { | ||
58 | |||
59 | 'toString': function() { | ||
60 | return "Clipperz.PM.Components.RecordDetail.DirectLoginsComponent component"; | ||
61 | }, | ||
62 | |||
63 | //------------------------------------------------------------------------- | ||
64 | |||
65 | 'addDirectLoginButton': function() { | ||
66 | return this._addDirectLoginButton; | ||
67 | }, | ||
68 | |||
69 | 'setAddDirectLoginButton': function(aValue) { | ||
70 | this._addDirectLoginButton = aValue; | ||
71 | }, | ||
72 | |||
73 | //------------------------------------------------------------------------- | ||
74 | |||
75 | 'render': function() { | ||
76 | this.element().update(""); | ||
77 | |||
78 | Clipperz.YUI.DomHelper.append(this.element().dom, | ||
79 | {tag:'div', cls:'directLoginsRecordBox', children:[ | ||
80 | {tag:'h3', htmlString:Clipperz.PM.Strings['recordDetailDirectLoginBlockTitle']}, | ||
81 | {tag:'ul', id:this.getId('directLogins')}, | ||
82 | |||
83 | {tag:'div', cls:'addDirectLoginBox', id:this.getId('addDirectLogin'), children:[ | ||
84 | {tag:'div', cls:'addDirectLoginBoxContent', children:[ | ||
85 | {tag:'div', cls:'bookmarkletConfiguration', children:[ | ||
86 | // {tag:'span', htmlString:Clipperz.PM.Strings['newRecordWizardBookmarkletConfigurationLabel']}, | ||
87 | {tag:'div', htmlString:Clipperz.PM.Strings['recordDetailNewDirectLoginDescription']}, | ||
88 | {tag:'textarea', id:this.getId('addDirectLoginTextarea')} | ||
89 | ]}, | ||
90 | {tag:'div', id:this.getId('addDirectLoginButton')} | ||
91 | ]} | ||
92 | ]} | ||
93 | ]} | ||
94 | ); | ||
95 | |||
96 | if (MochiKit.Base.keys(this.record().directLogins()).length == 0) { | ||
97 | //MochiKit.Logging.logDebug("--- DirectLoginsComponent.render - 3"); | ||
98 | Clipperz.YUI.DomHelper.append(this.getElement('directLogins'), | ||
99 | {tag:'li', children:[ | ||
100 | // {tag:'span', htmlString:Clipperz.PM.Strings['recordDetailDirectLoginBlockNoDirectLoginConfiguredLabel']} | ||
101 | {tag:'div', cls:'recordDetailNoDirectLoginDescriptionBox', htmlString:Clipperz.PM.Strings['recordDetailDirectLoginBlockNoDirectLoginConfiguredDescription']} | ||
102 | ]} | ||
103 | ); | ||
104 | //MochiKit.Logging.logDebug("--- DirectLoginsComponent.render - 4"); | ||
105 | } else { | ||
106 | //MochiKit.Logging.logDebug("--- DirectLoginsComponent.render - 5"); | ||
107 | for (directLoginReference in this.record().directLogins()) { | ||
108 | //MochiKit.Logging.logDebug("--- DirectLoginsComponent.render - 6"); | ||
109 | this.addDirectLogin(this.record().directLogins()[directLoginReference]); | ||
110 | //MochiKit.Logging.logDebug("--- DirectLoginsComponent.render - 7"); | ||
111 | } | ||
112 | //MochiKit.Logging.logDebug("--- DirectLoginsComponent.render - 8"); | ||
113 | } | ||
114 | //MochiKit.Logging.logDebug("--- DirectLoginsComponent.render - 9"); | ||
115 | |||
116 | this.setAddDirectLoginButton(new YAHOO.ext.Button(this.getDom('addDirectLoginButton'), { | ||
117 | text:Clipperz.PM.Strings['recordDetailAddNewDirectLoginButtonLabel'], | ||
118 | handler:this.addNewDirectLogin, | ||
119 | scope:this | ||
120 | })); | ||
121 | MochiKit.Signal.connect(this.getId('addDirectLoginTextarea'), 'onkeydown', this, 'onkeydown'); | ||
122 | //MochiKit.Logging.logDebug("--- DirectLoginsComponent.render - 11"); | ||
123 | |||
124 | this.update(); | ||
125 | //MochiKit.Logging.logDebug("<<< DirectLoginsComponent.render"); | ||
126 | }, | ||
127 | |||
128 | //------------------------------------------------------------------------- | ||
129 | |||
130 | 'addDirectLogin': function(aDirectLogin) { | ||
131 | //MochiKit.Logging.logDebug(">>> DirectLoginsComponent.addDirectLogin"); | ||
132 | new Clipperz.PM.Components.RecordDetail.DirectLoginComponent( | ||
133 | Clipperz.YUI.DomHelper.append(this.getDom('directLogins'), {tag:'div'}, true), | ||
134 | { | ||
135 | mainComponent:this.mainComponent(), | ||
136 | directLogin:aDirectLogin | ||
137 | } | ||
138 | ); | ||
139 | //MochiKit.Logging.logDebug("<<< DirectLoginsComponent.addDirectLogin"); | ||
140 | }, | ||
141 | |||
142 | //------------------------------------------------------------------------- | ||
143 | |||
144 | 'addNewDirectLogin': function() { | ||
145 | varnewDirectLogin; | ||
146 | varconfiguration; | ||
147 | |||
148 | //MochiKit.Logging.logDebug(">>> DirectLoginsComponent.addNewDirectLogin"); | ||
149 | if (MochiKit.Base.keys(this.record().directLogins()).length == 0) { | ||
150 | this.getElement('directLogins').update(""); | ||
151 | } | ||
152 | |||
153 | this.mainComponent().synchronizeComponentValues(); | ||
154 | |||
155 | this.mainComponent().exitModalView(); | ||
156 | configuration = Clipperz.PM.BookmarkletProcessor.checkBookmarkletConfiguration( | ||
157 | this.getDom('addDirectLoginTextarea').value, | ||
158 | this.getDom('addDirectLoginButton'), | ||
159 | MochiKit.Base.method(this.mainComponent(), 'enterModalView') | ||
160 | ); | ||
161 | this.mainComponent().enterModalView(); | ||
162 | |||
163 | newDirectLogin = new Clipperz.PM.DataModel.DirectLogin({record:this.record(), | ||
164 | label:configuration['page']['title'], | ||
165 | bookmarkletVersion:'0.2', | ||
166 | // bookmarkletVersion:configuration['version'], | ||
167 | formData:configuration['form']}); | ||
168 | this.record().addDirectLogin(newDirectLogin); | ||
169 | this.addDirectLogin(newDirectLogin); | ||
170 | this.getDom('addDirectLoginTextarea').value = ""; | ||
171 | //MochiKit.Logging.logDebug("<<< DirectLoginsComponent.addNewDirectLogin"); | ||
172 | }, | ||
173 | |||
174 | //------------------------------------------------------------------------- | ||
175 | |||
176 | 'updateViewMode': function() { | ||
177 | this.getElement('addDirectLogin').setVisibilityMode(YAHOO.ext.Element.DISPLAY); | ||
178 | this.getElement('addDirectLogin').hide(); | ||
179 | }, | ||
180 | |||
181 | //------------------------------------------------------------------------- | ||
182 | |||
183 | 'updateEditMode': function() { | ||
184 | this.getElement('addDirectLogin').show(); | ||
185 | }, | ||
186 | |||
187 | //------------------------------------------------------------------------- | ||
188 | |||
189 | 'onkeydown': function(anEvent) { | ||
190 | //MochiKit.Logging.logDebug(">>> onkeydown - " + anEvent.src().id + ": " + anEvent.key().code); | ||
191 | if (anEvent.key().code == 13) { | ||
192 | this.addNewDirectLogin(); | ||
193 | } | ||
194 | }, | ||
195 | |||
196 | //------------------------------------------------------------------------- | ||
197 | __syntaxFix__: "syntax fix" | ||
198 | }); | ||
199 | |||
diff --git a/frontend/beta/js/Clipperz/PM/Components/RecordDetail/FieldButtonComponent.js b/frontend/beta/js/Clipperz/PM/Components/RecordDetail/FieldButtonComponent.js new file mode 100644 index 0000000..9e1d56a --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/RecordDetail/FieldButtonComponent.js | |||
@@ -0,0 +1,117 @@ | |||
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 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | ||
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | ||
31 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } | ||
32 | if (typeof(Clipperz.PM.Components.RecordDetail) == 'undefined') { Clipperz.PM.Components.RecordDetail = {}; } | ||
33 | |||
34 | //############################################################################# | ||
35 | |||
36 | Clipperz.PM.Components.RecordDetail.FieldButtonComponent = function(anElement, args) { | ||
37 | args = args || {}; | ||
38 | |||
39 | Clipperz.PM.Components.RecordDetail.FieldButtonComponent.superclass.constructor.call(this, anElement, args); | ||
40 | |||
41 | this._button = null; | ||
42 | |||
43 | this.render(); | ||
44 | |||
45 | return this; | ||
46 | } | ||
47 | |||
48 | //============================================================================= | ||
49 | |||
50 | YAHOO.extendX(Clipperz.PM.Components.RecordDetail.FieldButtonComponent, Clipperz.PM.Components.RecordDetail.AbstractFieldSubComponent, { | ||
51 | |||
52 | 'toString': function() { | ||
53 | return "Clipperz.PM.Components.RecordDetail.FieldButtonComponent"; | ||
54 | }, | ||
55 | |||
56 | //------------------------------------------------------------------------- | ||
57 | |||
58 | 'buttonText': function() { | ||
59 | varresult; | ||
60 | |||
61 | if (this.recordField() == null) { | ||
62 | //TODO: this is never used. It is just an obsolete legacy chunk of code | ||
63 | result = Clipperz.PM.Strings['recordDetailAddFieldButtonLabel']; | ||
64 | } else { | ||
65 | result = Clipperz.PM.Strings['recordDetailRemoveFieldButtonLabel']; | ||
66 | } | ||
67 | |||
68 | return result; | ||
69 | }, | ||
70 | |||
71 | //------------------------------------------------------------------------- | ||
72 | |||
73 | 'button': function() { | ||
74 | return this._button; | ||
75 | }, | ||
76 | |||
77 | 'setButton': function(aValue) { | ||
78 | this._button = aValue; | ||
79 | }, | ||
80 | |||
81 | //------------------------------------------------------------------------- | ||
82 | |||
83 | 'render': function() { | ||
84 | this.element().update(""); | ||
85 | |||
86 | Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'div', id:this.getId('button')}) | ||
87 | this.setButton(new YAHOO.ext.Button(this.getDom('button'), {text:this.buttonText(), handler:this.handleButtonClick, scope:this})); | ||
88 | |||
89 | this.update(); | ||
90 | }, | ||
91 | |||
92 | //------------------------------------------------------------------------- | ||
93 | |||
94 | 'handleButtonClick': function() { | ||
95 | if (this.recordField() == null) { | ||
96 | this.mainComponent().addNewField(); | ||
97 | } else { | ||
98 | this.mainComponent().removeField(this.fieldComponent()); | ||
99 | } | ||
100 | }, | ||
101 | |||
102 | //------------------------------------------------------------------------- | ||
103 | |||
104 | 'updateEditMode': function() { | ||
105 | this.button().show(); | ||
106 | }, | ||
107 | |||
108 | //------------------------------------------------------------------------- | ||
109 | |||
110 | 'updateViewMode': function() { | ||
111 | this.button().hide(); | ||
112 | }, | ||
113 | |||
114 | //------------------------------------------------------------------------- | ||
115 | __syntaxFix__: "syntax fix" | ||
116 | }); | ||
117 | |||
diff --git a/frontend/beta/js/Clipperz/PM/Components/RecordDetail/FieldComponent.js b/frontend/beta/js/Clipperz/PM/Components/RecordDetail/FieldComponent.js new file mode 100644 index 0000000..c2d947e --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/RecordDetail/FieldComponent.js | |||
@@ -0,0 +1,189 @@ | |||
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 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | ||
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | ||
31 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } | ||
32 | if (typeof(Clipperz.PM.Components.RecordDetail) == 'undefined') { Clipperz.PM.Components.RecordDetail = {}; } | ||
33 | |||
34 | //############################################################################# | ||
35 | |||
36 | Clipperz.PM.Components.RecordDetail.FieldComponent = function(anElement, args) { | ||
37 | //MochiKit.Logging.logDebug(">>> new FieldComponent"); | ||
38 | args = args || {}; | ||
39 | |||
40 | Clipperz.PM.Components.RecordDetail.FieldComponent.superclass.constructor.call(this, anElement, args); | ||
41 | |||
42 | this._element = anElement; | ||
43 | this._recordField = args.recordField || null; | ||
44 | |||
45 | this._buttonComponent = null; | ||
46 | this._labelComponent = null; | ||
47 | this._dragHandler = null; | ||
48 | this._valueComponent = null; | ||
49 | this._typeComponent = null; | ||
50 | |||
51 | this.mainComponent().addEditComponent(this); | ||
52 | |||
53 | this.render(); | ||
54 | |||
55 | return this; | ||
56 | } | ||
57 | |||
58 | //============================================================================= | ||
59 | |||
60 | YAHOO.extendX(Clipperz.PM.Components.RecordDetail.FieldComponent, Clipperz.PM.Components.RecordDetail.AbstractComponent, { | ||
61 | |||
62 | 'toString': function() { | ||
63 | return "Clipperz.PM.Components.RecordDetail.FieldComponent component"; | ||
64 | }, | ||
65 | |||
66 | //------------------------------------------------------------------------- | ||
67 | |||
68 | 'recordField': function() { | ||
69 | return this._recordField; | ||
70 | }, | ||
71 | |||
72 | //------------------------------------------------------------------------- | ||
73 | |||
74 | 'buttonComponent': function() { | ||
75 | return this._buttonComponent; | ||
76 | }, | ||
77 | |||
78 | 'setButtonComponent': function(aValue) { | ||
79 | this._buttonComponent = aValue; | ||
80 | }, | ||
81 | |||
82 | //------------------------------------------------------------------------- | ||
83 | |||
84 | 'labelComponent': function() { | ||
85 | return this._labelComponent; | ||
86 | }, | ||
87 | |||
88 | 'setLabelComponent': function(aValue) { | ||
89 | this._labelComponent = aValue; | ||
90 | }, | ||
91 | |||
92 | //------------------------------------------------------------------------- | ||
93 | |||
94 | 'dragHandler': function() { | ||
95 | return this._dragHandler; | ||
96 | }, | ||
97 | |||
98 | 'setDragHandler': function(aValue) { | ||
99 | this._dragHandler = aValue; | ||
100 | }, | ||
101 | |||
102 | //------------------------------------------------------------------------- | ||
103 | |||
104 | 'valueComponent': function() { | ||
105 | return this._valueComponent; | ||
106 | }, | ||
107 | |||
108 | 'setValueComponent': function(aValue) { | ||
109 | this._valueComponent = aValue; | ||
110 | }, | ||
111 | |||
112 | //------------------------------------------------------------------------- | ||
113 | |||
114 | 'typeComponent': function() { | ||
115 | return this._typeComponent; | ||
116 | }, | ||
117 | |||
118 | 'setTypeComponent': function(aValue) { | ||
119 | this._typeComponent = aValue; | ||
120 | }, | ||
121 | |||
122 | //------------------------------------------------------------------------- | ||
123 | |||
124 | 'render': function() { | ||
125 | //MochiKit.Logging.logDebug(">>> RecordDetail.FieldComponent.render"); | ||
126 | Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'td',/* width:'32',*/ height:'24', cls:'removeFieldButton', align:'left', valign:'top', id:this.getId('button')}); | ||
127 | Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'td',/* width:'25%',*/ valign:'top', id:this.getId('label')}); | ||
128 | Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'td',/* width:'3',*/ valign:'top', id:this.getId('dragHandler')}); | ||
129 | Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'td',/* width:'50%',*/ valign:'top', children:[ | ||
130 | {tag:'div', cls:'Clipperz_recordFieldData', id:this.getId('value')} | ||
131 | ]}); | ||
132 | |||
133 | |||
134 | this.setButtonComponent(new Clipperz.PM.Components.RecordDetail.FieldButtonComponent(this.getElement('button'), {fieldComponent:this})); | ||
135 | this.setLabelComponent(new Clipperz.PM.Components.RecordDetail.FieldLabelComponent(this.getElement('label'), {fieldComponent:this})); | ||
136 | this.setDragHandler(new Clipperz.PM.Components.RecordDetail.FieldDragHandler(this.getElement('dragHandler'), {fieldComponent:this})); | ||
137 | this.setValueComponent(new Clipperz.PM.Components.RecordDetail.FieldValueComponent(this.getElement('value'), {fieldComponent:this})); | ||
138 | |||
139 | if (this.editMode() == 'EDIT') { | ||
140 | Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'td',/* width:'60',*/ align:'left', cls:'fieldTypeTD', valign:'top', id:this.getId('type')}); | ||
141 | this.setTypeComponent(new Clipperz.PM.Components.RecordDetail.FieldTypeComponent(this.getElement('type'), {fieldComponent:this})); | ||
142 | } | ||
143 | |||
144 | this.update(); | ||
145 | //MochiKit.Logging.logDebug("<<< RecordDetail.FieldComponent.render"); | ||
146 | }, | ||
147 | |||
148 | //------------------------------------------------------------------------- | ||
149 | |||
150 | 'handleButtonClick': function() { | ||
151 | this.mainComponent().record().removeField(this.recordField()); | ||
152 | |||
153 | // if (this.recordField() == null) { | ||
154 | // this.mainComponent().record().addNewField(); | ||
155 | // } else { | ||
156 | // this.mainComponent().record().removeField(this.recordField()); | ||
157 | // } | ||
158 | }, | ||
159 | |||
160 | //------------------------------------------------------------------------- | ||
161 | |||
162 | 'update': function(anEvent) { | ||
163 | //MochiKit.Logging.logDebug(">>> RecordDetail.FieldComponent.update"); | ||
164 | this.buttonComponent().update(); | ||
165 | this.labelComponent().update(); | ||
166 | this.dragHandler().update(); | ||
167 | this.valueComponent().update(); | ||
168 | if (this.editMode() == 'EDIT') { | ||
169 | this.typeComponent().update(); | ||
170 | } | ||
171 | //MochiKit.Logging.logDebug("<<< RecordDetail.FieldComponent.update"); | ||
172 | }, | ||
173 | |||
174 | //------------------------------------------------------------------------- | ||
175 | |||
176 | 'synchronizeComponentValues': function() { | ||
177 | //MochiKit.Logging.logDebug(">>> FieldComponent.synchronizeComponentValues"); | ||
178 | this.labelComponent().synchronizeComponentValues(); | ||
179 | this.valueComponent().synchronizeComponentValues(); | ||
180 | if (this.editMode() == 'EDIT') { | ||
181 | this.typeComponent().synchronizeComponentValues(); | ||
182 | } | ||
183 | //MochiKit.Logging.logDebug("<<< FieldComponent.synchronizeComponentValues"); | ||
184 | }, | ||
185 | |||
186 | //------------------------------------------------------------------------- | ||
187 | __syntaxFix__: "syntax fix" | ||
188 | }); | ||
189 | |||
diff --git a/frontend/beta/js/Clipperz/PM/Components/RecordDetail/FieldDragHandler.js b/frontend/beta/js/Clipperz/PM/Components/RecordDetail/FieldDragHandler.js new file mode 100644 index 0000000..13a08fc --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/RecordDetail/FieldDragHandler.js | |||
@@ -0,0 +1,59 @@ | |||
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 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | ||
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | ||
31 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } | ||
32 | if (typeof(Clipperz.PM.Components.RecordDetail) == 'undefined') { Clipperz.PM.Components.RecordDetail = {}; } | ||
33 | |||
34 | //############################################################################# | ||
35 | |||
36 | Clipperz.PM.Components.RecordDetail.FieldDragHandler = function(anElement, args) { | ||
37 | args = args || {}; | ||
38 | |||
39 | Clipperz.PM.Components.RecordDetail.FieldDragHandler.superclass.constructor.call(this, anElement, args); | ||
40 | |||
41 | this._element = anElement; | ||
42 | |||
43 | this.render(); | ||
44 | |||
45 | return this; | ||
46 | } | ||
47 | |||
48 | //============================================================================= | ||
49 | |||
50 | YAHOO.extendX(Clipperz.PM.Components.RecordDetail.FieldDragHandler, Clipperz.PM.Components.RecordDetail.AbstractFieldSubComponent, { | ||
51 | |||
52 | 'toString': function() { | ||
53 | return "Clipperz.PM.Components.RecordDetail.FieldDragHandler component"; | ||
54 | }, | ||
55 | |||
56 | //------------------------------------------------------------------------- | ||
57 | __syntaxFix__: "syntax fix" | ||
58 | }); | ||
59 | |||
diff --git a/frontend/beta/js/Clipperz/PM/Components/RecordDetail/FieldLabelComponent.js b/frontend/beta/js/Clipperz/PM/Components/RecordDetail/FieldLabelComponent.js new file mode 100644 index 0000000..3bbcd1d --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/RecordDetail/FieldLabelComponent.js | |||
@@ -0,0 +1,141 @@ | |||
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 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | ||
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | ||
31 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } | ||
32 | if (typeof(Clipperz.PM.Components.RecordDetail) == 'undefined') { Clipperz.PM.Components.RecordDetail = {}; } | ||
33 | |||
34 | //############################################################################# | ||
35 | |||
36 | Clipperz.PM.Components.RecordDetail.FieldLabelComponent = function(anElement, args) { | ||
37 | args = args || {}; | ||
38 | |||
39 | Clipperz.PM.Components.RecordDetail.FieldLabelComponent.superclass.constructor.call(this, anElement, args); | ||
40 | |||
41 | this._inputElement = null; | ||
42 | |||
43 | this.render(); | ||
44 | |||
45 | return this; | ||
46 | } | ||
47 | |||
48 | //============================================================================= | ||
49 | |||
50 | YAHOO.extendX(Clipperz.PM.Components.RecordDetail.FieldLabelComponent, Clipperz.PM.Components.RecordDetail.AbstractFieldSubComponent, { | ||
51 | |||
52 | 'toString': function() { | ||
53 | return "Clipperz.PM.Components.RecordDetail.FieldLabelComponent component"; | ||
54 | }, | ||
55 | |||
56 | //------------------------------------------------------------------------- | ||
57 | |||
58 | 'value': function() { | ||
59 | return this.recordField().label(); | ||
60 | }, | ||
61 | |||
62 | //------------------------------------------------------------------------- | ||
63 | |||
64 | 'inputElement': function() { | ||
65 | return this._inputElement; | ||
66 | }, | ||
67 | |||
68 | 'setInputElement': function(aValue) { | ||
69 | this._inputElement = aValue; | ||
70 | }, | ||
71 | |||
72 | //------------------------------------------------------------------------- | ||
73 | |||
74 | 'render': function() { | ||
75 | varnewTextFormField; | ||
76 | this.element().update(""); | ||
77 | Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'div', cls:'Clipperz_recordFieldLabel', id:this.getId('label')}); | ||
78 | // Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'div', style:'font-size:8pt;', html:this.recordField().key()}); | ||
79 | |||
80 | // this.setInputElement(new Clipperz.PM.Components.TextFormField(this.getElement('label'), {editMode:this.editMode(), value:this.value()})); | ||
81 | newTextFormField = new Clipperz.PM.Components.TextFormField(this.getElement('label'), {editMode:this.editMode(), value:this.value()}); | ||
82 | // newTextFormField.inputElement().setStyle({border:'3px solid cyan;'}); | ||
83 | newTextFormField.on('change', this.notifyChanges, this, true) | ||
84 | // this.inputElement().on('change', function() {alert("CHANGE");}); | ||
85 | // this.inputElement().getElement('editComponent_input').on('change', function() {alert("CHANGE");}) | ||
86 | // this.inputElement().on('blur', this.notifyChanges, this, true); | ||
87 | |||
88 | this.setInputElement(newTextFormField); | ||
89 | this.update(); | ||
90 | }, | ||
91 | |||
92 | 'notifyChanges': function() { | ||
93 | //MochiKit.Logging.logDebug(">>> FieldLabelComponent.notifyChanges - " + this); | ||
94 | this.synchronizeComponentValues(); | ||
95 | Clipperz.NotificationCenter.notify(this.recordField().recordVersion().record(), 'updatedFieldLabel'); | ||
96 | //MochiKit.Logging.logDebug("<<< FieldLabelComponent.notifyChanges"); | ||
97 | }, | ||
98 | |||
99 | //------------------------------------------------------------------------- | ||
100 | |||
101 | 'update': function() { | ||
102 | //MochiKit.Logging.logDebug(">>> FieldLabelComponent.update"); | ||
103 | this.inputElement().update({editMode:this.editMode(), value:this.value()}); | ||
104 | //MochiKit.Logging.logDebug("<<< FieldLabelComponent.update"); | ||
105 | }, | ||
106 | |||
107 | //------------------------------------------------------------------------- | ||
108 | /* | ||
109 | 'updateViewMode': function() { | ||
110 | varwidth; | ||
111 | varelement; | ||
112 | |||
113 | this.element().update(""); | ||
114 | width = this.element().getWidth(); | ||
115 | element = Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'div', html:this.value()}, true); | ||
116 | element.setWidth(width-1); | ||
117 | }, | ||
118 | |||
119 | //------------------------------------------------------------------------- | ||
120 | |||
121 | 'updateEditMode': function() { | ||
122 | varwidth; | ||
123 | |||
124 | this.element().update(""); | ||
125 | width = this.element().getWidth(true); | ||
126 | this.setInputElement(Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'input', type:'text', value:this.value()}, true)); | ||
127 | this.inputElement().setWidth(width-1); | ||
128 | }, | ||
129 | */ | ||
130 | //------------------------------------------------------------------------- | ||
131 | |||
132 | 'synchronizeComponentValues': function() { | ||
133 | if (this.inputElement() != null) { | ||
134 | this.recordField().setLabel(this.inputElement().value()); | ||
135 | } | ||
136 | }, | ||
137 | |||
138 | //------------------------------------------------------------------------- | ||
139 | __syntaxFix__: "syntax fix" | ||
140 | }); | ||
141 | |||
diff --git a/frontend/beta/js/Clipperz/PM/Components/RecordDetail/FieldTypeComponent.js b/frontend/beta/js/Clipperz/PM/Components/RecordDetail/FieldTypeComponent.js new file mode 100644 index 0000000..3bdd093 --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/RecordDetail/FieldTypeComponent.js | |||
@@ -0,0 +1,157 @@ | |||
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 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | ||
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | ||
31 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } | ||
32 | if (typeof(Clipperz.PM.Components.RecordDetail) == 'undefined') { Clipperz.PM.Components.RecordDetail = {}; } | ||
33 | |||
34 | //############################################################################# | ||
35 | |||
36 | Clipperz.PM.Components.RecordDetail.FieldTypeComponent = function(anElement, args) { | ||
37 | args = args || {}; | ||
38 | |||
39 | Clipperz.PM.Components.RecordDetail.FieldTypeComponent.superclass.constructor.call(this, anElement, args); | ||
40 | |||
41 | this._inputElement = null; | ||
42 | |||
43 | this.render(); | ||
44 | |||
45 | return this; | ||
46 | } | ||
47 | |||
48 | //============================================================================= | ||
49 | |||
50 | YAHOO.extendX(Clipperz.PM.Components.RecordDetail.FieldTypeComponent, Clipperz.PM.Components.RecordDetail.AbstractFieldSubComponent, { | ||
51 | |||
52 | 'toString': function() { | ||
53 | return "Clipperz.PM.Components.RecordDetail.FieldTypeComponent component"; | ||
54 | }, | ||
55 | |||
56 | //------------------------------------------------------------------------- | ||
57 | |||
58 | 'inputElement': function() { | ||
59 | return this._inputElement; | ||
60 | }, | ||
61 | |||
62 | 'setInputElement': function(aValue) { | ||
63 | this._inputElement = aValue; | ||
64 | }, | ||
65 | |||
66 | //------------------------------------------------------------------------- | ||
67 | |||
68 | 'value': function() { | ||
69 | return this.recordField().type(); | ||
70 | }, | ||
71 | |||
72 | 'canChangeType': function() { | ||
73 | var value; | ||
74 | var result; | ||
75 | |||
76 | value = this.value(); | ||
77 | result = ((value == 'TXT') || (value == 'PWD') || (value == 'URL') || (value == 'DATE') || (value == 'ADDR')); | ||
78 | |||
79 | return result | ||
80 | }, | ||
81 | |||
82 | //------------------------------------------------------------------------- | ||
83 | |||
84 | 'updateViewMode': function() { | ||
85 | this.element().update(""); | ||
86 | if (this.canChangeType()) { | ||
87 | varwidth; | ||
88 | var element; | ||
89 | |||
90 | width = this.element().getWidth(true); | ||
91 | element = Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'div', html:this.recordField().typeShortDescription()}, true); | ||
92 | element.setWidth(width-1); | ||
93 | } | ||
94 | }, | ||
95 | |||
96 | //------------------------------------------------------------------------- | ||
97 | |||
98 | 'updateEditMode': function() { | ||
99 | this.element().update(""); | ||
100 | |||
101 | if (this.canChangeType()) { | ||
102 | varwidth; | ||
103 | |||
104 | width = this.element().getWidth(true); | ||
105 | this.setInputElement(Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'select', children:[ | ||
106 | {tag:'option', value:'TXT', htmlString:Clipperz.PM.Strings['recordFieldTypologies']['TXT']['shortDescription']}, | ||
107 | {tag:'option', value:'PWD', htmlString:Clipperz.PM.Strings['recordFieldTypologies']['PWD']['shortDescription']}, | ||
108 | {tag:'option', value:'URL', htmlString:Clipperz.PM.Strings['recordFieldTypologies']['URL']['shortDescription']}, | ||
109 | {tag:'option', value:'DATE', htmlString:Clipperz.PM.Strings['recordFieldTypologies']['DATE']['shortDescription']}, | ||
110 | {tag:'option', value:'ADDR', htmlString:Clipperz.PM.Strings['recordFieldTypologies']['ADDR']['shortDescription']} | ||
111 | |||
112 | // {tag:'option', value:'CHECK', html:Clipperz.PM.DataModel.RecordField.TypeDescriptions['CHECK']['shortDescription']}, | ||
113 | // {tag:'option', value:'RADIO', html:Clipperz.PM.DataModel.RecordField.TypeDescriptions['RADIO']['shortDescription']}, | ||
114 | // {tag:'option', value:'CHECK', html:Clipperz.PM.DataModel.RecordField.TypeDescriptions['SELECT']['shortDescription']} | ||
115 | // {tag:'option', value:'NOTE', html:Clipperz.PM.DataModel.RecordField.TypeDescriptions['NOTE']['shortDescription']} | ||
116 | ]}, true)); | ||
117 | this.inputElement().setWidth(width-1); | ||
118 | this.inputElement().addHandler('change', true, this.onChange, this, true); | ||
119 | // this.selectCorrectOption(); | ||
120 | Clipperz.DOM.selectOptionMatchingValue(this.inputElement().dom, this.value()); | ||
121 | } | ||
122 | }, | ||
123 | |||
124 | //------------------------------------------------------------------------- | ||
125 | |||
126 | 'onChange': function() { | ||
127 | this.synchronizeComponentValues(); | ||
128 | this.fieldComponent().valueComponent().handleTypeChange(); | ||
129 | }, | ||
130 | |||
131 | //------------------------------------------------------------------------- | ||
132 | /* | ||
133 | 'selectCorrectOption': function() { | ||
134 | varoptions; | ||
135 | var i,c; | ||
136 | |||
137 | options = this.inputElement().getChildrenByTagName('option'); | ||
138 | c = options.length; | ||
139 | for (i=0; i<c; i++) { | ||
140 | if (options[i].dom.value == this.value()) { | ||
141 | options[i].dom.selected = true; | ||
142 | } | ||
143 | } | ||
144 | }, | ||
145 | */ | ||
146 | //------------------------------------------------------------------------- | ||
147 | |||
148 | 'synchronizeComponentValues': function() { | ||
149 | if (this.inputElement() != null) { | ||
150 | this.recordField().setType(this.inputElement().dom.value); | ||
151 | } | ||
152 | }, | ||
153 | |||
154 | //------------------------------------------------------------------------- | ||
155 | __syntaxFix__: "syntax fix" | ||
156 | }); | ||
157 | |||
diff --git a/frontend/beta/js/Clipperz/PM/Components/RecordDetail/FieldValueComponent.js b/frontend/beta/js/Clipperz/PM/Components/RecordDetail/FieldValueComponent.js new file mode 100644 index 0000000..a30992a --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/RecordDetail/FieldValueComponent.js | |||
@@ -0,0 +1,275 @@ | |||
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 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | ||
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | ||
31 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } | ||
32 | if (typeof(Clipperz.PM.Components.RecordDetail) == 'undefined') { Clipperz.PM.Components.RecordDetail = {}; } | ||
33 | |||
34 | //############################################################################# | ||
35 | |||
36 | Clipperz.PM.Components.RecordDetail.FieldValueComponent = function(anElement, args) { | ||
37 | args = args || {}; | ||
38 | |||
39 | Clipperz.PM.Components.RecordDetail.FieldValueComponent.superclass.constructor.call(this, anElement, args); | ||
40 | |||
41 | this._inputElement = null; | ||
42 | this._scrambledStatus = 'SCRAMBLED'; //'UNSCRAMBLED' | ||
43 | |||
44 | this.render(); | ||
45 | |||
46 | return this; | ||
47 | } | ||
48 | |||
49 | //============================================================================= | ||
50 | |||
51 | YAHOO.extendX(Clipperz.PM.Components.RecordDetail.FieldValueComponent, Clipperz.PM.Components.RecordDetail.AbstractFieldSubComponent, { | ||
52 | |||
53 | 'toString': function() { | ||
54 | return "Clipperz.PM.Components.RecordDetail.FieldValueComponent component"; | ||
55 | }, | ||
56 | |||
57 | //------------------------------------------------------------------------- | ||
58 | |||
59 | 'value': function() { | ||
60 | return this.recordField().value(); | ||
61 | }, | ||
62 | |||
63 | 'setValue': function(aValue) { | ||
64 | this.recordField().setValue(aValue); | ||
65 | }, | ||
66 | |||
67 | //------------------------------------------------------------------------- | ||
68 | |||
69 | 'inputElement': function() { | ||
70 | return this._inputElement; | ||
71 | }, | ||
72 | |||
73 | 'setInputElement': function(aValue) { | ||
74 | this._inputElement = aValue; | ||
75 | }, | ||
76 | |||
77 | //------------------------------------------------------------------------- | ||
78 | |||
79 | 'scrambledStatus': function() { | ||
80 | return this._scrambledStatus; | ||
81 | }, | ||
82 | |||
83 | 'setScrambledStatus': function(aValue) { | ||
84 | this._scrambledStatus = aValue; | ||
85 | }, | ||
86 | |||
87 | //------------------------------------------------------------------------- | ||
88 | |||
89 | 'handleTypeChange': function() { | ||
90 | //MochiKit.Logging.logDebug(">>> handling type change - " + this.recordField().type()); | ||
91 | this.synchronizeComponentValues(); | ||
92 | this.update(); | ||
93 | }, | ||
94 | |||
95 | //------------------------------------------------------------------------- | ||
96 | |||
97 | 'addrUrl': function() { | ||
98 | var result; | ||
99 | |||
100 | result = "http://maps.google.com/maps?q=" + this.value().split(' ').join('+'); | ||
101 | |||
102 | return result; | ||
103 | }, | ||
104 | |||
105 | //------------------------------------------------------------------------- | ||
106 | |||
107 | 'updateViewMode': function() { | ||
108 | var scarmbledStatus; | ||
109 | |||
110 | scrambledStatus = this.scrambledStatus() || 'SCRAMBLED'; | ||
111 | |||
112 | this.element().update(""); | ||
113 | if (this.recordField().hidden() == false) { | ||
114 | switch(this.recordField().type()) { | ||
115 | case 'TXT': | ||
116 | case 'PWD': | ||
117 | Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'span', html:this.value()}); | ||
118 | break; | ||
119 | case 'URL': | ||
120 | varurlLocation; | ||
121 | |||
122 | urlLocation = Clipperz.Base.sanitizeString(this.value()); | ||
123 | if (! (/^(https?|ftp|svn):\/\//.test(urlLocation))) { | ||
124 | urlLocation = 'http://' + urlLocation; | ||
125 | } | ||
126 | Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'a', href:urlLocation, html:this.value(), target:'_blank'}); | ||
127 | break; | ||
128 | case 'DATE': | ||
129 | Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'span', html:this.value()}); | ||
130 | break; | ||
131 | case 'ADDR': | ||
132 | Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'a', href:this.addrUrl(), html:this.value(), target:'_blank'}); | ||
133 | break; | ||
134 | } | ||
135 | } else { | ||
136 | var tableElement; | ||
137 | var tdElement; | ||
138 | var inputElement; | ||
139 | var passwordElementConfiguration; | ||
140 | |||
141 | if (scrambledStatus == 'SCRAMBLED') { | ||
142 | varscrambledInputElement; | ||
143 | |||
144 | if ((Clipperz_IEisBroken === true) && (Clipperz.PM.Proxy.defaultProxy.isReadOnly())) { | ||
145 | scrambledInputElement = {tag:'input', type:'password', value:"this.value()"}; | ||
146 | } else { | ||
147 | scrambledInputElement = {tag:'input', type:'text', cls:'scrambledField', title:Clipperz.PM.Strings['recordDetailPasswordFieldTooltipLabel'], value:"this.value()"}; | ||
148 | } | ||
149 | |||
150 | passwordElementConfiguration = | ||
151 | {tag:'table', border:'0', cellspacing:'2', cellpadding:'0', children:[ | ||
152 | {tag:'tbody', children:[ | ||
153 | {tag:'tr', children:[ | ||
154 | {tag:'td', valign:'top', children:[ | ||
155 | scrambledInputElement, | ||
156 | {tag:'a', cls:'scrambleLink', id:this.getId('scrambleLink'), href:'#', htmlString:Clipperz.PM.Strings['recordDetailPasswordFieldUnscrambleLabel']} | ||
157 | ]}, | ||
158 | {tag:'td', valign:'top', children:[ | ||
159 | {tag:'span', cls:'scrambledFieldLabel', htmlString:Clipperz.PM.Strings['recordDetailPasswordFieldHelpLabel']} | ||
160 | ]} | ||
161 | ]} | ||
162 | ]} | ||
163 | ]}; | ||
164 | } else { | ||
165 | passwordElementConfiguration = | ||
166 | {tag:'div', children:[ | ||
167 | {tag:'input', type:'text', cls:'unscrambledField', value:"this.value()"}, | ||
168 | {tag:'a', cls:'scrambleLink', id:this.getId('scrambleLink'), href:'#', htmlString:Clipperz.PM.Strings['recordDetailPasswordFieldScrambleLabel']} | ||
169 | ]}; | ||
170 | } | ||
171 | |||
172 | tableElement = Clipperz.YUI.DomHelper.append(this.element().dom, passwordElementConfiguration, true); | ||
173 | |||
174 | inputElement = tableElement.getChildrenByTagName('input')[0]; | ||
175 | inputElement.dom.value = this.value(); | ||
176 | inputElement.wrap({tag:'div', cls:'passwordBackground'}).setStyle('background-position', "0px -" + Math.min(128, Clipperz.PM.Crypto.passwordEntropy(this.value())) + "px"); | ||
177 | |||
178 | MochiKit.Signal.connect(inputElement.dom, 'onfocus', this, 'selectHiddenFieldOnFocus'); | ||
179 | MochiKit.Signal.connect(this.getDom('scrambleLink'), 'onclick', this, 'toggleScramble'); | ||
180 | } | ||
181 | }, | ||
182 | |||
183 | //------------------------------------------------------------------------- | ||
184 | |||
185 | 'updateEditMode': function() { | ||
186 | var inputElement; | ||
187 | var scarmbledStatus; | ||
188 | |||
189 | scrambledStatus = this.scrambledStatus() || 'SCRAMBLED'; | ||
190 | |||
191 | this.element().update(""); | ||
192 | switch(this.recordField().type()) { | ||
193 | case 'TXT': | ||
194 | case 'URL': | ||
195 | case 'ADDR': | ||
196 | inputElement = Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'input', type:'text', value:"this.value()"}, true); | ||
197 | inputElement.dom.value = this.value(); | ||
198 | break; | ||
199 | case 'PWD': | ||
200 | Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'table', width:'100%', cellpadding:'0', cellspacing:'0', children:[ | ||
201 | {tag:'tbody', children:[ | ||
202 | {tag:'tr', children:[ | ||
203 | {tag:'td', valign:'top', children:[ | ||
204 | {tag:'input', type:((scrambledStatus == 'SCRAMBLED') ? 'password' : 'text'), id:this.getId('passwordInputElement'), value:"this.value()"}, | ||
205 | {tag:'a', cls:'scrambleLink', id:this.getId('scrambleLink'), href:'#', html:(scrambledStatus == 'SCRAMBLED' ? Clipperz.PM.Strings['recordDetailPasswordFieldUnscrambleLabel'] : Clipperz.PM.Strings['recordDetailPasswordFieldScrambleLabel'])} | ||
206 | ]}, | ||
207 | {tag:'td', valign:'top', children:[ | ||
208 | {tag:'div', id:this.getId('passwordGenerator'), cls:'Clipperz_PasswordGenerator_button', html:' '} | ||
209 | ]} | ||
210 | ]} | ||
211 | ]} | ||
212 | ]}) | ||
213 | inputElement = this.getElement('passwordInputElement'); | ||
214 | inputElement.dom.value = this.value(); | ||
215 | new Clipperz.PM.Components.PasswordEntropyDisplay(this.getElement('passwordInputElement')); | ||
216 | new Clipperz.PM.Components.PasswordGenerator(this.getElement('passwordGenerator'), this); | ||
217 | MochiKit.Signal.connect(this.getDom('scrambleLink'), 'onclick', this, 'toggleScramble'); | ||
218 | break; | ||
219 | // case 'NOTE': | ||
220 | // inputElement = Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'textarea', rows:'5', html:this.value()}, true); | ||
221 | // break | ||
222 | case 'DATE': | ||
223 | inputElement = Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'input', type:'text', value:"this.value()"}, true); | ||
224 | inputElement.dom.value = this.value(); | ||
225 | break; | ||
226 | } | ||
227 | |||
228 | this.setInputElement(inputElement); | ||
229 | }, | ||
230 | |||
231 | //------------------------------------------------------------------------- | ||
232 | |||
233 | 'synchronizeComponentValues': function() { | ||
234 | //MochiKit.Logging.logDebug(">>> FieldValueComponent.synchronizeComponentValues"); | ||
235 | if (this.inputElement() != null) { | ||
236 | var value; | ||
237 | |||
238 | switch(this.recordField().type()) { | ||
239 | case 'TXT': | ||
240 | case 'URL': | ||
241 | case 'ADDR': | ||
242 | case 'PWD': | ||
243 | case 'DATE': | ||
244 | value = this.inputElement().dom.value; | ||
245 | break; | ||
246 | } | ||
247 | this.setValue(value); | ||
248 | } | ||
249 | //MochiKit.Logging.logDebug("<<< FieldValueComponent.synchronizeComponentValues"); | ||
250 | }, | ||
251 | |||
252 | //------------------------------------------------------------------------- | ||
253 | |||
254 | 'selectHiddenFieldOnFocus': function(anEvent) { | ||
255 | anEvent.src().select(); | ||
256 | }, | ||
257 | |||
258 | //------------------------------------------------------------------------- | ||
259 | |||
260 | 'toggleScramble': function(anEvent) { | ||
261 | this.synchronizeComponentValues(); | ||
262 | |||
263 | if (this.scrambledStatus() == 'SCRAMBLED') { | ||
264 | this.setScrambledStatus('UNSCRAMBLED'); | ||
265 | } else { | ||
266 | this.setScrambledStatus('SCRAMBLED'); | ||
267 | }; | ||
268 | |||
269 | this.update(); | ||
270 | }, | ||
271 | |||
272 | //------------------------------------------------------------------------- | ||
273 | __syntaxFix__: "syntax fix" | ||
274 | }); | ||
275 | |||
diff --git a/frontend/beta/js/Clipperz/PM/Components/RecordDetail/HeaderComponent.js b/frontend/beta/js/Clipperz/PM/Components/RecordDetail/HeaderComponent.js new file mode 100644 index 0000000..7aaca3e --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/RecordDetail/HeaderComponent.js | |||
@@ -0,0 +1,165 @@ | |||
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 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | ||
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | ||
31 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } | ||
32 | if (typeof(Clipperz.PM.Components.RecordDetail) == 'undefined') { Clipperz.PM.Components.RecordDetail = {}; } | ||
33 | |||
34 | //############################################################################# | ||
35 | |||
36 | Clipperz.PM.Components.RecordDetail.HeaderComponent = function(anElement, args) { | ||
37 | args = args || {}; | ||
38 | |||
39 | Clipperz.PM.Components.RecordDetail.HeaderComponent.superclass.constructor.call(this, anElement, args); | ||
40 | this.mainComponent().addEditComponent(this); | ||
41 | |||
42 | this._saveButton = null; | ||
43 | |||
44 | this.render(); | ||
45 | |||
46 | return this; | ||
47 | } | ||
48 | |||
49 | //============================================================================= | ||
50 | |||
51 | YAHOO.extendX(Clipperz.PM.Components.RecordDetail.HeaderComponent, Clipperz.PM.Components.RecordDetail.AbstractComponent, { | ||
52 | |||
53 | 'toString': function() { | ||
54 | return "Clipperz.PM.Components.RecordDetail.HeaderComponent component"; | ||
55 | }, | ||
56 | |||
57 | //------------------------------------------------------------------------- | ||
58 | |||
59 | 'render': function() { | ||
60 | var editButton; | ||
61 | |||
62 | //MochiKit.Logging.logDebug(">>> RecordDetail.HeaderComponent.appendTo"); | ||
63 | Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'div', cls:'recordDetailButtonsBox', children:[ | ||
64 | {tag:'div', id:this.getId('editButtonBox'), children:[ | ||
65 | {tag:'table', cls:'recordDetailButtonsTABLE', border:'0', cellpadding:'0', cellspacing:'0', children:[ | ||
66 | {tag:'tbody', children:[ | ||
67 | {tag:'tr', children:[ | ||
68 | {tag:'td', align:'center', children:[ | ||
69 | {tag:'div', id:this.getId('editButton')} | ||
70 | ]} | ||
71 | ]} | ||
72 | ]} | ||
73 | ]} | ||
74 | ]}, | ||
75 | {tag:'div', id:this.getId('saveCancelButtonBox'), children:[ | ||
76 | {tag:'table', cls:'recordDetailButtonsTABLE', border:'0', cellpadding:'0', cellspacing:'0', children:[ | ||
77 | {tag:'tbody', children:[ | ||
78 | {tag:'tr', children:[ | ||
79 | {tag:'td', width:'49%', align:'right', children:[ | ||
80 | {tag:'div', id:this.getId('saveButton')} | ||
81 | ]}, | ||
82 | {tag:'td', html:' '}, | ||
83 | {tag:'td', width:'49%', align:'left', children:[ | ||
84 | {tag:'div', id:this.getId('cancelButton')} | ||
85 | ]} | ||
86 | ]} | ||
87 | ]} | ||
88 | ]} | ||
89 | ]} | ||
90 | ]}); | ||
91 | |||
92 | this.getElement('editButtonBox').setVisibilityMode(YAHOO.ext.Element.DISPLAY); | ||
93 | this.getElement('saveCancelButtonBox').setVisibilityMode(YAHOO.ext.Element.DISPLAY); | ||
94 | |||
95 | editButton = new YAHOO.ext.Button(this.getDom('editButton'), {text:Clipperz.PM.Strings['recordDetailEditButtonLabel'], handler:this.editButtonHandler, scope:this}); | ||
96 | this.setSaveButton(new YAHOO.ext.Button(this.getDom('saveButton'), {text:Clipperz.PM.Strings['recordDetailSaveButtonLabel'], handler:this.saveButtonHandler, scope:this})); | ||
97 | new YAHOO.ext.Button(this.getDom('cancelButton'), {text:Clipperz.PM.Strings['recordDetailCancelButtonLabel'], handler:this.cancelButtonHandler, scope:this}); | ||
98 | |||
99 | if (Clipperz.PM.Proxy.defaultProxy.isReadOnly()) { | ||
100 | editButton.disable(); | ||
101 | } | ||
102 | |||
103 | this.update(); | ||
104 | //MochiKit.Logging.logDebug("<<< RecordDetail.HeaderComponent.appendTo"); | ||
105 | }, | ||
106 | |||
107 | //------------------------------------------------------------------------- | ||
108 | |||
109 | 'updateViewMode': function() { | ||
110 | //MochiKit.Logging.logDebug(">>> HeaderComponent.updateViewMode"); | ||
111 | this.getElement('editButtonBox').show(); | ||
112 | this.getElement('saveCancelButtonBox').hide(); | ||
113 | //MochiKit.Logging.logDebug("<<< HeaderComponent.updateViewMode"); | ||
114 | }, | ||
115 | |||
116 | //------------------------------------------------------------------------- | ||
117 | |||
118 | 'updateEditMode': function() { | ||
119 | this.getElement('editButtonBox').hide(); | ||
120 | this.getElement('saveCancelButtonBox').show(); | ||
121 | if (this.mainComponent().enableSaveButton() == true) { | ||
122 | //MochiKit.Logging.logDebug("--- HeaderComponent.updateViewMode - ENABLE"); | ||
123 | this.saveButton().enable(); | ||
124 | } else { | ||
125 | this.saveButton().disable(); | ||
126 | } | ||
127 | }, | ||
128 | |||
129 | //------------------------------------------------------------------------- | ||
130 | |||
131 | 'saveButton': function() { | ||
132 | return this._saveButton; | ||
133 | }, | ||
134 | |||
135 | 'setSaveButton': function(aValue) { | ||
136 | this._saveButton = aValue; | ||
137 | }, | ||
138 | |||
139 | //------------------------------------------------------------------------- | ||
140 | |||
141 | 'editButtonHandler': function(anEvent) { | ||
142 | this.mainComponent().setEditMode('EDIT'); | ||
143 | }, | ||
144 | |||
145 | //------------------------------------------------------------------------- | ||
146 | |||
147 | 'saveButtonHandler': function(anEvent) { | ||
148 | //MochiKit.Logging.logDebug(">>> RecordDetail.HeaderComponent.saveButtonHandler"); | ||
149 | this.mainComponent().setEditMode('VIEW', this.getElement('saveButton')); | ||
150 | //MochiKit.Logging.logDebug("<<< RecordDetail.HeaderComponent.saveButtonHandler"); | ||
151 | }, | ||
152 | |||
153 | //------------------------------------------------------------------------- | ||
154 | |||
155 | 'cancelButtonHandler': function(anEvent) { | ||
156 | this.record().cancelChanges(); | ||
157 | //MochiKit.Logging.logDebug("--- HeaderComponent.cancelButtonHandler - " + Clipperz.Base.serializeJSON(this.record().currentDataSnapshot())); | ||
158 | this.mainComponent().setEditMode('VIEW', null, true); | ||
159 | }, | ||
160 | |||
161 | //------------------------------------------------------------------------- | ||
162 | |||
163 | __syntaxFix__: "syntax fix" | ||
164 | }); | ||
165 | |||
diff --git a/frontend/beta/js/Clipperz/PM/Components/RecordDetail/MainComponent.js b/frontend/beta/js/Clipperz/PM/Components/RecordDetail/MainComponent.js new file mode 100644 index 0000000..53bf9c5 --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/RecordDetail/MainComponent.js | |||
@@ -0,0 +1,758 @@ | |||
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 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | ||
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | ||
31 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } | ||
32 | if (typeof(Clipperz.PM.Components.RecordDetail) == 'undefined') { Clipperz.PM.Components.RecordDetail = {}; } | ||
33 | |||
34 | //############################################################################# | ||
35 | |||
36 | Clipperz.PM.Components.RecordDetail.MainComponent = function(anElement, args) { | ||
37 | args = args || {}; | ||
38 | |||
39 | Clipperz.PM.Components.RecordDetail.MainComponent.superclass.constructor.call(this, anElement, args); | ||
40 | |||
41 | //this._element = args.element; | ||
42 | this._user = args.user; | ||
43 | this._editMode = args.editMode || 'VIEW'; //[ 'VIEW' | 'EDIT' ] | ||
44 | this._mainPanel = args.mainPanel; | ||
45 | |||
46 | this._record = null; | ||
47 | this._editComponents = []; | ||
48 | this._addFieldButton = null; | ||
49 | |||
50 | this._enableSaveButton = true; | ||
51 | this._shouldShowLoginInfo = (Clipperz.PM.Proxy.defaultProxy.isReadOnly() ? false : true); | ||
52 | |||
53 | //this._mainLayoutManager = null; | ||
54 | //this._layoutRegion = null; | ||
55 | |||
56 | Clipperz.NotificationCenter.register(null, 'loadingRecordData', this, 'render'); | ||
57 | Clipperz.NotificationCenter.register(null, 'decryptingRecordData', this, 'render'); | ||
58 | Clipperz.NotificationCenter.register(null, 'loadingRecordVersionData', this, 'render'); | ||
59 | Clipperz.NotificationCenter.register(null, 'decryptingRecordVersionData', this, 'render'); | ||
60 | Clipperz.NotificationCenter.register(null, 'setupDone', this, 'render'); | ||
61 | Clipperz.NotificationCenter.register(null, 'switchLanguage', this, 'render'); | ||
62 | |||
63 | this.render(); | ||
64 | |||
65 | return this; | ||
66 | } | ||
67 | |||
68 | //============================================================================= | ||
69 | |||
70 | YAHOO.extendX(Clipperz.PM.Components.RecordDetail.MainComponent, Clipperz.PM.Components.BaseComponent, { | ||
71 | |||
72 | 'toString': function() { | ||
73 | return "Clipperz.PM.Components.RecordDetail.MainComponent component"; | ||
74 | }, | ||
75 | |||
76 | //------------------------------------------------------------------------- | ||
77 | |||
78 | 'editMode': function() { | ||
79 | return this._editMode; | ||
80 | }, | ||
81 | |||
82 | 'setEditMode': function(aValue, aButtonElement, shouldSkipComponentSynchronization) { | ||
83 | //MochiKit.Logging.logDebug(">>> MainComponent.setEditingMode"); | ||
84 | this.scrollToTop(); | ||
85 | |||
86 | if (aValue == 'VIEW') { | ||
87 | if (shouldSkipComponentSynchronization == true) { | ||
88 | this.exitModalView(); | ||
89 | } else { | ||
90 | this.synchronizeComponentValues(); | ||
91 | if (this.record().hasPendingChanges()) { | ||
92 | if (this.record().isBrandNew()) { | ||
93 | this.record().removeEmptyFields(); | ||
94 | } | ||
95 | this.saveCurrentRecordChanges(aButtonElement); | ||
96 | } else { | ||
97 | if (this.record().isBrandNew()) { | ||
98 | this.record().user().removeRecord(this.record()); | ||
99 | } | ||
100 | this.exitModalView(); | ||
101 | } | ||
102 | } | ||
103 | } else if (aValue == 'EDIT') { | ||
104 | this.enterModalView(); | ||
105 | } else { | ||
106 | //???? | ||
107 | } | ||
108 | |||
109 | this._editMode = aValue; | ||
110 | this.render(); | ||
111 | }, | ||
112 | |||
113 | //------------------------------------------------------------------------- | ||
114 | |||
115 | 'user': function() { | ||
116 | return this._user; | ||
117 | }, | ||
118 | |||
119 | //------------------------------------------------------------------------- | ||
120 | |||
121 | 'mainPanel': function() { | ||
122 | return this._mainPanel; | ||
123 | }, | ||
124 | |||
125 | //------------------------------------------------------------------------- | ||
126 | |||
127 | 'render': function() { | ||
128 | //MochiKit.Logging.logDebug(">>> RecordDetail.MainComponent.render"); | ||
129 | this.setEnableSaveButton(true); | ||
130 | this.element().update(""); | ||
131 | |||
132 | if (this.record() == null) { | ||
133 | if (MochiKit.Base.keys(this.user().records()).length == 0) { | ||
134 | this.renderWithNoRecordAtAll(); | ||
135 | } else { | ||
136 | this.renderWithNoSelectedRecord(); | ||
137 | } | ||
138 | } else { | ||
139 | this.renderWithSelectedRecord(); | ||
140 | } | ||
141 | //MochiKit.Logging.logDebug("<<< RecordDetail.MainComponent.render"); | ||
142 | }, | ||
143 | |||
144 | //------------------------------------------------------------------------- | ||
145 | |||
146 | 'renderWithNoRecordAtAll': function() { | ||
147 | //MochiKit.Logging.logDebug(">>> RecordDetail.MainComponent.renderWithNoRecordAtAll"); | ||
148 | Clipperz.YUI.DomHelper.append(this.element().dom, | ||
149 | {tag:'form', cls:'noRecordAtAllFORM', children:[ | ||
150 | {tag:'div', cls:'recordTitleBlock', children:[ | ||
151 | {tag:'h2', id:'recordTitle', htmlString:Clipperz.PM.Strings['recordDetailNoRecordAtAllTitle']} | ||
152 | ]}, | ||
153 | {tag:'table', border:'0', cellspacing:'0', cellpadding:'0', children:[ | ||
154 | {tag:'tbody', children:[ | ||
155 | {tag:'tr', children:[ | ||
156 | {tag:'td', colspan:'5', children:[ | ||
157 | {tag:'div', cls:'recordDetailDescriptionBox', htmlString:Clipperz.PM.Strings['recordDetailNoRecordAtAllDescription']} | ||
158 | ]} | ||
159 | ]} | ||
160 | ]} | ||
161 | ]} | ||
162 | ]} | ||
163 | ); | ||
164 | //MochiKit.Logging.logDebug("<<< RecordDetail.MainComponent.renderWithNoRecordAtAll"); | ||
165 | }, | ||
166 | |||
167 | //------------------------------------------------------------------------- | ||
168 | |||
169 | 'renderWithNoSelectedRecord': function() { | ||
170 | //MochiKit.Logging.logDebug(">>> RecordDetail.MainComponent.renderWithNoSelectedRecord"); | ||
171 | Clipperz.YUI.DomHelper.append(this.element().dom, | ||
172 | {tag:'form', cls:'noRecordSelectedFORM', children:[ | ||
173 | {tag:'div', cls:'recordTitleBlock', children:[ | ||
174 | {tag:'h2', id:'recordTitle', htmlString:Clipperz.PM.Strings['recordDetailNoRecordSelectedTitle']} | ||
175 | ]}, | ||
176 | {tag:'table', border:'0', cellspacing:'0', cellpadding:'0', children:[ | ||
177 | {tag:'tbody', children:[ | ||
178 | {tag:'tr', children:[ | ||
179 | {tag:'td', colspan:'5', children:[ | ||
180 | {tag:'div', cls:'recordDetailDescriptionBox', htmlString:Clipperz.PM.Strings['recordDetailNoRecordSelectedDescription']} | ||
181 | ]} | ||
182 | ]}, | ||
183 | {tag:'tr', colspan:'5', children:[ | ||
184 | {tag:'td', colspan:'5', children:this.loginInfo()} | ||
185 | ]} | ||
186 | ]} | ||
187 | ]} | ||
188 | ]} | ||
189 | ); | ||
190 | //MochiKit.Logging.logDebug("--- RecordDetail.MainComponent.renderWithNoSelectedRecord - 1"); | ||
191 | |||
192 | if (MochiKit.DOM.getElement('fullLoginHistoryLink') != null) { | ||
193 | MochiKit.Signal.connect('fullLoginHistoryLink', 'onclick', this, 'showLoginHistoryPanel'); | ||
194 | } | ||
195 | //MochiKit.Logging.logDebug("--- RecordDetail.MainComponent.renderWithNoSelectedRecord - 2"); | ||
196 | |||
197 | if (MochiKit.DOM.getElement('offlineCopyDownloadWarningLink') != null) { | ||
198 | MochiKit.Signal.connect('offlineCopyDownloadWarningLink', 'onclick', this, 'showDownloadOfflineCopyPanel'); | ||
199 | } | ||
200 | //MochiKit.Logging.logDebug("<<< RecordDetail.MainComponent.renderWithNoSelectedRecord"); | ||
201 | }, | ||
202 | |||
203 | //------------------------------------------------------------------------- | ||
204 | |||
205 | 'renderWithSelectedRecord': function() { | ||
206 | //MochiKit.Logging.logDebug(">>> RecordDetail.MainComponent.renderWithSelectedRecord"); | ||
207 | if (this.record().shouldLoadData() === true) { | ||
208 | // this.renderWithSelectedRecordLoading(); | ||
209 | //MochiKit.Logging.logDebug("--- RecordDetail.MainComponent.renderWithSelectedRecord - 1.1"); | ||
210 | this.renderWhileProcessingWithMessage(Clipperz.PM.Strings['recordDetailLoadingRecordMessage']); | ||
211 | //MochiKit.Logging.logDebug("--- RecordDetail.MainComponent.renderWithSelectedRecord - 1.2"); | ||
212 | } else if (this.record().shouldDecryptData() === true) { | ||
213 | // this.renderWithSelectedRecordDecrypting(); | ||
214 | //MochiKit.Logging.logDebug("--- RecordDetail.MainComponent.renderWithSelectedRecord - 2.1"); | ||
215 | this.renderWhileProcessingWithMessage(Clipperz.PM.Strings['recordDetailDecryptingRecordMessage']); | ||
216 | //MochiKit.Logging.logDebug("--- RecordDetail.MainComponent.renderWithSelectedRecord - 2.2"); | ||
217 | } else if (this.record().currentVersion().shouldLoadData() === true) { | ||
218 | //MochiKit.Logging.logDebug("--- RecordDetail.MainComponent.renderWithSelectedRecord - 3.1"); | ||
219 | this.renderWhileProcessingWithMessage(Clipperz.PM.Strings['recordDetailLoadingRecordVersionMessage']); | ||
220 | //MochiKit.Logging.logDebug("--- RecordDetail.MainComponent.renderWithSelectedRecord - 3.2"); | ||
221 | } else if (this.record().currentVersion().shouldDecryptData() === true) { | ||
222 | // this.renderWithSelectedRecordCurrentVersionDecrypting(); | ||
223 | //MochiKit.Logging.logDebug("--- RecordDetail.MainComponent.renderWithSelectedRecord - 4.1"); | ||
224 | this.renderWhileProcessingWithMessage(Clipperz.PM.Strings['recordDetailDecryptingRecordVersionMessage']); | ||
225 | //MochiKit.Logging.logDebug("--- RecordDetail.MainComponent.renderWithSelectedRecord - 4.2"); | ||
226 | } else { | ||
227 | //MochiKit.Logging.logDebug("--- RecordDetail.MainComponent.renderWithSelectedRecord - 5.1"); | ||
228 | this.renderWithSelectedRecordData(); | ||
229 | //MochiKit.Logging.logDebug("--- RecordDetail.MainComponent.renderWithSelectedRecord - 5.2"); | ||
230 | } | ||
231 | //MochiKit.Logging.logDebug("<<< RecordDetail.MainComponent.renderWithSelectedRecord"); | ||
232 | }, | ||
233 | |||
234 | //......................................................................... | ||
235 | |||
236 | 'renderWhileProcessingWithMessage': function(aMessage) { | ||
237 | //MochiKit.Logging.logDebug(">>> RecordDetail.MainComponent.renderWhileProcessingWithMessage"); | ||
238 | Clipperz.YUI.DomHelper.append(this.element().dom, | ||
239 | {tag:'form', cls:'processingRecordFORM', children:[ | ||
240 | {tag:'div', cls:'recordTitleBlock', children:[ | ||
241 | {tag:'h2', id:'recordTitle', html:this.record().label()} | ||
242 | ]}, | ||
243 | {tag:'table', border:'0', cellspacing:'0', cellpadding:'0', children:[ | ||
244 | {tag:'tbody', children:[ | ||
245 | {tag:'tr', cls:'recordTR', children:[ | ||
246 | {tag:'td', colspan:'5', children:[ | ||
247 | {tag:'div', cls:'recordDetailDescriptionBox', children:[ | ||
248 | {tag:'h5', cls:'recordLoadingMessage', html:aMessage} | ||
249 | ]} | ||
250 | ]} | ||
251 | ]} | ||
252 | ]} | ||
253 | ]} | ||
254 | ]} | ||
255 | ); | ||
256 | //MochiKit.Logging.logDebug("<<< RecordDetail.MainComponent.renderWhileProcessingWithMessage"); | ||
257 | }, | ||
258 | |||
259 | //......................................................................... | ||
260 | /* | ||
261 | 'renderWithSelectedRecordLoading': function() { | ||
262 | Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'div', cls:'', style:'border:1px solid red; padding: 20px;', children:[ | ||
263 | {tag:'div', cls:'Clipprez_RecordDetailTitle', children:[ | ||
264 | {tag:'h3', html:this.record().label()}, | ||
265 | {tag:'h3', html:"loading"} | ||
266 | ]} | ||
267 | ]}); | ||
268 | }, | ||
269 | |||
270 | //......................................................................... | ||
271 | |||
272 | 'renderWithSelectedRecordDecrypting': function() { | ||
273 | Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'div', cls:'', style:'border:1px solid red; padding: 20px;', children:[ | ||
274 | {tag:'div', cls:'Clipprez_RecordDetailTitle', children:[ | ||
275 | {tag:'h3', html:this.record().label()}, | ||
276 | {tag:'h3', html:"decrypting ... "} | ||
277 | ]} | ||
278 | ]}); | ||
279 | }, | ||
280 | |||
281 | //......................................................................... | ||
282 | |||
283 | 'renderWithSelectedRecordCurrentVersionDecrypting': function() { | ||
284 | Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'div', cls:'', style:'border:1px solid red; padding: 20px;', children:[ | ||
285 | {tag:'div', cls:'Clipprez_RecordDetailTitle', children:[ | ||
286 | {tag:'h3', html:this.record().label()}, | ||
287 | {tag:'h3', html:"decrypting version ... "} | ||
288 | ]} | ||
289 | ]}); | ||
290 | }, | ||
291 | */ | ||
292 | //------------------------------------------------------------------------- | ||
293 | |||
294 | 'renderWithErrorMessage': function(anErrorMessage) { | ||
295 | //MochiKit.Logging.logDebug(">>> RecordDetail.MainComponent.renderWithErrorMessage"); | ||
296 | this.element().update(""); | ||
297 | |||
298 | //MochiKit.Logging.logDebug("--- RecordDetail.MainComponent.renderWithErrorMessage - 1"); | ||
299 | Clipperz.YUI.DomHelper.append(this.element().dom, | ||
300 | {tag:'form', cls:'errorMessageFORM', children:[ | ||
301 | {tag:'div', cls:'recordTitleBlock', children:[ | ||
302 | {tag:'h2', id:'recordTitle', html:this.record().label()} | ||
303 | ]}, | ||
304 | {tag:'table', border:'0', cellspacing:'0', cellpadding:'0', children:[ | ||
305 | {tag:'tbody', children:[ | ||
306 | {tag:'tr', cls:'recordTR', children:[ | ||
307 | {tag:'td', colspan:'5', children:[ | ||
308 | {tag:'div', cls:'recordDetailDescriptionBox loadingError', children:[ | ||
309 | {tag:'h5', htmlString:Clipperz.PM.Strings['recordDetailLoadingErrorMessageTitle']}, | ||
310 | {tag:'p', html:anErrorMessage.message} | ||
311 | ]} | ||
312 | ]} | ||
313 | ]} | ||
314 | ]} | ||
315 | ]} | ||
316 | ]} | ||
317 | ); | ||
318 | //MochiKit.Logging.logDebug("<<< RecordDetail.MainComponent.renderWithErrorMessage"); | ||
319 | }, | ||
320 | |||
321 | //------------------------------------------------------------------------- | ||
322 | |||
323 | 'renderWithSelectedRecordData': function() { | ||
324 | varcolumns; | ||
325 | |||
326 | this.resetEditComponents(); | ||
327 | |||
328 | columns = [ | ||
329 | {tag:'td', width:'25', html:' '}, | ||
330 | {tag:'td', width:'25%', htmlString:Clipperz.PM.Strings['recordDetailLabelFieldColumnLabel']}, | ||
331 | {tag:'td', width:'3', html:' '}, | ||
332 | {tag:'td', /*width:'80%',*/ htmlString:Clipperz.PM.Strings['recordDetailDataFieldColumnLabel']} | ||
333 | ]; | ||
334 | |||
335 | if (this.editMode() == 'EDIT') { | ||
336 | columns.push({tag:'td', /*width:'55',*/ htmlString:Clipperz.PM.Strings['recordDetailTypeFieldColumnLabel']}) | ||
337 | } | ||
338 | |||
339 | //MochiKit.Logging.logDebug(">>> RecordDetail.MainComponent.renderWithSelectedRecordData"); | ||
340 | Clipperz.YUI.DomHelper.append(this.element().dom, | ||
341 | {tag:'form', cls:'recordDataFORM', children:[ | ||
342 | {tag:'div', cls:'recordTitleBlock', id:this.getId('title')}, | ||
343 | {tag:'div', id:'recordDetailDataBox', cls:'recordDetailDataBox', children:[ | ||
344 | |||
345 | {tag:'table', width:'100%', border:'0', cellspacing:'0', cellpadding:'0', children:[ | ||
346 | {tag:'tbody', children:[ | ||
347 | {tag:'tr', children:[ | ||
348 | {tag:'td', width:'5', html:" "}, | ||
349 | {tag:'td', children:[ | ||
350 | |||
351 | {tag:'table', cls:'recordDetailDataBoxTABLE', border:'0', cellspacing:'0', cellpadding:'0', children:[ | ||
352 | {tag:'tbody', id:this.getId('tbody'), children:[ | ||
353 | {tag:'tr', /*cls:'recordNoteTR',*/ children:[ | ||
354 | {tag:'td', colspan:'5', id:this.getId('notes')} | ||
355 | ]}, | ||
356 | {tag:'tr', cls:'recordFieldsTR', children:columns /*[ | ||
357 | {tag:'td', width:'25', html:' '}, | ||
358 | {tag:'td', width:'25%', htmlString:Clipperz.PM.Strings['recordDetailLabelFieldColumnLabel']}, | ||
359 | {tag:'td', width:'3', html:' '}, | ||
360 | {tag:'td', / *width:'80%',* / htmlString:Clipperz.PM.Strings['recordDetailDataFieldColumnLabel']}, | ||
361 | {tag:'td', / *width:'55',* / htmlString:Clipperz.PM.Strings['recordDetailTypeFieldColumnLabel']} | ||
362 | ] */} | ||
363 | ]} | ||
364 | ]}, | ||
365 | {tag:'div', cls:'addFieldButton', id:this.getId('addField'), children:[ | ||
366 | {tag:'div', id:this.getId('addFieldButton')} | ||
367 | ]}, | ||
368 | {tag:'div', id:this.getId('directLogins')}, | ||
369 | {tag:'div', id:this.getId('footer')} | ||
370 | |||
371 | ]} | ||
372 | ]} | ||
373 | ]} | ||
374 | ]} | ||
375 | |||
376 | ]} | ||
377 | ]} | ||
378 | ); | ||
379 | |||
380 | //MochiKit.Logging.logDebug("--- RecordDetail.MainComponent.renderWithSelectedRecordData - 1"); | ||
381 | |||
382 | new Clipperz.PM.Components.RecordDetail.TitleComponent(this.getElement('title'), {mainComponent:this}); | ||
383 | //MochiKit.Logging.logDebug("--- RecordDetail.MainComponent.renderWithSelectedRecordData - 2"); | ||
384 | new Clipperz.PM.Components.RecordDetail.NotesComponent(this.getElement('notes'), {mainComponent:this}); | ||
385 | //MochiKit.Logging.logDebug("--- RecordDetail.MainComponent.renderWithSelectedRecordData - 3"); | ||
386 | new Clipperz.PM.Components.RecordDetail.DirectLoginsComponent(this.getElement('directLogins'), {mainComponent:this}); | ||
387 | //MochiKit.Logging.logDebug("--- RecordDetail.MainComponent.renderWithSelectedRecordData - 4"); | ||
388 | new Clipperz.PM.Components.RecordDetail.HeaderComponent(this.getElement('footer'), {mainComponent:this}); | ||
389 | //MochiKit.Logging.logDebug("--- RecordDetail.MainComponent.renderWithSelectedRecordData - 5"); | ||
390 | MochiKit.Iter.forEach(MochiKit.Base.values(this.record().currentVersion().fields()), this.appendFieldComponent, this); | ||
391 | //MochiKit.Logging.logDebug("--- RecordDetail.MainComponent.renderWithSelectedRecordData - 6"); | ||
392 | this.setAddFieldButton(new YAHOO.ext.Button(this.getDom('addFieldButton'), {text:Clipperz.PM.Strings['recordDetailAddFieldButtonLabel'], handler:this.addNewRecordField, scope:this})); | ||
393 | //MochiKit.Logging.logDebug("--- RecordDetail.MainComponent.renderWithSelectedRecordData - 7"); | ||
394 | |||
395 | this.update(); | ||
396 | |||
397 | //MochiKit.Logging.logDebug("<<< RecordDetail.MainComponent.renderWithSelectedRecordData"); | ||
398 | }, | ||
399 | |||
400 | //------------------------------------------------------------------------- | ||
401 | |||
402 | 'editComponents': function() { | ||
403 | return this._editComponents; | ||
404 | }, | ||
405 | |||
406 | 'resetEditComponents': function() { | ||
407 | this._editComponents = []; | ||
408 | }, | ||
409 | |||
410 | 'addEditComponent': function(aValue) { | ||
411 | this.editComponents().push(aValue); | ||
412 | }, | ||
413 | |||
414 | 'removeEditComponent': function(aValue) { | ||
415 | Clipperz.Base.removeFromArray(this.editComponents(), aValue); | ||
416 | }, | ||
417 | |||
418 | //------------------------------------------------------------------------- | ||
419 | |||
420 | 'record': function() { | ||
421 | return this._record; | ||
422 | }, | ||
423 | |||
424 | 'setRecord': function(aValue) { | ||
425 | varresult; | ||
426 | |||
427 | //MochiKit.Logging.logDebug(">>> MainComponent.setRecord") | ||
428 | if (this._record != aValue) { | ||
429 | vardeferredResult; | ||
430 | |||
431 | deferredResult = new MochiKit.Async.Deferred(); | ||
432 | |||
433 | if ((this._record != null) && (this.editMode() == 'EDIT')) { | ||
434 | this.synchronizeComponentValues(); | ||
435 | deferredResult.addCallback(MochiKit.Base.method(this._record, 'saveChanges')); | ||
436 | } | ||
437 | |||
438 | this._record = aValue; | ||
439 | |||
440 | if (aValue != null) { | ||
441 | this.setShouldShowLoginInfo(false); | ||
442 | deferredResult.addCallback(MochiKit.Base.method(this._record, 'deferredData')); | ||
443 | } | ||
444 | deferredResult.addCallbacks( | ||
445 | MochiKit.Base.method(this, 'render'), | ||
446 | MochiKit.Base.method(this, 'renderWithErrorMessage') | ||
447 | ); | ||
448 | deferredResult.callback(); | ||
449 | this.scrollToTop(); | ||
450 | |||
451 | result = deferredResult; | ||
452 | } else { | ||
453 | result = MochiKit.Async.success(); | ||
454 | } | ||
455 | //MochiKit.Logging.logDebug("<<< MainComponent.setRecord") | ||
456 | |||
457 | return result; | ||
458 | }, | ||
459 | |||
460 | //------------------------------------------------------------------------- | ||
461 | |||
462 | 'saveCurrentRecordChanges': function(aButtonElement) { | ||
463 | var deferred; | ||
464 | var currentNumberOfRecords; | ||
465 | |||
466 | deferred = new MochiKit.Async.Deferred(); | ||
467 | deferred.addCallback(MochiKit.Base.method(Clipperz.PM.Components.MessageBox(), 'deferredShow'), | ||
468 | { | ||
469 | title:Clipperz.PM.Strings['recordDetailSavingChangesMessagePanelInitialTitle'], | ||
470 | text:Clipperz.PM.Strings['recordDetailSavingChangesMessagePanelInitialText'], | ||
471 | width:240, | ||
472 | showProgressBar:true, | ||
473 | showCloseButton:false, | ||
474 | steps:6 | ||
475 | }, | ||
476 | aButtonElement.dom | ||
477 | ); | ||
478 | deferred.addCallback(MochiKit.Base.method(this, 'exitModalView')); | ||
479 | deferred.addCallback(MochiKit.Base.method(this.record(), 'saveChanges')); | ||
480 | deferred.addCallback(Clipperz.NotificationCenter.deferredNotification, this.record(), 'recordUpdated'); | ||
481 | deferred.addCallback(function(res) { | ||
482 | Clipperz.PM.Components.MessageBox().hide(YAHOO.ext.Element.get('main')); | ||
483 | return res; | ||
484 | }); | ||
485 | |||
486 | currentNumberOfRecords = MochiKit.Base.keys(this.user().records()).length; | ||
487 | if ((this.record().isBrandNew()) && (this.user().preferences().shouldShowDonationPanel()) && (currentNumberOfRecords >= 5)) { | ||
488 | deferred.addCallback(Clipperz.PM.showDonationSplashScreen, this.user(), 'recordListAddRecordButton'); | ||
489 | } | ||
490 | |||
491 | deferred.callback(); | ||
492 | }, | ||
493 | |||
494 | //------------------------------------------------------------------------- | ||
495 | |||
496 | 'update': function(anEvent) { | ||
497 | if (this.editMode() == 'EDIT') { | ||
498 | this.updateEditMode(); | ||
499 | } else if (this.editMode() == 'VIEW') { | ||
500 | this.updateViewMode(); | ||
501 | } | ||
502 | |||
503 | MochiKit.Iter.forEach(this.editComponents(), MochiKit.Base.methodcaller('update')); | ||
504 | }, | ||
505 | |||
506 | //------------------------------------------------------------------------- | ||
507 | |||
508 | 'updateViewMode': function() { | ||
509 | this.addFieldButton().hide(); | ||
510 | }, | ||
511 | |||
512 | //------------------------------------------------------------------------- | ||
513 | |||
514 | 'updateEditMode': function() { | ||
515 | this.addFieldButton().show(); | ||
516 | }, | ||
517 | |||
518 | //------------------------------------------------------------------------- | ||
519 | |||
520 | 'appendFieldComponent': function(aRecordField) { | ||
521 | //MochiKit.Logging.logDebug(">>> MainComponent.appendFieldComponent"); | ||
522 | new Clipperz.PM.Components.RecordDetail.FieldComponent( | ||
523 | Clipperz.YUI.DomHelper.append(this.getDom('tbody'), {tag:'tr'}, true), | ||
524 | {recordField:aRecordField, mainComponent:this} | ||
525 | ); | ||
526 | //MochiKit.Logging.logDebug("<<< MainComponent.appendFieldComponent"); | ||
527 | }, | ||
528 | |||
529 | //------------------------------------------------------------------------- | ||
530 | |||
531 | 'removeField': function(aFieldComponent) { | ||
532 | varrecordField; | ||
533 | |||
534 | //MochiKit.Logging.logDebug(">>> MainComponent.removeField") | ||
535 | recordField = aFieldComponent.recordField(); | ||
536 | this.removeEditComponent(aFieldComponent); | ||
537 | aFieldComponent.destroy(); | ||
538 | this.record().removeField(recordField); | ||
539 | |||
540 | Clipperz.NotificationCenter.notify(this.record(), 'removedField'); | ||
541 | //MochiKit.Logging.logDebug("<<< MainComponent.removeField") | ||
542 | }, | ||
543 | |||
544 | //------------------------------------------------------------------------- | ||
545 | |||
546 | 'synchronizeComponentValues': function() { | ||
547 | MochiKit.Iter.forEach(this.editComponents(), MochiKit.Base.methodcaller('synchronizeComponentValues')); | ||
548 | }, | ||
549 | |||
550 | //========================================================================= | ||
551 | |||
552 | 'addFieldButton': function() { | ||
553 | return this._addFieldButton; | ||
554 | }, | ||
555 | |||
556 | 'setAddFieldButton': function(aValue) { | ||
557 | this._addFieldButton = aValue; | ||
558 | }, | ||
559 | |||
560 | 'addNewRecordField': function() { | ||
561 | varnewField; | ||
562 | |||
563 | newField = this.record().addNewField(); | ||
564 | this.appendFieldComponent(newField); | ||
565 | |||
566 | Clipperz.NotificationCenter.notify(this.record(), 'addNewRecordField'); | ||
567 | }, | ||
568 | |||
569 | //------------------------------------------------------------------------- | ||
570 | |||
571 | 'enterModalView': function() { | ||
572 | /* | ||
573 | if (this.user().preferences().useSafeEditMode()) { | ||
574 | var headerMaskElement; | ||
575 | var verticalMaskElement; | ||
576 | |||
577 | headerMaskElement = YAHOO.ext.Element.get('recordDetailEditModeHeaderMask'); | ||
578 | headerMaskElement.show().mask(); | ||
579 | |||
580 | verticalMaskElement = YAHOO.ext.Element.get('recordDetailEditModeVerticalMask'); | ||
581 | verticalMaskElement.show().mask(); | ||
582 | } | ||
583 | */ | ||
584 | this.mainPanel().enterModalView(); | ||
585 | }, | ||
586 | |||
587 | //------------------------------------------------------------------------- | ||
588 | |||
589 | 'exitModalView': function() { | ||
590 | /* | ||
591 | if (this.user().preferences().useSafeEditMode()) { | ||
592 | var headerMaskElement; | ||
593 | var verticalMaskElement; | ||
594 | |||
595 | headerMaskElement = YAHOO.ext.Element.get('recordDetailEditModeHeaderMask'); | ||
596 | headerMaskElement.unmask(); | ||
597 | headerMaskElement.hide(); | ||
598 | |||
599 | verticalMaskElement = YAHOO.ext.Element.get('recordDetailEditModeVerticalMask'); | ||
600 | verticalMaskElement.unmask(); | ||
601 | verticalMaskElement.hide(); | ||
602 | } | ||
603 | */ | ||
604 | this.mainPanel().exitModalView(); | ||
605 | }, | ||
606 | |||
607 | //------------------------------------------------------------------------- | ||
608 | |||
609 | 'enableSaveButton': function() { | ||
610 | return this._enableSaveButton; | ||
611 | }, | ||
612 | |||
613 | 'setEnableSaveButton': function(aValue) { | ||
614 | this._enableSaveButton = aValue; | ||
615 | }, | ||
616 | |||
617 | //------------------------------------------------------------------------- | ||
618 | |||
619 | 'scrollToTop': function() { | ||
620 | YAHOO.ext.Element.get('recordTitleTopBlock').scrollIntoView(document.body); | ||
621 | }, | ||
622 | |||
623 | //------------------------------------------------------------------------- | ||
624 | |||
625 | 'loginInfo': function() { | ||
626 | varresult; | ||
627 | |||
628 | if (this.shouldShowLoginInfo() == true) { | ||
629 | // && (typeof(this.user().loginInfo()['latest']) != 'undefined')) { | ||
630 | varimageExtension; | ||
631 | var currentConnectionText; | ||
632 | var currentIP; | ||
633 | var contentChildren; | ||
634 | |||
635 | result = []; | ||
636 | contentChildren = []; | ||
637 | |||
638 | imageExtension = (Clipperz_IEisBroken == true) ? 'gif': 'png'; | ||
639 | |||
640 | contentChildren.push({tag:'h4', valign:'top', htmlString:Clipperz.PM.Strings['WELCOME_BACK']}); | ||
641 | |||
642 | currentIP = (this.user().loginInfo()['current']['ip'].match(/^\d{1,3}(.\d{1,3}){3}$/)) ? this.user().loginInfo()['current']['ip'] : Clipperz.PM.Strings['unknown_ip']; | ||
643 | currentConnectionText = Clipperz.PM.Strings['currentConnectionText']; | ||
644 | currentConnectionText = currentConnectionText.replace(/__ip__/, "<b>" + Clipperz.Base.sanitizeString(this.user().loginInfo()['current']['ip']) + "</b>"); | ||
645 | currentConnectionText = currentConnectionText.replace(/__country__/, "<b>" + Clipperz.PM.Strings['countries'][Clipperz.Base.sanitizeString(this.user().loginInfo()['current']['country'])] + "</b>"); | ||
646 | currentConnectionText = currentConnectionText.replace(/__browser__/, "<b>" + Clipperz.PM.Strings['browsers'][Clipperz.Base.sanitizeString(this.user().loginInfo()['current']['browser'])] + "</b>"); | ||
647 | currentConnectionText = currentConnectionText.replace(/__operatingSystem__/, "<b>" + Clipperz.PM.Strings['operatingSystems'][Clipperz.Base.sanitizeString(this.user().loginInfo()['current']['operatingSystem'])] + "</b>"); | ||
648 | |||
649 | contentChildren.push( | ||
650 | {tag:'div', cls:'loginInfo_now', children:[ | ||
651 | {tag:'div', cls:'text', htmlString:currentConnectionText}, | ||
652 | {tag:'div', cls:'icons', children:[ | ||
653 | {tag:'img', title:Clipperz.PM.Strings['countries'][Clipperz.Base.sanitizeString(this.user().loginInfo()['current']['country'])], cls:'flag', src:Clipperz.PM.Strings['icons_baseUrl'] + "/flags/" + Clipperz.Base.sanitizeString(this.user().loginInfo()['current']['country']).toLowerCase() + "." + imageExtension, width:'32', height:'32'}, | ||
654 | {tag:'img', title:Clipperz.PM.Strings['browsers'][Clipperz.Base.sanitizeString(this.user().loginInfo()['current']['browser'])], src:Clipperz.PM.Strings['icons_baseUrl'] + "/browsers/" + Clipperz.Base.sanitizeString(this.user().loginInfo()['current']['browser']).toLowerCase() + "." + imageExtension, width:'32', height:'32'}, | ||
655 | {tag:'img', title:Clipperz.PM.Strings['operatingSystems'][Clipperz.Base.sanitizeString(this.user().loginInfo()['current']['operatingSystem'])], src:Clipperz.PM.Strings['icons_baseUrl'] + "/operatingSystems/" + Clipperz.Base.sanitizeString(this.user().loginInfo()['current']['operatingSystem']).toLowerCase() + "." + imageExtension, width:'32', height:'32'} | ||
656 | ]} | ||
657 | ]} | ||
658 | ); | ||
659 | |||
660 | if (typeof(this.user().loginInfo()['latest']) != 'undefined') { | ||
661 | var latestLoginDate; | ||
662 | var elapsedTimeDescription; | ||
663 | var latestIP; | ||
664 | var latestConnectionText; | ||
665 | |||
666 | latestLoginDate = Clipperz.PM.Date.parseDateWithUTCFormat(Clipperz.Base.sanitizeString(this.user().loginInfo()['latest']['date'])); | ||
667 | |||
668 | elapsedTimeDescription = Clipperz.PM.Date.getElapsedTimeDescription(latestLoginDate); | ||
669 | latestIP = (this.user().loginInfo()['latest']['ip'].match(/^\d{1,3}(.\d{1,3}){3}$/)) ? this.user().loginInfo()['latest']['ip'] : Clipperz.PM.Strings['unknown_ip']; | ||
670 | |||
671 | latestConnectionText = Clipperz.PM.Strings['latestConnectionText']; | ||
672 | latestConnectionText = latestConnectionText.replace(/__elapsedTimeDescription__/, "<b>" + elapsedTimeDescription + "</b>"); | ||
673 | latestConnectionText = latestConnectionText.replace(/__time__/, Clipperz.PM.Date.formatDateWithTemplate(latestLoginDate, Clipperz.PM.Strings['fullDate_format'])); | ||
674 | latestConnectionText = latestConnectionText.replace(/__ip__/, "<b>" + Clipperz.Base.sanitizeString(this.user().loginInfo()['latest']['ip']) + "</b>"); | ||
675 | latestConnectionText = latestConnectionText.replace(/__country__/, "<b>" + Clipperz.PM.Strings['countries'][Clipperz.Base.sanitizeString(this.user().loginInfo()['latest']['country'])] + "</b>"); | ||
676 | latestConnectionText = latestConnectionText.replace(/__browser__/, "<b>" + Clipperz.PM.Strings['browsers'][Clipperz.Base.sanitizeString(this.user().loginInfo()['latest']['browser'])] + "</b>"); | ||
677 | latestConnectionText = latestConnectionText.replace(/__operatingSystem__/, "<b>" + Clipperz.PM.Strings['operatingSystems'][Clipperz.Base.sanitizeString(this.user().loginInfo()['latest']['operatingSystem'])] + "</b>"); | ||
678 | |||
679 | |||
680 | contentChildren.push( | ||
681 | {tag:'div', cls:'loginInfo_latest', children:[ | ||
682 | {tag:'div', cls:'inner_header', html:' '}, | ||
683 | {tag:'div', cls:'content', children:[ | ||
684 | {tag:'div', cls:'text', htmlString:latestConnectionText}, | ||
685 | {tag:'div', cls:'icons', children:[ | ||
686 | {tag:'img', title:Clipperz.PM.Strings['countries'][Clipperz.Base.sanitizeString(this.user().loginInfo()['latest']['country'])], cls:'flag', src:Clipperz.PM.Strings['icons_baseUrl'] + "/flags/" + Clipperz.Base.sanitizeString(this.user().loginInfo()['latest']['country']).toLowerCase() + "." + imageExtension, width:'32', height:'32'}, | ||
687 | {tag:'img', title:Clipperz.PM.Strings['browsers'][Clipperz.Base.sanitizeString(this.user().loginInfo()['latest']['browser'])], src:Clipperz.PM.Strings['icons_baseUrl'] + "/browsers/" + Clipperz.Base.sanitizeString(this.user().loginInfo()['latest']['browser']).toLowerCase() + "." + imageExtension, width:'32', height:'32'}, | ||
688 | {tag:'img', title:Clipperz.PM.Strings['operatingSystems'][Clipperz.Base.sanitizeString(this.user().loginInfo()['latest']['operatingSystem'])], src:Clipperz.PM.Strings['icons_baseUrl'] + "/operatingSystems/" + Clipperz.Base.sanitizeString(this.user().loginInfo()['latest']['operatingSystem']).toLowerCase() + "." + imageExtension, width:'32', height:'32'} | ||
689 | ]} | ||
690 | ]}, | ||
691 | {tag:'div', children:[ | ||
692 | {tag:'a', href:'#', id:'fullLoginHistoryLink', htmlString:Clipperz.PM.Strings['fullLoginHistoryLinkLabel']} | ||
693 | ]}, | ||
694 | {tag:'div', cls:'inner_footer', html:' '} | ||
695 | ]} | ||
696 | ); | ||
697 | } | ||
698 | |||
699 | contentChildren.push( | ||
700 | {tag:'table', id:'shouldDownloadOfflineCopyWarningBox', children:[ | ||
701 | {tag:'tbody', width:'100%', children:[ | ||
702 | {tag:'tr', children:[ | ||
703 | {tag:'td', cls:'offlineCopyDownloadWarningIconTD', valign:'top', align:'center', width:'50', children:(this.user().shouldDownloadOfflineCopy() ? [{tag:'img', src:Clipperz.PM.Strings['icons_baseUrl'] + "/misc/offlineCopyWarning.png" , width:'32', height:'32'}]: [])}, | ||
704 | {tag:'td', children:[ | ||
705 | {tag:'div', cls:'offlineCopyDownloadWarning', htmlString:(this.user().shouldDownloadOfflineCopy() ? Clipperz.PM.Strings['offlineCopyDownloadWarning']: Clipperz.PM.Strings['offlineCopyDownloadOk'])} | ||
706 | ]} | ||
707 | ]} | ||
708 | ]} | ||
709 | ]} | ||
710 | ); | ||
711 | |||
712 | |||
713 | result = [{tag:'div', id:'loginInfoWrapper', children:[{tag:'div', id:'loginInfo', children:[ | ||
714 | {tag:'div', cls:'header', html:' '}, | ||
715 | {tag:'div', cls:'content', children:contentChildren}, | ||
716 | {tag:'div', cls:'footer', html:' '} | ||
717 | ]}]}]; | ||
718 | |||
719 | // this.setShouldShowLoginInfo(false); | ||
720 | } else { | ||
721 | resut = []; | ||
722 | } | ||
723 | |||
724 | return result; | ||
725 | }, | ||
726 | |||
727 | //------------------------------------------------------------------------- | ||
728 | |||
729 | 'shouldShowLoginInfo': function() { | ||
730 | return this._shouldShowLoginInfo; | ||
731 | }, | ||
732 | |||
733 | 'setShouldShowLoginInfo': function(aValue) { | ||
734 | this._shouldShowLoginInfo = aValue; | ||
735 | }, | ||
736 | |||
737 | //------------------------------------------------------------------------- | ||
738 | |||
739 | 'showLoginHistoryPanel': function(anEvent) { | ||
740 | anEvent.stop(); | ||
741 | |||
742 | Clipperz.NotificationCenter.notify(this, 'selectTab', 'mainTabPanel.accountTab', true); | ||
743 | Clipperz.NotificationCenter.notify(this, 'selectTab', 'accountTabPanel.loginHistoryTab', true); | ||
744 | }, | ||
745 | |||
746 | //------------------------------------------------------------------------- | ||
747 | |||
748 | 'showDownloadOfflineCopyPanel': function(anEvent) { | ||
749 | anEvent.stop(); | ||
750 | |||
751 | Clipperz.NotificationCenter.notify(this, 'selectTab', 'mainTabPanel.dataTab', true); | ||
752 | Clipperz.NotificationCenter.notify(this, 'selectTab', 'dataTabPanel.offlineCopyTab', true); | ||
753 | }, | ||
754 | |||
755 | //------------------------------------------------------------------------- | ||
756 | __syntaxFix__: "syntax fix" | ||
757 | }); | ||
758 | |||
diff --git a/frontend/beta/js/Clipperz/PM/Components/RecordDetail/NotesComponent.js b/frontend/beta/js/Clipperz/PM/Components/RecordDetail/NotesComponent.js new file mode 100644 index 0000000..6f454fc --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/RecordDetail/NotesComponent.js | |||
@@ -0,0 +1,240 @@ | |||
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 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | ||
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | ||
31 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } | ||
32 | if (typeof(Clipperz.PM.Components.RecordDetail) == 'undefined') { Clipperz.PM.Components.RecordDetail = {}; } | ||
33 | |||
34 | //############################################################################# | ||
35 | |||
36 | |||
37 | |||
38 | Clipperz.PM.Components.RecordDetail.NotesComponent = function(anElement, args) { | ||
39 | //MochiKit.Logging.logDebug(">>> new NotesComponent"); | ||
40 | args = args || {}; | ||
41 | |||
42 | Clipperz.PM.Components.RecordDetail.NotesComponent.superclass.constructor.call(this, anElement, args); | ||
43 | |||
44 | this.mainComponent().addEditComponent(this); | ||
45 | |||
46 | this._staticOffset = null; | ||
47 | this._componentHeight = 50; | ||
48 | this._mouseMoveIdentifier = null; | ||
49 | this._mouseUpIdentifier = null; | ||
50 | |||
51 | this.element().setVisibilityMode(YAHOO.ext.Element.DISPLAY); | ||
52 | |||
53 | this.render(); | ||
54 | //MochiKit.Logging.logDebug("<<< new NotesComponent"); | ||
55 | |||
56 | return this; | ||
57 | } | ||
58 | |||
59 | //============================================================================= | ||
60 | |||
61 | YAHOO.extendX(Clipperz.PM.Components.RecordDetail.NotesComponent, Clipperz.PM.Components.RecordDetail.AbstractComponent, { | ||
62 | |||
63 | 'toString': function() { | ||
64 | return "Clipperz.PM.Components.RecordDetail.NotesComponent component"; | ||
65 | }, | ||
66 | |||
67 | //------------------------------------------------------------------------- | ||
68 | |||
69 | 'value': function() { | ||
70 | return this.record().notes(); | ||
71 | }, | ||
72 | |||
73 | 'setValue': function(aValue) { | ||
74 | this.record().setNotes(aValue); | ||
75 | }, | ||
76 | |||
77 | //------------------------------------------------------------------------- | ||
78 | |||
79 | 'render': function() { | ||
80 | //MochiKit.Logging.logDebug(">>> NotesComponent.render"); | ||
81 | /* | ||
82 | Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'td', colspan:'5', children:[ | ||
83 | {tag:'span', cls:'noteFieldLabel', htmlString:Clipperz.PM.Strings['recordDetailNotesLabel']}, | ||
84 | {tag:'div', cls:'noteFieldContent', id:this.getId('notes')} | ||
85 | ]}); | ||
86 | */ | ||
87 | Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'span', cls:'noteFieldLabel', htmlString:Clipperz.PM.Strings['recordDetailNotesLabel']}); | ||
88 | Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'div', cls:'noteFieldContent', id:this.getId('notes'), children:[ | ||
89 | {tag:'div', id:this.getId('resizableDiv'), cls:'resizable-textarea', children:[ | ||
90 | {tag:'div', id:this.getId('contentView'), cls:'viewMode', html:""}, | ||
91 | {tag:'div', id:this.getId('contentEdit'), children:[ | ||
92 | {tag:'span', children:[ | ||
93 | {tag:'textarea', id:this.getId('textarea'), html:""} | ||
94 | ]} | ||
95 | ]}, | ||
96 | {tag:'div', id:this.getId('grippie'), cls:'grippie'} | ||
97 | ]} | ||
98 | ]}); | ||
99 | |||
100 | this.getElement('contentView').setVisibilityMode(YAHOO.ext.Element.DISPLAY); | ||
101 | this.getElement('contentEdit').setVisibilityMode(YAHOO.ext.Element.DISPLAY); | ||
102 | |||
103 | MochiKit.Signal.connect(this.getId('grippie'), 'onmousedown', this, 'startResize'); | ||
104 | |||
105 | this.update(); | ||
106 | //MochiKit.Logging.logDebug("<<< NotesComponent.render"); | ||
107 | }, | ||
108 | |||
109 | //------------------------------------------------------------------------- | ||
110 | |||
111 | 'updateViewMode': function() { | ||
112 | //MochiKit.Logging.logDebug(">>> NotesComponent.updateViewMode"); | ||
113 | // this.getElement('notes').update(this.value().replace(/\n/g, '<br>')); | ||
114 | |||
115 | this.getElement('contentView').update(Clipperz.Base.sanitizeString(this.value()).replace(/\n/g, '<br>')); | ||
116 | |||
117 | if (this.isNoteEmpty()) { | ||
118 | this.element().hide(); | ||
119 | } else { | ||
120 | this.getElement('contentView').show(); | ||
121 | this.getElement('contentView').setHeight(this.componentHeight()); | ||
122 | } | ||
123 | this.getElement('contentEdit').hide(); | ||
124 | |||
125 | //MochiKit.Logging.logDebug("<<< NotesComponent.updateViewMode"); | ||
126 | }, | ||
127 | |||
128 | //------------------------------------------------------------------------- | ||
129 | |||
130 | 'updateEditMode': function() { | ||
131 | //MochiKit.Logging.logDebug(">>> NotesComponent.updateEditMode"); | ||
132 | this.getDom('textarea').value = this.value().replace(/\n/g, Clipperz_normalizedNewLine); | ||
133 | |||
134 | this.getElement('contentView').hide(); | ||
135 | this.getElement('contentEdit').show(); | ||
136 | |||
137 | this.getElement('textarea').setHeight(this.componentHeight()); | ||
138 | //MochiKit.Logging.logDebug("<<< NotesComponent.updateEditMode"); | ||
139 | }, | ||
140 | |||
141 | //------------------------------------------------------------------------- | ||
142 | |||
143 | 'synchronizeComponentValues': function() { | ||
144 | //MochiKit.Logging.logDebug(">>> NotesComponent.synchronizeComponentValues"); | ||
145 | if (this.getElement('textarea') != null) { | ||
146 | this.setValue(this.getDom('textarea').value.replace(/(\x0a\x0d|\x0d\x0a)/g,'\n')); | ||
147 | } | ||
148 | //MochiKit.Logging.logDebug("<<< NotesComponent.synchronizeComponentValues"); | ||
149 | }, | ||
150 | |||
151 | //------------------------------------------------------------------------- | ||
152 | |||
153 | 'componentHeight': function() { | ||
154 | return this._componentHeight; | ||
155 | }, | ||
156 | |||
157 | 'setComponentHeight': function(aValue) { | ||
158 | this._componentHeight = aValue; | ||
159 | }, | ||
160 | |||
161 | //------------------------------------------------------------------------- | ||
162 | |||
163 | 'isNoteEmpty': function() { | ||
164 | return !/[^ \n]/.test(this.value()); | ||
165 | }, | ||
166 | |||
167 | //------------------------------------------------------------------------- | ||
168 | |||
169 | 'staticOffset': function() { | ||
170 | return this._staticOffset; | ||
171 | }, | ||
172 | |||
173 | 'setStaticOffset': function(aValue) { | ||
174 | this._staticOffset = aValue; | ||
175 | }, | ||
176 | |||
177 | //------------------------------------------------------------------------- | ||
178 | |||
179 | 'startResize': function(anEvent) { | ||
180 | //MochiKit.Logging.logDebug(">>> startResize"); | ||
181 | if (this.editMode() == 'VIEW') { | ||
182 | this.setStaticOffset(this.getElement('contentView').getHeight() - anEvent.mouse().page['y']) | ||
183 | } else { | ||
184 | this.setStaticOffset(this.getElement('textarea').getHeight() - anEvent.mouse().page['y']) | ||
185 | // this.getElement('textarea').setStyle('opacity', 0.25); | ||
186 | } | ||
187 | this.setMouseMoveIdentifier(MochiKit.Signal.connect(MochiKit.DOM.currentDocument(), 'onmousemove', this, 'whileResizing')); | ||
188 | this.setMouseUpIdentifier(MochiKit.Signal.connect(MochiKit.DOM.currentDocument(), 'onmouseup', this, 'endResize')); | ||
189 | anEvent.stop(); | ||
190 | //MochiKit.Logging.logDebug("<<< startResize"); | ||
191 | }, | ||
192 | |||
193 | //------------------------------------------------------------------------- | ||
194 | |||
195 | 'whileResizing': function(anEvent) { | ||
196 | //MochiKit.Logging.logDebug(">>> whileResizing"); | ||
197 | this.getElement('textarea').setHeight(Math.max(32, this.staticOffset() + anEvent.mouse().page['y']) + 'px'); | ||
198 | this.getElement('contentView').setHeight(Math.max(32, this.staticOffset() + anEvent.mouse().page['y']) + 'px'); | ||
199 | anEvent.stop(); | ||
200 | //MochiKit.Logging.logDebug("<<< whileResizing"); | ||
201 | }, | ||
202 | |||
203 | //------------------------------------------------------------------------- | ||
204 | |||
205 | 'endResize': function(anEvent) { | ||
206 | //MochiKit.Logging.logDebug(">>> endResize"); | ||
207 | MochiKit.Signal.disconnect(this.mouseMoveIdentifier()); | ||
208 | this.setMouseMoveIdentifier(null); | ||
209 | MochiKit.Signal.disconnect(this.mouseUpIdentifier()); | ||
210 | this.setMouseUpIdentifier(null); | ||
211 | // this.getElement('textarea').setStyle('opacity', 1); | ||
212 | |||
213 | this.setComponentHeight(this.getElement('textarea').getHeight()); | ||
214 | //MochiKit.Logging.logDebug("<<< endResize"); | ||
215 | }, | ||
216 | |||
217 | //------------------------------------------------------------------------- | ||
218 | |||
219 | 'mouseMoveIdentifier': function() { | ||
220 | return this._mouseMoveIdentifier; | ||
221 | }, | ||
222 | |||
223 | 'setMouseMoveIdentifier': function(aValue) { | ||
224 | this._mouseMoveIdentifier = aValue; | ||
225 | }, | ||
226 | |||
227 | //------------------------------------------------------------------------- | ||
228 | |||
229 | 'mouseUpIdentifier': function() { | ||
230 | return this._mouseUpIdentifier; | ||
231 | }, | ||
232 | |||
233 | 'setMouseUpIdentifier': function(aValue) { | ||
234 | this._mouseUpIdentifier = aValue; | ||
235 | }, | ||
236 | |||
237 | //------------------------------------------------------------------------- | ||
238 | __syntaxFix__: "syntax fix" | ||
239 | }); | ||
240 | |||
diff --git a/frontend/beta/js/Clipperz/PM/Components/RecordDetail/TitleComponent.js b/frontend/beta/js/Clipperz/PM/Components/RecordDetail/TitleComponent.js new file mode 100644 index 0000000..52e718c --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/RecordDetail/TitleComponent.js | |||
@@ -0,0 +1,137 @@ | |||
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 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | ||
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | ||
31 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } | ||
32 | if (typeof(Clipperz.PM.Components.RecordDetail) == 'undefined') { Clipperz.PM.Components.RecordDetail = {}; } | ||
33 | |||
34 | //############################################################################# | ||
35 | |||
36 | Clipperz.PM.Components.RecordDetail.TitleComponent = function(anElement, args) { | ||
37 | args = args || {}; | ||
38 | |||
39 | Clipperz.PM.Components.RecordDetail.TitleComponent.superclass.constructor.call(this, anElement, args); | ||
40 | |||
41 | //this._inputElement = null; | ||
42 | |||
43 | this.mainComponent().addEditComponent(this); | ||
44 | |||
45 | this.render(); | ||
46 | |||
47 | return this; | ||
48 | } | ||
49 | |||
50 | //============================================================================= | ||
51 | |||
52 | YAHOO.extendX(Clipperz.PM.Components.RecordDetail.TitleComponent, Clipperz.PM.Components.RecordDetail.AbstractComponent, { | ||
53 | |||
54 | 'toString': function() { | ||
55 | return "Clipperz.PM.Components.RecordDetail.TitleComponent component"; | ||
56 | }, | ||
57 | |||
58 | //------------------------------------------------------------------------- | ||
59 | |||
60 | 'value': function() { | ||
61 | return this.record().label(); | ||
62 | }, | ||
63 | |||
64 | 'setValue': function(aValue) { | ||
65 | this.record().setLabel(aValue); | ||
66 | }, | ||
67 | |||
68 | //------------------------------------------------------------------------- | ||
69 | /* | ||
70 | 'inputElement': function() { | ||
71 | return this._inputElement; | ||
72 | }, | ||
73 | |||
74 | 'setInputElement': function(aValue) { | ||
75 | this._inputElement = aValue; | ||
76 | }, | ||
77 | */ | ||
78 | //------------------------------------------------------------------------- | ||
79 | |||
80 | 'render': function() { | ||
81 | // Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'td', html:' '}); | ||
82 | // Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'td', colspan:"3", html:' ', children:[ | ||
83 | // {tag:'div', /*style:'border: 1px solid green;',*/ id:this.getId('title')} | ||
84 | // ]}); | ||
85 | // Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'td', html:' '}); | ||
86 | // | ||
87 | // this.setInputElement(new Clipperz.PM.Components.TextFormField(this.getElement('title'), {editMode:this.editMode(), value:this.value()})); | ||
88 | |||
89 | this.update(); | ||
90 | }, | ||
91 | |||
92 | //------------------------------------------------------------------------- | ||
93 | /* | ||
94 | 'update': function() { | ||
95 | this.inputElement().update({value:this.value(), editMode:this.editMode()}); | ||
96 | }, | ||
97 | */ | ||
98 | //------------------------------------------------------------------------- | ||
99 | |||
100 | 'updateViewMode': function() { | ||
101 | this.element().update(""); | ||
102 | Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'h2', html:this.value()}); | ||
103 | }, | ||
104 | |||
105 | //------------------------------------------------------------------------- | ||
106 | |||
107 | 'updateEditMode': function() { | ||
108 | //MochiKit.Logging.logDebug(">>> TitleComponent.updateEditMode"); | ||
109 | // this.getElement('title').update(""); | ||
110 | // Clipperz.YUI.DomHelper.append(this.getDom('title'), {tag:'div', id:this.getId('title_input')}); | ||
111 | // this.setInputElement(Clipperz.YUI.DomHelper.append(this.getDom('title_input'), {tag:'input', type:'text', value:this.value()}, true)); | ||
112 | |||
113 | this.element().update(""); | ||
114 | Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'input', id:this.getId('titleField'), type:'text', value:"this.value()"}); | ||
115 | this.getElement('titleField').dom.value = this.value(); | ||
116 | |||
117 | //MochiKit.Logging.logDebug("<<< TitleComponent.updateEditMode"); | ||
118 | }, | ||
119 | |||
120 | //------------------------------------------------------------------------- | ||
121 | |||
122 | 'synchronizeComponentValues': function() { | ||
123 | var inputElement; | ||
124 | |||
125 | //MochiKit.Logging.logDebug(">>> TitleComponent.synchronizeComponentValues"); | ||
126 | inputElement = this.element().getChildrenByTagName('input')[0]; | ||
127 | |||
128 | if (inputElement != null) { | ||
129 | this.setValue(inputElement.dom.value); | ||
130 | } | ||
131 | //MochiKit.Logging.logDebug("<<< TitleComponent.synchronizeComponentValues"); | ||
132 | }, | ||
133 | |||
134 | //------------------------------------------------------------------------- | ||
135 | __syntaxFix__: "syntax fix" | ||
136 | }); | ||
137 | |||
diff --git a/frontend/beta/js/Clipperz/PM/Components/TabPanel/TabPanelController.js b/frontend/beta/js/Clipperz/PM/Components/TabPanel/TabPanelController.js new file mode 100644 index 0000000..c872462 --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/TabPanel/TabPanelController.js | |||
@@ -0,0 +1,158 @@ | |||
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 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | ||
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | ||
31 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } | ||
32 | if (typeof(Clipperz.PM.Components.TabPanel) == 'undefined') { Clipperz.PM.Components.TabPanel = {}; } | ||
33 | |||
34 | Clipperz.PM.Components.TabPanel.TabPanelController = function(args) { | ||
35 | args = args || {}; | ||
36 | |||
37 | Clipperz.PM.Components.TabPanel.TabPanelController.superclass.constructor.call(this); | ||
38 | |||
39 | this._name = args.name || 'undefined'; | ||
40 | this._config = args.config; | ||
41 | this._selectedTab = args.selectedTab || ((MochiKit.Base.keys(args.config).length > 0) ? MochiKit.Base.keys(args.config)[0] : null); | ||
42 | |||
43 | this._tabs = {}; | ||
44 | this._panels = {}; | ||
45 | |||
46 | Clipperz.NotificationCenter.register(null, 'selectTab', this, 'handleSelectTabNotification'); | ||
47 | return this; | ||
48 | } | ||
49 | |||
50 | //============================================================================= | ||
51 | |||
52 | YAHOO.extendX(Clipperz.PM.Components.TabPanel.TabPanelController, YAHOO.ext.util.Observable, { | ||
53 | |||
54 | //------------------------------------------------------------------------- | ||
55 | |||
56 | 'name': function() { | ||
57 | return this._name; | ||
58 | }, | ||
59 | |||
60 | //------------------------------------------------------------------------- | ||
61 | |||
62 | 'tabs': function() { | ||
63 | return this._tabs; | ||
64 | }, | ||
65 | |||
66 | //------------------------------------------------------------------------- | ||
67 | |||
68 | 'panels': function() { | ||
69 | return this._panels; | ||
70 | }, | ||
71 | |||
72 | //------------------------------------------------------------------------- | ||
73 | |||
74 | 'config': function() { | ||
75 | return this._config; | ||
76 | }, | ||
77 | |||
78 | //------------------------------------------------------------------------- | ||
79 | |||
80 | 'selectedTab': function() { | ||
81 | return this._selectedTab; | ||
82 | }, | ||
83 | |||
84 | 'setSelectedTab': function(aValue) { | ||
85 | this._selectedTab = aValue; | ||
86 | }, | ||
87 | |||
88 | //------------------------------------------------------------------------- | ||
89 | |||
90 | 'setUp': function() { | ||
91 | vartabId; | ||
92 | |||
93 | //MochiKit.Logging.logDebug(">>> TabPanelController.setUp - config: " + Clipperz.Base.serializeJSON(this.config())); | ||
94 | for (tabId in this.config()) { | ||
95 | vartabElement; | ||
96 | varpanelElement; | ||
97 | |||
98 | //MochiKit.Logging.logDebug("--- TabPanelController.setUp - tabId: " + tabId); | ||
99 | //MochiKit.Logging.logDebug("--- TabPanelController.setUp - panelId: " + this.config()[tabId]); | ||
100 | tabElement = YAHOO.ext.Element.get(tabId); | ||
101 | tabElement.addClassOnOver("hover"); | ||
102 | MochiKit.Signal.connect(tabId, 'onclick', this, 'selectTabHandler'); | ||
103 | |||
104 | panelElement = YAHOO.ext.Element.get(this.config()[tabId]); | ||
105 | |||
106 | this._tabs[tabId] = tabElement; | ||
107 | this._panels[tabId] = panelElement; | ||
108 | |||
109 | if (tabId == this.selectedTab()) { | ||
110 | tabElement.addClass('selectedTab'); | ||
111 | panelElement.addClass('selectedPanel'); | ||
112 | } else { | ||
113 | panelElement.addClass('hiddenPanel'); | ||
114 | } | ||
115 | } | ||
116 | //MochiKit.Logging.logDebug("<<< TabPanelController.setUp"); | ||
117 | }, | ||
118 | |||
119 | //------------------------------------------------------------------------- | ||
120 | |||
121 | 'selectTab': function(aTab) { | ||
122 | if (aTab != this.selectedTab()) { | ||
123 | this.tabs()[this.selectedTab()].removeClass('selectedTab'); | ||
124 | this.panels()[this.selectedTab()].removeClass('selectedPanel').addClass('hiddenPanel'); | ||
125 | |||
126 | this.tabs()[aTab].addClass('selectedTab'); | ||
127 | this.panels()[aTab].addClass('selectedPanel').removeClass('hiddenPanel'); | ||
128 | |||
129 | this.setSelectedTab(aTab); | ||
130 | |||
131 | Clipperz.NotificationCenter.notify(this, 'tabSelected', aTab); | ||
132 | } | ||
133 | }, | ||
134 | |||
135 | //------------------------------------------------------------------------- | ||
136 | |||
137 | 'selectTabHandler': function(anEvent) { | ||
138 | this.selectTab(anEvent.src().id); | ||
139 | }, | ||
140 | |||
141 | //------------------------------------------------------------------------- | ||
142 | |||
143 | 'handleSelectTabNotification': function(aNotificationEvent) { | ||
144 | var parameters; | ||
145 | var splittedParamters; | ||
146 | vartargetTabPanel; | ||
147 | |||
148 | parameters = aNotificationEvent.parameters(); | ||
149 | splittedParamters = parameters.split('.'); | ||
150 | targetTabPanel = splittedParamters[0]; | ||
151 | if (targetTabPanel == this.name()) { | ||
152 | this.selectTab(splittedParamters[1]) | ||
153 | } | ||
154 | }, | ||
155 | |||
156 | //------------------------------------------------------------------------- | ||
157 | __syntaxFix__: "syntax fix" | ||
158 | }); | ||
diff --git a/frontend/beta/js/Clipperz/PM/Components/TextFormField.js b/frontend/beta/js/Clipperz/PM/Components/TextFormField.js new file mode 100644 index 0000000..cb4f06a --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/TextFormField.js | |||
@@ -0,0 +1,310 @@ | |||
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 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | ||
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | ||
31 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } | ||
32 | |||
33 | Clipperz.PM.Components.TextFormField = function(anElement, args) { | ||
34 | args = args || {}; | ||
35 | |||
36 | //MochiKit.Logging.logDebug(">>> new TextFormField"); | ||
37 | Clipperz.PM.Components.TextFormField.superclass.constructor.call(this, args); | ||
38 | |||
39 | this._element = anElement; | ||
40 | this._editMode = args.editMode || 'VIEW'; | ||
41 | this._value = args.value || ""; | ||
42 | this._inputElement = null; | ||
43 | this._wrapper = null; | ||
44 | this._multiline = args.multiline || false; | ||
45 | |||
46 | //this.multiline = args.multiline || true; | ||
47 | //this.editing = true; | ||
48 | //this.completeOnBlur = true; | ||
49 | //this.autoSizeTask = new YAHOO.ext.util.DelayedTask(this.autoSize, this); | ||
50 | //this.textSizeEl = Clipperz.YUI.DomHelper.append(document.body, { | ||
51 | // tag: 'div', | ||
52 | // cls: 'yinline-editor-sizer ' + (this.cls || '') | ||
53 | //}); | ||
54 | |||
55 | this.render(); | ||
56 | //MochiKit.Logging.logDebug("<<< new TextFormField"); | ||
57 | |||
58 | return this; | ||
59 | }; | ||
60 | |||
61 | YAHOO.extendX(Clipperz.PM.Components.TextFormField, Clipperz.PM.Components.BaseComponent, { | ||
62 | |||
63 | 'toString': function() { | ||
64 | return "Clipperz.PM.Components.TextFormField"; | ||
65 | }, | ||
66 | |||
67 | //----------------------------------------------------- | ||
68 | |||
69 | 'value': function() { | ||
70 | if (this.inputElement() != null) { | ||
71 | this._value = this.inputElement().dom.value; | ||
72 | } | ||
73 | |||
74 | return this._value; | ||
75 | // return this.inlineEditor().getValue(); | ||
76 | }, | ||
77 | |||
78 | 'setValue': function(aValue) { | ||
79 | this._value = aValue; | ||
80 | // this.getElement('viewComponent_Content').update(aValue); | ||
81 | // this.inlineEditor().setValue(aValue); | ||
82 | }, | ||
83 | |||
84 | //----------------------------------------------------- | ||
85 | |||
86 | 'multiline': function() { | ||
87 | return this._multiline; | ||
88 | }, | ||
89 | |||
90 | //----------------------------------------------------- | ||
91 | |||
92 | 'editMode': function() { | ||
93 | return this._editMode; | ||
94 | }, | ||
95 | |||
96 | 'setEditMode': function(aValue) { | ||
97 | this._editMode = aValue; | ||
98 | }, | ||
99 | |||
100 | //----------------------------------------------------- | ||
101 | |||
102 | 'inputElement': function() { | ||
103 | return this._inputElement; | ||
104 | }, | ||
105 | |||
106 | 'setInputElement': function(aValue) { | ||
107 | this._inputElement = aValue; | ||
108 | }, | ||
109 | |||
110 | //----------------------------------------------------- | ||
111 | |||
112 | 'on': function(anEventName, anHandler, aScope, shouldOverride) { | ||
113 | //MochiKit.Logging.logDebug(">>> TextFormField.on - inputElement: " + this.inputElement()); | ||
114 | return this.inputElement().on(anEventName, anHandler, aScope, shouldOverride); | ||
115 | //MochiKit.Logging.logDebug("<<< TextFormField.on - inputElement: " + this.inputElement()); | ||
116 | }, | ||
117 | |||
118 | //----------------------------------------------------- | ||
119 | |||
120 | 'wrapper': function() { | ||
121 | return this._wrapper; | ||
122 | }, | ||
123 | |||
124 | //----------------------------------------------------- | ||
125 | |||
126 | 'render': function() { | ||
127 | var editModeConfiguration; | ||
128 | var viewModeConfiguration; | ||
129 | |||
130 | editModeConfiguration = {tag:'div', id:this.getId('editComponent'), children:[]}; | ||
131 | if (this.multiline() == false) { | ||
132 | editModeConfiguration.children.push({tag:'input', type:'text', id:this.getId('editComponent_input'), value:"this.value(1)"}); | ||
133 | } else { | ||
134 | editModeConfiguration.children.push({tag:'textarea', id:this.getId('editComponent_input'), html:"this.value(2)"}); | ||
135 | } | ||
136 | |||
137 | viewModeConfiguration = {tag:'div', id:this.getId('viewComponent'), /*style:'border: 1px solid blue;',*/ children:[ | ||
138 | {tag:'span', id:this.getId('viewComponent_Content'), html:this.value()} | ||
139 | ]} | ||
140 | |||
141 | //MochiKit.Logging.logDebug(">>> TextFormField.render"); | ||
142 | this._wrapper = Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'div', id:this.getId('wrapper'), children:[ | ||
143 | {tag:'div', id:this.getId('editModeBox'), children:[editModeConfiguration]}, | ||
144 | {tag:'div', id:this.getId('viewModeBox'), children:[viewModeConfiguration]} | ||
145 | ]}, true); | ||
146 | |||
147 | this.getElement('editModeBox').setVisibilityMode(YAHOO.ext.Element.DISPLAY); | ||
148 | this.getElement('viewModeBox').setVisibilityMode(YAHOO.ext.Element.DISPLAY); | ||
149 | |||
150 | this.getElement('editComponent_input').dom.value = this.value(); | ||
151 | this.setInputElement(this.getElement('editComponent_input')); | ||
152 | |||
153 | this.update(); | ||
154 | //MochiKit.Logging.logDebug("<<< TextFormField.render"); | ||
155 | }, | ||
156 | |||
157 | //----------------------------------------------------- | ||
158 | |||
159 | 'update': function(args) { | ||
160 | args = args || {}; | ||
161 | |||
162 | //MochiKit.Logging.logDebug(">>> TextFormField.update"); | ||
163 | if (typeof(args.value) != 'undefined') { | ||
164 | this.setValue(args.value); | ||
165 | } | ||
166 | if (typeof(args.editMode) != 'undefined') { | ||
167 | this.setEditMode(args.editMode) | ||
168 | } | ||
169 | |||
170 | if (this.editMode() == 'VIEW') { | ||
171 | this.updateViewMode(); | ||
172 | } else if (this.editMode() == 'EDIT') { | ||
173 | this.updateEditMode(); | ||
174 | } else { | ||
175 | //????? | ||
176 | } | ||
177 | //MochiKit.Logging.logDebug("<<< TextFormField.update"); | ||
178 | }, | ||
179 | |||
180 | //----------------------------------------------------- | ||
181 | |||
182 | 'updateEditMode': function() { | ||
183 | //MochiKit.Logging.logDebug(">>> TextFormField.updateEditMode"); | ||
184 | this.getElement('viewModeBox').hide(); | ||
185 | this.getElement('editModeBox').show(); | ||
186 | |||
187 | if (this.multiline() == false) { | ||
188 | this.getElement('editComponent_input').dom.value = this.value(); | ||
189 | } else { | ||
190 | this.getElement('editComponent_input').update(Clipperz.Base.sanitizeString(this.value())); | ||
191 | } | ||
192 | //MochiKit.Logging.logDebug("<<< TextFormField.updateEditMode"); | ||
193 | }, | ||
194 | |||
195 | //----------------------------------------------------- | ||
196 | |||
197 | 'updateViewMode': function() { | ||
198 | //MochiKit.Logging.logDebug(">>> TextFormField.updateViewMode"); | ||
199 | this.getElement('editModeBox').hide(); | ||
200 | this.getElement('viewModeBox').show(); | ||
201 | |||
202 | this.getElement('viewComponent_Content').update(Clipperz.Base.sanitizeString(this.value())); | ||
203 | //MochiKit.Logging.logDebug("<<< TextFormField.updateViewMode"); | ||
204 | }, | ||
205 | |||
206 | //##################################################### | ||
207 | //##################################################### | ||
208 | //##################################################### | ||
209 | //##################################################### | ||
210 | /* | ||
211 | 'onEnter': function(k, e) { | ||
212 | MochiKit.Logging.logDebug(">>> TextFormField.onEnter"); | ||
213 | if (this.multiline && (e.ctrlKey || e.shiftKey)) { | ||
214 | return; | ||
215 | } else { | ||
216 | this.completeEdit(); | ||
217 | e.stopEvent(); | ||
218 | } | ||
219 | MochiKit.Logging.logDebug("<<< TextFormField.onEnter"); | ||
220 | }, | ||
221 | |||
222 | //----------------------------------------------------- | ||
223 | |||
224 | 'onEsc': function() { | ||
225 | MochiKit.Logging.logDebug(">>> TextFormField.onEsc"); | ||
226 | // if (this.ignoreNoChange) { | ||
227 | // this.revert(true); | ||
228 | // } else { | ||
229 | this.revert(false); | ||
230 | this.completeEdit(); | ||
231 | // } | ||
232 | MochiKit.Logging.logDebug("<<< TextFormField.onEsc"); | ||
233 | }, | ||
234 | |||
235 | //----------------------------------------------------- | ||
236 | |||
237 | onBlur : function(){ | ||
238 | MochiKit.Logging.logDebug(">>> TextFormField.onBlur"); | ||
239 | if (this.editing && this.completeOnBlur !== false) { | ||
240 | this.completeEdit(); | ||
241 | } | ||
242 | MochiKit.Logging.logDebug("<<< TextFormField.onBlur"); | ||
243 | }, | ||
244 | |||
245 | //----------------------------------------------------- | ||
246 | |||
247 | 'onKeyUp': function(e) { | ||
248 | var k = e.getKey(); | ||
249 | if (this.editing && (k < 33 || k > 40) && k != 27) { | ||
250 | this.autoSizeTask.delay(50); | ||
251 | } | ||
252 | }, | ||
253 | |||
254 | //----------------------------------------------------- | ||
255 | |||
256 | 'autoSize': function() { | ||
257 | var el = this.inputElement(); | ||
258 | var wrap = this.getElement('editComponent'); | ||
259 | var v = el.dom.value; | ||
260 | var ts = this.textSizeEl; | ||
261 | |||
262 | if (v.length < 1) { | ||
263 | ts.innerHTML = "  "; | ||
264 | } else { | ||
265 | v = v.replace(/[<> ]/g, ' '); | ||
266 | if (this.multiline) { | ||
267 | v = v.replace(/\n/g, '<br /> '); | ||
268 | } | ||
269 | ts.innerHTML = v; | ||
270 | } | ||
271 | |||
272 | var ww = wrap.dom.offsetWidth; | ||
273 | var wh = wrap.dom.offsetHeight; | ||
274 | var w = ts.offsetWidth; | ||
275 | var h = ts.offsetHeight; | ||
276 | // lots of magic numbers in this block - wtf? | ||
277 | // the logic is to prevent the scrollbars from flashing | ||
278 | // in firefox. Updates the right element first | ||
279 | // so there's never overflow. | ||
280 | if (ww > w+4) { | ||
281 | el.setWidth(w+4); | ||
282 | wrap.setWidth(w+8); | ||
283 | } else { | ||
284 | wrap.setWidth(w+8); | ||
285 | el.setWidth(w+4); | ||
286 | } | ||
287 | if (wh > h+4) { | ||
288 | el.setHeight(h); | ||
289 | wrap.setHeight(h+4); | ||
290 | } else { | ||
291 | wrap.setHeight(h+4); | ||
292 | el.setHeight(h); | ||
293 | } | ||
294 | }, | ||
295 | |||
296 | //----------------------------------------------------- | ||
297 | |||
298 | 'completeEdit': function() { | ||
299 | MochiKit.Logging.logDebug(">>> TextFormField.completeEdit"); | ||
300 | |||
301 | }, | ||
302 | |||
303 | 'revert': function() { | ||
304 | MochiKit.Logging.logDebug(">>> TextFormField.revert"); | ||
305 | |||
306 | }, | ||
307 | */ | ||
308 | //----------------------------------------------------- | ||
309 | __syntaxFix__: '__syntaxFix__' | ||
310 | }); | ||