summaryrefslogtreecommitdiff
path: root/frontend/gamma/js/Clipperz/PM/UI/Common/Components/MessagePanelWithProgressBar.js
Unidiff
Diffstat (limited to 'frontend/gamma/js/Clipperz/PM/UI/Common/Components/MessagePanelWithProgressBar.js') (more/less context) (ignore whitespace changes)
-rw-r--r--frontend/gamma/js/Clipperz/PM/UI/Common/Components/MessagePanelWithProgressBar.js164
1 files changed, 164 insertions, 0 deletions
diff --git a/frontend/gamma/js/Clipperz/PM/UI/Common/Components/MessagePanelWithProgressBar.js b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/MessagePanelWithProgressBar.js
new file mode 100644
index 0000000..275bbed
--- a/dev/null
+++ b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/MessagePanelWithProgressBar.js
@@ -0,0 +1,164 @@
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
29Clipperz.Base.module('Clipperz.PM.UI.Common.Components');
30
31Clipperz.PM.UI.Common.Components.MessagePanelWithProgressBar = function(args) {
32 args = args || {};
33
34 Clipperz.PM.UI.Common.Components.MessagePanelWithProgressBar.superclass.constructor.apply(this, arguments);
35
36 // this._openFromElement = args.openFromElement || null;
37 this._onOkCloseToElement = args.onOkCloseToElement || null;
38 this._onCancelCloseToElement = args.onCancelCloseToElement|| null;
39
40 this._canCancelWhileProcessing= ((typeof(args.canCancelWhileProcessing) == 'undefined') ? true : args.canCancelWhileProcessing);
41
42 return this;
43}
44
45//=============================================================================
46
47Clipperz.Base.extend(Clipperz.PM.UI.Common.Components.MessagePanelWithProgressBar, Clipperz.PM.UI.Common.Components.SimpleMessagePanel, {
48
49 //-------------------------------------------------------------------------
50
51 'toString': function () {
52 return "Clipperz.PM.UI.Common.Components.MessagePanelWithProgressBar component";
53 },
54
55 //-------------------------------------------------------------------------
56/*
57 'openFromElement': function () {
58 return this._openFromElement;
59 },
60*/
61 //-------------------------------------------------------------------------
62
63 'onOkCloseToElement': function () {
64 return this._onOkCloseToElement;
65 },
66
67 'setOnOkCloseToElement': function (anElement) {
68 this._onOkCloseToElement = anElement;
69 },
70
71 //-------------------------------------------------------------------------
72
73 'onCancelCloseToElement': function () {
74 return this._onCancelCloseToElement;
75 },
76
77 'setOnCancelCloseToElement': function (anElement) {
78 this._onCancelCloseToElement = anElement;
79 },
80
81 //-------------------------------------------------------------------------
82
83 'canCancelWhileProcessing': function () {
84 return this._canCancelWhileProcessing;
85 },
86
87 //-------------------------------------------------------------------------
88
89 'deferredShowModal': function (someArgs, aResult) {
90 if (someArgs['onOkCloseToElement'] != null) {
91 this.setOnOkCloseToElement(someArgs['onOkCloseToElement']);
92 }
93
94 if (someArgs['onCancelCloseToElement'] != null) {
95 this.setOnCancelCloseToElement(someArgs['onCancelCloseToElement']);
96 }
97
98 Clipperz.PM.UI.Common.Components.MessagePanelWithProgressBar.superclass.deferredShowModal.apply(this, arguments);
99 return this.deferred();
100 },
101
102 //-------------------------------------------------------------------------
103
104 'showProgressBar': function () {
105 varprogressBarElement;
106
107 this.getElement('container').innerHTML = '';
108
109 progressBarElement = this.append(this.getElement('container'), {tag:'div', cls:'progressBarWrapper'});
110 this.addComponent(new Clipperz.PM.UI.Common.Components.ProgressBar({'element':progressBarElement}));
111
112 if (this.canCancelWhileProcessing() == true) {
113 this.setButtons([{text:"Cancel", result:'CANCEL'}]);
114 } else {
115 this.setButtons([]);
116 }
117 },
118
119 //-------------------------------------------------------------------------
120
121 'showFailure': function (someParameters) {
122 // this.setType('ALERT');
123 this.setType(someParameters['type']);
124 // this.setTitle("Login failed");
125 this.setTitle(someParameters['title']);
126 // this.setText("Wrong passphrase; the unlock has failed.");
127 this.setText(someParameters['text']);
128 // this.getElement('container').innerHTML = '';
129 this.getElement('container').innerHTML = '';
130 // this.setButtons([{text:"Close", result:'CANCEL', isDefault:true}]);
131 this.setButtons(someParameters['buttons']);
132 },
133
134 //-------------------------------------------------------------------------
135
136 'closeOk': function () {
137//console.log("=== closeOk");
138 this.showProgressBar();
139 MochiKit.Async.callLater(0.5, MochiKit.Base.method(this.deferred(), 'callback'));
140 this._deferred = null;
141 },
142
143 'closeCancel': function () {
144//console.log("=== closeCancel");
145 this.deferredHideModal({closeToElement:this.onCancelCloseToElement()});
146 this.deferred().cancel();
147 this._deferred = null;
148 },
149
150 //-------------------------------------------------------------------------
151
152 'deferredDone': function () {
153//console.log("=== deferredDone");
154 return this.deferredHideModal({closeToElement:this.onOkCloseToElement()});
155 },
156
157 'deferredError': function (someParameters) {
158//console.log("=== deferredError");
159 this.showFailure(someParameters);
160 },
161
162 //-------------------------------------------------------------------------
163 __syntaxFix__: "syntax fix"
164});