summaryrefslogtreecommitdiff
path: root/frontend/delta/js/Clipperz/PM/DataModel/DirectLoginInput.js
Unidiff
Diffstat (limited to 'frontend/delta/js/Clipperz/PM/DataModel/DirectLoginInput.js') (more/less context) (ignore whitespace changes)
-rw-r--r--frontend/delta/js/Clipperz/PM/DataModel/DirectLoginInput.js192
1 files changed, 192 insertions, 0 deletions
diff --git a/frontend/delta/js/Clipperz/PM/DataModel/DirectLoginInput.js b/frontend/delta/js/Clipperz/PM/DataModel/DirectLoginInput.js
new file mode 100644
index 0000000..d9995fc
--- a/dev/null
+++ b/frontend/delta/js/Clipperz/PM/DataModel/DirectLoginInput.js
@@ -0,0 +1,192 @@
1/*
2
3Copyright 2008-2013 Clipperz Srl
4
5This file is part of Clipperz, the online password manager.
6For further information about its features and functionalities please
7refer to http://www.clipperz.com.
8
9* Clipperz is free software: you can redistribute it and/or modify it
10 under the terms of the GNU Affero General Public License as published
11 by the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13
14* Clipperz is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17 See the GNU Affero General Public License for more details.
18
19* You should have received a copy of the GNU Affero General Public
20 License along with Clipperz. If not, see http://www.gnu.org/licenses/.
21
22*/
23
24if (typeof(Clipperz) == 'undefined') { Clipperz = {}; }
25if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; }
26if (typeof(Clipperz.PM.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; }
27
28//#############################################################################
29
30Clipperz.PM.DataModel.DirectLoginInput = function(args) {
31 this._args = args;
32
33 return this;
34}
35
36Clipperz.PM.DataModel.DirectLoginInput.prototype = MochiKit.Base.update(null, {
37
38 'args': function() {
39 return this._args;
40 },
41
42 //-------------------------------------------------------------------------
43
44 'name': function() {
45 return this.args()['name'];
46 },
47
48 //-------------------------------------------------------------------------
49
50 'type': function() {
51 var result;
52
53 result = this.args()['type'];
54
55 if (result != null) {
56 result = result.toLowerCase();
57 }
58 return result;
59 },
60
61 //-------------------------------------------------------------------------
62
63 'options': function() {
64 return this.args()['options'];
65 },
66
67 //-------------------------------------------------------------------------
68
69 'value': function() {
70 return this.args()['value'];
71 },
72
73 //-------------------------------------------------------------------------
74 /*
75 'formConfiguration': function(someFormValues, someBindings, someFields) {
76 var result;
77
78 if (this.shouldSetValue()) {
79 switch (this.type()) {
80 case 'select':
81 var currentValue;
82 var options;
83
84 // currentValue = this.directLogin()._configuration['formValues'][this.name()];
85 currentValue = someFormValues[this.name()];
86 options = this.args()['options'];
87
88 result = MochiKit.DOM.SELECT({name:this.name()},
89 MochiKit.Base.map(function(anOption) {
90 var options;
91
92 options = {value:anOption['value']};
93 if (currentValue == anOption['value']) {
94 options.selected = true;
95 }
96
97 return MochiKit.DOM.OPTION(options, anOption['label'])
98 }, options)
99 )
100 break;
101 case 'checkbox':
102 var options;
103
104 options = {type:'checkbox', name: this.name()};
105 // if (this.directLogin()._configuration['formValues'][this.name()] == true) {
106 if (someFormValues[this.name()] == true) {
107 options['checked'] = true;
108 };
109
110 result = MochiKit.DOM.INPUT(options, null);
111 break;
112 case 'radio':
113 var currentName;
114 var currentValue;
115 var options;
116
117 currentName = this.name();
118 // currentValue = this.directLogin()._configuration['formValues'][this.name()];
119 currentValue = someFormValues[this.name()];
120 options = this.args()['options'];
121
122 result = MochiKit.DOM.DIV(null,
123 MochiKit.Base.map(function(anOption) {
124 var options;
125 var isChecked;
126 var inputNode;
127 var divNode;
128
129 options = {type:'radio', name:currentName, value:anOption['value']}
130 isChecked = (currentValue == anOption['value']);
131 if (isChecked) {
132 options.checked = true;
133 }
134
135 if (Clipperz_IEisBroken == true) {
136 var checkedValue;
137
138 checkedValue = (isChecked ? " CHECKED" : "");
139 inputNode = MochiKit.DOM.currentDocument().createElement("<INPUT TYPE='RADIO' NAME='" + currentName + "' VALUE='" + anOption['value'] + "'" + checkedValue + ">");
140 } else {
141 inputNode = MochiKit.DOM.INPUT(options, anOption['value']);
142 }
143 divNode = MochiKit.DOM.DIV(null, inputNode);
144
145 return divNode;
146 }, options)
147 );
148 break;
149 }
150 } else {
151 var binding;
152 // binding = this.directLogin().bindings()[this.name()];
153 binding = someBindings[this.name()];
154
155 result = MochiKit.DOM.INPUT({
156 type:((this.type() != 'password') ? this.type() : 'text'),
157 name:this.name(),
158 // value:((binding != null)? binding.field().value() : this.value())
159 value:((binding != null)? someFields[binding.fieldKey()]['value'] : this.value())
160 // value:((binding != null)? someFields[binding.fieldKey()].value() : this.value())
161 }, null);
162 }
163
164 return result;
165 },
166 */
167 //-------------------------------------------------------------------------
168
169 'needsFormValue': function() {
170 var type;
171 var result;
172
173 type = this.type();
174 result = ((type == 'checkbox') || (type == 'radio') || (type == 'select'));
175
176 return result;
177 },
178
179 'needsBinding': function() {
180 var type;
181 var result;
182
183 type = this.type();
184 result = ((type == 'text') || (type == 'password'));
185
186 return result;
187 },
188
189 //-------------------------------------------------------------------------
190 __syntaxFix__: "syntax fix"
191});
192