- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / resources / chromeos / login / screen_app_launch_splash.js
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 /**
6  * @fileoverview App install/launch splash screen implementation.
7  */
8
9 login.createScreen('AppLaunchSplashScreen', 'app-launch-splash', function() {
10   return {
11     EXTERNAL_API: [
12       'toggleNetworkConfig',
13       'updateApp',
14       'updateMessage',
15     ],
16
17     /** @override */
18     decorate: function() {
19       $('splash-config-network').addEventListener('click', function(e) {
20         chrome.send('configureNetwork');
21       });
22
23       var networkContainer = $('splash-config-network-container');
24       networkContainer.addEventListener(
25           'webkitTransitionEnd',
26           function(e) {
27             if (this.classList.contains('faded'))
28               $('splash-config-network').hidden = true;
29           }.bind(networkContainer)
30       );
31
32       // Ensure the webkitTransitionEnd event gets called after a wait time.
33       // The wait time should be inline with the transition duration time
34       // defined in css file. The current value in css is 1000ms. To avoid
35       // the emulated webkitTransitionEnd firing before real one, a 1050ms
36       // delay is used.
37       ensureTransitionEndEvent(networkContainer, 1050);
38     },
39
40     /**
41      * Event handler that is invoked just before the frame is shown.
42      * @param {string} data Screen init payload.
43      */
44     onBeforeShow: function(data) {
45       $('splash-config-network').hidden = true;
46       this.toggleNetworkConfig(false);
47       this.updateApp(data['appInfo']);
48
49       $('splash-shortcut-info').hidden = !data['shortcutEnabled'];
50
51       Oobe.getInstance().headerHidden = true;
52       Oobe.getInstance().solidBackground = true;
53     },
54
55     /**
56      * Event handler that is invoked just before the frame is hidden.
57      */
58     onBeforeHide: function() {
59     },
60
61     /**
62      * Toggles visibility of the network configuration option.
63      * @param {boolean} visible Whether to show the option.
64      */
65     toggleNetworkConfig: function(visible) {
66       var container = $('splash-config-network-container');
67       var currVisible = !container.classList.contains('faded');
68       if (currVisible == visible)
69         return;
70
71       if (visible) {
72         $('splash-config-network').hidden = false;
73         container.classList.remove('faded');
74       } else {
75         container.classList.add('faded');
76       }
77     },
78
79     /**
80      * Updates the app name and icon.
81      * @param {Object} app Details of app being launched.
82      */
83     updateApp: function(app) {
84       $('splash-header').textContent = app.name;
85       $('splash-header').style.backgroundImage = 'url(' + app.iconURL + ')';
86     },
87
88     /**
89      * Updates the message for the current launch state.
90      * @param {string} message Description for current launch state.
91      */
92     updateMessage: function(message) {
93       $('splash-launch-text').textContent = message;
94     }
95   };
96 });