OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 * 'settings-animated-pages' is a container for a page and animated subpages. | 7 * 'settings-animated-pages' is a container for a page and animated subpages. |
8 * It provides a set of common behaviors and animations. | 8 * It provides a set of common behaviors and animations. |
9 * | 9 * |
10 * Example: | 10 * Example: |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 */ | 44 */ |
45 previousRoute_: null, | 45 previousRoute_: null, |
46 | 46 |
47 /** @override */ | 47 /** @override */ |
48 created: function() { | 48 created: function() { |
49 // Observe the light DOM so we know when it's ready. | 49 // Observe the light DOM so we know when it's ready. |
50 this.lightDomObserver_ = | 50 this.lightDomObserver_ = |
51 Polymer.dom(this).observeNodes(this.lightDomChanged_.bind(this)); | 51 Polymer.dom(this).observeNodes(this.lightDomChanged_.bind(this)); |
52 }, | 52 }, |
53 | 53 |
54 /** @override */ | |
55 attached: function() { | |
56 this.outline_ = cr.ui.FocusOutlineManager.forDocument(document); | |
57 }, | |
58 | |
59 /** | 54 /** |
60 * @param {!Event} e | 55 * @param {!Event} e |
61 * @private | 56 * @private |
62 */ | 57 */ |
63 onIronSelect_: function(e) { | 58 onIronSelect_: function(e) { |
64 if (!this.focusConfig || !this.previousRoute_) | 59 if (!this.focusConfig || !this.previousRoute_) |
65 return; | 60 return; |
66 | 61 |
67 // Don't attempt to focus any anchor element, unless last navigation was a | 62 // Don't attempt to focus any anchor element, unless last navigation was a |
68 // 'pop' (backwards) navigation. | 63 // 'pop' (backwards) navigation. |
(...skipping 10 matching lines...) Expand all Loading... |
79 whitelist += ', settings-subpage[route-path=\"' + | 74 whitelist += ', settings-subpage[route-path=\"' + |
80 settings.Route.INTERNET_NETWORKS.path + '\"]'; | 75 settings.Route.INTERNET_NETWORKS.path + '\"]'; |
81 // </if> | 76 // </if> |
82 | 77 |
83 if (!e.detail.item.matches('neon-animatable, ' + whitelist)) | 78 if (!e.detail.item.matches('neon-animatable, ' + whitelist)) |
84 return; | 79 return; |
85 | 80 |
86 var selector = this.focusConfig.get(this.previousRoute_.path); | 81 var selector = this.focusConfig.get(this.previousRoute_.path); |
87 if (selector) { | 82 if (selector) { |
88 // neon-animatable has "display: none" until the animation finishes, so | 83 // neon-animatable has "display: none" until the animation finishes, so |
89 // calling focus() on any of its children has no effect until | 84 // calling focus() on any of its children has no effect until "display: |
90 // "display: none" is removed. Therefore can't call focus() from within | 85 // none" is removed. Therefore, don't set focus from within the |
91 // the currentRouteChanged callback. Using 'iron-select' listener which | 86 // currentRouteChanged callback. Using 'iron-select' listener which fires |
92 // fires after the animation has finished allows focus() to work as | 87 // after the animation has finished allows setting focus to work. |
93 // expected. | 88 cr.ui.focusWithoutInk(assert(this.querySelector(selector))); |
94 var toFocus = this.querySelector(selector); | |
95 var suppressInk = !this.outline_.visible; | |
96 var origNoInk; | |
97 | |
98 if (suppressInk) { | |
99 origNoInk = toFocus.noink; | |
100 toFocus.noink = true; | |
101 } | |
102 | |
103 toFocus.focus(); | |
104 | |
105 if (suppressInk) | |
106 toFocus.noink = origNoInk; | |
107 } | 89 } |
108 }, | 90 }, |
109 | 91 |
110 /** | 92 /** |
111 * Called initially once the effective children are ready. | 93 * Called initially once the effective children are ready. |
112 * @private | 94 * @private |
113 */ | 95 */ |
114 lightDomChanged_: function() { | 96 lightDomChanged_: function() { |
115 if (this.lightDomReady_) | 97 if (this.lightDomReady_) |
116 return; | 98 return; |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 // instance, such that the stamped instance will also be ignored by the | 196 // instance, such that the stamped instance will also be ignored by the |
215 // searching algorithm. | 197 // searching algorithm. |
216 if (template.hasAttribute('no-search')) | 198 if (template.hasAttribute('no-search')) |
217 subpage.setAttribute('no-search', ''); | 199 subpage.setAttribute('no-search', ''); |
218 | 200 |
219 // Render synchronously so neon-animated-pages can select the subpage. | 201 // Render synchronously so neon-animated-pages can select the subpage. |
220 template.if = true; | 202 template.if = true; |
221 template.render(); | 203 template.render(); |
222 }, | 204 }, |
223 }); | 205 }); |
OLD | NEW |