Diffstat (limited to 'frontend/delta/js/Clipperz/PM/UI/Components/Overlay.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/delta/js/Clipperz/PM/UI/Components/Overlay.js | 122 |
1 files changed, 122 insertions, 0 deletions
diff --git a/frontend/delta/js/Clipperz/PM/UI/Components/Overlay.js b/frontend/delta/js/Clipperz/PM/UI/Components/Overlay.js new file mode 100644 index 0000000..cc4a06c --- a/dev/null +++ b/frontend/delta/js/Clipperz/PM/UI/Components/Overlay.js | |||
@@ -0,0 +1,122 @@ | |||
1 | /* | ||
2 | |||
3 | Copyright 2008-2013 Clipperz Srl | ||
4 | |||
5 | This file is part of Clipperz, the online password manager. | ||
6 | For further information about its features and functionalities please | ||
7 | refer to http://www.clipperz.com. | ||
8 | |||
9 | * Clipperz is free software: you can redistribute it and/or modify it | ||
10 | under the terms of the GNU Affero General Public License as published | ||
11 | by the Free Software Foundation, either version 3 of the License, or | ||
12 | (at your option) any later version. | ||
13 | |||
14 | * Clipperz is distributed in the hope that it will be useful, but | ||
15 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
17 | See the GNU Affero General Public License for more details. | ||
18 | |||
19 | * You should have received a copy of the GNU Affero General Public | ||
20 | License along with Clipperz. If not, see http://www.gnu.org/licenses/. | ||
21 | |||
22 | */ | ||
23 | |||
24 | Clipperz.Base.module('Clipperz.PM.UI.Components'); | ||
25 | |||
26 | Clipperz.PM.UI.Components.Overlay = function(args) { | ||
27 | args = args || {}; | ||
28 | |||
29 | this._defaultDelay = 2; | ||
30 | this._element = MochiKit.DOM.getElement('overlay'); | ||
31 | |||
32 | return this; | ||
33 | } | ||
34 | |||
35 | //============================================================================= | ||
36 | |||
37 | Clipperz.Base.extend(Clipperz.PM.UI.Components.Overlay, Object, { | ||
38 | |||
39 | //------------------------------------------------------------------------- | ||
40 | |||
41 | 'toString': function () { | ||
42 | return "Clipperz.PM.UI.Components.Overlay component"; | ||
43 | }, | ||
44 | |||
45 | 'element': function () { | ||
46 | // return MochiKit.DOM.getElement('overlay'); | ||
47 | return this._element; | ||
48 | }, | ||
49 | |||
50 | 'getElement': function (aClass) { | ||
51 | return MochiKit.Selector.findChildElements(this.element(), ['.'+aClass])[0]; | ||
52 | }, | ||
53 | |||
54 | //------------------------------------------------------------------------- | ||
55 | |||
56 | 'show': function (aMessage) { | ||
57 | this.resetStatus(); | ||
58 | this.setMessage(aMessage); | ||
59 | MochiKit.DOM.removeElementClass(this.element(), 'ios-overlay-hide'); | ||
60 | MochiKit.DOM.addElementClass(this.element(), 'ios-overlay-show'); | ||
61 | }, | ||
62 | |||
63 | 'done': function (aMessage, aDelayBeforeHiding) { | ||
64 | this.completed(this.showDoneIcon, aMessage, aDelayBeforeHiding); | ||
65 | }, | ||
66 | |||
67 | 'failed': function (aMessage, aDelayBeforeHiding) { | ||
68 | this.completed(this.showFailIcon, aMessage, aDelayBeforeHiding); | ||
69 | }, | ||
70 | |||
71 | //------------------------------------------------------------------------- | ||
72 | |||
73 | 'resetStatus': function () { | ||
74 | MochiKit.Style.showElement(this.element()); | ||
75 | MochiKit.Style.showElement(this.getElement('spinner')); | ||
76 | MochiKit.Style.hideElement(this.getElement('done')); | ||
77 | MochiKit.Style.hideElement(this.getElement('failed')); | ||
78 | }, | ||
79 | |||
80 | 'setMessage': function (aMessage) { | ||
81 | if (typeof(aMessage) != 'undefined') { | ||
82 | this.getElement('title').innerHTML = aMessage; | ||
83 | } | ||
84 | }, | ||
85 | |||
86 | 'completed': function (aFunctionToShowResult, aMessage, aDelayBeforeHiding) { | ||
87 | var delay = aDelayBeforeHiding || this.defaultDelay(); | ||
88 | |||
89 | this.hideSpinner(); | ||
90 | MochiKit.Base.bind(aFunctionToShowResult, this)(); | ||
91 | this.setMessage(aMessage); | ||
92 | |||
93 | MochiKit.Async.callLater(delay, MochiKit.Base.bind(this.hide, this)) | ||
94 | }, | ||
95 | |||
96 | 'hide': function () { | ||
97 | MochiKit.DOM.removeElementClass(this.element(), 'ios-overlay-show'); | ||
98 | MochiKit.DOM.addElementClass(this.element(), 'ios-overlay-hide'); | ||
99 | MochiKit.Async.callLater(1, MochiKit.Style.hideElement, this.element()); | ||
100 | }, | ||
101 | |||
102 | 'hideSpinner': function () { | ||
103 | MochiKit.Style.hideElement(this.getElement('spinner')); | ||
104 | }, | ||
105 | |||
106 | 'showDoneIcon': function () { | ||
107 | MochiKit.Style.showElement(this.getElement('done')); | ||
108 | }, | ||
109 | |||
110 | 'showFailIcon': function () { | ||
111 | MochiKit.Style.showElement(this.getElement('failed')); | ||
112 | }, | ||
113 | |||
114 | //------------------------------------------------------------------------- | ||
115 | |||
116 | 'defaultDelay': function () { | ||
117 | return this._defaultDelay; | ||
118 | }, | ||
119 | |||
120 | //------------------------------------------------------------------------- | ||
121 | __syntaxFix__: "syntax fix" | ||
122 | }); | ||