summaryrefslogtreecommitdiff
path: root/frontend/beta/js/Clipperz/PM/DataModel/DirectLoginInput.js
authorGiulio 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)
commitef68436ac04da078ffdcacd7e1f785473a303d45 (patch) (unidiff)
treec403752d66a2c4775f00affd4fa8431b29c5b68c /frontend/beta/js/Clipperz/PM/DataModel/DirectLoginInput.js
parent597ecfbc0249d83e1b856cbd558340c01237a360 (diff)
downloadclipperz-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/DataModel/DirectLoginInput.js') (more/less context) (ignore whitespace changes)
-rw-r--r--frontend/beta/js/Clipperz/PM/DataModel/DirectLoginInput.js229
1 files changed, 229 insertions, 0 deletions
diff --git a/frontend/beta/js/Clipperz/PM/DataModel/DirectLoginInput.js b/frontend/beta/js/Clipperz/PM/DataModel/DirectLoginInput.js
new file mode 100644
index 0000000..3302ed6
--- a/dev/null
+++ b/frontend/beta/js/Clipperz/PM/DataModel/DirectLoginInput.js
@@ -0,0 +1,229 @@
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
29if (typeof(Clipperz) == 'undefined') { Clipperz = {}; }
30if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; }
31if (typeof(Clipperz.PM.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; }
32
33//#############################################################################
34
35Clipperz.PM.DataModel.DirectLoginInput = function(aDirectLogin, args) {
36 args = args || {};
37
38//console.log(">>> new DirectLoginInput - args: %o" + args);
39 this._directLogin = aDirectLogin;
40 this._args = args;
41
42 return this;
43}
44
45Clipperz.PM.DataModel.DirectLoginInput.prototype = MochiKit.Base.update(null, {
46
47 'directLogin': function() {
48 return this._directLogin;
49 },
50
51 //-------------------------------------------------------------------------
52
53 'args': function() {
54 return this._args;
55 },
56
57 //-------------------------------------------------------------------------
58
59 'name': function() {
60 return this.args()['name'];
61 },
62
63 //-------------------------------------------------------------------------
64
65 'type': function() {
66 var result;
67
68 result = this.args()['type'];
69
70 if (result != null) {
71 result = result.toLowerCase();
72 }
73 return result;
74 },
75
76 //-------------------------------------------------------------------------
77
78 'value': function() {
79 return this.args()['value'];
80 },
81
82 //-------------------------------------------------------------------------
83
84 'formConfiguration': function() {
85 var result;
86
87//MochiKit.Logging.logDebug(">>> DirectLoginInput.formConfiguration - " + this.name());
88 if (this.shouldSetValue()) {
89//MochiKit.Logging.logDebug("--- DirectLoginInput.formConfiguration - 1");
90 switch (this.type()) {
91 case 'select':
92 var currentValue;
93 var options;
94
95//MochiKit.Logging.logDebug("--- DirectLoginInput.formConfiguration - 2");
96 currentValue = this.directLogin().formValues()[this.name()];
97//MochiKit.Logging.logDebug("--- DirectLoginInput.formConfiguration - 2.1");
98 options = this.args()['options'];
99//MochiKit.Logging.logDebug("--- DirectLoginInput.formConfiguration - 2.2");
100
101 result = MochiKit.DOM.SELECT({name:this.name()},
102 MochiKit.Base.map(function(anOption) {
103 var options;
104
105//MochiKit.Logging.logDebug("--- DirectLoginInput.formConfiguration - 2.3");
106 //TODO: remove the value: field and replace it with element.dom.value = <some value>
107 options = {value:anOption['value']};
108//MochiKit.Logging.logDebug("--- DirectLoginInput.formConfiguration - 2.4");
109 if (currentValue == anOption['value']) {
110//MochiKit.Logging.logDebug("--- DirectLoginInput.formConfiguration - 2.5");
111 options.selected = true;
112//MochiKit.Logging.logDebug("--- DirectLoginInput.formConfiguration - 2.6");
113 }
114//MochiKit.Logging.logDebug("--- DirectLoginInput.formConfiguration - 2.7");
115
116 return MochiKit.DOM.OPTION(options, anOption['label'])
117 }, options)
118 )
119//MochiKit.Logging.logDebug("--- DirectLoginInput.formConfiguration - 2.8");
120 break;
121 case 'checkbox':
122 var options;
123
124//MochiKit.Logging.logDebug("--- DirectLoginInput.formConfiguration - 3");
125 options = {type:'checkbox', name: this.name()};
126 if (this.directLogin().formValues()[this.name()] == true) {
127 options['checked'] = true;
128 };
129
130 result = MochiKit.DOM.INPUT(options, null);
131 break;
132 case 'radio':
133 var currentName;
134 var currentValue;
135 var options;
136
137//MochiKit.Logging.logDebug("--- DirectLoginInput.formConfiguration - 4");
138 currentName = this.name();
139//MochiKit.Logging.logDebug("--- DirectLoginInput.formConfiguration - 4.1");
140 currentValue = this.directLogin().formValues()[this.name()];
141//MochiKit.Logging.logDebug("--- DirectLoginInput.formConfiguration - 4.2");
142 options = this.args()['options'];
143//MochiKit.Logging.logDebug("--- DirectLoginInput.formConfiguration - 4.3");
144
145 result = MochiKit.DOM.DIV(null,
146 MochiKit.Base.map(function(anOption) {
147 var options;
148 var isChecked;
149 var inputNode;
150 var divNode;
151
152//MochiKit.Logging.logDebug("--- DirectLoginInput.formConfiguration - 4.4");
153 //TODO: remove the value: field and replace it with element.dom.value = <some value>
154 options = {type:'radio', name:currentName, value:anOption['value']}
155 isChecked = (currentValue == anOption['value']);
156//MochiKit.Logging.logDebug("--- DirectLoginInput.formConfiguration - 4.5");
157 if (isChecked) {
158//MochiKit.Logging.logDebug("--- DirectLoginInput.formConfiguration - 4.6");
159 options.checked = true;
160//MochiKit.Logging.logDebug("--- DirectLoginInput.formConfiguration - 4.7");
161 }
162//MochiKit.Logging.logDebug("--- DirectLoginInput.formConfiguration - 4.8 - options: " + Clipperz.Base.serializeJSON(options));
163//MochiKit.Logging.logDebug("--- DirectLoginInput.formConfiguration - 4.8 - value: " + anOption['value']);
164
165 if (Clipperz_IEisBroken == true) {
166 var checkedValue;
167
168//MochiKit.Logging.logDebug("--- DirectLoginInput.formConfiguration - 4.8.1");
169 checkedValue = (isChecked ? " CHECKED" : "");
170//MochiKit.Logging.logDebug("--- DirectLoginInput.formConfiguration - 4.8.2");
171 inputNode = MochiKit.DOM.currentDocument().createElement("<INPUT TYPE='RADIO' NAME='" + currentName + "' VALUE='" + anOption['value'] + "'" + checkedValue + ">");
172//MochiKit.Logging.logDebug("--- DirectLoginInput.formConfiguration - 4.8.3");
173 } else {
174//MochiKit.Logging.logDebug("--- DirectLoginInput.formConfiguration - 4.8.4");
175 inputNode = MochiKit.DOM.INPUT(options, anOption['value']);
176//MochiKit.Logging.logDebug("--- DirectLoginInput.formConfiguration - 4.8.5");
177 }
178//MochiKit.Logging.logDebug("--- DirectLoginInput.formConfiguration - 4.9");
179 divNode = MochiKit.DOM.DIV(null, inputNode);
180//MochiKit.Logging.logDebug("--- DirectLoginInput.formConfiguration - 4.10");
181
182 return divNode;
183 // return MochiKit.DOM.DIV(null, MochiKit.DOM.INPUT(options, anOption['value']));
184 }, options)
185 );
186//MochiKit.Logging.logDebug("--- DirectLoginInput.formConfiguration - 4.9");
187 break;
188 }
189 } else {
190 var binding;
191//MochiKit.Logging.logDebug("--- DirectLoginInput.formConfiguration - 5");
192 binding = this.directLogin().bindings()[this.name()];
193
194//MochiKit.Logging.logDebug("--- DirectLoginInput.formConfiguration - 6");
195 //TODO: remove the value: field and replace it with element.dom.value = <some value>
196 result = MochiKit.DOM.INPUT({
197 type:((this.type() != 'password') ? this.type() : 'text'),
198 // type:(((this.type() != 'password') && (this.type() != 'submit')) ? this.type() : 'text'),
199 name:this.name(),
200 value:((binding != null)? binding.field().value() : this.value())
201 }, null);
202//MochiKit.Logging.logDebug("--- DirectLoginInput.formConfiguration - 7");
203 }
204
205//MochiKit.Logging.logDebug("<<< DirectLoginInput.formConfiguration: ");
206 return result;
207 },
208
209 //-------------------------------------------------------------------------
210
211 'shouldSetValue': function() {
212 var type;
213 var result;
214
215//MochiKit.Logging.logDebug(">>> DirectLoginInput.shouldSetValue");
216 type = this.type();
217 result = ((type == 'checkbox') || (type == 'radio') || (type == 'select'));
218//if (result == true) {
219 //MochiKit.Logging.logDebug("DIRECT LOGIN INPUT need value: " + Clipperz.Base.serializeJSON(this.args()));
220//}
221//MochiKit.Logging.logDebug("<<< DirectLoginInput.shouldSetValue");
222 return result;
223 },
224
225 //-------------------------------------------------------------------------
226 __syntaxFix__: "syntax fix"
227
228});
229