Diffstat (limited to 'frontend/beta/js/Clipperz/PM/Components/RecordDetail/DirectLoginBindingComponent.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/beta/js/Clipperz/PM/Components/RecordDetail/DirectLoginBindingComponent.js | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/frontend/beta/js/Clipperz/PM/Components/RecordDetail/DirectLoginBindingComponent.js b/frontend/beta/js/Clipperz/PM/Components/RecordDetail/DirectLoginBindingComponent.js index 36dd9a8..0e4640e 100644 --- a/frontend/beta/js/Clipperz/PM/Components/RecordDetail/DirectLoginBindingComponent.js +++ b/frontend/beta/js/Clipperz/PM/Components/RecordDetail/DirectLoginBindingComponent.js | |||
@@ -1,171 +1,169 @@ | |||
1 | /* | 1 | /* |
2 | 2 | ||
3 | Copyright 2008-2011 Clipperz Srl | 3 | Copyright 2008-2013 Clipperz Srl |
4 | 4 | ||
5 | This file is part of Clipperz Community Edition. | 5 | This file is part of Clipperz, the online password manager. |
6 | Clipperz Community Edition is an online password manager. | ||
7 | For further information about its features and functionalities please | 6 | For further information about its features and functionalities please |
8 | refer to http://www.clipperz.com. | 7 | refer 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 | ||
26 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | 24 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } |
27 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | 25 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } |
28 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } | 26 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } |
29 | if (typeof(Clipperz.PM.Components.RecordDetail) == 'undefined') { Clipperz.PM.Components.RecordDetail = {}; } | 27 | if (typeof(Clipperz.PM.Components.RecordDetail) == 'undefined') { Clipperz.PM.Components.RecordDetail = {}; } |
30 | 28 | ||
31 | //############################################################################# | 29 | //############################################################################# |
32 | 30 | ||
33 | Clipperz.PM.Components.RecordDetail.DirectLoginBindingComponent = function(anElement, args) { | 31 | Clipperz.PM.Components.RecordDetail.DirectLoginBindingComponent = function(anElement, args) { |
34 | //MochiKit.Logging.logDebug(">>> new DirectLoginBindingComponent"); | 32 | //MochiKit.Logging.logDebug(">>> new DirectLoginBindingComponent"); |
35 | args = args || {}; | 33 | args = args || {}; |
36 | 34 | ||
37 | Clipperz.PM.Components.RecordDetail.DirectLoginBindingComponent.superclass.constructor.call(this, anElement, args); | 35 | Clipperz.PM.Components.RecordDetail.DirectLoginBindingComponent.superclass.constructor.call(this, anElement, args); |
38 | 36 | ||
39 | this._directLoginBinding = args.directLoginBinding || null; | 37 | this._directLoginBinding = args.directLoginBinding || null; |
40 | this.render(); | 38 | this.render(); |
41 | 39 | ||
42 | Clipperz.NotificationCenter.register(this.record(), 'addNewRecordField',this, 'syncAndUpdateEditMode'); | 40 | Clipperz.NotificationCenter.register(this.record(), 'addNewRecordField',this, 'syncAndUpdateEditMode'); |
43 | Clipperz.NotificationCenter.register(this.record(), 'removedField', this, 'syncAndUpdateEditMode'); | 41 | Clipperz.NotificationCenter.register(this.record(), 'removedField', this, 'syncAndUpdateEditMode'); |
44 | Clipperz.NotificationCenter.register(this.record(), 'updatedFieldLabel',this, 'syncAndUpdateEditMode'); | 42 | Clipperz.NotificationCenter.register(this.record(), 'updatedFieldLabel',this, 'syncAndUpdateEditMode'); |
45 | //MochiKit.Logging.logDebug("<<< new DirectLoginBindingComponent"); | 43 | //MochiKit.Logging.logDebug("<<< new DirectLoginBindingComponent"); |
46 | 44 | ||
47 | return this; | 45 | return this; |
48 | } | 46 | } |
49 | 47 | ||
50 | //============================================================================= | 48 | //============================================================================= |
51 | 49 | ||
52 | YAHOO.extendX(Clipperz.PM.Components.RecordDetail.DirectLoginBindingComponent, Clipperz.PM.Components.RecordDetail.AbstractComponent, { | 50 | YAHOO.extendX(Clipperz.PM.Components.RecordDetail.DirectLoginBindingComponent, Clipperz.PM.Components.RecordDetail.AbstractComponent, { |
53 | 51 | ||
54 | 'toString': function() { | 52 | 'toString': function() { |
55 | return "Clipperz.PM.Components.RecordDetail.DirectLoginBindingComponent component"; | 53 | return "Clipperz.PM.Components.RecordDetail.DirectLoginBindingComponent component"; |
56 | }, | 54 | }, |
57 | 55 | ||
58 | //------------------------------------------------------------------------- | 56 | //------------------------------------------------------------------------- |
59 | 57 | ||
60 | 'directLoginBinding': function() { | 58 | 'directLoginBinding': function() { |
61 | return this._directLoginBinding; | 59 | return this._directLoginBinding; |
62 | }, | 60 | }, |
63 | 61 | ||
64 | //------------------------------------------------------------------------- | 62 | //------------------------------------------------------------------------- |
65 | 63 | ||
66 | 'render': function() { | 64 | 'render': function() { |
67 | // Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'span', style:'font-weight:bold;', html:this.directLoginBinding().key()}) | 65 | // Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'span', style:'font-weight:bold;', html:this.directLoginBinding().key()}) |
68 | // Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'span', html:this.directLoginBinding().value()}) | 66 | // Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'span', html:this.directLoginBinding().value()}) |
69 | //MochiKit.Logging.logDebug(">>> DirectLoginBindingComponent.render"); | 67 | //MochiKit.Logging.logDebug(">>> DirectLoginBindingComponent.render"); |
70 | Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'td', cls:'directLoginBindingLabelTD', children:[ | 68 | Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'td', cls:'directLoginBindingLabelTD', children:[ |
71 | {tag:'span', html:this.directLoginBinding().key()} | 69 | {tag:'span', html:this.directLoginBinding().key()} |
72 | ]}); | 70 | ]}); |
73 | //MochiKit.Logging.logDebug("--- DirectLoginBindingComponent.render - 1"); | 71 | //MochiKit.Logging.logDebug("--- DirectLoginBindingComponent.render - 1"); |
74 | Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'td', cls:'directLoginBindingValueTD', children:[ | 72 | Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'td', cls:'directLoginBindingValueTD', children:[ |
75 | {tag:'div', id:this.getId('editModeBox'), children:[ | 73 | {tag:'div', id:this.getId('editModeBox'), children:[ |
76 | {tag:'select', id:this.getId('select'), children:this.recordFieldOptions()} | 74 | {tag:'select', id:this.getId('select'), children:this.recordFieldOptions()} |
77 | ]}, | 75 | ]}, |
78 | {tag:'div', id:this.getId('viewModeBox'), children:[ | 76 | {tag:'div', id:this.getId('viewModeBox'), children:[ |
79 | {tag:'span', id:this.getId('viewValue'), html:""} | 77 | {tag:'span', id:this.getId('viewValue'), html:""} |
80 | ]} | 78 | ]} |
81 | ]}); | 79 | ]}); |
82 | //MochiKit.Logging.logDebug("--- DirectLoginBindingComponent.render - 2"); | 80 | //MochiKit.Logging.logDebug("--- DirectLoginBindingComponent.render - 2"); |
83 | this.getElement('editModeBox').setVisibilityMode(YAHOO.ext.Element.DISPLAY); | 81 | this.getElement('editModeBox').setVisibilityMode(YAHOO.ext.Element.DISPLAY); |
84 | this.getElement('viewModeBox').setVisibilityMode(YAHOO.ext.Element.DISPLAY); | 82 | this.getElement('viewModeBox').setVisibilityMode(YAHOO.ext.Element.DISPLAY); |
85 | 83 | ||
86 | this.update(); | 84 | this.update(); |
87 | //MochiKit.Logging.logDebug("<<< DirectLoginBindingComponent.render"); | 85 | //MochiKit.Logging.logDebug("<<< DirectLoginBindingComponent.render"); |
88 | }, | 86 | }, |
89 | 87 | ||
90 | //------------------------------------------------------------------------- | 88 | //------------------------------------------------------------------------- |
91 | 89 | ||
92 | 'recordFieldOptions': function() { | 90 | 'recordFieldOptions': function() { |
93 | varresult; | 91 | varresult; |
94 | var option; | 92 | var option; |
95 | varrecordFieldKey; | 93 | varrecordFieldKey; |
96 | varrecordFields; | 94 | varrecordFields; |
97 | 95 | ||
98 | //MochiKit.Logging.logDebug(">>> DirectLoginBindingComponent.recordFieldOptions"); | 96 | //MochiKit.Logging.logDebug(">>> DirectLoginBindingComponent.recordFieldOptions"); |
99 | recordFields = this.directLoginBinding().directLogin().record().currentVersion().fields(); | 97 | recordFields = this.directLoginBinding().directLogin().record().currentVersion().fields(); |
100 | result = []; | 98 | result = []; |
101 | option = {tag:'option', value:null, html:'---'}; | 99 | option = {tag:'option', value:null, html:'---'}; |
102 | result.push(option); | 100 | result.push(option); |
103 | for (recordFieldKey in recordFields) { | 101 | for (recordFieldKey in recordFields) { |
104 | //TODO: remove the value: field and replace it with element.dom.value = <some value> | 102 | //TODO: remove the value: field and replace it with element.dom.value = <some value> |
105 | option = {tag:'option', value:recordFieldKey, html:recordFields[recordFieldKey].label()} | 103 | option = {tag:'option', value:recordFieldKey, html:recordFields[recordFieldKey].label()} |
106 | if (recordFieldKey == this.directLoginBinding().fieldKey()) { | 104 | if (recordFieldKey == this.directLoginBinding().fieldKey()) { |
107 | option['selected'] = true; | 105 | option['selected'] = true; |
108 | } | 106 | } |
109 | result.push(option); | 107 | result.push(option); |
110 | } | 108 | } |
111 | //MochiKit.Logging.logDebug("<<< DirectLoginBindingComponent.recordFieldOptions"); | 109 | //MochiKit.Logging.logDebug("<<< DirectLoginBindingComponent.recordFieldOptions"); |
112 | 110 | ||
113 | return result; | 111 | return result; |
114 | }, | 112 | }, |
115 | 113 | ||
116 | //------------------------------------------------------------------------- | 114 | //------------------------------------------------------------------------- |
117 | 115 | ||
118 | 'syncAndUpdateEditMode': function() { | 116 | 'syncAndUpdateEditMode': function() { |
119 | this.synchronizeComponentValues(); | 117 | this.synchronizeComponentValues(); |
120 | this.updateEditMode(); | 118 | this.updateEditMode(); |
121 | }, | 119 | }, |
122 | 120 | ||
123 | 'updateEditMode': function() { | 121 | 'updateEditMode': function() { |
124 | varselectElementBox; | 122 | varselectElementBox; |
125 | 123 | ||
126 | //MochiKit.Logging.logDebug(">>> DirectLoginBindingComponent.updateEditMode"); | 124 | //MochiKit.Logging.logDebug(">>> DirectLoginBindingComponent.updateEditMode"); |
127 | this.getElement('viewModeBox').hide(); | 125 | this.getElement('viewModeBox').hide(); |
128 | 126 | ||
129 | selectElementBox = this.getElement('editModeBox'); | 127 | selectElementBox = this.getElement('editModeBox'); |
130 | selectElementBox.update(""); | 128 | selectElementBox.update(""); |
131 | 129 | ||
132 | Clipperz.YUI.DomHelper.append(selectElementBox.dom, {tag:'select', id:this.getId('select'), children:this.recordFieldOptions()}); | 130 | Clipperz.YUI.DomHelper.append(selectElementBox.dom, {tag:'select', id:this.getId('select'), children:this.recordFieldOptions()}); |
133 | 131 | ||
134 | /* | 132 | /* |
135 | selectElement = this.getElement('select'); | 133 | selectElement = this.getElement('select'); |
136 | 134 | ||
137 | selectElement.update(""); | 135 | selectElement.update(""); |
138 | MochiKit.Iter.forEach(this.recordFieldOptions(), function(anOption) { | 136 | MochiKit.Iter.forEach(this.recordFieldOptions(), function(anOption) { |
139 | Clipperz.YUI.DomHelper.append(selectElement.dom, anOption); | 137 | Clipperz.YUI.DomHelper.append(selectElement.dom, anOption); |
140 | }); | 138 | }); |
141 | */ | 139 | */ |
142 | 140 | ||
143 | 141 | ||
144 | this.getElement('editModeBox').show(); | 142 | this.getElement('editModeBox').show(); |
145 | //MochiKit.Logging.logDebug("<<< DirectLoginBindingComponent.updateEditMode"); | 143 | //MochiKit.Logging.logDebug("<<< DirectLoginBindingComponent.updateEditMode"); |
146 | }, | 144 | }, |
147 | 145 | ||
148 | //------------------------------------------------------------------------- | 146 | //------------------------------------------------------------------------- |
149 | 147 | ||
150 | 'updateViewMode': function() { | 148 | 'updateViewMode': function() { |
151 | //MochiKit.Logging.logDebug(">>> DirectLoginBindingComponent.updateViewMode"); | 149 | //MochiKit.Logging.logDebug(">>> DirectLoginBindingComponent.updateViewMode"); |
152 | this.getElement('editModeBox').hide(); | 150 | this.getElement('editModeBox').hide(); |
153 | this.getElement('viewModeBox').show(); | 151 | this.getElement('viewModeBox').show(); |
154 | 152 | ||
155 | this.getElement('viewValue').update(this.directLoginBinding().field().label()); | 153 | this.getElement('viewValue').update(this.directLoginBinding().field().label()); |
156 | //MochiKit.Logging.logDebug("<<< DirectLoginBindingComponent.updateViewMode"); | 154 | //MochiKit.Logging.logDebug("<<< DirectLoginBindingComponent.updateViewMode"); |
157 | }, | 155 | }, |
158 | 156 | ||
159 | //------------------------------------------------------------------------- | 157 | //------------------------------------------------------------------------- |
160 | 158 | ||
161 | 'synchronizeComponentValues': function() { | 159 | 'synchronizeComponentValues': function() { |
162 | //MochiKit.Logging.logDebug(">>> DirectLoginBindingComponent.synchronizeComponentValues") | 160 | //MochiKit.Logging.logDebug(">>> DirectLoginBindingComponent.synchronizeComponentValues") |
163 | //MochiKit.Logging.logDebug("--- DirectLoginBindingComponent.synchronizeComponentValues - 1 - " + this.getId('select')); | 161 | //MochiKit.Logging.logDebug("--- DirectLoginBindingComponent.synchronizeComponentValues - 1 - " + this.getId('select')); |
164 | this.directLoginBinding().setFieldKey(this.getDom('select').value); | 162 | this.directLoginBinding().setFieldKey(this.getDom('select').value); |
165 | //MochiKit.Logging.logDebug("<<< DirectLoginBindingComponent.synchronizeComponentValues"); | 163 | //MochiKit.Logging.logDebug("<<< DirectLoginBindingComponent.synchronizeComponentValues"); |
166 | }, | 164 | }, |
167 | 165 | ||
168 | //------------------------------------------------------------------------- | 166 | //------------------------------------------------------------------------- |
169 | __syntaxFix__: "syntax fix" | 167 | __syntaxFix__: "syntax fix" |
170 | }); | 168 | }); |
171 | 169 | ||