summaryrefslogtreecommitdiff
path: root/frontend/beta/js/Clipperz/PM/Components/RecordDetail/DirectLoginValueComponent.js
Unidiff
Diffstat (limited to 'frontend/beta/js/Clipperz/PM/Components/RecordDetail/DirectLoginValueComponent.js') (more/less context) (ignore whitespace changes)
-rw-r--r--frontend/beta/js/Clipperz/PM/Components/RecordDetail/DirectLoginValueComponent.js22
1 files changed, 10 insertions, 12 deletions
diff --git a/frontend/beta/js/Clipperz/PM/Components/RecordDetail/DirectLoginValueComponent.js b/frontend/beta/js/Clipperz/PM/Components/RecordDetail/DirectLoginValueComponent.js
index d210100..b478d94 100644
--- a/frontend/beta/js/Clipperz/PM/Components/RecordDetail/DirectLoginValueComponent.js
+++ b/frontend/beta/js/Clipperz/PM/Components/RecordDetail/DirectLoginValueComponent.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.Components) == 'undefined') { Clipperz.PM.Components = {}; } 26if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; }
29if (typeof(Clipperz.PM.Components.RecordDetail) == 'undefined') { Clipperz.PM.Components.RecordDetail = {}; } 27if (typeof(Clipperz.PM.Components.RecordDetail) == 'undefined') { Clipperz.PM.Components.RecordDetail = {}; }
30 28
31//############################################################################# 29//#############################################################################
32 30
33Clipperz.PM.Components.RecordDetail.DirectLoginValueComponent = function(anElement, args) { 31Clipperz.PM.Components.RecordDetail.DirectLoginValueComponent = function(anElement, args) {
34//MochiKit.Logging.logDebug(">>> new DirectLoginValueComponent"); 32//MochiKit.Logging.logDebug(">>> new DirectLoginValueComponent");
35 args = args || {}; 33 args = args || {};
36 34
37 Clipperz.PM.Components.RecordDetail.DirectLoginValueComponent.superclass.constructor.call(this, anElement, args); 35 Clipperz.PM.Components.RecordDetail.DirectLoginValueComponent.superclass.constructor.call(this, anElement, args);
38 36
39 this._directLoginInputValue = args.directLoginInputValue || null; 37 this._directLoginInputValue = args.directLoginInputValue || null;
40 this._value = this.directLoginInputValue().directLogin().formValues()[this.directLoginInputValue().name()]; 38 this._value = this.directLoginInputValue().directLogin().formValues()[this.directLoginInputValue().name()];
41 39
42 this.render(); 40 this.render();
43//MochiKit.Logging.logDebug("<<< new DirectLoginValueComponent - record: " + this.record()); 41//MochiKit.Logging.logDebug("<<< new DirectLoginValueComponent - record: " + this.record());
44 42
45 return this; 43 return this;
46} 44}
47 45
48//============================================================================= 46//=============================================================================
49 47
50YAHOO.extendX(Clipperz.PM.Components.RecordDetail.DirectLoginValueComponent, Clipperz.PM.Components.RecordDetail.AbstractComponent, { 48YAHOO.extendX(Clipperz.PM.Components.RecordDetail.DirectLoginValueComponent, Clipperz.PM.Components.RecordDetail.AbstractComponent, {
51 49
52 'toString': function() { 50 'toString': function() {
53 return "Clipperz.PM.Components.RecordDetail.DirectLoginValueComponent component - " + this.directLoginInputValue().name(); 51 return "Clipperz.PM.Components.RecordDetail.DirectLoginValueComponent component - " + this.directLoginInputValue().name();
54 }, 52 },
55 53
56 //------------------------------------------------------------------------- 54 //-------------------------------------------------------------------------
57 55
58 'directLoginInputValue': function() { 56 'directLoginInputValue': function() {
59 return this._directLoginInputValue; 57 return this._directLoginInputValue;
60 }, 58 },
61 59
62 //------------------------------------------------------------------------- 60 //-------------------------------------------------------------------------
63 61
64 'render': function() { 62 'render': function() {
65//MochiKit.Logging.logDebug(">>> DirectLoginValueComponent.render"); 63//MochiKit.Logging.logDebug(">>> DirectLoginValueComponent.render");
66 Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'td', cls:'directLoginDataLabelTD', children:[ 64 Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'td', cls:'directLoginDataLabelTD', children:[
67 {tag:'span', html:this.directLoginInputValue().name()} 65 {tag:'span', html:this.directLoginInputValue().name()}
68 ]}); 66 ]});
69//MochiKit.Logging.logDebug("--- DirectLoginValueComponent.render - 1"); 67//MochiKit.Logging.logDebug("--- DirectLoginValueComponent.render - 1");
70 Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'td', cls:'directLoginDataValueTD', children:[ 68 Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'td', cls:'directLoginDataValueTD', children:[
71 {tag:'span', id:this.getId('inputElement')} 69 {tag:'span', id:this.getId('inputElement')}
72 ]}); 70 ]});
73//MochiKit.Logging.logDebug("--- DirectLoginValueComponent.render - 2"); 71//MochiKit.Logging.logDebug("--- DirectLoginValueComponent.render - 2");
74 this.update(); 72 this.update();
75//MochiKit.Logging.logDebug("<<< DirectLoginValueComponent.render"); 73//MochiKit.Logging.logDebug("<<< DirectLoginValueComponent.render");
76 }, 74 },
77 75
78 //------------------------------------------------------------------------- 76 //-------------------------------------------------------------------------
79 77
80 'inputElementConfiguration': function() { 78 'inputElementConfiguration': function() {
81 var result; 79 var result;
82 var currentValue; 80 var currentValue;
83 81
84//MochiKit.Logging.logDebug(">>> DirectLoginValueComponent.inputElementConfiguration - " + this.directLoginInputValue().name()); 82//MochiKit.Logging.logDebug(">>> DirectLoginValueComponent.inputElementConfiguration - " + this.directLoginInputValue().name());
85 result = []; 83 result = [];
86 currentValue = this.value(); 84 currentValue = this.value();
87 85
88 switch (this.directLoginInputValue().type()) { 86 switch (this.directLoginInputValue().type()) {
89 case 'checkbox': 87 case 'checkbox':
90 var checkbox; 88 var checkbox;
91//{"type":"checkbox", "name":"rememberUsernameChk", "value":"checkbox"} 89//{"type":"checkbox", "name":"rememberUsernameChk", "value":"checkbox"}
92 checkbox = {tag:'input', id:this.getId('checkbox'), type:'checkbox'} 90 checkbox = {tag:'input', id:this.getId('checkbox'), type:'checkbox'}
93 if (currentValue == true) { 91 if (currentValue == true) {
94 checkbox.checked = true; 92 checkbox.checked = true;
95 } 93 }
96 result.push(checkbox); 94 result.push(checkbox);
97 break; 95 break;
98 96
99 case 'select': 97 case 'select':
100 var input; 98 var input;
101//{"type":"select", "name":"DOMAIN", "options":[{"selected":true, "label":"@tin.it", "value":"tin.it"}, {"selected":false, "label":"@virgilio.it", "value":"virgilio.it"}]} 99//{"type":"select", "name":"DOMAIN", "options":[{"selected":true, "label":"@tin.it", "value":"tin.it"}, {"selected":false, "label":"@virgilio.it", "value":"virgilio.it"}]}
102 input = {tag:'select', id:this.getId('select'), name:this.directLoginInputValue().name(), children:[]}; 100 input = {tag:'select', id:this.getId('select'), name:this.directLoginInputValue().name(), children:[]};
103 input.children.push({tag:'option', value:null, html:"---"}); 101 input.children.push({tag:'option', value:null, html:"---"});
104 MochiKit.Iter.forEach(this.directLoginInputValue().args()['options'], function(anOption) { 102 MochiKit.Iter.forEach(this.directLoginInputValue().args()['options'], function(anOption) {
105 var option; 103 var option;
106 104
107 //TODO: remove the value: field and replace it with element.dom.value = <some value> 105 //TODO: remove the value: field and replace it with element.dom.value = <some value>
108 option = {tag:'option', value:anOption['value'], html:anOption['label']} 106 option = {tag:'option', value:anOption['value'], html:anOption['label']}
109 if (currentValue == anOption['value']) { 107 if (currentValue == anOption['value']) {
110 option.selected = true; 108 option.selected = true;
111 } 109 }
112 input.children.push(option); 110 input.children.push(option);
113 }) 111 })
114 result.push(input); 112 result.push(input);
115 break; 113 break;
116 114
117 case 'radio': 115 case 'radio':
118 var name; 116 var name;
119 var radioBox; 117 var radioBox;
120 118
121//MochiKit.Logging.logDebug("--- DirectLoginValueComponent.inputElementConfiguration - 3"); 119//MochiKit.Logging.logDebug("--- DirectLoginValueComponent.inputElementConfiguration - 3");
122 name = this.getId(this.directLoginInputValue().name()); 120 name = this.getId(this.directLoginInputValue().name());
123 radioBox = {tag:'div', id:this.getId('radioBox'), children:[]}; 121 radioBox = {tag:'div', id:this.getId('radioBox'), children:[]};
124 result.push(radioBox); 122 result.push(radioBox);
125//MochiKit.Logging.logDebug("--- DirectLoginValueComponent.inputElementConfiguration - 3.1 - options.length: " + this.directLoginInputValue().args()['options'].length); 123//MochiKit.Logging.logDebug("--- DirectLoginValueComponent.inputElementConfiguration - 3.1 - options.length: " + this.directLoginInputValue().args()['options'].length);
126//{"name":"dominio", "type":"radio", "options":[{"value":"@alice.it", "checked":true}, {"value":"@tin.it", "checked":false}, {"value":"@virgilio.it", "checked":false}, {"value":"@tim.it", "checked":false}]} 124//{"name":"dominio", "type":"radio", "options":[{"value":"@alice.it", "checked":true}, {"value":"@tin.it", "checked":false}, {"value":"@virgilio.it", "checked":false}, {"value":"@tim.it", "checked":false}]}
127 125
128 MochiKit.Iter.forEach(this.directLoginInputValue().args()['options'], function(anOption) { 126 MochiKit.Iter.forEach(this.directLoginInputValue().args()['options'], function(anOption) {
129 varradio; 127 varradio;
130 128
131//MochiKit.Logging.logDebug("--- DirectLoginValueComponent.inputElementConfiguration - 3.1.1"); 129//MochiKit.Logging.logDebug("--- DirectLoginValueComponent.inputElementConfiguration - 3.1.1");
132 //TODO: remove the value: field and replace it with element.dom.value = <some value> 130 //TODO: remove the value: field and replace it with element.dom.value = <some value>
133 radio = {tag:'input', type:'radio', name:name, value:anOption['value']}; 131 radio = {tag:'input', type:'radio', name:name, value:anOption['value']};
134//MochiKit.Logging.logDebug("--- DirectLoginValueComponent.inputElementConfiguration - 3.1.2"); 132//MochiKit.Logging.logDebug("--- DirectLoginValueComponent.inputElementConfiguration - 3.1.2");
135 if (currentValue == anOption['value']) { 133 if (currentValue == anOption['value']) {
136//MochiKit.Logging.logDebug("--- DirectLoginValueComponent.inputElementConfiguration - 3.1.3"); 134//MochiKit.Logging.logDebug("--- DirectLoginValueComponent.inputElementConfiguration - 3.1.3");
137 radio.checked = true; 135 radio.checked = true;
138//MochiKit.Logging.logDebug("--- DirectLoginValueComponent.inputElementConfiguration - 3.1.4"); 136//MochiKit.Logging.logDebug("--- DirectLoginValueComponent.inputElementConfiguration - 3.1.4");
139 } 137 }
140//MochiKit.Logging.logDebug("--- DirectLoginValueComponent.inputElementConfiguration - 3.1.5"); 138//MochiKit.Logging.logDebug("--- DirectLoginValueComponent.inputElementConfiguration - 3.1.5");
141 radioBox.children.push({tag:'div', children:[ radio, {tag:'span', html:anOption['value']} ]}) 139 radioBox.children.push({tag:'div', children:[ radio, {tag:'span', html:anOption['value']} ]})
142//MochiKit.Logging.logDebug("--- DirectLoginValueComponent.inputElementConfiguration - 3.1.6"); 140//MochiKit.Logging.logDebug("--- DirectLoginValueComponent.inputElementConfiguration - 3.1.6");
143 }) 141 })
144//MochiKit.Logging.logDebug("--- DirectLoginValueComponent.inputElementConfiguration - 3.2"); 142//MochiKit.Logging.logDebug("--- DirectLoginValueComponent.inputElementConfiguration - 3.2");
145 break; 143 break;
146 } 144 }
147//MochiKit.Logging.logDebug("<<< DirectLoginValueComponent.inputElementConfiguration"); 145//MochiKit.Logging.logDebug("<<< DirectLoginValueComponent.inputElementConfiguration");
148 146
149 return result; 147 return result;
150 }, 148 },
151 149
152 //------------------------------------------------------------------------- 150 //-------------------------------------------------------------------------
153 151
154 'inputValue': function() { 152 'inputValue': function() {
155 var result; 153 var result;
156 154
157 switch (this.directLoginInputValue().type()) { 155 switch (this.directLoginInputValue().type()) {
158 case 'checkbox': 156 case 'checkbox':
159 result = this.getDom('checkbox').checked; 157 result = this.getDom('checkbox').checked;
160 break; 158 break;
161 case 'select': 159 case 'select':
162 result = this.getDom('select').value; 160 result = this.getDom('select').value;
163 break; 161 break;
164 case 'radio': 162 case 'radio':
165 var checkedRadioButtons; 163 var checkedRadioButtons;
166 164
167 checkedRadioButtons = MochiKit.Base.filter(function(aRadioButton) { return aRadioButton.dom.checked }, 165 checkedRadioButtons = MochiKit.Base.filter(function(aRadioButton) { return aRadioButton.dom.checked },
168 this.getElement('radioBox').getChildrenByTagName('input')); 166 this.getElement('radioBox').getChildrenByTagName('input'));
169 167
170 if (checkedRadioButtons.length == 0) { 168 if (checkedRadioButtons.length == 0) {
171 result = null; 169 result = null;
172 } else { 170 } else {
173 result = checkedRadioButtons[0].dom.value; 171 result = checkedRadioButtons[0].dom.value;
174 } 172 }
175 break; 173 break;
176 } 174 }
177 175
178 return result; 176 return result;
179 }, 177 },
180 178
181 //------------------------------------------------------------------------- 179 //-------------------------------------------------------------------------
182 180
183 'value': function() { 181 'value': function() {
184 return this._value; 182 return this._value;
185 }, 183 },
186 184
187 'setValue': function(aValue) { 185 'setValue': function(aValue) {
188 this._value = aValue; 186 this._value = aValue;
189 }, 187 },
190 188
191 //------------------------------------------------------------------------- 189 //-------------------------------------------------------------------------
192 190
193 'updateEditMode': function() { 191 'updateEditMode': function() {
194//MochiKit.Logging.logDebug(">>> DirectLoginValueComponent.updateEditMode - " + this); 192//MochiKit.Logging.logDebug(">>> DirectLoginValueComponent.updateEditMode - " + this);
195 this.getElement('inputElement').update(""); 193 this.getElement('inputElement').update("");
196//MochiKit.Logging.logDebug("--- DirectLoginValueComponent.updateEditMode - 1"); 194//MochiKit.Logging.logDebug("--- DirectLoginValueComponent.updateEditMode - 1");
197 Clipperz.YUI.DomHelper.append(this.getDom('inputElement'), {tag:'div', children:this.inputElementConfiguration()}); 195 Clipperz.YUI.DomHelper.append(this.getDom('inputElement'), {tag:'div', children:this.inputElementConfiguration()});
198//MochiKit.Logging.logDebug("<<< DirectLoginValueComponent.updateEditMode"); 196//MochiKit.Logging.logDebug("<<< DirectLoginValueComponent.updateEditMode");
199 }, 197 },
200 198
201 //------------------------------------------------------------------------- 199 //-------------------------------------------------------------------------
202 200
203 'updateViewMode': function() { 201 'updateViewMode': function() {
204//MochiKit.Logging.logDebug(">>> DirectLoginValueComponent.updateViewMode"); 202//MochiKit.Logging.logDebug(">>> DirectLoginValueComponent.updateViewMode");
205 // this.getElement('inputElement').update(this.directLoginInputValue().value()); 203 // this.getElement('inputElement').update(this.directLoginInputValue().value());
206 204
207 this.getElement('inputElement').update(""); 205 this.getElement('inputElement').update("");
208 206
209 switch (this.directLoginInputValue().type()) { 207 switch (this.directLoginInputValue().type()) {
210 case 'checkbox': 208 case 'checkbox':
211 if (this.value() == true) { 209 if (this.value() == true) {
212 this.getElement('inputElement').update(Clipperz.PM.Strings['directLoginConfigurationCheckBoxFieldSelectedValue']); 210 this.getElement('inputElement').update(Clipperz.PM.Strings['directLoginConfigurationCheckBoxFieldSelectedValue']);
213 } else { 211 } else {
214 this.getElement('inputElement').update(Clipperz.PM.Strings['directLoginConfigurationCheckBoxFieldNotSelectedValue']) 212 this.getElement('inputElement').update(Clipperz.PM.Strings['directLoginConfigurationCheckBoxFieldNotSelectedValue'])