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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 }; | 53 }; |
54 | 54 |
55 /** @const */ | 55 /** @const */ |
56 remoting.kIT2MeVisitedStorageKey = 'it2me-visited'; | 56 remoting.kIT2MeVisitedStorageKey = 'it2me-visited'; |
57 /** @const */ | 57 /** @const */ |
58 remoting.kMe2MeVisitedStorageKey = 'me2me-visited'; | 58 remoting.kMe2MeVisitedStorageKey = 'me2me-visited'; |
59 | 59 |
60 /** | 60 /** |
61 * @param {Element} element The element to check. | 61 * @param {Element} element The element to check. |
62 * @param {string} attrName The attribute on the element to check. | 62 * @param {string} attrName The attribute on the element to check. |
63 * @param {Array.<string>} modes The modes to check for. | 63 * @param {Array<string>} modes The modes to check for. |
64 * @return {boolean} True if any mode in |modes| is found within the attribute. | 64 * @return {boolean} True if any mode in |modes| is found within the attribute. |
65 */ | 65 */ |
66 remoting.hasModeAttribute = function(element, attrName, modes) { | 66 remoting.hasModeAttribute = function(element, attrName, modes) { |
67 var attr = element.getAttribute(attrName); | 67 var attr = element.getAttribute(attrName); |
68 for (var i = 0; i < modes.length; ++i) { | 68 for (var i = 0; i < modes.length; ++i) { |
69 if (attr.match(new RegExp('(\\s|^)' + modes[i] + '(\\s|$)')) != null) { | 69 if (attr.match(new RegExp('(\\s|^)' + modes[i] + '(\\s|$)')) != null) { |
70 return true; | 70 return true; |
71 } | 71 } |
72 } | 72 } |
73 return false; | 73 return false; |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 var options = /** @type {MutationObserverInit} */({ | 232 var options = /** @type {MutationObserverInit} */({ |
233 subtree: false, | 233 subtree: false, |
234 attributes: true | 234 attributes: true |
235 }); | 235 }); |
236 for (var i = 0; i < dialogs.length; ++i) { | 236 for (var i = 0; i < dialogs.length; ++i) { |
237 observer.observe(dialogs[i], options); | 237 observer.observe(dialogs[i], options); |
238 } | 238 } |
239 }; | 239 }; |
240 | 240 |
241 /** | 241 /** |
242 * @param {Array.<MutationRecord>} mutations The set of mutations affecting | 242 * @param {Array<MutationRecord>} mutations The set of mutations affecting |
243 * an observed node. | 243 * an observed node. |
244 */ | 244 */ |
245 function confineOrRestoreFocus_(mutations) { | 245 function confineOrRestoreFocus_(mutations) { |
246 // The list of mutations can include duplicates, so reduce it to a canonical | 246 // The list of mutations can include duplicates, so reduce it to a canonical |
247 // show/hide list. | 247 // show/hide list. |
248 /** @type {Array.<Node>} */ | 248 /** @type {Array<Node>} */ |
249 var shown = []; | 249 var shown = []; |
250 /** @type {Array.<Node>} */ | 250 /** @type {Array<Node>} */ |
251 var hidden = []; | 251 var hidden = []; |
252 for (var i = 0; i < mutations.length; ++i) { | 252 for (var i = 0; i < mutations.length; ++i) { |
253 var mutation = mutations[i]; | 253 var mutation = mutations[i]; |
254 if (mutation.type == 'attributes' && | 254 if (mutation.type == 'attributes' && |
255 mutation.attributeName == 'hidden') { | 255 mutation.attributeName == 'hidden') { |
256 var node = mutation.target; | 256 var node = mutation.target; |
257 if (node.hidden && hidden.indexOf(node) == -1) { | 257 if (node.hidden && hidden.indexOf(node) == -1) { |
258 hidden.push(node); | 258 hidden.push(node); |
259 } else if (!node.hidden && shown.indexOf(node) == -1) { | 259 } else if (!node.hidden && shown.indexOf(node) == -1) { |
260 shown.push(node); | 260 shown.push(node); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 } | 295 } |
296 | 296 |
297 /** | 297 /** |
298 * @param {string} tag | 298 * @param {string} tag |
299 */ | 299 */ |
300 remoting.showSetupProcessingMessage = function(tag) { | 300 remoting.showSetupProcessingMessage = function(tag) { |
301 var messageDiv = document.getElementById('host-setup-processing-message'); | 301 var messageDiv = document.getElementById('host-setup-processing-message'); |
302 l10n.localizeElementFromTag(messageDiv, tag); | 302 l10n.localizeElementFromTag(messageDiv, tag); |
303 remoting.setMode(remoting.AppMode.HOST_SETUP_PROCESSING); | 303 remoting.setMode(remoting.AppMode.HOST_SETUP_PROCESSING); |
304 } | 304 } |
OLD | NEW |