summaryrefslogtreecommitdiff
path: root/frontend/beta/js/Clipperz/PM/Components/RecordDetail/DirectLoginsComponent.js
Unidiff
Diffstat (limited to 'frontend/beta/js/Clipperz/PM/Components/RecordDetail/DirectLoginsComponent.js') (more/less context) (show whitespace changes)
-rw-r--r--frontend/beta/js/Clipperz/PM/Components/RecordDetail/DirectLoginsComponent.js199
1 files changed, 199 insertions, 0 deletions
diff --git a/frontend/beta/js/Clipperz/PM/Components/RecordDetail/DirectLoginsComponent.js b/frontend/beta/js/Clipperz/PM/Components/RecordDetail/DirectLoginsComponent.js
new file mode 100644
index 0000000..3292a95
--- a/dev/null
+++ b/frontend/beta/js/Clipperz/PM/Components/RecordDetail/DirectLoginsComponent.js
@@ -0,0 +1,199 @@
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
29if (typeof(Clipperz) == 'undefined') { Clipperz = {}; }
30if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; }
31if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; }
32if (typeof(Clipperz.PM.Components.RecordDetail) == 'undefined') { Clipperz.PM.Components.RecordDetail = {}; }
33
34//#############################################################################
35
36Clipperz.PM.Components.RecordDetail.DirectLoginsComponent = function(anElement, args) {
37//MochiKit.Logging.logDebug(">>> new Clipperz.PM.Components.RecordDetail.DirectLoginsComponent");
38 args = args || {};
39
40//MochiKit.Logging.logDebug("--- new Clipperz.PM.Components.RecordDetail.DirectLoginsComponent - 0");
41 Clipperz.PM.Components.RecordDetail.DirectLoginsComponent.superclass.constructor.call(this, anElement, args);
42//MochiKit.Logging.logDebug("--- new Clipperz.PM.Components.RecordDetail.DirectLoginsComponent - 1");
43
44 this._addDirectLoginButton = null;
45
46//MochiKit.Logging.logDebug("--- new Clipperz.PM.Components.RecordDetail.DirectLoginsComponent - 2");
47 this.mainComponent().addEditComponent(this);
48//MochiKit.Logging.logDebug("--- new Clipperz.PM.Components.RecordDetail.DirectLoginsComponent - 3");
49 this.render();
50//MochiKit.Logging.logDebug("<<< new Clipperz.PM.Components.RecordDetail.DirectLoginsComponent");
51
52 return this;
53}
54
55//=============================================================================
56
57YAHOO.extendX(Clipperz.PM.Components.RecordDetail.DirectLoginsComponent, Clipperz.PM.Components.RecordDetail.AbstractComponent, {
58
59 'toString': function() {
60 return "Clipperz.PM.Components.RecordDetail.DirectLoginsComponent component";
61 },
62
63 //-------------------------------------------------------------------------
64
65 'addDirectLoginButton': function() {
66 return this._addDirectLoginButton;
67 },
68
69 'setAddDirectLoginButton': function(aValue) {
70 this._addDirectLoginButton = aValue;
71 },
72
73 //-------------------------------------------------------------------------
74
75 'render': function() {
76 this.element().update("");
77
78 Clipperz.YUI.DomHelper.append(this.element().dom,
79 {tag:'div', cls:'directLoginsRecordBox', children:[
80 {tag:'h3', htmlString:Clipperz.PM.Strings['recordDetailDirectLoginBlockTitle']},
81 {tag:'ul', id:this.getId('directLogins')},
82
83 {tag:'div', cls:'addDirectLoginBox', id:this.getId('addDirectLogin'), children:[
84 {tag:'div', cls:'addDirectLoginBoxContent', children:[
85 {tag:'div', cls:'bookmarkletConfiguration', children:[
86 // {tag:'span', htmlString:Clipperz.PM.Strings['newRecordWizardBookmarkletConfigurationLabel']},
87 {tag:'div', htmlString:Clipperz.PM.Strings['recordDetailNewDirectLoginDescription']},
88 {tag:'textarea', id:this.getId('addDirectLoginTextarea')}
89 ]},
90 {tag:'div', id:this.getId('addDirectLoginButton')}
91 ]}
92 ]}
93 ]}
94 );
95
96 if (MochiKit.Base.keys(this.record().directLogins()).length == 0) {
97//MochiKit.Logging.logDebug("--- DirectLoginsComponent.render - 3");
98 Clipperz.YUI.DomHelper.append(this.getElement('directLogins'),
99 {tag:'li', children:[
100 // {tag:'span', htmlString:Clipperz.PM.Strings['recordDetailDirectLoginBlockNoDirectLoginConfiguredLabel']}
101 {tag:'div', cls:'recordDetailNoDirectLoginDescriptionBox', htmlString:Clipperz.PM.Strings['recordDetailDirectLoginBlockNoDirectLoginConfiguredDescription']}
102 ]}
103 );
104//MochiKit.Logging.logDebug("--- DirectLoginsComponent.render - 4");
105 } else {
106//MochiKit.Logging.logDebug("--- DirectLoginsComponent.render - 5");
107 for (directLoginReference in this.record().directLogins()) {
108//MochiKit.Logging.logDebug("--- DirectLoginsComponent.render - 6");
109 this.addDirectLogin(this.record().directLogins()[directLoginReference]);
110//MochiKit.Logging.logDebug("--- DirectLoginsComponent.render - 7");
111 }
112//MochiKit.Logging.logDebug("--- DirectLoginsComponent.render - 8");
113 }
114//MochiKit.Logging.logDebug("--- DirectLoginsComponent.render - 9");
115
116 this.setAddDirectLoginButton(new YAHOO.ext.Button(this.getDom('addDirectLoginButton'), {
117 text:Clipperz.PM.Strings['recordDetailAddNewDirectLoginButtonLabel'],
118 handler:this.addNewDirectLogin,
119 scope:this
120 }));
121 MochiKit.Signal.connect(this.getId('addDirectLoginTextarea'), 'onkeydown', this, 'onkeydown');
122//MochiKit.Logging.logDebug("--- DirectLoginsComponent.render - 11");
123
124 this.update();
125//MochiKit.Logging.logDebug("<<< DirectLoginsComponent.render");
126 },
127
128 //-------------------------------------------------------------------------
129
130 'addDirectLogin': function(aDirectLogin) {
131//MochiKit.Logging.logDebug(">>> DirectLoginsComponent.addDirectLogin");
132 new Clipperz.PM.Components.RecordDetail.DirectLoginComponent(
133 Clipperz.YUI.DomHelper.append(this.getDom('directLogins'), {tag:'div'}, true),
134 {
135 mainComponent:this.mainComponent(),
136 directLogin:aDirectLogin
137 }
138 );
139//MochiKit.Logging.logDebug("<<< DirectLoginsComponent.addDirectLogin");
140 },
141
142 //-------------------------------------------------------------------------
143
144 'addNewDirectLogin': function() {
145 varnewDirectLogin;
146 varconfiguration;
147
148//MochiKit.Logging.logDebug(">>> DirectLoginsComponent.addNewDirectLogin");
149 if (MochiKit.Base.keys(this.record().directLogins()).length == 0) {
150 this.getElement('directLogins').update("");
151 }
152
153 this.mainComponent().synchronizeComponentValues();
154
155 this.mainComponent().exitModalView();
156 configuration = Clipperz.PM.BookmarkletProcessor.checkBookmarkletConfiguration(
157 this.getDom('addDirectLoginTextarea').value,
158 this.getDom('addDirectLoginButton'),
159 MochiKit.Base.method(this.mainComponent(), 'enterModalView')
160 );
161 this.mainComponent().enterModalView();
162
163 newDirectLogin = new Clipperz.PM.DataModel.DirectLogin({record:this.record(),
164 label:configuration['page']['title'],
165 bookmarkletVersion:'0.2',
166 // bookmarkletVersion:configuration['version'],
167 formData:configuration['form']});
168 this.record().addDirectLogin(newDirectLogin);
169 this.addDirectLogin(newDirectLogin);
170 this.getDom('addDirectLoginTextarea').value = "";
171//MochiKit.Logging.logDebug("<<< DirectLoginsComponent.addNewDirectLogin");
172 },
173
174 //-------------------------------------------------------------------------
175
176 'updateViewMode': function() {
177 this.getElement('addDirectLogin').setVisibilityMode(YAHOO.ext.Element.DISPLAY);
178 this.getElement('addDirectLogin').hide();
179 },
180
181 //-------------------------------------------------------------------------
182
183 'updateEditMode': function() {
184 this.getElement('addDirectLogin').show();
185 },
186
187 //-------------------------------------------------------------------------
188
189 'onkeydown': function(anEvent) {
190//MochiKit.Logging.logDebug(">>> onkeydown - " + anEvent.src().id + ": " + anEvent.key().code);
191 if (anEvent.key().code == 13) {
192 this.addNewDirectLogin();
193 }
194 },
195
196 //-------------------------------------------------------------------------
197 __syntaxFix__: "syntax fix"
198});
199