Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(183)

Side by Side Diff: chrome/browser/resources/settings/settings_page/settings_animated_pages.js

Issue 2156413002: Settings Router Refactor: Migrate to settings.Route.navigateTo calls. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use timing fix Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 28 matching lines...) Expand all
39 }, 39 },
40 }, 40 },
41 41
42 /** @override */ 42 /** @override */
43 created: function() { 43 created: function() {
44 // Observe the light DOM so we know when it's ready. 44 // Observe the light DOM so we know when it's ready.
45 this.lightDomObserver_ = Polymer.dom(this).observeNodes( 45 this.lightDomObserver_ = Polymer.dom(this).observeNodes(
46 this.lightDomChanged_.bind(this)); 46 this.lightDomChanged_.bind(this));
47 47
48 this.addEventListener('subpage-back', function() { 48 this.addEventListener('subpage-back', function() {
49 assert(this.currentRoute.section == this.section); 49 settings.navigateTo(this.currentRoute.parent);
50 assert(this.currentRoute.subpage.length >= 1);
51
52 this.setSubpageChain(this.currentRoute.subpage.slice(0, -1));
53 }.bind(this)); 50 }.bind(this));
54 }, 51 },
55 52
56 /** 53 /**
57 * Called initially once the effective children are ready. 54 * Called initially once the effective children are ready.
58 * @private 55 * @private
59 */ 56 */
60 lightDomChanged_: function() { 57 lightDomChanged_: function() {
61 if (this.lightDomReady_) 58 if (this.lightDomReady_)
62 return; 59 return;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 // Set the subpage's id for use by neon-animated-pages. 131 // Set the subpage's id for use by neon-animated-pages.
135 var subpage = /** @type {{_content: DocumentFragment}} */(template)._content 132 var subpage = /** @type {{_content: DocumentFragment}} */(template)._content
136 .querySelector('settings-subpage'); 133 .querySelector('settings-subpage');
137 if (!subpage.id) 134 if (!subpage.id)
138 subpage.id = id; 135 subpage.id = id;
139 136
140 // Render synchronously so neon-animated-pages can select the subpage. 137 // Render synchronously so neon-animated-pages can select the subpage.
141 template.if = true; 138 template.if = true;
142 template.render(); 139 template.render();
143 }, 140 },
144
145 /**
146 * Buttons in this pageset should use this method to transition to subpages.
147 * @param {!Array<string>} subpage The chain of subpages within the page.
148 */
149 setSubpageChain: function(subpage) {
150 var node = window.event.currentTarget;
151 var page;
152 while (node) {
153 if (node.dataset && node.dataset.page)
154 page = node.dataset.page;
155 // A shadow root has a |host| rather than a |parentNode|.
156 node = node.host || node.parentNode;
157 }
158 this.currentRoute = {
159 page: page,
160 section: subpage.length > 0 ? this.section : '',
161 subpage: subpage,
162 };
163 },
164 }); 141 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698