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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 HOST_SETUP: 'home.host-setup', | 43 HOST_SETUP: 'home.host-setup', |
44 HOST_SETUP_INSTALL: 'home.host-setup.install', | 44 HOST_SETUP_INSTALL: 'home.host-setup.install', |
45 HOST_SETUP_INSTALL_PENDING: 'home.host-setup.install-pending', | 45 HOST_SETUP_INSTALL_PENDING: 'home.host-setup.install-pending', |
46 HOST_SETUP_ASK_PIN: 'home.host-setup.ask-pin', | 46 HOST_SETUP_ASK_PIN: 'home.host-setup.ask-pin', |
47 HOST_SETUP_PROCESSING: 'home.host-setup.processing', | 47 HOST_SETUP_PROCESSING: 'home.host-setup.processing', |
48 HOST_SETUP_DONE: 'home.host-setup.done', | 48 HOST_SETUP_DONE: 'home.host-setup.done', |
49 HOST_SETUP_ERROR: 'home.host-setup.error', | 49 HOST_SETUP_ERROR: 'home.host-setup.error', |
50 IN_SESSION: 'in-session' | 50 IN_SESSION: 'in-session' |
51 }; | 51 }; |
52 | 52 |
| 53 /** @const */ |
| 54 remoting.kIT2MeVisitedStorageKey = 'it2me-visited'; |
| 55 /** @const */ |
| 56 remoting.kMe2MeVisitedStorageKey = 'me2me-visited'; |
| 57 |
53 /** | 58 /** |
54 * @param {Element} element The element to check. | 59 * @param {Element} element The element to check. |
55 * @param {string} attrName The attribute on the element to check. | 60 * @param {string} attrName The attribute on the element to check. |
56 * @param {Array.<string>} modes The modes to check for. | 61 * @param {Array.<string>} modes The modes to check for. |
57 * @return {boolean} True if any mode in |modes| is found within the attribute. | 62 * @return {boolean} True if any mode in |modes| is found within the attribute. |
58 */ | 63 */ |
59 remoting.hasModeAttribute = function(element, attrName, modes) { | 64 remoting.hasModeAttribute = function(element, attrName, modes) { |
60 var attr = element.getAttribute(attrName); | 65 var attr = element.getAttribute(attrName); |
61 for (var i = 0; i < modes.length; ++i) { | 66 for (var i = 0; i < modes.length; ++i) { |
62 if (attr.match(new RegExp('(\\s|^)' + modes[i] + '(\\s|$)')) != null) { | 67 if (attr.match(new RegExp('(\\s|^)' + modes[i] + '(\\s|$)')) != null) { |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 // Get the first element of a dictionary or array, without needing to know | 150 // Get the first element of a dictionary or array, without needing to know |
146 // the key. | 151 // the key. |
147 /** @type {string} */ | 152 /** @type {string} */ |
148 var key = Object.keys(items)[0]; | 153 var key = Object.keys(items)[0]; |
149 var visited = !!items[key]; | 154 var visited = !!items[key]; |
150 document.getElementById(mode + '-first-run').hidden = visited; | 155 document.getElementById(mode + '-first-run').hidden = visited; |
151 document.getElementById(mode + '-content').hidden = !visited; | 156 document.getElementById(mode + '-content').hidden = !visited; |
152 }; | 157 }; |
153 | 158 |
154 remoting.showOrHideIT2MeUi = function() { | 159 remoting.showOrHideIT2MeUi = function() { |
155 remoting.storage.local.get('it2me-visited', | 160 remoting.storage.local.get(remoting.kIT2MeVisitedStorageKey, |
156 remoting.showOrHideCallback.bind(null, 'it2me')); | 161 remoting.showOrHideCallback.bind(null, 'it2me')); |
157 }; | 162 }; |
158 | 163 |
159 remoting.showOrHideMe2MeUi = function() { | 164 remoting.showOrHideMe2MeUi = function() { |
160 remoting.storage.local.get('me2me-visited', | 165 remoting.storage.local.get(remoting.kMe2MeVisitedStorageKey, |
161 remoting.showOrHideCallback.bind(null, 'me2me')); | 166 remoting.showOrHideCallback.bind(null, 'me2me')); |
162 }; | 167 }; |
163 | 168 |
164 remoting.showIT2MeUiAndSave = function() { | 169 remoting.showIT2MeUiAndSave = function() { |
165 var items = {}; | 170 var items = {}; |
166 items['it2me-visited'] = true; | 171 items[remoting.kIT2MeVisitedStorageKey] = true; |
167 remoting.storage.local.set(items); | 172 remoting.storage.local.set(items); |
168 remoting.showOrHideCallback('it2me', [true]); | 173 remoting.showOrHideCallback('it2me', [true]); |
169 }; | 174 }; |
170 | 175 |
171 remoting.showMe2MeUiAndSave = function() { | 176 remoting.showMe2MeUiAndSave = function() { |
172 var items = {}; | 177 var items = {}; |
173 items['me2me-visited'] = true; | 178 items[remoting.kMe2MeVisitedStorageKey] = true; |
174 remoting.storage.local.set(items); | 179 remoting.storage.local.set(items); |
175 remoting.showOrHideCallback('me2me', [true]); | 180 remoting.showOrHideCallback('me2me', [true]); |
176 }; | 181 }; |
177 | 182 |
178 remoting.resetInfographics = function() { | 183 remoting.resetInfographics = function() { |
179 remoting.storage.local.remove('it2me-visited'); | 184 remoting.storage.local.remove(remoting.kIT2MeVisitedStorageKey); |
180 remoting.storage.local.remove('me2me-visited'); | 185 remoting.storage.local.remove(remoting.kMe2MeVisitedStorageKey); |
181 remoting.showOrHideCallback('it2me', [false]); | 186 remoting.showOrHideCallback('it2me', [false]); |
182 remoting.showOrHideCallback('me2me', [false]); | 187 remoting.showOrHideCallback('me2me', [false]); |
183 } | 188 } |
184 | 189 |
185 | 190 |
186 /** | 191 /** |
187 * Initialize all modal dialogs (class kd-modaldialog), adding event handlers | 192 * Initialize all modal dialogs (class kd-modaldialog), adding event handlers |
188 * to confine keyboard navigation to child controls of the dialog when it is | 193 * to confine keyboard navigation to child controls of the dialog when it is |
189 * shown and restore keyboard navigation when it is hidden. | 194 * shown and restore keyboard navigation when it is hidden. |
190 */ | 195 */ |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 break; | 253 break; |
249 } | 254 } |
250 } | 255 } |
251 if (removeFromKeyboardNavigation) { | 256 if (removeFromKeyboardNavigation) { |
252 element.setAttribute(kSavedAttributeName, element.tabIndex); | 257 element.setAttribute(kSavedAttributeName, element.tabIndex); |
253 element.tabIndex = -1; | 258 element.tabIndex = -1; |
254 } | 259 } |
255 } | 260 } |
256 } | 261 } |
257 } | 262 } |
OLD | NEW |