Chromium Code Reviews| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 65 if (!this.queuedRouteChange_) | 65 if (!this.queuedRouteChange_) |
| 66 return; | 66 return; |
| 67 this.async(this.currentRouteChanged.bind( | 67 this.async(this.currentRouteChanged.bind( |
| 68 this, | 68 this, |
| 69 this.queuedRouteChange_.newRoute, | 69 this.queuedRouteChange_.newRoute, |
| 70 this.queuedRouteChange_.oldRoute)); | 70 this.queuedRouteChange_.oldRoute)); |
| 71 }, | 71 }, |
| 72 | 72 |
| 73 /** @protected */ | 73 /** @protected */ |
| 74 currentRouteChanged: function(newRoute, oldRoute) { | 74 currentRouteChanged: function(newRoute, oldRoute) { |
| 75 if (newRoute.section == this.section && newRoute.subpage.length > 0) { | 75 if (newRoute.section == this.section && newRoute.isSubpage()) { |
| 76 this.switchToSubpage_(newRoute, oldRoute); | 76 this.switchToSubpage_(newRoute, oldRoute); |
| 77 } else { | 77 } else { |
| 78 this.$.animatedPages.exitAnimation = 'fade-out-animation'; | 78 this.$.animatedPages.exitAnimation = 'fade-out-animation'; |
| 79 this.$.animatedPages.entryAnimation = 'fade-in-animation'; | 79 this.$.animatedPages.entryAnimation = 'fade-in-animation'; |
| 80 this.$.animatedPages.selected = 'main'; | 80 this.$.animatedPages.selected = 'main'; |
| 81 } | 81 } |
| 82 }, | 82 }, |
| 83 | 83 |
| 84 /** | 84 /** |
| 85 * Selects the subpage specified by |newRoute|. | 85 * Selects the subpage specified by |newRoute|. |
| 86 * @param {!settings.Route} newRoute | 86 * @param {!settings.Route} newRoute |
| 87 * @param {!settings.Route} oldRoute | 87 * @param {!settings.Route} oldRoute |
| 88 * @private | 88 * @private |
| 89 */ | 89 */ |
| 90 switchToSubpage_: function(newRoute, oldRoute) { | 90 switchToSubpage_: function(newRoute, oldRoute) { |
|
michaelpg
2016/08/09 03:07:48
it looks like this function can be triggered for d
tommycli
2016/08/09 16:03:14
Hmmm... should we change isSubpage() to return fal
michaelpg
2016/08/09 20:39:32
I think the existing behavior is wrong, but I'm no
tommycli
2016/08/10 17:21:33
Okay, I tested this, and the best behavior is to m
michaelpg
2016/08/10 18:45:51
Not sure how that would work, given we still need
tommycli
2016/08/10 18:52:17
The only navigable dialog is Clear Browsing Data,
| |
| 91 // Don't manipulate the light DOM until it's ready. | 91 // Don't manipulate the light DOM until it's ready. |
| 92 if (!this.lightDomReady_) { | 92 if (!this.lightDomReady_) { |
| 93 this.queuedRouteChange_ = this.queuedRouteChange_ || {oldRoute: oldRoute}; | 93 this.queuedRouteChange_ = this.queuedRouteChange_ || {oldRoute: oldRoute}; |
| 94 this.queuedRouteChange_.newRoute = newRoute; | 94 this.queuedRouteChange_.newRoute = newRoute; |
| 95 return; | 95 return; |
| 96 } | 96 } |
| 97 | 97 |
| 98 this.ensureSubpageInstance_(); | 98 this.ensureSubpageInstance_(); |
| 99 | 99 |
| 100 if (oldRoute) { | 100 if (oldRoute) { |
| 101 var oldRouteIsSubpage = oldRoute.subpage.length > 0; | 101 if (oldRoute.isSubpage() && oldRoute.contains(newRoute)) { |
| 102 if (oldRouteIsSubpage && oldRoute.contains(newRoute)) { | |
| 103 // Slide left for a descendant subpage. | 102 // Slide left for a descendant subpage. |
| 104 this.$.animatedPages.exitAnimation = 'slide-left-animation'; | 103 this.$.animatedPages.exitAnimation = 'slide-left-animation'; |
| 105 this.$.animatedPages.entryAnimation = 'slide-from-right-animation'; | 104 this.$.animatedPages.entryAnimation = 'slide-from-right-animation'; |
| 106 } else if (newRoute.contains(oldRoute)) { | 105 } else if (newRoute.contains(oldRoute)) { |
| 107 // Slide right for an ancestor subpage. | 106 // Slide right for an ancestor subpage. |
| 108 this.$.animatedPages.exitAnimation = 'slide-right-animation'; | 107 this.$.animatedPages.exitAnimation = 'slide-right-animation'; |
| 109 this.$.animatedPages.entryAnimation = 'slide-from-left-animation'; | 108 this.$.animatedPages.entryAnimation = 'slide-from-left-animation'; |
| 110 } else { | 109 } else { |
| 111 // The old route is not a subpage or is at the same level, so just fade. | 110 // The old route is not a subpage or is at the same level, so just fade. |
| 112 this.$.animatedPages.exitAnimation = 'fade-out-animation'; | 111 this.$.animatedPages.exitAnimation = 'fade-out-animation'; |
| 113 this.$.animatedPages.entryAnimation = 'fade-in-animation'; | 112 this.$.animatedPages.entryAnimation = 'fade-in-animation'; |
| 114 | 113 |
| 115 if (!oldRouteIsSubpage) { | 114 if (!oldRoute.isSubpage()) { |
| 116 // Set the height the expand animation should start at before | 115 // Set the height the expand animation should start at before |
| 117 // beginning the transition to the new subpage. | 116 // beginning the transition to the new subpage. |
| 118 // TODO(michaelpg): Remove MainPageBehavior's dependency on this | 117 // TODO(michaelpg): Remove MainPageBehavior's dependency on this |
| 119 // height being set. | 118 // height being set. |
| 120 this.style.height = this.clientHeight + 'px'; | 119 this.style.height = this.clientHeight + 'px'; |
| 121 this.async(function() { | 120 this.async(function() { |
| 122 this.style.height = ''; | 121 this.style.height = ''; |
| 123 }); | 122 }); |
| 124 } | 123 } |
| 125 } | 124 } |
| 126 } | 125 } |
| 127 | 126 |
| 128 this.$.animatedPages.selected = newRoute.subpage.slice(-1)[0]; | 127 this.$.animatedPages.selected = newRoute.path; |
| 129 }, | 128 }, |
| 130 | 129 |
| 131 /** | 130 /** |
| 132 * Ensures that the template enclosing the subpage is stamped. | 131 * Ensures that the template enclosing the subpage is stamped. |
| 133 * @private | 132 * @private |
| 134 */ | 133 */ |
| 135 ensureSubpageInstance_: function() { | 134 ensureSubpageInstance_: function() { |
| 136 var id = settings.getCurrentRoute().subpage.slice(-1)[0]; | 135 var id = settings.getCurrentRoute().path; |
|
michaelpg
2016/08/09 03:07:48
an ID of "/foo/var" is... unusual, although appare
tommycli
2016/08/09 16:03:14
Well... technically, the paths are all on dom-if n
michaelpg
2016/08/09 20:39:32
Yeah, let's do that!
BTW, thanks for the info, al
tommycli
2016/08/10 17:21:33
Done.
| |
| 137 var template = Polymer.dom(this).querySelector( | 136 var template = Polymer.dom(this).querySelector( |
| 138 'template[name="' + id + '"]'); | 137 'template[name="' + id + '"]'); |
| 139 | 138 |
| 140 // Nothing to do if the subpage isn't wrapped in a <template> or the | 139 // Nothing to do if the subpage isn't wrapped in a <template> or the |
| 141 // template is already stamped. | 140 // template is already stamped. |
| 142 if (!template || template.if) | 141 if (!template || template.if) |
| 143 return; | 142 return; |
| 144 | 143 |
| 145 // Set the subpage's id for use by neon-animated-pages. | 144 // Set the subpage's id for use by neon-animated-pages. |
| 146 var subpage = /** @type {{_content: DocumentFragment}} */(template)._content | 145 var subpage = /** @type {{_content: DocumentFragment}} */(template)._content |
| 147 .querySelector('settings-subpage'); | 146 .querySelector('settings-subpage'); |
| 148 if (!subpage.id) | 147 if (!subpage.id) |
| 149 subpage.id = id; | 148 subpage.id = id; |
| 150 // Carry over the 'no-search' attribute from the template to the stamped | 149 // Carry over the 'no-search' attribute from the template to the stamped |
| 151 // instance, such that the stamped instance will also be ignored by the | 150 // instance, such that the stamped instance will also be ignored by the |
| 152 // searching algorithm. | 151 // searching algorithm. |
| 153 if (template.hasAttribute('no-search')) | 152 if (template.hasAttribute('no-search')) |
| 154 subpage.setAttribute('no-search', ''); | 153 subpage.setAttribute('no-search', ''); |
| 155 | 154 |
| 156 // Render synchronously so neon-animated-pages can select the subpage. | 155 // Render synchronously so neon-animated-pages can select the subpage. |
| 157 template.if = true; | 156 template.if = true; |
| 158 template.render(); | 157 template.render(); |
| 159 }, | 158 }, |
| 160 }); | 159 }); |
| OLD | NEW |