| 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 16 matching lines...) Expand all Loading... |
| 27 * The section name must match the name specified in route.js. | 27 * The section name must match the name specified in route.js. |
| 28 */ | 28 */ |
| 29 section: { | 29 section: { |
| 30 type: String, | 30 type: String, |
| 31 }, | 31 }, |
| 32 }, | 32 }, |
| 33 | 33 |
| 34 /** @override */ | 34 /** @override */ |
| 35 created: function() { | 35 created: function() { |
| 36 // Observe the light DOM so we know when it's ready. | 36 // Observe the light DOM so we know when it's ready. |
| 37 this.lightDomObserver_ = Polymer.dom(this).observeNodes( | 37 this.lightDomObserver_ = |
| 38 this.lightDomChanged_.bind(this)); | 38 Polymer.dom(this).observeNodes(this.lightDomChanged_.bind(this)); |
| 39 }, | 39 }, |
| 40 | 40 |
| 41 /** | 41 /** |
| 42 * Called initially once the effective children are ready. | 42 * Called initially once the effective children are ready. |
| 43 * @private | 43 * @private |
| 44 */ | 44 */ |
| 45 lightDomChanged_: function() { | 45 lightDomChanged_: function() { |
| 46 if (this.lightDomReady_) | 46 if (this.lightDomReady_) |
| 47 return; | 47 return; |
| 48 | 48 |
| 49 this.lightDomReady_ = true; | 49 this.lightDomReady_ = true; |
| 50 Polymer.dom(this).unobserveNodes(this.lightDomObserver_); | 50 Polymer.dom(this).unobserveNodes(this.lightDomObserver_); |
| 51 this.runQueuedRouteChange_(); | 51 this.runQueuedRouteChange_(); |
| 52 }, | 52 }, |
| 53 | 53 |
| 54 /** | 54 /** |
| 55 * Calls currentRouteChanged with the deferred route change info. | 55 * Calls currentRouteChanged with the deferred route change info. |
| 56 * @private | 56 * @private |
| 57 */ | 57 */ |
| 58 runQueuedRouteChange_: function() { | 58 runQueuedRouteChange_: function() { |
| 59 if (!this.queuedRouteChange_) | 59 if (!this.queuedRouteChange_) |
| 60 return; | 60 return; |
| 61 this.async(this.currentRouteChanged.bind( | 61 this.async(this.currentRouteChanged.bind( |
| 62 this, | 62 this, this.queuedRouteChange_.newRoute, |
| 63 this.queuedRouteChange_.newRoute, | |
| 64 this.queuedRouteChange_.oldRoute)); | 63 this.queuedRouteChange_.oldRoute)); |
| 65 }, | 64 }, |
| 66 | 65 |
| 67 /** @protected */ | 66 /** @protected */ |
| 68 currentRouteChanged: function(newRoute, oldRoute) { | 67 currentRouteChanged: function(newRoute, oldRoute) { |
| 69 if (newRoute.section == this.section && newRoute.isSubpage()) { | 68 if (newRoute.section == this.section && newRoute.isSubpage()) { |
| 70 this.switchToSubpage_(newRoute, oldRoute); | 69 this.switchToSubpage_(newRoute, oldRoute); |
| 71 } else { | 70 } else { |
| 72 this.$.animatedPages.exitAnimation = 'fade-out-animation'; | 71 this.$.animatedPages.exitAnimation = 'fade-out-animation'; |
| 73 this.$.animatedPages.entryAnimation = 'fade-in-animation'; | 72 this.$.animatedPages.entryAnimation = 'fade-in-animation'; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 var routePath = settings.getCurrentRoute().path; | 128 var routePath = settings.getCurrentRoute().path; |
| 130 var template = Polymer.dom(this).querySelector( | 129 var template = Polymer.dom(this).querySelector( |
| 131 'template[route-path="' + routePath + '"]'); | 130 'template[route-path="' + routePath + '"]'); |
| 132 | 131 |
| 133 // Nothing to do if the subpage isn't wrapped in a <template> or the | 132 // Nothing to do if the subpage isn't wrapped in a <template> or the |
| 134 // template is already stamped. | 133 // template is already stamped. |
| 135 if (!template || template.if) | 134 if (!template || template.if) |
| 136 return; | 135 return; |
| 137 | 136 |
| 138 // Set the subpage's id for use by neon-animated-pages. | 137 // Set the subpage's id for use by neon-animated-pages. |
| 139 var subpage = /** @type {{_content: DocumentFragment}} */(template)._content | 138 var subpage = /** @type {{_content: DocumentFragment}} */ (template) |
| 140 .querySelector('settings-subpage'); | 139 ._content.querySelector('settings-subpage'); |
| 141 subpage.setAttribute('route-path', routePath); | 140 subpage.setAttribute('route-path', routePath); |
| 142 | 141 |
| 143 // Carry over the 'no-search' attribute from the template to the stamped | 142 // Carry over the 'no-search' attribute from the template to the stamped |
| 144 // instance, such that the stamped instance will also be ignored by the | 143 // instance, such that the stamped instance will also be ignored by the |
| 145 // searching algorithm. | 144 // searching algorithm. |
| 146 if (template.hasAttribute('no-search')) | 145 if (template.hasAttribute('no-search')) |
| 147 subpage.setAttribute('no-search', ''); | 146 subpage.setAttribute('no-search', ''); |
| 148 | 147 |
| 149 // Render synchronously so neon-animated-pages can select the subpage. | 148 // Render synchronously so neon-animated-pages can select the subpage. |
| 150 template.if = true; | 149 template.if = true; |
| 151 template.render(); | 150 template.render(); |
| 152 }, | 151 }, |
| 153 }); | 152 }); |
| OLD | NEW |