Chromium Code Reviews| Index: chrome/browser/resources/md_bookmarks/router.js |
| diff --git a/chrome/browser/resources/md_bookmarks/router.js b/chrome/browser/resources/md_bookmarks/router.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..7b1e93c83c33c3049a27afba5d866f638118ad0f |
| --- /dev/null |
| +++ b/chrome/browser/resources/md_bookmarks/router.js |
| @@ -0,0 +1,50 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +Polymer({ |
| + /** |
| + * This element is a one way bound interface that routes the page URL to |
| + * the searchTerm and selectedId. Clients must initialize themselves by |
| + * reading the router's fields after attach. |
| + */ |
| + is: 'bookmarks-router', |
| + |
| + properties: { |
| + // Parameter q is routed to the searchTerm. |
| + // Parameter id is routed to the selectedId. |
| + queryParams_: Object, |
| + |
| + searchTerm: { |
| + type: String, |
| + observer: 'onSearchTermChanged_', |
| + }, |
| + |
| + /** @type {?string} */ |
| + selectedId: { |
| + type: String, |
| + observer: 'onSelectedChanged_', |
| + }, |
| + }, |
| + |
| + observers: [ |
| + 'onQueryChanged_(queryParams_.*)', |
| + ], |
| + |
| + /** @private */ |
| + onQueryChanged_: function() { |
| + this.searchTerm = this.queryParams_.q || ''; |
| + this.selectedId = this.queryParams_.id; |
| + this.fire('url-changed'); |
|
tsergeant
2017/01/19 06:45:56
Rather than adding a new handler, is it possible t
angelayang
2017/01/20 00:58:15
for sure
|
| + }, |
| + |
| + /** @private */ |
| + onSelectedChanged_: function() { |
| + this.set('queryParams_.id', this.selectedId || null); |
| + }, |
| + |
| + /** @private */ |
| + onSearchTermChanged_: function() { |
| + this.set('queryParams_.q', this.searchTerm || null); |
| + }, |
| +}); |