summaryrefslogtreecommitdiff
path: root/frontend/beta/js/Clipperz/PM/Components/TextFormField.js
Unidiff
Diffstat (limited to 'frontend/beta/js/Clipperz/PM/Components/TextFormField.js') (more/less context) (ignore whitespace changes)
-rw-r--r--frontend/beta/js/Clipperz/PM/Components/TextFormField.js22
1 files changed, 10 insertions, 12 deletions
diff --git a/frontend/beta/js/Clipperz/PM/Components/TextFormField.js b/frontend/beta/js/Clipperz/PM/Components/TextFormField.js
index c6f0349..2b383ce 100644
--- a/frontend/beta/js/Clipperz/PM/Components/TextFormField.js
+++ b/frontend/beta/js/Clipperz/PM/Components/TextFormField.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 = {}; }
29 27
30Clipperz.PM.Components.TextFormField = function(anElement, args) { 28Clipperz.PM.Components.TextFormField = function(anElement, args) {
31 args = args || {}; 29 args = args || {};
32 30
33//MochiKit.Logging.logDebug(">>> new TextFormField"); 31//MochiKit.Logging.logDebug(">>> new TextFormField");
34 Clipperz.PM.Components.TextFormField.superclass.constructor.call(this, args); 32 Clipperz.PM.Components.TextFormField.superclass.constructor.call(this, args);
35 33
36 this._element = anElement; 34 this._element = anElement;
37 this._editMode = args.editMode || 'VIEW'; 35 this._editMode = args.editMode || 'VIEW';
38 this._value = args.value || ""; 36 this._value = args.value || "";
39 this._inputElement = null; 37 this._inputElement = null;
40 this._wrapper = null; 38 this._wrapper = null;
41 this._multiline = args.multiline || false; 39 this._multiline = args.multiline || false;
42 40
43 //this.multiline = args.multiline || true; 41 //this.multiline = args.multiline || true;
44 //this.editing = true; 42 //this.editing = true;
45 //this.completeOnBlur = true; 43 //this.completeOnBlur = true;
46 //this.autoSizeTask = new YAHOO.ext.util.DelayedTask(this.autoSize, this); 44 //this.autoSizeTask = new YAHOO.ext.util.DelayedTask(this.autoSize, this);
47 //this.textSizeEl = Clipperz.YUI.DomHelper.append(document.body, { 45 //this.textSizeEl = Clipperz.YUI.DomHelper.append(document.body, {
48 // tag: 'div', 46 // tag: 'div',
49 // cls: 'yinline-editor-sizer ' + (this.cls || '') 47 // cls: 'yinline-editor-sizer ' + (this.cls || '')
50 //}); 48 //});
51 49
52 this.render(); 50 this.render();
53//MochiKit.Logging.logDebug("<<< new TextFormField"); 51//MochiKit.Logging.logDebug("<<< new TextFormField");
54 52
55 return this; 53 return this;
56}; 54};
57 55
58YAHOO.extendX(Clipperz.PM.Components.TextFormField, Clipperz.PM.Components.BaseComponent, { 56YAHOO.extendX(Clipperz.PM.Components.TextFormField, Clipperz.PM.Components.BaseComponent, {
59 57
60 'toString': function() { 58 'toString': function() {
61 return "Clipperz.PM.Components.TextFormField"; 59 return "Clipperz.PM.Components.TextFormField";
62 }, 60 },
63 61
64 //----------------------------------------------------- 62 //-----------------------------------------------------
65 63
66 'value': function() { 64 'value': function() {
67 if (this.inputElement() != null) { 65 if (this.inputElement() != null) {
68 this._value = this.inputElement().dom.value; 66 this._value = this.inputElement().dom.value;
69 } 67 }
70 68
71 return this._value; 69 return this._value;
72 // return this.inlineEditor().getValue(); 70 // return this.inlineEditor().getValue();
73 }, 71 },
74 72
75 'setValue': function(aValue) { 73 'setValue': function(aValue) {
76 this._value = aValue; 74 this._value = aValue;
77 // this.getElement('viewComponent_Content').update(aValue); 75 // this.getElement('viewComponent_Content').update(aValue);
78 // this.inlineEditor().setValue(aValue); 76 // this.inlineEditor().setValue(aValue);
79 }, 77 },
80 78
81 //----------------------------------------------------- 79 //-----------------------------------------------------
82 80
83 'multiline': function() { 81 'multiline': function() {
84 return this._multiline; 82 return this._multiline;
85 }, 83 },
86 84
87 //----------------------------------------------------- 85 //-----------------------------------------------------
88 86
89 'editMode': function() { 87 'editMode': function() {
90 return this._editMode; 88 return this._editMode;
91 }, 89 },
92 90
93 'setEditMode': function(aValue) { 91 'setEditMode': function(aValue) {
94 this._editMode = aValue; 92 this._editMode = aValue;
95 }, 93 },
96 94
97 //----------------------------------------------------- 95 //-----------------------------------------------------
98 96
99 'inputElement': function() { 97 'inputElement': function() {
100 return this._inputElement; 98 return this._inputElement;
101 }, 99 },
102 100
103 'setInputElement': function(aValue) { 101 'setInputElement': function(aValue) {
104 this._inputElement = aValue; 102 this._inputElement = aValue;
105 }, 103 },
106 104
107 //----------------------------------------------------- 105 //-----------------------------------------------------
108 106
109 'on': function(anEventName, anHandler, aScope, shouldOverride) { 107 'on': function(anEventName, anHandler, aScope, shouldOverride) {
110//MochiKit.Logging.logDebug(">>> TextFormField.on - inputElement: " + this.inputElement()); 108//MochiKit.Logging.logDebug(">>> TextFormField.on - inputElement: " + this.inputElement());
111 return this.inputElement().on(anEventName, anHandler, aScope, shouldOverride); 109 return this.inputElement().on(anEventName, anHandler, aScope, shouldOverride);
112//MochiKit.Logging.logDebug("<<< TextFormField.on - inputElement: " + this.inputElement()); 110//MochiKit.Logging.logDebug("<<< TextFormField.on - inputElement: " + this.inputElement());
113 }, 111 },
114 112
115 //----------------------------------------------------- 113 //-----------------------------------------------------
116 114
117 'wrapper': function() { 115 'wrapper': function() {
118 return this._wrapper; 116 return this._wrapper;
119 }, 117 },
120 118
121 //----------------------------------------------------- 119 //-----------------------------------------------------
122 120
123 'render': function() { 121 'render': function() {
124 var editModeConfiguration; 122 var editModeConfiguration;
125 var viewModeConfiguration; 123 var viewModeConfiguration;
126 124
127 editModeConfiguration = {tag:'div', id:this.getId('editComponent'), children:[]}; 125 editModeConfiguration = {tag:'div', id:this.getId('editComponent'), children:[]};
128 if (this.multiline() == false) { 126 if (this.multiline() == false) {
129 editModeConfiguration.children.push({tag:'input', type:'text', id:this.getId('editComponent_input'), value:"this.value(1)"}); 127 editModeConfiguration.children.push({tag:'input', type:'text', id:this.getId('editComponent_input'), value:"this.value(1)"});
130 } else { 128 } else {
131 editModeConfiguration.children.push({tag:'textarea', id:this.getId('editComponent_input'), html:"this.value(2)"}); 129 editModeConfiguration.children.push({tag:'textarea', id:this.getId('editComponent_input'), html:"this.value(2)"});
132 } 130 }
133 131
134 viewModeConfiguration = {tag:'div', id:this.getId('viewComponent'), /*style:'border: 1px solid blue;',*/ children:[ 132 viewModeConfiguration = {tag:'div', id:this.getId('viewComponent'), /*style:'border: 1px solid blue;',*/ children:[
135 {tag:'span', id:this.getId('viewComponent_Content'), html:this.value()} 133 {tag:'span', id:this.getId('viewComponent_Content'), html:this.value()}
136 ]} 134 ]}
137 135
138//MochiKit.Logging.logDebug(">>> TextFormField.render"); 136//MochiKit.Logging.logDebug(">>> TextFormField.render");
139 this._wrapper = Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'div', id:this.getId('wrapper'), children:[ 137 this._wrapper = Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'div', id:this.getId('wrapper'), children:[
140 {tag:'div', id:this.getId('editModeBox'), children:[editModeConfiguration]}, 138 {tag:'div', id:this.getId('editModeBox'), children:[editModeConfiguration]},
141 {tag:'div', id:this.getId('viewModeBox'), children:[viewModeConfiguration]} 139 {tag:'div', id:this.getId('viewModeBox'), children:[viewModeConfiguration]}
142 ]}, true); 140 ]}, true);
143 141
144 this.getElement('editModeBox').setVisibilityMode(YAHOO.ext.Element.DISPLAY); 142 this.getElement('editModeBox').setVisibilityMode(YAHOO.ext.Element.DISPLAY);
145 this.getElement('viewModeBox').setVisibilityMode(YAHOO.ext.Element.DISPLAY); 143 this.getElement('viewModeBox').setVisibilityMode(YAHOO.ext.Element.DISPLAY);
146 144
147 this.getElement('editComponent_input').dom.value = this.value(); 145 this.getElement('editComponent_input').dom.value = this.value();
148 this.setInputElement(this.getElement('editComponent_input')); 146 this.setInputElement(this.getElement('editComponent_input'));
149 147
150 this.update(); 148 this.update();
151//MochiKit.Logging.logDebug("<<< TextFormField.render"); 149//MochiKit.Logging.logDebug("<<< TextFormField.render");
152 }, 150 },
153 151
154 //----------------------------------------------------- 152 //-----------------------------------------------------
155 153
156 'update': function(args) { 154 'update': function(args) {
157 args = args || {}; 155 args = args || {};
158 156
159//MochiKit.Logging.logDebug(">>> TextFormField.update"); 157//MochiKit.Logging.logDebug(">>> TextFormField.update");
160 if (typeof(args.value) != 'undefined') { 158 if (typeof(args.value) != 'undefined') {
161 this.setValue(args.value); 159 this.setValue(args.value);
162 } 160 }
163 if (typeof(args.editMode) != 'undefined') { 161 if (typeof(args.editMode) != 'undefined') {
164 this.setEditMode(args.editMode) 162 this.setEditMode(args.editMode)
165 } 163 }
166 164
167 if (this.editMode() == 'VIEW') { 165 if (this.editMode() == 'VIEW') {
168 this.updateViewMode(); 166 this.updateViewMode();
169 } else if (this.editMode() == 'EDIT') { 167 } else if (this.editMode() == 'EDIT') {
170 this.updateEditMode(); 168 this.updateEditMode();
171 } else { 169 } else {
172 //????? 170 //?????
173 } 171 }
174//MochiKit.Logging.logDebug("<<< TextFormField.update"); 172//MochiKit.Logging.logDebug("<<< TextFormField.update");
175 }, 173 },
176 174
177 //----------------------------------------------------- 175 //-----------------------------------------------------
178 176
179 'updateEditMode': function() { 177 'updateEditMode': function() {
180//MochiKit.Logging.logDebug(">>> TextFormField.updateEditMode"); 178//MochiKit.Logging.logDebug(">>> TextFormField.updateEditMode");
181 this.getElement('viewModeBox').hide(); 179 this.getElement('viewModeBox').hide();
182 this.getElement('editModeBox').show(); 180 this.getElement('editModeBox').show();
183 181
184 if (this.multiline() == false) { 182 if (this.multiline() == false) {
185 this.getElement('editComponent_input').dom.value = this.value(); 183 this.getElement('editComponent_input').dom.value = this.value();
186 } else { 184 } else {
187 this.getElement('editComponent_input').update(Clipperz.Base.sanitizeString(this.value())); 185 this.getElement('editComponent_input').update(Clipperz.Base.sanitizeString(this.value()));
188 } 186 }
189//MochiKit.Logging.logDebug("<<< TextFormField.updateEditMode"); 187//MochiKit.Logging.logDebug("<<< TextFormField.updateEditMode");
190 }, 188 },
191 189
192 //----------------------------------------------------- 190 //-----------------------------------------------------
193 191
194 'updateViewMode': function() { 192 'updateViewMode': function() {
195//MochiKit.Logging.logDebug(">>> TextFormField.updateViewMode"); 193//MochiKit.Logging.logDebug(">>> TextFormField.updateViewMode");
196 this.getElement('editModeBox').hide(); 194 this.getElement('editModeBox').hide();
197 this.getElement('viewModeBox').show(); 195 this.getElement('viewModeBox').show();
198 196
199 this.getElement('viewComponent_Content').update(Clipperz.Base.sanitizeString(this.value())); 197 this.getElement('viewComponent_Content').update(Clipperz.Base.sanitizeString(this.value()));
200//MochiKit.Logging.logDebug("<<< TextFormField.updateViewMode"); 198//MochiKit.Logging.logDebug("<<< TextFormField.updateViewMode");
201 }, 199 },
202 200
203 //##################################################### 201 //#####################################################
204 //##################################################### 202 //#####################################################
205 //##################################################### 203 //#####################################################
206 //##################################################### 204 //#####################################################
207 /* 205 /*
208 'onEnter': function(k, e) { 206 'onEnter': function(k, e) {
209MochiKit.Logging.logDebug(">>> TextFormField.onEnter"); 207MochiKit.Logging.logDebug(">>> TextFormField.onEnter");
210 if (this.multiline && (e.ctrlKey || e.shiftKey)) { 208 if (this.multiline && (e.ctrlKey || e.shiftKey)) {
211 return; 209 return;
212 } else { 210 } else {
213 this.completeEdit(); 211 this.completeEdit();
214 e.stopEvent(); 212 e.stopEvent();