Diffstat (limited to 'frontend/gamma/js/Clipperz/PM/UI/Mobile/Components/Overlay.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/gamma/js/Clipperz/PM/UI/Mobile/Components/Overlay.js | 136 |
1 files changed, 136 insertions, 0 deletions
diff --git a/frontend/gamma/js/Clipperz/PM/UI/Mobile/Components/Overlay.js b/frontend/gamma/js/Clipperz/PM/UI/Mobile/Components/Overlay.js new file mode 100644 index 0000000..da08d0f --- a/dev/null +++ b/frontend/gamma/js/Clipperz/PM/UI/Mobile/Components/Overlay.js | |||
@@ -0,0 +1,136 @@ | |||
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.Mobile.Components'); | ||
25 | |||
26 | Clipperz.PM.UI.Mobile.Components.Overlay = function(args) { | ||
27 | args = args || {}; | ||
28 | |||
29 | this._defaultDelay = 2; | ||
30 | |||
31 | Clipperz.PM.UI.Mobile.Components.Overlay.superclass.constructor.apply(this, arguments); | ||
32 | |||
33 | this.render(); | ||
34 | MochiKit.Style.hideElement(this.element()); | ||
35 | |||
36 | return this; | ||
37 | } | ||
38 | |||
39 | //============================================================================= | ||
40 | |||
41 | Clipperz.Base.extend(Clipperz.PM.UI.Mobile.Components.Overlay, Clipperz.PM.UI.Mobile.Components.BaseComponent, { | ||
42 | |||
43 | //------------------------------------------------------------------------- | ||
44 | |||
45 | 'toString': function () { | ||
46 | return "Clipperz.PM.UI.Mobile.Components.Overlay component"; | ||
47 | }, | ||
48 | |||
49 | //------------------------------------------------------------------------- | ||
50 | |||
51 | 'show': function (aMessage) { | ||
52 | this.resetStatus(); | ||
53 | this.setMessage(aMessage); | ||
54 | MochiKit.DOM.removeElementClass(this.element(), 'ios-overlay-hide'); | ||
55 | MochiKit.DOM.addElementClass(this.element(), 'ios-overlay-show'); | ||
56 | }, | ||
57 | |||
58 | 'done': function (aMessage, aDelayBeforeHiding) { | ||
59 | this.completed(this.showDoneIcon, aMessage, aDelayBeforeHiding); | ||
60 | }, | ||
61 | |||
62 | 'failed': function (aMessage, aDelayBeforeHiding) { | ||
63 | this.completed(this.showFailIcon, aMessage, aDelayBeforeHiding); | ||
64 | }, | ||
65 | |||
66 | //------------------------------------------------------------------------- | ||
67 | |||
68 | 'resetStatus': function () { | ||
69 | MochiKit.Style.showElement(this.element()); | ||
70 | MochiKit.Style.showElement(this.getElement('spinner')); | ||
71 | MochiKit.Style.hideElement(this.getElement('done')); | ||
72 | MochiKit.Style.hideElement(this.getElement('failed')); | ||
73 | }, | ||
74 | |||
75 | 'setMessage': function (aMessage) { | ||
76 | if (typeof(aMessage) != 'undefined') { | ||
77 | this.getElement('title').innerHTML = aMessage; | ||
78 | } | ||
79 | }, | ||
80 | |||
81 | 'completed': function (aFunctionToShowResult, aMessage, aDelayBeforeHiding) { | ||
82 | var delay = aDelayBeforeHiding || this.defaultDelay(); | ||
83 | |||
84 | this.hideSpinner(); | ||
85 | MochiKit.Base.bind(aFunctionToShowResult, this)(); | ||
86 | this.setMessage(aMessage); | ||
87 | |||
88 | MochiKit.Async.callLater(delay, MochiKit.Base.bind(this.hide, this)) | ||
89 | }, | ||
90 | |||
91 | 'hide': function () { | ||
92 | MochiKit.DOM.removeElementClass(this.element(), 'ios-overlay-show'); | ||
93 | MochiKit.DOM.addElementClass(this.element(), 'ios-overlay-hide'); | ||
94 | MochiKit.Async.callLater(1, MochiKit.Style.hideElement, this.element()); | ||
95 | }, | ||
96 | |||
97 | 'hideSpinner': function () { | ||
98 | MochiKit.Style.hideElement(this.getElement('spinner')); | ||
99 | }, | ||
100 | |||
101 | 'showDoneIcon': function () { | ||
102 | MochiKit.Style.showElement(this.getElement('done')); | ||
103 | }, | ||
104 | |||
105 | 'showFailIcon': function () { | ||
106 | MochiKit.Style.showElement(this.getElement('failed')); | ||
107 | }, | ||
108 | |||
109 | //------------------------------------------------------------------------- | ||
110 | |||
111 | 'defaultDelay': function () { | ||
112 | return this._defaultDelay; | ||
113 | }, | ||
114 | |||
115 | //------------------------------------------------------------------------- | ||
116 | |||
117 | 'renderSelf': function () { | ||
118 | this.setElement(Clipperz.DOM.Helper.append(MochiKit.DOM.currentDocument().body, | ||
119 | {tag:'div', id:'ui-ios-overlay', cls:'ui-ios-overlay', children:[ | ||
120 | {tag:'div', cls:'spinner', id:this.getId('spinner'), children:[ | ||
121 | {tag:'div', cls:'bar01'}, {tag:'div', cls:'bar02'}, {tag:'div', cls:'bar03'}, {tag:'div', cls:'bar04'}, {tag:'div', cls:'bar05'}, {tag:'div', cls:'bar06'}, {tag:'div', cls:'bar07'}, {tag:'div', cls:'bar08'}, {tag:'div', cls:'bar09'}, {tag:'div', cls:'bar10'}, {tag:'div', cls:'bar11'}, {tag:'div', cls:'bar12'} | ||
122 | ]}, | ||
123 | |||
124 | // {tag:'span', cls:'icon', id:this.getId('done'), html:''}, | ||
125 | {tag:'span', cls:'icon', id:this.getId('done'), html:'done'}, | ||
126 | // {tag:'span', cls:'icon', id:this.getId('failed'), html:''}, | ||
127 | {tag:'span', cls:'icon', id:this.getId('failed'), html:'failed'}, | ||
128 | |||
129 | {tag:'span', cls:'title', id:this.getId('title'), html:""} | ||
130 | ]} | ||
131 | )); | ||
132 | }, | ||
133 | |||
134 | //------------------------------------------------------------------------- | ||
135 | __syntaxFix__: "syntax fix" | ||
136 | }); | ||