OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * @fileoverview | 6 * @fileoverview |
7 * Functions related to controlling the modal UI state of the app. UI states | 7 * Functions related to controlling the modal UI state of the app. UI states |
8 * are expressed as HTML attributes with a dotted hierarchy. For example, the | 8 * are expressed as HTML attributes with a dotted hierarchy. For example, the |
9 * string 'host.shared' will match any elements with an associated attribute | 9 * string 'host.shared' will match any elements with an associated attribute |
10 * of 'host' or 'host.shared', showing those elements and hiding all others. | 10 * of 'host' or 'host.shared', showing those elements and hiding all others. |
(...skipping 18 matching lines...) Expand all Loading... |
29 HOST_SHARE_FAILED: 'home.host.share-failed', | 29 HOST_SHARE_FAILED: 'home.host.share-failed', |
30 HOST_SHARE_FINISHED: 'home.host.share-finished', | 30 HOST_SHARE_FINISHED: 'home.host.share-finished', |
31 CLIENT: 'home.client', | 31 CLIENT: 'home.client', |
32 CLIENT_UNCONNECTED: 'home.client.unconnected', | 32 CLIENT_UNCONNECTED: 'home.client.unconnected', |
33 CLIENT_PIN_PROMPT: 'home.client.pin-prompt', | 33 CLIENT_PIN_PROMPT: 'home.client.pin-prompt', |
34 CLIENT_CONNECTING: 'home.client.connecting', | 34 CLIENT_CONNECTING: 'home.client.connecting', |
35 CLIENT_CONNECT_FAILED_IT2ME: 'home.client.connect-failed.it2me', | 35 CLIENT_CONNECT_FAILED_IT2ME: 'home.client.connect-failed.it2me', |
36 CLIENT_CONNECT_FAILED_ME2ME: 'home.client.connect-failed.me2me', | 36 CLIENT_CONNECT_FAILED_ME2ME: 'home.client.connect-failed.me2me', |
37 CLIENT_SESSION_FINISHED_IT2ME: 'home.client.session-finished.it2me', | 37 CLIENT_SESSION_FINISHED_IT2ME: 'home.client.session-finished.it2me', |
38 CLIENT_SESSION_FINISHED_ME2ME: 'home.client.session-finished.me2me', | 38 CLIENT_SESSION_FINISHED_ME2ME: 'home.client.session-finished.me2me', |
| 39 HISTORY: 'home.history', |
39 IN_SESSION: 'in-session' | 40 IN_SESSION: 'in-session' |
40 }; | 41 }; |
41 | 42 |
42 /** | 43 /** |
43 * Update the DOM by showing or hiding elements based on whether or not they | 44 * Update the DOM by showing or hiding elements based on whether or not they |
44 * have an attribute matching the specified name. | 45 * have an attribute matching the specified name. |
45 * @param {string} mode The value against which to match the attribute. | 46 * @param {string} mode The value against which to match the attribute. |
46 * @param {string} attr The attribute name to match. | 47 * @param {string} attr The attribute name to match. |
47 * @return {void} Nothing. | 48 * @return {void} Nothing. |
48 */ | 49 */ |
49 remoting.updateModalUi = function(mode, attr) { | 50 remoting.updateModalUi = function(mode, attr) { |
50 var modes = mode.split('.'); | 51 var modes = mode.split('.'); |
51 for (var i = 1; i < modes.length; ++i) | 52 for (var i = 1; i < modes.length; ++i) |
52 modes[i] = modes[i - 1] + '.' + modes[i]; | 53 modes[i] = modes[i - 1] + '.' + modes[i]; |
53 var elements = document.querySelectorAll('[' + attr + ']'); | 54 var elements = document.querySelectorAll('[' + attr + ']'); |
54 for (var i = 0; i < elements.length; ++i) { | 55 for (var i = 0; i < elements.length; ++i) { |
55 var element = /** @type {Element} */ elements[i]; | 56 var element = /** @type {Element} */ elements[i]; |
56 var hidden = true; | 57 var hidden = true; |
57 for (var m = 0; m < modes.length; ++m) { | 58 for (var m = 0; m < modes.length; ++m) { |
58 if (hasClass(element.getAttribute(attr), modes[m])) { | 59 if (hasClass(element.getAttribute(attr), modes[m])) { |
59 hidden = false; | 60 hidden = false; |
60 break; | 61 break; |
61 } | 62 } |
62 } | 63 } |
63 element.hidden = hidden; | 64 element.hidden = hidden; |
64 } | 65 } |
65 } | 66 }; |
66 | 67 |
67 /** | 68 /** |
68 * @type {remoting.AppMode} The current app mode | 69 * @type {remoting.AppMode} The current app mode |
69 */ | 70 */ |
70 remoting.currentMode = remoting.AppMode.HOME; | 71 remoting.currentMode = remoting.AppMode.HOME; |
71 | 72 |
72 /** | 73 /** |
73 * Change the app's modal state to |mode|, determined by the data-ui-mode | 74 * Change the app's modal state to |mode|, determined by the data-ui-mode |
74 * attribute. | 75 * attribute. |
75 * | 76 * |
(...skipping 16 matching lines...) Expand all Loading... |
92 } | 93 } |
93 }; | 94 }; |
94 | 95 |
95 /** | 96 /** |
96 * Get the major mode that the app is running in. | 97 * Get the major mode that the app is running in. |
97 * @return {string} The app's current major mode. | 98 * @return {string} The app's current major mode. |
98 */ | 99 */ |
99 remoting.getMajorMode = function() { | 100 remoting.getMajorMode = function() { |
100 return remoting.currentMode.split('.')[0]; | 101 return remoting.currentMode.split('.')[0]; |
101 }; | 102 }; |
OLD | NEW |