Changeset View
Changeset View
Standalone View
Standalone View
effects/logout/package/contents/code/main.js
Show All 15 Lines | |||||
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | GNU General Public License for more details. | 17 | GNU General Public License for more details. | ||
18 | 18 | | |||
19 | You should have received a copy of the GNU General Public License | 19 | You should have received a copy of the GNU General Public License | ||
20 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 20 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
21 | *********************************************************************/ | 21 | *********************************************************************/ | ||
22 | /*global effect, effects, animate, animationTime, Effect*/ | 22 | /*global effect, effects, animate, animationTime, Effect*/ | ||
23 | var logoutEffect = { | 23 | var logoutEffect = { | ||
24 | duration: animationTime(800), | 24 | inDuration: animationTime(800), | ||
25 | outDuration: animationTime(400), | ||||
25 | loadConfig: function () { | 26 | loadConfig: function () { | ||
26 | "use strict"; | 27 | "use strict"; | ||
27 | logoutEffect.duration = animationTime(800); | 28 | logoutEffect.inDuration = animationTime(800); | ||
29 | logoutEffect.outDuration = animationTime(400); | ||||
28 | }, | 30 | }, | ||
29 | isLogoutWindow: function (window) { | 31 | isLogoutWindow: function (window) { | ||
30 | "use strict"; | 32 | "use strict"; | ||
31 | var windowClass = window.windowClass; | 33 | var windowClass = window.windowClass; | ||
32 | if (windowClass === "ksmserver ksmserver") { | 34 | if (windowClass === "ksmserver ksmserver") { | ||
33 | return true; | 35 | return true; | ||
34 | } | 36 | } | ||
35 | return false; | 37 | return false; | ||
36 | }, | 38 | }, | ||
37 | opened: function (window) { | 39 | opened: function (window) { | ||
38 | "use strict"; | 40 | "use strict"; | ||
39 | if (!logoutEffect.isLogoutWindow(window)) { | 41 | if (!logoutEffect.isLogoutWindow(window)) { | ||
40 | return; | 42 | return; | ||
41 | } | 43 | } | ||
42 | animate({ | 44 | // If the Out animation is still active, kill it. | ||
45 | if (window.outAnimation !== undefined) { | ||||
46 | cancel(window.outAnimation); | ||||
47 | delete window.outAnimation; | ||||
48 | } | ||||
49 | window.inAnimation = animate({ | ||||
43 | window: window, | 50 | window: window, | ||
44 | duration: logoutEffect.duration, | 51 | duration: logoutEffect.inDuration, | ||
45 | type: Effect.Opacity, | 52 | type: Effect.Opacity, | ||
46 | from: 0.0, | 53 | from: 0.0, | ||
47 | to: 1.0 | 54 | to: 1.0 | ||
48 | }); | 55 | }); | ||
49 | }, | 56 | }, | ||
57 | closed: function (window) { | ||||
58 | "use strict"; | ||||
59 | if (!logoutEffect.isLogoutWindow(window)) { | ||||
60 | return; | ||||
61 | } | ||||
62 | // If the In animation is still active, kill it. | ||||
63 | if (window.inAnimation !== undefined) { | ||||
64 | cancel(window.inAnimation); | ||||
65 | delete window.inAnimation; | ||||
66 | } | ||||
67 | window.outAnimation = animate({ | ||||
68 | window: window, | ||||
69 | duration: logoutEffect.outDuration, | ||||
70 | type: Effect.Opacity, | ||||
71 | from: 1.0, | ||||
72 | to: 0.0 | ||||
73 | }); | ||||
74 | }, | ||||
50 | init: function () { | 75 | init: function () { | ||
51 | "use strict"; | 76 | "use strict"; | ||
52 | logoutEffect.loadConfig(); | 77 | logoutEffect.loadConfig(); | ||
53 | effects.windowAdded.connect(logoutEffect.opened); | 78 | effects.windowAdded.connect(logoutEffect.opened); | ||
54 | effects.windowShown.connect(logoutEffect.opened); | 79 | effects.windowShown.connect(logoutEffect.opened); | ||
80 | effects.windowClosed.connect(logoutEffect.closed); | ||||
81 | effects.windowHidden.connect(logoutEffect.closed); | ||||
55 | } | 82 | } | ||
56 | }; | 83 | }; | ||
57 | logoutEffect.init(); | 84 | logoutEffect.init(); | ||
58 | 85 | |