summaryrefslogtreecommitdiff
path: root/frontend/gamma/js/Clipperz/PM/UI/Common/Controllers
Unidiff
Diffstat (limited to 'frontend/gamma/js/Clipperz/PM/UI/Common/Controllers') (more/less context) (show whitespace changes)
-rw-r--r--frontend/gamma/js/Clipperz/PM/UI/Common/Controllers/DirectLoginRunner.js267
-rw-r--r--frontend/gamma/js/Clipperz/PM/UI/Common/Controllers/ProgressBarController.js143
-rw-r--r--frontend/gamma/js/Clipperz/PM/UI/Common/Controllers/TabPanelController.js188
-rw-r--r--frontend/gamma/js/Clipperz/PM/UI/Common/Controllers/WizardController.js31
4 files changed, 629 insertions, 0 deletions
diff --git a/frontend/gamma/js/Clipperz/PM/UI/Common/Controllers/DirectLoginRunner.js b/frontend/gamma/js/Clipperz/PM/UI/Common/Controllers/DirectLoginRunner.js
new file mode 100644
index 0000000..e534435
--- a/dev/null
+++ b/frontend/gamma/js/Clipperz/PM/UI/Common/Controllers/DirectLoginRunner.js
@@ -0,0 +1,267 @@
1/*
2
3Copyright 2008-2011 Clipperz Srl
4
5This file is part of Clipperz's Javascript Crypto Library.
6Javascript Crypto Library provides web developers with an extensive
7and efficient set of cryptographic functions. The library aims to
8obtain maximum execution speed while preserving modularity and
9reusability.
10For further information about its features and functionalities please
11refer to http://www.clipperz.com
12
13* Javascript Crypto Library is free software: you can redistribute
14 it and/or modify it under the terms of the GNU Affero General Public
15 License as published by the Free Software Foundation, either version
16 3 of the License, or (at your option) any later version.
17
18* Javascript Crypto Library is distributed in the hope that it will
19 be useful, but WITHOUT ANY WARRANTY; without even the implied
20 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21 See the GNU Affero General Public License for more details.
22
23* You should have received a copy of the GNU Affero General Public
24 License along with Javascript Crypto Library. If not, see
25 <http://www.gnu.org/licenses/>.
26
27*/
28
29Clipperz.Base.module('Clipperz.PM.UI.Common.Controllers');
30
31Clipperz.PM.UI.Common.Controllers.DirectLoginRunner = function(args) {
32 this._directLogin = args['directLogin'] || Clipperz.Base.exception.raise('MandatoryParameter');
33 this._target = Clipperz.PM.Crypto.randomKey();
34
35 return this;
36}
37
38MochiKit.Base.update(Clipperz.PM.UI.Common.Controllers.DirectLoginRunner.prototype, {
39
40 'toString': function() {
41 return "Clipperz.PM.UI.Common.Controllers.DirectLoginRunner";
42 },
43
44 //-----------------------------------------------------------------------------
45
46 'directLogin': function () {
47 return this._directLogin;
48 },
49
50 //-----------------------------------------------------------------------------
51
52 'target': function () {
53 return this._target;
54 },
55
56 //=============================================================================
57
58 'setWindowTitle': function (aWindow, aTitle) {
59 aWindow.document.title = aTitle;
60 },
61
62 'setWindowBody': function (aWindow, anHTML) {
63 aWindow.document.body.innerHTML = anHTML;
64 },
65
66 //=============================================================================
67
68 'initialWindowSetup': function (aWindow) {
69 this.setWindowTitle(aWindow, "Loading Clipperz Direct Login");
70 this.setWindowBody (aWindow, MochiKit.DOM.toHTML(MochiKit.DOM.H3("Loading Clipperz Direct Login ...")));
71 },
72
73 //-----------------------------------------------------------------------------
74
75 'updateWindowWithDirectLoginLabel': function (aWindow, aLabel) {
76 var titleText;
77 var bodyText;
78
79 titleText = "Loading '__label__' Direct Login".replace(/__label__/, aLabel)
80 bodyText = "Loading '__label__' Direct Login... ".replace(/__label__/, aLabel)
81
82 this.setWindowTitle(aWindow, titleText);
83 this.setWindowBody (aWindow, MochiKit.DOM.toHTML(MochiKit.DOM.H3(bodyText)));
84 },
85
86 //-----------------------------------------------------------------------------
87
88 'updateWindowWithHTMLContent': function (aWindow, anHtml) {
89 this.setWindowBody(aWindow, anHtml);
90 },
91
92 //=============================================================================
93
94 'submitLoginForm': function(aWindow, aSubmitFunction) {
95 MochiKit.DOM.withWindow(aWindow, MochiKit.Base.bind(function () {
96 var formElement;
97 var submitButtons;
98
99 formElement = MochiKit.DOM.getElement('directLoginForm');
100
101 submitButtons = MochiKit.Base.filter(function(anInputElement) {
102 return ((anInputElement.tagName.toLowerCase() == 'input') && (anInputElement.getAttribute('type').toLowerCase() == 'submit'));
103 }, formElement.elements);
104
105 if (submitButtons.length == 0) {
106 if (typeof(formElement.submit) == 'function') {
107 formElement.submit();
108 } else {
109 aSubmitFunction.apply(formElement);
110 }
111/*
112 varformSubmitFunction;
113
114 formSubmitFunction = MochiKit.Base.method(formElement, 'submit');
115 if (Clipperz_IEisBroken == true) {
116 formElement.submit();
117 } else {
118 formSubmitFunction();
119 }
120*/
121 } else {
122 submitButtons[0].click();
123 }
124 }, this));
125 },
126
127 //-------------------------------------------------------------------------
128
129 'runSubmitFormDirectLogin': function (aWindow, someAttributes) {
130 var html;
131 var formElement;
132 var submitFunction;
133
134 formElement = MochiKit.DOM.FORM({
135 'id':'directLoginForm',
136 'method':someAttributes['formAttributes']['method'],
137 'action':someAttributes['formAttributes']['action']
138 });
139
140 submitFunction = formElement.submit;
141
142 MochiKit.DOM.appendChildNodes(formElement, MochiKit.Base.map(function (anInputAttributes) {
143 return MochiKit.DOM.INPUT({'type':'hidden', 'name':anInputAttributes[0], 'value':anInputAttributes[1]});
144 }, MochiKit.Base.items(someAttributes['inputValues'])));
145
146 html ='';
147 html += '<h3>Loading ' + someAttributes['label'] + ' ...</h3>';
148 html +=MochiKit.DOM.appendChildNodes(MochiKit.DOM.DIV(), MochiKit.DOM.appendChildNodes(MochiKit.DOM.DIV({style:'display:none; visibility:hidden;'}), formElement)).innerHTML;
149
150 this.updateWindowWithHTMLContent(aWindow, html);
151 this.submitLoginForm(aWindow, submitFunction);
152 },
153
154 //-------------------------------------------------------------------------
155
156 'runHttpAuthDirectLogin': function(aWindow, someAttributes) {
157 var completeUrl;
158 var url;
159
160//console.log("runHttpAuthDirectLogin", someAttributes);
161 url = someAttributes['inputValues']['url'];
162
163 if (/^https?\:\/\//.test(url) == false) {
164 url = 'http://' + url;
165 }
166
167 if (Clipperz_IEisBroken === true) {
168 completeUrl = url;
169 } else {
170 var username;
171 var password;
172
173 username = someAttributes['inputValues']['username'];
174 password = someAttributes['inputValues']['password'];
175 /(^https?\:\/\/)?(.*)/.test(url);
176
177 completeUrl = RegExp.$1 + username + ':' + password + '@' + RegExp.$2;
178 }
179
180 window.open(completeUrl, this.target());
181 },
182
183 //=============================================================================
184
185 'runDirectLogin': function (aWindow) {
186 var deferredResult;
187
188//console.log(">>> runDirectLogin");
189 deferredResult = new Clipperz.Async.Deferred("DirectLoginRunner.openDirectLogin", {trace:false});
190 deferredResult.addMethod(this, 'initialWindowSetup', aWindow);
191 deferredResult.addMethod(this.directLogin(), 'label');
192 deferredResult.addMethod(this, 'updateWindowWithDirectLoginLabel', aWindow);
193 deferredResult.collectResults({
194 'type': MochiKit.Base.method(this.directLogin(), 'type'),
195 'label': MochiKit.Base.method(this.directLogin(), 'label'),
196 'formAttributes':MochiKit.Base.method(this.directLogin(), 'formAttributes'),
197 'inputValues': MochiKit.Base.method(this.directLogin(), 'inputValues')
198 });
199//deferredResult.addCallback(function (aValue) { console.log("SOME ATTRIBUTES", aValue); return aValue; });
200 deferredResult.addCallback(MochiKit.Base.bind(function (someAttributes) {
201//console.log("SOME ATTRIBUTES", someAttributes);
202 switch (someAttributes['type']) {
203 case 'http_auth':
204 this.runHttpAuthDirectLogin(aWindow, someAttributes);
205 break;
206 case 'simple_url':
207 this.runSimpleUrlDirectLogin(aWindow, someAttributes);
208 break;
209 default:
210 this.runSubmitFormDirectLogin(aWindow, someAttributes);
211 break;
212 }
213 }, this));
214 deferredResult.callback();
215//console.log("<<< runDirectLogin");
216
217 return deferredResult;
218 },
219
220 //=============================================================================
221
222 'run': function () {
223 var newWindow;
224
225 newWindow = window.open(Clipperz.PM.Strings.getValue('directLoginJumpPageUrl'), this.target());
226
227 return this.runDirectLogin(newWindow);
228 },
229
230 //=============================================================================
231
232 'test': function () {
233 var iFrame;
234 var newWindow;
235
236 iFrame = MochiKit.DOM.createDOM('iframe');
237 MochiKit.DOM.appendChildNodes(MochiKit.DOM.currentDocument().body, iFrame);
238
239 newWindow = iFrame.contentWindow;
240
241 return this.runDirectLogin(newWindow);
242 },
243
244 //=============================================================================
245 __syntaxFix__: "syntax fix"
246});
247
248//-----------------------------------------------------------------------------
249
250Clipperz.PM.UI.Common.Controllers.DirectLoginRunner.openDirectLogin = function (aDirectLogin) {
251 varrunner;
252
253 runner = new Clipperz.PM.UI.Common.Controllers.DirectLoginRunner({directLogin:aDirectLogin});
254 return runner.run();
255};
256
257//-----------------------------------------------------------------------------
258
259Clipperz.PM.UI.Common.Controllers.DirectLoginRunner.testDirectLogin = function (aDirectLogin) {
260 varrunner;
261
262//console.log(">>>>>> TESTING DIRECT LOGIN");
263 runner = new Clipperz.PM.UI.Common.Controllers.DirectLoginRunner({directLogin:aDirectLogin});
264 return runner.test();
265};
266
267//-----------------------------------------------------------------------------
diff --git a/frontend/gamma/js/Clipperz/PM/UI/Common/Controllers/ProgressBarController.js b/frontend/gamma/js/Clipperz/PM/UI/Common/Controllers/ProgressBarController.js
new file mode 100644
index 0000000..a4fa400
--- a/dev/null
+++ b/frontend/gamma/js/Clipperz/PM/UI/Common/Controllers/ProgressBarController.js
@@ -0,0 +1,143 @@
1/*
2
3Copyright 2008-2011 Clipperz Srl
4
5This file is part of Clipperz's Javascript Crypto Library.
6Javascript Crypto Library provides web developers with an extensive
7and efficient set of cryptographic functions. The library aims to
8obtain maximum execution speed while preserving modularity and
9reusability.
10For further information about its features and functionalities please
11refer to http://www.clipperz.com
12
13* Javascript Crypto Library is free software: you can redistribute
14 it and/or modify it under the terms of the GNU Affero General Public
15 License as published by the Free Software Foundation, either version
16 3 of the License, or (at your option) any later version.
17
18* Javascript Crypto Library is distributed in the hope that it will
19 be useful, but WITHOUT ANY WARRANTY; without even the implied
20 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21 See the GNU Affero General Public License for more details.
22
23* You should have received a copy of the GNU Affero General Public
24 License along with Javascript Crypto Library. If not, see
25 <http://www.gnu.org/licenses/>.
26
27*/
28
29Clipperz.Base.module('Clipperz.PM.UI.Common.Controllers');
30
31Clipperz.PM.UI.Common.Controllers.ProgressBarController = function(args) {
32 args = args || {};
33
34 this._numberOfSteps= 0;
35 this._currentStep= 0;
36
37 MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'initProgress', this, 'initProgressHandle');
38 MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'updateProgress',this, 'updateProgressHandle');
39 MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'advanceProgress',this, 'advanceProgressHandle');
40 MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'progressDone', this, 'progressDoneHandle');
41
42 return this;
43}
44
45MochiKit.Base.update(Clipperz.PM.UI.Common.Controllers.ProgressBarController.prototype, {
46
47 'toString': function() {
48 return "Clipperz.PM.UI.Common.Controllers.ProgressBarController";
49 },
50
51 //-----------------------------------------------------------------------------
52
53 'numberOfSteps': function() {
54 return this._numberOfSteps;
55 },
56
57 'setNumberOfSteps': function (aValue) {
58 this._numberOfSteps = aValue;
59 },
60
61 'updateNumberOfSteps': function (aValue) {
62 this._numberOfSteps += aValue;
63 },
64
65 //-----------------------------------------------------------------------------
66
67 'currentStep': function() {
68 return this._currentStep;
69 },
70
71 'advanceCurrentStep': function () {
72 this._currentStep ++;
73 },
74
75 //-----------------------------------------------------------------------------
76
77 'completedPercentage': function () {
78 var result;
79//Clipperz.log(">>> completedPercentage" + this.currentStep() + "/" + this.numberOfSteps(), this.currentStep() / this.numberOfSteps());
80 if (this.numberOfSteps() == 0) {
81 result = 0;
82 } else {
83 result = (Math.min(100, 100 * (this.currentStep() / this.numberOfSteps())));
84 }
85//Clipperz.log("<<< completedPercentage", result);
86 return result;
87 },
88
89 //-----------------------------------------------------------------------------
90
91 'resetStatus': function () {
92 this._numberOfSteps= 0;
93 this._currentStep= 0;
94 },
95
96 //-----------------------------------------------------------------------------
97
98 'updateProgress': function () {
99//Clipperz.log(">>> updateProgress: " + this.completedPercentage() + "%");
100 MochiKit.Signal.signal(this, 'updateProgress', this.completedPercentage());
101 },
102
103 //=============================================================================
104
105 'initProgressHandle': function (anEvent) {
106//Clipperz.log(">>> initProgressHandle - steps: " + (anEvent != null ? anEvent['steps'] : 0));
107 this.resetStatus();
108 if (anEvent != null) {
109 this.setNumberOfSteps(anEvent['steps']);
110 }
111 MochiKit.Signal.signal(this, 'initProgress');
112 this.updateProgress();
113 },
114
115 //.............................................................................
116
117 'updateProgressHandle': function (anEvent) {
118 this.updateNumberOfSteps(anEvent['extraSteps']);
119//Clipperz.log("=== updateProgressHandle - steps: " + this.numberOfSteps() + " (extra " + anEvent['extraSteps'] + ")");
120 this.updateProgress();
121 },
122
123 //.............................................................................
124
125 'advanceProgressHandle': function (anEvent) {
126 this.advanceCurrentStep();
127//Clipperz.log("--- advanceProgressHandle: " + this.currentStep() + "/" + this.numberOfSteps());
128 this.updateProgress();
129 },
130
131 //.............................................................................
132
133 'progressDoneHandle': function (anEvent) {
134//Clipperz.log("<<< progressDoneHandle: " + this.currentStep() + "/" + this.numberOfSteps());
135 this.resetStatus();
136 MochiKit.Signal.signal(this, 'progressDone');
137 },
138
139 //=============================================================================
140 __syntaxFix__: "syntax fix"
141});
142
143Clipperz.PM.UI.Common.Controllers.ProgressBarController.defaultController = new Clipperz.PM.UI.Common.Controllers.ProgressBarController();
diff --git a/frontend/gamma/js/Clipperz/PM/UI/Common/Controllers/TabPanelController.js b/frontend/gamma/js/Clipperz/PM/UI/Common/Controllers/TabPanelController.js
new file mode 100644
index 0000000..fbc5929
--- a/dev/null
+++ b/frontend/gamma/js/Clipperz/PM/UI/Common/Controllers/TabPanelController.js
@@ -0,0 +1,188 @@
1/*
2
3Copyright 2008-2011 Clipperz Srl
4
5This file is part of Clipperz's Javascript Crypto Library.
6Javascript Crypto Library provides web developers with an extensive
7and efficient set of cryptographic functions. The library aims to
8obtain maximum execution speed while preserving modularity and
9reusability.
10For further information about its features and functionalities please
11refer to http://www.clipperz.com
12
13* Javascript Crypto Library is free software: you can redistribute
14 it and/or modify it under the terms of the GNU Affero General Public
15 License as published by the Free Software Foundation, either version
16 3 of the License, or (at your option) any later version.
17
18* Javascript Crypto Library is distributed in the hope that it will
19 be useful, but WITHOUT ANY WARRANTY; without even the implied
20 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21 See the GNU Affero General Public License for more details.
22
23* You should have received a copy of the GNU Affero General Public
24 License along with Javascript Crypto Library. If not, see
25 <http://www.gnu.org/licenses/>.
26
27*/
28
29Clipperz.Base.module('Clipperz.PM.UI.Common.Controllers');
30
31Clipperz.PM.UI.Common.Controllers.TabPanelController = function(args) {
32 args = args || {};
33
34 this._component = args.component;
35 this._configuration = args.configuration;
36 this._isEnabled = args.enabled || true;
37
38 this._selectedTab = null;
39 return this;
40}
41
42MochiKit.Base.update(Clipperz.PM.UI.Common.Controllers.TabPanelController.prototype, {
43
44 'toString': function() {
45 return "Clipperz.PM.UI.Common.Controllers.TabPanelController";
46 },
47
48 //-----------------------------------------------------------------------------
49
50 'component': function() {
51 return this._component;
52 },
53
54 'configuration': function() {
55 return this._configuration;
56 },
57
58 //-----------------------------------------------------------------------------
59
60 'getElement': function(anElementID) {
61 return this.component().getElement(anElementID);
62 },
63
64 'tabForTabElement': function(anElement) {
65 varresult;
66
67 for (result in this.configuration()) {
68 if (this.getElement(this.configuration()[result]['tab']) == anElement) {
69 break;
70 }
71 }
72
73 return result;
74 },
75
76 //-----------------------------------------------------------------------------
77
78 'setupTab': function(aConfiguration) {
79 vartabElement;
80
81 tabElement = this.getElement(aConfiguration['tab']);
82
83 MochiKit.DOM.removeElementClass(tabElement, 'selected');
84 MochiKit.Signal.connect(tabElement, 'onclick', this, 'handleTabClick')
85 },
86
87 'setupPanel': function(aConfiguration) {
88 this.hidePanel(aConfiguration['panel']);
89 },
90
91 'setup': function(args) {
92 args = args || {};
93
94 MochiKit.Base.map(MochiKit.Base.method(this, 'setupTab'),MochiKit.Base.values(this.configuration()));
95 MochiKit.Base.map(MochiKit.Base.method(this, 'setupPanel'),MochiKit.Base.values(this.configuration()));
96 this.selectTab(args.selected);
97 },
98
99 //-----------------------------------------------------------------------------
100
101 'hidePanel': function(aPanel) {
102 MochiKit.DOM.removeElementClass(this.getElement(aPanel), 'selected');
103 },
104
105 'selectTab': function(aTab) {
106 if ((aTab != this.selectedTab()) && (this.isEnabled())) {
107 if (this.selectedTab() != null) {
108 MochiKit.DOM.removeElementClass(this.getElement(this.configuration()[this.selectedTab()]['tab']),'selected');
109 MochiKit.DOM.removeElementClass(this.getElement(this.configuration()[this.selectedTab()]['panel']),'selected');
110 }
111
112 if (aTab != null) {
113 MochiKit.DOM.addElementClass(this.getElement(this.configuration()[aTab]['tab']),'selected');
114 MochiKit.DOM.addElementClass(this.getElement(this.configuration()[aTab]['panel']),'selected');
115 }
116
117 this.setSelectedTab(aTab);
118 MochiKit.Signal.signal(this, 'tabSelected', aTab);
119 }
120 },
121
122 //-----------------------------------------------------------------------------
123
124 'selectedTab': function() {
125 return this._selectedTab;
126 },
127
128 'setSelectedTab': function(aTab) {
129 this._selectedTab = aTab;
130 },
131
132 //-----------------------------------------------------------------------------
133
134 'selectedTabElement': function() {
135 var result;
136
137 if (this.selectedTab() != null) {
138 result = this.getElement(this.configuration()[this.selectedTab()]['tab']);
139 } else {
140 result = null;
141 }
142
143 return null;
144 },
145
146 'selectedTabPanelElement': function() {
147 var result;
148
149 if (this.selectedTab() != null) {
150 result = this.getElement(this.configuration()[this.selectedTab()]['panel']);
151 } else {
152 result = null;
153 }
154
155 return result;
156 },
157
158 //-----------------------------------------------------------------------------
159
160 'handleTabClick': function(anEvent) {
161 this.selectTab(this.tabForTabElement(anEvent.src()));
162 anEvent.preventDefault();
163 },
164
165 //=============================================================================
166
167 'isEnabled': function () {
168 return this._isEnabled;
169 },
170
171 'enable': function () {
172 this._isEnabled = true;
173 MochiKit.Base.map(MochiKit.Base.bind(function (aTabComponentID) {
174 MochiKit.DOM.removeElementClass(this.getElement(this.configuration()[aTabComponentID]['tab']), 'disabled');
175 }, this), MochiKit.Base.keys(this.configuration()));
176 },
177
178 'disable': function () {
179 this._isEnabled = false;
180 MochiKit.Base.map(MochiKit.Base.bind(function (aTabComponentID) {
181 MochiKit.DOM.addElementClass(this.getElement(this.configuration()[aTabComponentID]['tab']), 'disabled');
182 }, this), MochiKit.Base.keys(this.configuration()));
183 },
184
185 //=============================================================================
186
187 __syntaxFix__: "syntax fix"
188});
diff --git a/frontend/gamma/js/Clipperz/PM/UI/Common/Controllers/WizardController.js b/frontend/gamma/js/Clipperz/PM/UI/Common/Controllers/WizardController.js
new file mode 100644
index 0000000..868cea6
--- a/dev/null
+++ b/frontend/gamma/js/Clipperz/PM/UI/Common/Controllers/WizardController.js
@@ -0,0 +1,31 @@
1/*
2
3Copyright 2008-2011 Clipperz Srl
4
5This file is part of Clipperz's Javascript Crypto Library.
6Javascript Crypto Library provides web developers with an extensive
7and efficient set of cryptographic functions. The library aims to
8obtain maximum execution speed while preserving modularity and
9reusability.
10For further information about its features and functionalities please
11refer to http://www.clipperz.com
12
13* Javascript Crypto Library is free software: you can redistribute
14 it and/or modify it under the terms of the GNU Affero General Public
15 License as published by the Free Software Foundation, either version
16 3 of the License, or (at your option) any later version.
17
18* Javascript Crypto Library is distributed in the hope that it will
19 be useful, but WITHOUT ANY WARRANTY; without even the implied
20 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21 See the GNU Affero General Public License for more details.
22
23* You should have received a copy of the GNU Affero General Public
24 License along with Javascript Crypto Library. If not, see
25 <http://www.gnu.org/licenses/>.
26
27*/
28
29 //Still empty, but here it should be reasonable to factor in code duplicated between
30 //- DirectLoginWizardController
31 //- NewUserWizardController \ No newline at end of file