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