summaryrefslogtreecommitdiff
path: root/frontend/beta/js/Clipperz/YUI/MessageBox.js
Unidiff
Diffstat (limited to 'frontend/beta/js/Clipperz/YUI/MessageBox.js') (more/less context) (ignore whitespace changes)
-rw-r--r--frontend/beta/js/Clipperz/YUI/MessageBox.js22
1 files changed, 10 insertions, 12 deletions
diff --git a/frontend/beta/js/Clipperz/YUI/MessageBox.js b/frontend/beta/js/Clipperz/YUI/MessageBox.js
index c7b4702..8b8ca7f 100644
--- a/frontend/beta/js/Clipperz/YUI/MessageBox.js
+++ b/frontend/beta/js/Clipperz/YUI/MessageBox.js
@@ -1,118 +1,116 @@
1/* 1/*
2 2
3Copyright 2008-2011 Clipperz Srl 3Copyright 2008-2013 Clipperz Srl
4 4
5This file is part of Clipperz Community Edition. 5This file is part of Clipperz, the online password manager.
6Clipperz Community Edition is an online password manager.
7For further information about its features and functionalities please 6For further information about its features and functionalities please
8refer to http://www.clipperz.com. 7refer 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
26Clipperz.YUI.MessageBox = function(){ 24Clipperz.YUI.MessageBox = function(){
27 var dlg, opt, mask; 25 var dlg, opt, mask;
28 var bodyEl, msgEl, textboxEl, textareaEl, progressEl, pp; 26 var bodyEl, msgEl, textboxEl, textareaEl, progressEl, pp;
29 var buttons, activeTextEl, bwidth; 27 var buttons, activeTextEl, bwidth;
30 28
31 var handleButton = function(button){ 29 var handleButton = function(button){
32 if(typeof opt.fn == 'function'){ 30 if(typeof opt.fn == 'function'){
33 if(opt.fn.call(opt.scope||window, button, activeTextEl.dom.value) !== false){ 31 if(opt.fn.call(opt.scope||window, button, activeTextEl.dom.value) !== false){
34 dlg.hide(); 32 dlg.hide();
35 } 33 }
36 }else{ 34 }else{
37 dlg.hide(); 35 dlg.hide();
38 } 36 }
39 }; 37 };
40 38
41 return { 39 return {
42 updateButtons: function(b){ 40 updateButtons: function(b){
43 var width = 0; 41 var width = 0;
44 if(!b){ 42 if(!b){
45 buttons['ok'].hide(); 43 buttons['ok'].hide();
46 buttons['cancel'].hide(); 44 buttons['cancel'].hide();
47 buttons['yes'].hide(); 45 buttons['yes'].hide();
48 buttons['no'].hide(); 46 buttons['no'].hide();
49 return width; 47 return width;
50 } 48 }
51 for(var k in buttons){ 49 for(var k in buttons){
52 if(typeof buttons[k] != 'function'){ 50 if(typeof buttons[k] != 'function'){
53 if(b[k]){ 51 if(b[k]){
54 buttons[k].show(); 52 buttons[k].show();
55 buttons[k].setText(typeof b[k] == 'string' ? b[k] : YAHOO.ext.MessageBox.buttonText[k]); 53 buttons[k].setText(typeof b[k] == 'string' ? b[k] : YAHOO.ext.MessageBox.buttonText[k]);
56 width += buttons[k].el.getWidth()+15; 54 width += buttons[k].el.getWidth()+15;
57 }else{ 55 }else{
58 buttons[k].hide(); 56 buttons[k].hide();
59 } 57 }
60 } 58 }
61 } 59 }
62 return width; 60 return width;
63 }, 61 },
64 62
65 getDialog : function(){ 63 getDialog : function(){
66 if(!dlg){ 64 if(!dlg){
67 dlg = new YAHOO.ext.BasicDialog('mb-dlg', { 65 dlg = new YAHOO.ext.BasicDialog('mb-dlg', {
68 autoCreate:true, 66 autoCreate:true,
69 shadow:true, 67 shadow:true,
70 draggable:true, 68 draggable:true,
71 resizable:false, 69 resizable:false,
72 constraintoviewport:true, 70 constraintoviewport:true,
73 fixedcenter:true, 71 fixedcenter:true,
74 shim:true, 72 shim:true,
75 modal:true, 73 modal:true,
76 width:400, height:100, 74 width:400, height:100,
77 buttonAlign:'center', 75 buttonAlign:'center',
78 closeClick : function(){ 76 closeClick : function(){
79 if(opt && opt.buttons && opt.buttons.no && !opt.buttons.cancel){ 77 if(opt && opt.buttons && opt.buttons.no && !opt.buttons.cancel){
80 handleButton('no'); 78 handleButton('no');
81 }else{ 79 }else{
82 handleButton('cancel'); 80 handleButton('cancel');
83 } 81 }
84 } 82 }
85 }); 83 });
86 dlg.closeClick = function(){ 84 dlg.closeClick = function(){
87 alert('wtf'); 85 alert('wtf');
88 }; 86 };
89 mask = dlg.mask; 87 mask = dlg.mask;
90 dlg.addKeyListener(27, dlg.hide, dlg); 88 dlg.addKeyListener(27, dlg.hide, dlg);
91 buttons = {}; 89 buttons = {};
92 buttons['ok'] = dlg.addButton(this.buttonText['ok'], handleButton.createCallback('ok')); 90 buttons['ok'] = dlg.addButton(this.buttonText['ok'], handleButton.createCallback('ok'));
93 buttons['yes'] = dlg.addButton(this.buttonText['yes'], handleButton.createCallback('yes')); 91 buttons['yes'] = dlg.addButton(this.buttonText['yes'], handleButton.createCallback('yes'));
94 buttons['no'] = dlg.addButton(this.buttonText['no'], handleButton.createCallback('no')); 92 buttons['no'] = dlg.addButton(this.buttonText['no'], handleButton.createCallback('no'));
95 buttons['cancel'] = dlg.addButton(this.buttonText['cancel'], handleButton.createCallback('cancel')); 93 buttons['cancel'] = dlg.addButton(this.buttonText['cancel'], handleButton.createCallback('cancel'));
96 bodyEl = dlg.body.createChild({ 94 bodyEl = dlg.body.createChild({
97 tag:'div', 95 tag:'div',
98 html:'<span class="ext-mb-text"></span><br /><input type="text" class="ext-mb-input"><textarea class="ext-mb-textarea"></textarea><div class="ext-mb-progress-wrap"><div class="ext-mb-progress"><div class="ext-mb-progress-bar">&#160;</div></div></div>' 96 html:'<span class="ext-mb-text"></span><br /><input type="text" class="ext-mb-input"><textarea class="ext-mb-textarea"></textarea><div class="ext-mb-progress-wrap"><div class="ext-mb-progress"><div class="ext-mb-progress-bar">&#160;</div></div></div>'
99 }); 97 });
100 msgEl = bodyEl.dom.firstChild; 98 msgEl = bodyEl.dom.firstChild;
101 textboxEl = getEl(bodyEl.dom.childNodes[2]); 99 textboxEl = getEl(bodyEl.dom.childNodes[2]);
102 textboxEl.enableDisplayMode(); 100 textboxEl.enableDisplayMode();
103 textboxEl.addKeyListener([10,13], function(){ 101 textboxEl.addKeyListener([10,13], function(){
104 if(dlg.isVisible() && opt && opt.buttons){ 102 if(dlg.isVisible() && opt && opt.buttons){
105 if(opt.buttons.ok){ 103 if(opt.buttons.ok){
106 handleButton('ok'); 104 handleButton('ok');
107 }else if(opt.buttons.yes){ 105 }else if(opt.buttons.yes){
108 handleButton('yes'); 106 handleButton('yes');
109 } 107 }
110 } 108 }
111 }); 109 });
112 textareaEl = getEl(bodyEl.dom.childNodes[3]); 110 textareaEl = getEl(bodyEl.dom.childNodes[3]);
113 textareaEl.enableDisplayMode(); 111 textareaEl.enableDisplayMode();
114 progressEl = getEl(bodyEl.dom.childNodes[4]); 112 progressEl = getEl(bodyEl.dom.childNodes[4]);
115 progressEl.enableDisplayMode(); 113 progressEl.enableDisplayMode();
116 pp = getEl(progressEl.dom.firstChild.firstChild); 114 pp = getEl(progressEl.dom.firstChild.firstChild);
117 } 115 }
118 return dlg; 116 return dlg;