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

Side by Side Diff: third_party/polymer/v0_8/components/more-routing/more-route-selector.html

Issue 1140393002: Update more-routing for md-settings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 <!-- 1 <!--
2 Copyright (c) 2015 The Polymer Project Authors. All rights reserved. 2 Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
3 This code may only be used under the BSD style license found at http://polymer.g ithub.io/LICENSE.txt 3 This code may only be used under the BSD style license found at http://polymer.g ithub.io/LICENSE.txt
4 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt 4 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
5 The complete set of contributors may be found at http://polymer.github.io/CONTRI BUTORS.txt 5 The complete set of contributors may be found at http://polymer.github.io/CONTRI BUTORS.txt
6 Code distributed by Google as part of the polymer project is also 6 Code distributed by Google as part of the polymer project is also
7 subject to an additional IP rights grant found at http://polymer.github.io/PATEN TS.txt 7 subject to an additional IP rights grant found at http://polymer.github.io/PATEN TS.txt
8 --> 8 -->
9 <link rel="import" href="../polymer/polymer.html"> 9 <link rel="import" href="../polymer/polymer.html">
10 10
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 this._updateRoutes(); 120 this._updateRoutes();
121 }, 121 },
122 122
123 /** 123 /**
124 * Handle a change in selected item, driven by the targeted selector. 124 * Handle a change in selected item, driven by the targeted selector.
125 * 125 *
126 * Note that this will fail if a route is chosen that requires params not 126 * Note that this will fail if a route is chosen that requires params not
127 * defined by the current URL. 127 * defined by the current URL.
128 */ 128 */
129 _onSelectedItemChanged: function(event) { 129 _onSelectedItemChanged: function(event) {
130 if (this._settingSelection) return;
130 var route = this._routeForItem(event.detail.value); 131 var route = this._routeForItem(event.detail.value);
131 if (!route) return; 132 if (!route) return;
132 route.navigateTo(); 133 route.navigateTo();
133 }, 134 },
134 135
135 _updateRoutes: function() { 136 _updateRoutes: function() {
136 var routes = []; 137 var routes = [];
137 if (this._managedSelector) { 138 if (this._managedSelector) {
138 routes = this._managedSelector.items.map(this._routeForItem.bind(this)); 139 routes = this._managedSelector.items.map(this._routeForItem.bind(this));
139 } 140 }
140 this._setRoutes(routes); 141 this._setRoutes(routes);
141 }, 142 },
142 143
143 _onMoreRouteChange: function(event) { 144 _onMoreRouteChange: function(event) {
144 if (!this._managedSelector) return; 145 if (!this._managedSelector) return;
145 var route = event.detail.newRoute; 146
146 this._managedSelector.select(this.routes.indexOf(route)); 147 var selected = '';
148
149 var index = this.routes.indexOf(event.detail.newRoute);
150 var attrForSelected = this._managedSelector.attrForSelected;
151 if (!attrForSelected) {
152 selected = index;
153 } else {
154 var item = this._managedSelector.items[index];
155 if (item)
156 selected = item[attrForSelected] || item.getAttribute(attrForSelected);
157 }
158
159 // Make sure that we don't turn around and re-navigate
160 this._settingSelection = true;
161 this._managedSelector.select(selected);
162 this._settingSelection = false;
147 }, 163 },
148 164
149 _findTargetSelector: function() { 165 _findTargetSelector: function() {
150 var children = Polymer.dom(this).children; 166 var children = Polymer.dom(this).children;
151 if (children.length !== 1) { 167 if (children.length !== 1) {
152 console.error(this, 'expects only a single selector child'); 168 console.error(this, 'expects only a single selector child');
153 return null; 169 return null;
154 } 170 }
155 171
156 var child = children[0]; 172 var child = children[0];
(...skipping 18 matching lines...) Expand all
175 var expression = item.getAttribute(this.routeAttribute); 191 var expression = item.getAttribute(this.routeAttribute);
176 var route = MoreRouting.getRoute(expression, this.parentRoute); 192 var route = MoreRouting.getRoute(expression, this.parentRoute);
177 // Associate the route w/ its element while we're here. 193 // Associate the route w/ its element while we're here.
178 item.moreRouteContext = route; 194 item.moreRouteContext = route;
179 195
180 return route; 196 return route;
181 }, 197 },
182 198
183 }); 199 });
184 </script> 200 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698