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_ = Polymer.dom(this).observeNodes( | 50 this.lightDomObserver_ = Polymer.dom(this).observeNodes( |
51 this.lightDomChanged_.bind(this)); | 51 this.lightDomChanged_.bind(this)); |
52 }, | 52 }, |
53 | 53 |
| 54 /** @override */ |
| 55 attached: function() { |
| 56 this.outline_ = cr.ui.FocusOutlineManager.forDocument(document); |
| 57 }, |
| 58 |
54 /** | 59 /** |
55 * @param {!Event} e | 60 * @param {!Event} e |
56 * @private | 61 * @private |
57 */ | 62 */ |
58 onIronSelect_: function(e) { | 63 onIronSelect_: function(e) { |
59 if (!this.focusConfig || !this.previousRoute_) | 64 if (!this.focusConfig || !this.previousRoute_) |
60 return; | 65 return; |
61 | 66 |
62 // Don't attempt to focus any anchor element, unless last navigation was a | 67 // Don't attempt to focus any anchor element, unless last navigation was a |
63 // 'pop' (backwards) navigation. | 68 // 'pop' (backwards) navigation. |
(...skipping 11 matching lines...) Expand all Loading... |
75 } | 80 } |
76 | 81 |
77 var selector = this.focusConfig.get(this.previousRoute_.path); | 82 var selector = this.focusConfig.get(this.previousRoute_.path); |
78 if (selector) { | 83 if (selector) { |
79 // neon-animatable has "display: none" until the animation finishes, so | 84 // neon-animatable has "display: none" until the animation finishes, so |
80 // calling focus() on any of its children has no effect until | 85 // calling focus() on any of its children has no effect until |
81 // "display: none" is removed. Therefore can't call focus() from within | 86 // "display: none" is removed. Therefore can't call focus() from within |
82 // the currentRouteChanged callback. Using 'iron-select' listener which | 87 // the currentRouteChanged callback. Using 'iron-select' listener which |
83 // fires after the animation has finished allows focus() to work as | 88 // fires after the animation has finished allows focus() to work as |
84 // expected. | 89 // expected. |
85 this.querySelector(selector).focus(); | 90 var toFocus = this.querySelector(selector); |
| 91 var suppressInk = !this.outline_.visible; |
| 92 var origNoInk; |
| 93 |
| 94 if (suppressInk) { |
| 95 origNoInk = toFocus.noink; |
| 96 toFocus.noink = true; |
| 97 } |
| 98 |
| 99 toFocus.focus(); |
| 100 |
| 101 if (suppressInk) |
| 102 toFocus.noink = origNoInk; |
86 } | 103 } |
87 }, | 104 }, |
88 | 105 |
89 /** | 106 /** |
90 * Called initially once the effective children are ready. | 107 * Called initially once the effective children are ready. |
91 * @private | 108 * @private |
92 */ | 109 */ |
93 lightDomChanged_: function() { | 110 lightDomChanged_: function() { |
94 if (this.lightDomReady_) | 111 if (this.lightDomReady_) |
95 return; | 112 return; |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 // instance, such that the stamped instance will also be ignored by the | 211 // instance, such that the stamped instance will also be ignored by the |
195 // searching algorithm. | 212 // searching algorithm. |
196 if (template.hasAttribute('no-search')) | 213 if (template.hasAttribute('no-search')) |
197 subpage.setAttribute('no-search', ''); | 214 subpage.setAttribute('no-search', ''); |
198 | 215 |
199 // Render synchronously so neon-animated-pages can select the subpage. | 216 // Render synchronously so neon-animated-pages can select the subpage. |
200 template.if = true; | 217 template.if = true; |
201 template.render(); | 218 template.render(); |
202 }, | 219 }, |
203 }); | 220 }); |
OLD | NEW |