summaryrefslogtreecommitdiff
path: root/frontend/gamma/js/Clipperz/PM/UI/Common/Components/SimpleMessagePanel.js
Unidiff
Diffstat (limited to 'frontend/gamma/js/Clipperz/PM/UI/Common/Components/SimpleMessagePanel.js') (more/less context) (ignore whitespace changes)
-rw-r--r--frontend/gamma/js/Clipperz/PM/UI/Common/Components/SimpleMessagePanel.js15
1 files changed, 6 insertions, 9 deletions
diff --git a/frontend/gamma/js/Clipperz/PM/UI/Common/Components/SimpleMessagePanel.js b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/SimpleMessagePanel.js
index b9bb850..1992154 100644
--- a/frontend/gamma/js/Clipperz/PM/UI/Common/Components/SimpleMessagePanel.js
+++ b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/SimpleMessagePanel.js
@@ -1,282 +1,279 @@
1/* 1/*
2 2
3Copyright 2008-2011 Clipperz Srl 3Copyright 2008-2011 Clipperz Srl
4 4
5This file is part of Clipperz's Javascript Crypto Library. 5This file is part of Clipperz Community Edition.
6Javascript Crypto Library provides web developers with an extensive 6Clipperz Community Edition is an online password manager.
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 7For further information about its features and functionalities please
11refer to http://www.clipperz.com 8refer to http://www.clipperz.com.
12 9
13* Javascript Crypto Library is free software: you can redistribute 10* Clipperz Community Edition is free software: you can redistribute
14 it and/or modify it under the terms of the GNU Affero General Public 11 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 12 License as published by the Free Software Foundation, either version
16 3 of the License, or (at your option) any later version. 13 3 of the License, or (at your option) any later version.
17 14
18* Javascript Crypto Library is distributed in the hope that it will 15* Clipperz Community Edition is distributed in the hope that it will
19 be useful, but WITHOUT ANY WARRANTY; without even the implied 16 be useful, but WITHOUT ANY WARRANTY; without even the implied
20 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 17 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21 See the GNU Affero General Public License for more details. 18 See the GNU Affero General Public License for more details.
22 19
23* You should have received a copy of the GNU Affero General Public 20* You should have received a copy of the GNU Affero General Public
24 License along with Javascript Crypto Library. If not, see 21 License along with Clipperz Community Edition. If not, see
25 <http://www.gnu.org/licenses/>. 22 <http://www.gnu.org/licenses/>.
26 23
27*/ 24*/
28 25
29Clipperz.Base.module('Clipperz.PM.UI.Web.Components'); 26Clipperz.Base.module('Clipperz.PM.UI.Web.Components');
30 27
31Clipperz.PM.UI.Common.Components.SimpleMessagePanel = function(args) { 28Clipperz.PM.UI.Common.Components.SimpleMessagePanel = function(args) {
32 args = args || {}; 29 args = args || {};
33 30
34 Clipperz.PM.UI.Common.Components.SimpleMessagePanel.superclass.constructor.apply(this, arguments); 31 Clipperz.PM.UI.Common.Components.SimpleMessagePanel.superclass.constructor.apply(this, arguments);
35 32
36 this._title = args.title || Clipperz.Base.exception.raise('MandatoryParameter'); 33 this._title = args.title || Clipperz.Base.exception.raise('MandatoryParameter');
37 this._text = args.text || Clipperz.Base.exception.raise('MandatoryParameter'); 34 this._text = args.text || Clipperz.Base.exception.raise('MandatoryParameter');
38 this._type = args.type || Clipperz.Base.exception.raise('MandatoryParameter'); //ALERT, INFO, ERROR 35 this._type = args.type || Clipperz.Base.exception.raise('MandatoryParameter'); //ALERT, INFO, ERROR
39 this._buttons = args.buttons || Clipperz.Base.exception.raise('MandatoryParameter'); 36 this._buttons = args.buttons || Clipperz.Base.exception.raise('MandatoryParameter');
40 37
41 this._buttonComponents = []; 38 this._buttonComponents = [];
42 this._deferred = null; 39 this._deferred = null;
43 40
44 this.renderModalMask(); 41 this.renderModalMask();
45 42
46 return this; 43 return this;
47} 44}
48 45
49//============================================================================= 46//=============================================================================
50 47
51Clipperz.Base.extend(Clipperz.PM.UI.Common.Components.SimpleMessagePanel, Clipperz.PM.UI.Common.Components.BaseComponent, { 48Clipperz.Base.extend(Clipperz.PM.UI.Common.Components.SimpleMessagePanel, Clipperz.PM.UI.Common.Components.BaseComponent, {
52 49
53 //------------------------------------------------------------------------- 50 //-------------------------------------------------------------------------
54 51
55 'toString': function () { 52 'toString': function () {
56 return "Clipperz.PM.UI.Common.Components.SimpleMessagePanel component"; 53 return "Clipperz.PM.UI.Common.Components.SimpleMessagePanel component";
57 }, 54 },
58 55
59 //------------------------------------------------------------------------- 56 //-------------------------------------------------------------------------
60 57
61 'deferred': function() { 58 'deferred': function() {
62 if (this._deferred == null) { 59 if (this._deferred == null) {
63 this._deferred = new Clipperz.Async.Deferred("SimpleMessagePanel.deferred", {trace:false}); 60 this._deferred = new Clipperz.Async.Deferred("SimpleMessagePanel.deferred", {trace:false});
64 } 61 }
65 62
66 return this._deferred; 63 return this._deferred;
67 }, 64 },
68 65
69 //------------------------------------------------------------------------- 66 //-------------------------------------------------------------------------
70 67
71 'title': function () { 68 'title': function () {
72 return this._title; 69 return this._title;
73 }, 70 },
74 71
75 'setTitle': function (aValue) { 72 'setTitle': function (aValue) {
76 this._title = aValue; 73 this._title = aValue;
77 74
78 if (this.getElement('title') != null) { 75 if (this.getElement('title') != null) {
79 this.getElement('title').innerHTML = aValue; 76 this.getElement('title').innerHTML = aValue;
80 } 77 }
81 }, 78 },
82 79
83 //------------------------------------------------------------------------- 80 //-------------------------------------------------------------------------
84 81
85 'text': function () { 82 'text': function () {
86 return this._text; 83 return this._text;
87 }, 84 },
88 85
89 'setText': function (aValue) { 86 'setText': function (aValue) {
90 this._text = aValue; 87 this._text = aValue;
91 88
92 if (this.getElement('text') != null) { 89 if (this.getElement('text') != null) {
93 this.getElement('text').innerHTML = aValue; 90 this.getElement('text').innerHTML = aValue;
94 } 91 }
95 }, 92 },
96 93
97 //------------------------------------------------------------------------- 94 //-------------------------------------------------------------------------
98 95
99 'type': function () { 96 'type': function () {
100 return this._type; 97 return this._type;
101 }, 98 },
102 99
103 'setType': function (aValue) { 100 'setType': function (aValue) {
104 if (this.getElement('icon') != null) { 101 if (this.getElement('icon') != null) {
105 MochiKit.DOM.removeElementClass(this.getId('icon'), this._type); 102 MochiKit.DOM.removeElementClass(this.getId('icon'), this._type);
106 MochiKit.DOM.addElementClass(this.getId('icon'), aValue); 103 MochiKit.DOM.addElementClass(this.getId('icon'), aValue);
107 } 104 }
108 105
109 this._type = aValue; 106 this._type = aValue;
110 }, 107 },
111 108
112 //------------------------------------------------------------------------- 109 //-------------------------------------------------------------------------
113 110
114 'buttons': function () { 111 'buttons': function () {
115 return this._buttons; 112 return this._buttons;
116 }, 113 },
117 114
118 'setButtons': function (someValues) { 115 'setButtons': function (someValues) {
119 MochiKit.Iter.forEach(this.buttonComponents(), MochiKit.Base.methodcaller('clear')); 116 MochiKit.Iter.forEach(this.buttonComponents(), MochiKit.Base.methodcaller('clear'));
120 117
121 this._buttons = someValues; 118 this._buttons = someValues;
122 119
123 if (this.getElement('buttonArea') != null) { 120 if (this.getElement('buttonArea') != null) {
124 this.renderButtons(); 121 this.renderButtons();
125 } 122 }
126 }, 123 },
127 124
128 //......................................................................... 125 //.........................................................................
129 126
130 'buttonComponents': function () { 127 'buttonComponents': function () {
131 return this._buttonComponents; 128 return this._buttonComponents;
132 }, 129 },
133 130
134 //------------------------------------------------------------------------- 131 //-------------------------------------------------------------------------
135 132
136 'renderSelf': function() { 133 'renderSelf': function() {
137 this.append(this.element(), {tag:'div', cls:'SimpleMessagePanel', id:this.getId('panel'), children: [ 134 this.append(this.element(), {tag:'div', cls:'SimpleMessagePanel', id:this.getId('panel'), children: [
138 {tag:'div', cls:'header', children:[]}, 135 {tag:'div', cls:'header', children:[]},
139 {tag:'div', cls:'body', children:[ 136 {tag:'div', cls:'body', children:[
140 {tag:'div', id:this.getId('icon'),cls:'img ' + this.type(), children:[{tag:'div'}]}, 137 {tag:'div', id:this.getId('icon'),cls:'img ' + this.type(), children:[{tag:'div'}]},
141 {tag:'h3', id:this.getId('title'),html:this.title()}, 138 {tag:'h3', id:this.getId('title'),html:this.title()},
142 {tag:'p', id:this.getId('text'),html:this.text()}, 139 {tag:'p', id:this.getId('text'),html:this.text()},
143 {tag:'div', id:this.getId('container')}, 140 {tag:'div', id:this.getId('container')},
144 {tag:'div', id:this.getId('buttonArea'), cls:'buttonArea', children:[]} 141 {tag:'div', id:this.getId('buttonArea'), cls:'buttonArea', children:[]}
145 ]}, 142 ]},
146 {tag:'div', cls:'footer', children:[]} 143 {tag:'div', cls:'footer', children:[]}
147 ]}); 144 ]});
148 145
149 MochiKit.Signal.connect(this.getId('panel'), 'onkeydown', this, 'keyDownHandler'); 146 MochiKit.Signal.connect(this.getId('panel'), 'onkeydown', this, 'keyDownHandler');
150 147
151 this.renderButtons(); 148 this.renderButtons();
152 }, 149 },
153 150
154 //------------------------------------------------------------------------- 151 //-------------------------------------------------------------------------
155 152
156 'renderButtons': function () { 153 'renderButtons': function () {
157 this.getElement('buttonArea').innerHTML = ''; 154 this.getElement('buttonArea').innerHTML = '';
158 155
159 MochiKit.Base.map(MochiKit.Base.bind(function (aButton) { 156 MochiKit.Base.map(MochiKit.Base.bind(function (aButton) {
160 var buttonElement; 157 var buttonElement;
161 var buttonComponent; 158 var buttonComponent;
162 159
163 // element = this.append(this.getElement('buttonArea'), {tag:'div', cls:'button' + (aButton['isDefault'] === true ? ' default' : ''), children:[ 160 // element = this.append(this.getElement('buttonArea'), {tag:'div', cls:'button' + (aButton['isDefault'] === true ? ' default' : ''), children:[
164 // {tag:'a', href:'#'/*, id:this.getId('buttonLink')*/, html:aButton['text']} 161 // {tag:'a', href:'#'/*, id:this.getId('buttonLink')*/, html:aButton['text']}
165 // ]}); 162 // ]});
166 163
167 buttonElement = this.append(this.getElement('buttonArea'), {tag:'div'}); 164 buttonElement = this.append(this.getElement('buttonArea'), {tag:'div'});
168 buttonComponent = new Clipperz.PM.UI.Common.Components.Button({'element':buttonElement, 'text':aButton['text'], 'isDefault':aButton['isDefault']}); 165 buttonComponent = new Clipperz.PM.UI.Common.Components.Button({'element':buttonElement, 'text':aButton['text'], 'isDefault':aButton['isDefault']});
169 this.buttonComponents().push(buttonComponent); 166 this.buttonComponents().push(buttonComponent);
170 167
171 MochiKit.Signal.connect(buttonComponent, 'onclick', MochiKit.Base.method(this, 'buttonEventHandler', aButton)); 168 MochiKit.Signal.connect(buttonComponent, 'onclick', MochiKit.Base.method(this, 'buttonEventHandler', aButton));
172 }, this), MochiKit.Iter.reversed(this.buttons())); 169 }, this), MochiKit.Iter.reversed(this.buttons()));
173 }, 170 },
174 171
175 //------------------------------------------------------------------------- 172 //-------------------------------------------------------------------------
176 173
177 'displayElement': function() { 174 'displayElement': function() {
178 return this.getElement('panel'); 175 return this.getElement('panel');
179 }, 176 },
180 177
181 //------------------------------------------------------------------------- 178 //-------------------------------------------------------------------------
182 179
183 'closeOk': function () { 180 'closeOk': function () {
184 this.deferred().callback(); 181 this.deferred().callback();
185 this._deferred = null; 182 this._deferred = null;
186 }, 183 },
187 184
188 'closeCancel': function () { 185 'closeCancel': function () {
189 this.deferred().cancel(); 186 this.deferred().cancel();
190 this._deferred = null; 187 this._deferred = null;
191 }, 188 },
192 189
193 'closeError': function () { 190 'closeError': function () {
194 this.deferred().errback(); 191 this.deferred().errback();
195 this._deferred = null; 192 this._deferred = null;
196 }, 193 },
197 194
198 //------------------------------------------------------------------------- 195 //-------------------------------------------------------------------------
199 196
200 'buttonEventHandler': function(aButton, anEvent) { 197 'buttonEventHandler': function(aButton, anEvent) {
201 anEvent.preventDefault(); 198 anEvent.preventDefault();
202 199
203 // MochiKit.Signal.signal(this, 'cancelEvent'); 200 // MochiKit.Signal.signal(this, 'cancelEvent');
204 switch (aButton['result']) { 201 switch (aButton['result']) {
205 case 'OK': 202 case 'OK':
206//console.log("==> OK"); 203//console.log("==> OK");
207 this.closeOk(); 204 this.closeOk();
208 break; 205 break;
209 case 'CANCEL': 206 case 'CANCEL':
210//console.log("==> CANCEL"); 207//console.log("==> CANCEL");
211 this.closeCancel(); 208 this.closeCancel();
212 break; 209 break;
213 default: 210 default:
214//console.log("==> ????"); 211//console.log("==> ????");
215 this.closeError(); 212 this.closeError();
216 break; 213 break;
217 } 214 }
218//console.log("<=="); 215//console.log("<==");
219 }, 216 },
220 217
221 //------------------------------------------------------------------------- 218 //-------------------------------------------------------------------------
222 219
223 'deferredShow': function (someArgs, aResult) { 220 'deferredShow': function (someArgs, aResult) {
224 this.deferredShowModal(someArgs); 221 this.deferredShowModal(someArgs);
225 222
226 this.deferred().addMethod(this, 'deferredHideModal', {closeToElement:someArgs.onOkCloseToElement }); 223 this.deferred().addMethod(this, 'deferredHideModal', {closeToElement:someArgs.onOkCloseToElement });
227 this.deferred().addErrback (MochiKit.Base.method(this, 'deferredHideModal', {closeToElement:someArgs.onCancelCloseToElement })); 224 this.deferred().addErrback (MochiKit.Base.method(this, 'deferredHideModal', {closeToElement:someArgs.onCancelCloseToElement }));
228 this.deferred().addCallback(MochiKit.Async.succeed, aResult); 225 this.deferred().addCallback(MochiKit.Async.succeed, aResult);
229 226
230 return this.deferred(); 227 return this.deferred();
231 }, 228 },
232 229
233 //------------------------------------------------------------------------- 230 //-------------------------------------------------------------------------
234 231
235 'modalDialogMask': function () { 232 'modalDialogMask': function () {
236 return this.getId('modalDialogMask'); 233 return this.getId('modalDialogMask');
237 }, 234 },
238 235
239 'modalDialog': function () { 236 'modalDialog': function () {
240 return this.getId('modalDialog'); 237 return this.getId('modalDialog');
241 }, 238 },
242 239
243 'modalDialogFrame': function() { 240 'modalDialogFrame': function() {
244 return this.getId('modalDialogFrame'); 241 return this.getId('modalDialogFrame');
245 }, 242 },
246 243
247 //------------------------------------------------------------------------- 244 //-------------------------------------------------------------------------
248 245
249 'renderModalMask': function () { 246 'renderModalMask': function () {
250 Clipperz.DOM.Helper.append(MochiKit.DOM.currentDocument().body, 247 Clipperz.DOM.Helper.append(MochiKit.DOM.currentDocument().body,
251 {tag:'div', id:this.getId('modalDialogWrapper'), cls:'modalDialogWrapper simpleMessagePanelMask', children:[ 248 {tag:'div', id:this.getId('modalDialogWrapper'), cls:'modalDialogWrapper simpleMessagePanelMask', children:[
252 {tag:'div', id:this.getId('modalDialogMask'), cls:'modalDialogMask simpleMessagePanelMask'}, 249 {tag:'div', id:this.getId('modalDialogMask'), cls:'modalDialogMask simpleMessagePanelMask'},
253 {tag:'div', id:this.getId('modalDialogFrame'), cls:'modalDialogFrame simpleMessagePanelMask'}, 250 {tag:'div', id:this.getId('modalDialogFrame'), cls:'modalDialogFrame simpleMessagePanelMask'},
254 {tag:'div', id:this.getId('modalDialog'), cls:'modalDialog simpleMessagePanelMask'} 251 {tag:'div', id:this.getId('modalDialog'), cls:'modalDialog simpleMessagePanelMask'}
255 ]} 252 ]}
256 ); 253 );
257 254
258 MochiKit.Style.hideElement(this.getId('modalDialogMask')); 255 MochiKit.Style.hideElement(this.getId('modalDialogMask'));
259 MochiKit.Style.hideElement(this.getId('modalDialogFrame')); 256 MochiKit.Style.hideElement(this.getId('modalDialogFrame'));
260 }, 257 },
261 258
262 //------------------------------------------------------------------------- 259 //-------------------------------------------------------------------------
263 260
264 'keyDownHandler': function (anEvent) { 261 'keyDownHandler': function (anEvent) {
265 if (anEvent.key().string == 'KEY_ENTER') { 262 if (anEvent.key().string == 'KEY_ENTER') {
266 anEvent.preventDefault(); 263 anEvent.preventDefault();
267//console.log("13 - RETURN ?", this); 264//console.log("13 - RETURN ?", this);
268 this.closeOk(); 265 this.closeOk();
269//console.log('<<< 13') 266//console.log('<<< 13')
270 } 267 }
271 268
272 if (anEvent.key().string == 'KEY_ESCAPE') { 269 if (anEvent.key().string == 'KEY_ESCAPE') {
273 anEvent.preventDefault(); 270 anEvent.preventDefault();
274//console.log("27 - ESC ?", this); 271//console.log("27 - ESC ?", this);
275 this.closeCancel(); 272 this.closeCancel();
276//console.log("<<< 27"); 273//console.log("<<< 27");
277 } 274 }
278 }, 275 },
279 276
280 //------------------------------------------------------------------------- 277 //-------------------------------------------------------------------------
281 __syntaxFix__: "syntax fix" 278 __syntaxFix__: "syntax fix"
282}); 279});