summaryrefslogtreecommitdiff
path: root/frontend/gamma/js/Clipperz/PM/UI/Web/Components/CardDialogRecordFieldComponent.js
authorGiulio Cesare Solaroli <giulio.cesare@clipperz.com>2011-10-02 23:56:18 (UTC)
committer Giulio Cesare Solaroli <giulio.cesare@clipperz.com>2011-10-02 23:56:18 (UTC)
commitef68436ac04da078ffdcacd7e1f785473a303d45 (patch) (unidiff)
treec403752d66a2c4775f00affd4fa8431b29c5b68c /frontend/gamma/js/Clipperz/PM/UI/Web/Components/CardDialogRecordFieldComponent.js
parent597ecfbc0249d83e1b856cbd558340c01237a360 (diff)
downloadclipperz-ef68436ac04da078ffdcacd7e1f785473a303d45.zip
clipperz-ef68436ac04da078ffdcacd7e1f785473a303d45.tar.gz
clipperz-ef68436ac04da078ffdcacd7e1f785473a303d45.tar.bz2
First version of the newly restructured repository
Diffstat (limited to 'frontend/gamma/js/Clipperz/PM/UI/Web/Components/CardDialogRecordFieldComponent.js') (more/less context) (show whitespace changes)
-rw-r--r--frontend/gamma/js/Clipperz/PM/UI/Web/Components/CardDialogRecordFieldComponent.js190
1 files changed, 190 insertions, 0 deletions
diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/CardDialogRecordFieldComponent.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/CardDialogRecordFieldComponent.js
new file mode 100644
index 0000000..c1a7c13
--- a/dev/null
+++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/CardDialogRecordFieldComponent.js
@@ -0,0 +1,190 @@
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
29Clipperz.Base.module('Clipperz.PM.UI.Web.Components');
30
31Clipperz.PM.UI.Web.Components.CardDialogRecordFieldComponent = function(args) {
32 args = args || {};
33
34 Clipperz.PM.UI.Web.Components.CardDialogRecordFieldComponent.superclass.constructor.apply(this, arguments);
35
36 this._reference = args.reference|| Clipperz.Base.exception.raise('MandatoryParameter');
37 this._actionType = null;
38
39 return this;
40}
41
42//=============================================================================
43
44Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.CardDialogRecordFieldComponent, Clipperz.PM.UI.Common.Components.BaseComponent, {
45
46 //-------------------------------------------------------------------------
47
48 'toString': function () {
49 return "Clipperz.PM.UI.Web.Components.CardDialogRecordFieldComponent component";
50 },
51
52 //-------------------------------------------------------------------------
53
54 'renderSelf': function() {
55 this.append(this.element(), [
56 {tag:'td', cls:'fieldState'},
57 {tag:'td', cls:'fieldLabel', children:[
58 {tag:'input', cls:'label', id:this.getId('label')}
59 ]},
60 {tag:'td', cls:'fieldLock', children:[
61 {tag:'div', cls:'unlocked', id:this.getId('isHidden')}
62 ]},
63 {tag:'td', cls:'fieldValue', children:[
64 {tag:'div', cls:'unlocked', id:this.getId('valueWrapper'), children:[
65 {tag:'input', type:'text', cls:'value', id:this.getId('value')}
66 ]}
67 ]},
68 {tag:'td', cls:'fieldAction', children:[
69 {tag:'a', href:'#', id:this.getId('actionLink'), html:'&nbsp;'}
70 ]},
71 {tag:'td', cls:'fieldAddDelete', children:[
72 {tag:'div', cls:'delete', children:[
73 {tag:'span', children:[
74 {tag:'a', href:'#', id:this.getId('delete'), html:"delete"}
75 ]}
76 ]}
77 ]}
78 ]);
79
80 MochiKit.Signal.connect(this.getId('label'), 'onkeyup',MochiKit.Base.partial(MochiKit.Signal.signal, this, 'changedValue'));
81 MochiKit.Signal.connect(this.getId('isHidden'), 'onclick',this, 'toggleIsHidden');
82 MochiKit.Signal.connect(this.getId('value'), 'onkeyup',MochiKit.Base.partial(MochiKit.Signal.signal, this, 'changedValue'));
83 MochiKit.Signal.connect(this.getId('actionLink'), 'onclick',this, 'handleActionLink');
84 MochiKit.Signal.connect(this.getId('delete'), 'onclick',this, 'deleteField');
85 // MochiKit.Signal.connect(this.getId('delete'), 'onclick',MochiKit.Base.partial(MochiKit.Signal.signal, this, 'deleteField', this.reference()));
86 },
87
88 //-------------------------------------------------------------------------
89
90 'shouldShowElementWhileRendering': function () {
91 return false;
92 },
93
94 //=========================================================================
95
96 'reference': function () {
97 return this._reference;
98 },
99
100 //=========================================================================
101
102 'label': function () {
103 return this.getElement('label').value;
104 },
105
106 'setLabel': function (aValue) {
107 // this.getElement('label').value = Clipperz.Base.sanitizeString(aValue);
108 this.getElement('label').value = aValue;
109 },
110
111 //=========================================================================
112
113 'value': function () {
114 return this.getElement('value').value;
115 },
116
117 'setValue': function (aValue) {
118 // this.getElement('value').value = Clipperz.Base.sanitizeString(aValue);
119 this.getElement('value').value = aValue;
120 },
121
122 //-------------------------------------------------------------------------
123
124 'actionType': function () {
125 return this._actionType;
126 },
127
128 'setActionType': function (anActionType) {
129 this._actionType = anActionType;
130
131 switch (this._actionType) {
132 case 'NONE':
133 MochiKit.Style.hideElement(this.getId('actionLink'));
134 MochiKit.DOM.setElementClass(this.getId('actionLink'), '');
135 break;
136 case 'URL':
137 MochiKit.Style.showElement(this.getId('actionLink'));
138 MochiKit.DOM.setElementClass(this.getId('actionLink'), 'url');
139 break;
140 case 'EMAIL':
141 MochiKit.Style.showElement(this.getId('actionLink'));
142 MochiKit.DOM.setElementClass(this.getId('actionLink'), 'email');
143 break;
144 case 'PASSWORD':
145 MochiKit.Style.showElement(this.getId('actionLink'));
146 MochiKit.DOM.setElementClass(this.getId('actionLink'), 'password');
147 break;
148 }
149 },
150
151 //=========================================================================
152
153 'isHidden': function () {
154 // return this.getElement('value').value;
155 return MochiKit.DOM.hasElementClass(this.getElement('isHidden'), 'locked');
156 },
157
158 'setIsHidden': function (aValue) {
159 // this.getElement('value').value = Clipperz.Base.sanitizeString(aValue);
160 MochiKit.DOM.setElementClass(this.getElement('isHidden'), (aValue ? 'locked': 'unlocked'));
161 MochiKit.DOM.setElementClass(this.getElement('valueWrapper'), (aValue ? 'locked': 'unlocked'));
162 },
163
164 'toggleIsHidden': function (anEvent) {
165 anEvent.preventDefault();
166
167 this.setIsHidden(! this.isHidden());
168 MochiKit.Signal.signal(this, 'changedValue');
169 },
170
171 //=========================================================================
172
173 'handleActionLink': function (anEvent) {
174 anEvent.preventDefault();
175
176//console.log("ACTION LINK - " + this.actionType());
177 MochiKit.Signal.signal(this, 'performAction', this.reference(), anEvent.target());
178 },
179
180 //=========================================================================
181
182 'deleteField': function (anEvent) {
183 anEvent.preventDefault();
184
185 MochiKit.Signal.signal(this, 'deleteField', this.reference());
186 },
187
188 //=========================================================================
189 __syntaxFix__: "syntax fix"
190});