Diffstat (limited to 'frontend/gamma/js/Clipperz/PM/UI/Web/Components/DirectLoginEditingBindingComponent.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/gamma/js/Clipperz/PM/UI/Web/Components/DirectLoginEditingBindingComponent.js | 168 |
1 files changed, 168 insertions, 0 deletions
diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/DirectLoginEditingBindingComponent.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/DirectLoginEditingBindingComponent.js new file mode 100644 index 0000000..9a9c0b2 --- a/dev/null +++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/DirectLoginEditingBindingComponent.js | |||
@@ -0,0 +1,168 @@ | |||
1 | /* | ||
2 | |||
3 | Copyright 2008-2011 Clipperz Srl | ||
4 | |||
5 | This file is part of Clipperz's Javascript Crypto Library. | ||
6 | Javascript Crypto Library provides web developers with an extensive | ||
7 | and efficient set of cryptographic functions. The library aims to | ||
8 | obtain maximum execution speed while preserving modularity and | ||
9 | reusability. | ||
10 | For further information about its features and functionalities please | ||
11 | refer 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 | |||
29 | Clipperz.Base.module('Clipperz.PM.UI.Web.Components'); | ||
30 | |||
31 | Clipperz.PM.UI.Web.Components.DirectLoginEditingBindingComponent = function(args) { | ||
32 | args = args || {}; | ||
33 | |||
34 | Clipperz.PM.UI.Web.Components.DirectLoginEditingBindingComponent.superclass.constructor.apply(this, arguments); | ||
35 | |||
36 | this._formFieldName = args.formFieldName|| Clipperz.Base.exception.raise('MandatoryParameter'); | ||
37 | this._fields = args.fields || Clipperz.Base.exception.raise('MandatoryParameter'); | ||
38 | this._initiallySelectedFieldKey = args.selectedFieldKey|| null; | ||
39 | |||
40 | return this; | ||
41 | } | ||
42 | |||
43 | //============================================================================= | ||
44 | |||
45 | Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.DirectLoginEditingBindingComponent, Clipperz.PM.UI.Common.Components.BaseComponent, { | ||
46 | |||
47 | //------------------------------------------------------------------------- | ||
48 | |||
49 | 'toString': function () { | ||
50 | return "Clipperz.PM.UI.Web.Components.DirectLoginEditingBindingComponent component"; | ||
51 | }, | ||
52 | |||
53 | //------------------------------------------------------------------------- | ||
54 | |||
55 | 'formFieldName': function () { | ||
56 | return this._formFieldName; | ||
57 | }, | ||
58 | |||
59 | //------------------------------------------------------------------------- | ||
60 | |||
61 | 'fields': function () { | ||
62 | return this._fields; | ||
63 | }, | ||
64 | |||
65 | //------------------------------------------------------------------------- | ||
66 | |||
67 | 'selectedValue': function () { | ||
68 | var result; | ||
69 | |||
70 | result = this.getElement('select').value; | ||
71 | |||
72 | if (result == '---') { | ||
73 | result = null; | ||
74 | } | ||
75 | |||
76 | return result; | ||
77 | }, | ||
78 | |||
79 | 'initiallySelectedFieldKey': function () { | ||
80 | return this._initiallySelectedFieldKey; | ||
81 | }, | ||
82 | |||
83 | //========================================================================= | ||
84 | |||
85 | 'renderSelf': function() { | ||
86 | var initiallySelectedOptions; | ||
87 | |||
88 | this.append(this.element(), {tag:'div', id:this.getId('div'), cls:'binding', children:[ | ||
89 | {tag:'span', cls:'formFieldName', html:this.formFieldName()}, | ||
90 | {tag:'span', cls:'fieldLock', id:this.getId('isHidden'), children:[ | ||
91 | {tag:'a', href:'#', id:this.getId('showHide'), html:' '} | ||
92 | ]}, | ||
93 | {tag:'input', id:this.getId('input'), cls:'formFieldExampleValue', disabled:true, value:''}, | ||
94 | {tag:'select', name:this.formFieldName(), id:this.getId('select'), cls:'formFieldMatchinCardField', children: | ||
95 | MochiKit.Base.flattenArguments( | ||
96 | {tag:'option', value:'---', html:"---"}, | ||
97 | MochiKit.Base.map( | ||
98 | MochiKit.Base.bind(function (aField) { return {tag:'option', value:aField['reference'], html:aField['label']}; }, this), | ||
99 | this.fields() | ||
100 | ) | ||
101 | ) | ||
102 | } | ||
103 | ]}); | ||
104 | |||
105 | MochiKit.Signal.connect(this.getElement('select'), 'onchange', this, 'handleSelectChange'); | ||
106 | MochiKit.Signal.connect(this.getElement('showHide'), 'onclick', this, 'handleShowHide'); | ||
107 | |||
108 | if (! MochiKit.Base.isUndefinedOrNull(this.initiallySelectedFieldKey())) { | ||
109 | initiallySelectedOptions = MochiKit.Selector.findChildElements(this.element(), ['option[value=' + this.initiallySelectedFieldKey() + ']']); | ||
110 | if (initiallySelectedOptions.length == 1) { | ||
111 | MochiKit.DOM.updateNodeAttributes(initiallySelectedOptions[0], {selected:true}); | ||
112 | this.handleSelectChange(); | ||
113 | } | ||
114 | } | ||
115 | }, | ||
116 | |||
117 | //------------------------------------------------------------------------- | ||
118 | |||
119 | 'setFieldValue': function (aValue) { | ||
120 | this.getElement('input').value = aValue; | ||
121 | }, | ||
122 | |||
123 | 'isHidden': function () { | ||
124 | return MochiKit.DOM.hasElementClass(this.getElement('div'), 'locked'); | ||
125 | }, | ||
126 | |||
127 | 'setIsHidden': function (aValue) { | ||
128 | if (aValue == true) { | ||
129 | MochiKit.DOM.addElementClass(this.getElement('div'), 'locked'); | ||
130 | MochiKit.DOM.addElementClass(this.getElement('div'), 'showLocked'); | ||
131 | } else { | ||
132 | MochiKit.DOM.removeElementClass(this.getElement('div'), 'locked'); | ||
133 | MochiKit.DOM.removeElementClass(this.getElement('div'), 'showLocked'); | ||
134 | } | ||
135 | }, | ||
136 | |||
137 | 'isShowLocked': function () { | ||
138 | return MochiKit.DOM.hasElementClass(this.getElement('div'), 'showLocked'); | ||
139 | }, | ||
140 | |||
141 | //------------------------------------------------------------------------- | ||
142 | |||
143 | 'handleSelectChange': function (anEvent) { | ||
144 | // this.getElement('input').value = this.valueOfField(anEvent.src().value); | ||
145 | MochiKit.Signal.signal(this, 'bindChange', this); | ||
146 | }, | ||
147 | |||
148 | 'handleShowHide': function (anEvent) { | ||
149 | anEvent.preventDefault(); | ||
150 | |||
151 | if (this.isShowLocked()) { | ||
152 | MochiKit.DOM.removeElementClass(this.getElement('div'), 'showLocked'); | ||
153 | } else { | ||
154 | MochiKit.DOM.addElementClass(this.getElement('div'), 'showLocked'); | ||
155 | } | ||
156 | }, | ||
157 | |||
158 | //========================================================================= | ||
159 | __syntaxFix__: "syntax fix" | ||
160 | }); | ||
161 | |||
162 | |||
163 | |||
164 | |||
165 | |||
166 | |||
167 | |||
168 | |||