author | Giulio Cesare Solaroli <giulio.cesare@solaroli.it> | 2011-10-03 16:04:12 (UTC) |
---|---|---|
committer | Giulio Cesare Solaroli <giulio.cesare@solaroli.it> | 2011-10-03 16:04:12 (UTC) |
commit | 541bb378ddece2eab135a8066a16994e94436dea (patch) (unidiff) | |
tree | ff160ea3e26f7fe07fcfd401387c5a0232ca715e /frontend/beta/js/Clipperz/PM/Components/Import/MainComponent.js | |
parent | 1bf431fd3d45cbdf4afa3e12afefe5d24f4d3bc7 (diff) | |
parent | ecad5e895831337216544e81f1a467e0c68c4a6a (diff) | |
download | clipperz-541bb378ddece2eab135a8066a16994e94436dea.zip clipperz-541bb378ddece2eab135a8066a16994e94436dea.tar.gz clipperz-541bb378ddece2eab135a8066a16994e94436dea.tar.bz2 |
Merge pull request #1 from gcsolaroli/master
First version of the restructured repository
Diffstat (limited to 'frontend/beta/js/Clipperz/PM/Components/Import/MainComponent.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/beta/js/Clipperz/PM/Components/Import/MainComponent.js | 332 |
1 files changed, 332 insertions, 0 deletions
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 | |||