summaryrefslogtreecommitdiff
path: root/frontend/gamma/js/Clipperz/PM/DataModel/DirectLoginInput.js
Unidiff
Diffstat (limited to 'frontend/gamma/js/Clipperz/PM/DataModel/DirectLoginInput.js') (more/less context) (show whitespace changes)
-rw-r--r--frontend/gamma/js/Clipperz/PM/DataModel/DirectLoginInput.js203
1 files changed, 203 insertions, 0 deletions
diff --git a/frontend/gamma/js/Clipperz/PM/DataModel/DirectLoginInput.js b/frontend/gamma/js/Clipperz/PM/DataModel/DirectLoginInput.js
new file mode 100644
index 0000000..673d5ee
--- a/dev/null
+++ b/frontend/gamma/js/Clipperz/PM/DataModel/DirectLoginInput.js
@@ -0,0 +1,203 @@
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(args) {
36 this._args = args;
37
38 return this;
39}
40
41Clipperz.PM.DataModel.DirectLoginInput.prototype = MochiKit.Base.update(null, {
42
43 'args': function() {
44 return this._args;
45 },
46
47 //-------------------------------------------------------------------------
48
49 'name': function() {
50 return this.args()['name'];
51 },
52
53 //-------------------------------------------------------------------------
54
55 'type': function() {
56 var result;
57
58 result = this.args()['type'];
59
60 if (result != null) {
61 result = result.toLowerCase();
62 }
63 return result;
64 },
65
66 //-------------------------------------------------------------------------
67
68 'options': function() {
69 return this.args()['options'];
70 },
71
72 //-------------------------------------------------------------------------
73
74 'value': function() {
75 return this.args()['value'];
76 },
77
78 //-------------------------------------------------------------------------
79 /*
80 'formConfiguration': function(someFormValues, someBindings, someFields) {
81 var result;
82//console.log("### DirectLoginInput.formConfiguration", someFields);
83 if (this.shouldSetValue()) {
84 switch (this.type()) {
85 case 'select':
86 var currentValue;
87 var options;
88
89 // currentValue = this.directLogin()._configuration['formValues'][this.name()];
90 currentValue = someFormValues[this.name()];
91 options = this.args()['options'];
92
93 result = MochiKit.DOM.SELECT({name:this.name()},
94 MochiKit.Base.map(function(anOption) {
95 var options;
96
97 options = {value:anOption['value']};
98 if (currentValue == anOption['value']) {
99 options.selected = true;
100 }
101
102 return MochiKit.DOM.OPTION(options, anOption['label'])
103 }, options)
104 )
105 break;
106 case 'checkbox':
107 var options;
108
109 options = {type:'checkbox', name: this.name()};
110 // if (this.directLogin()._configuration['formValues'][this.name()] == true) {
111 if (someFormValues[this.name()] == true) {
112 options['checked'] = true;
113 };
114
115 result = MochiKit.DOM.INPUT(options, null);
116 break;
117 case 'radio':
118 var currentName;
119 var currentValue;
120 var options;
121
122 currentName = this.name();
123 // currentValue = this.directLogin()._configuration['formValues'][this.name()];
124 currentValue = someFormValues[this.name()];
125 options = this.args()['options'];
126
127 result = MochiKit.DOM.DIV(null,
128 MochiKit.Base.map(function(anOption) {
129 var options;
130 var isChecked;
131 var inputNode;
132 var divNode;
133
134 options = {type:'radio', name:currentName, value:anOption['value']}
135 isChecked = (currentValue == anOption['value']);
136 if (isChecked) {
137 options.checked = true;
138 }
139
140 if (Clipperz_IEisBroken == true) {
141 var checkedValue;
142
143 checkedValue = (isChecked ? " CHECKED" : "");
144 inputNode = MochiKit.DOM.currentDocument().createElement("<INPUT TYPE='RADIO' NAME='" + currentName + "' VALUE='" + anOption['value'] + "'" + checkedValue + ">");
145 } else {
146 inputNode = MochiKit.DOM.INPUT(options, anOption['value']);
147 }
148 divNode = MochiKit.DOM.DIV(null, inputNode);
149
150 return divNode;
151 }, options)
152 );
153 break;
154 }
155 } else {
156 var binding;
157 // binding = this.directLogin().bindings()[this.name()];
158 binding = someBindings[this.name()];
159
160//console.log("### binding", binding);
161//if (binding != null) {
162 ///console.log(" binding.field()", binding.field());
163 ///console.log(" binding.field().value()", binding.field().value());
164 //console.log(" someFields[binding.fieldKey()].value()", someFields[binding.fieldKey()].value());
165//}
166 result = MochiKit.DOM.INPUT({
167 type:((this.type() != 'password') ? this.type() : 'text'),
168 name:this.name(),
169 // value:((binding != null)? binding.field().value() : this.value())
170 value:((binding != null)? someFields[binding.fieldKey()]['value'] : this.value())
171 // value:((binding != null)? someFields[binding.fieldKey()].value() : this.value())
172 }, null);
173 }
174
175 return result;
176 },
177 */
178 //-------------------------------------------------------------------------
179
180 'needsFormValue': function() {
181 var type;
182 var result;
183
184 type = this.type();
185 result = ((type == 'checkbox') || (type == 'radio') || (type == 'select'));
186
187 return result;
188 },
189
190 'needsBinding': function() {
191 var type;
192 var result;
193
194 type = this.type();
195 result = ((type == 'text') || (type == 'password'));
196
197 return result;
198 },
199
200 //-------------------------------------------------------------------------
201 __syntaxFix__: "syntax fix"
202});
203