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..ca91000b3f748f82b62d24a3a38333d28fc34202 |
| --- /dev/null |
| +++ b/chrome/browser/resources/md_bookmarks/router.js |
| @@ -0,0 +1,55 @@ |
| +// 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({ |
|
calamity
2017/01/18 03:37:21
This element deserves a comment, particularly beca
angelayang
2017/01/18 06:34:02
Done.
|
| + is: 'bookmarks-router', |
| + |
| + properties: { |
| + /** Path is routed to the selectedId */ |
| + path: { |
|
calamity
2017/01/18 03:37:21
I think you can make a few of these fields private
angelayang
2017/01/18 06:34:02
Done.
|
| + type: String, |
| + observer: 'onPathChanged_', |
| + }, |
| + |
| + /** Parameter is routed to the searchTerm */ |
|
calamity
2017/01/18 03:37:21
Use // for non-jsdoc comments.
angelayang
2017/01/18 06:34:02
Done.
|
| + queryParams: { |
| + type: Object, |
| + }, |
|
jiaxi
2017/01/17 05:19:02
queryParams: Object,
angelayang
2017/01/17 05:36:03
Done.
|
| + |
| + searchTerm: { |
| + type: String, |
| + observer: 'onSearchTermChanged_', |
| + }, |
| + |
| + /** @type {?string} */ |
| + selectedId: { |
| + type: String, |
| + observer: 'onSelectedChanged_', |
| + }, |
| + }, |
| + |
| + observers: [ |
| + 'onQueryChanged_(queryParams.*)', |
| + ], |
| + |
| + /** @private */ |
| + onPathChanged_: function() { |
| + this.selectedId = this.path.substr(1) || null; |
| + }, |
| + |
| + /** @private */ |
| + onQueryChanged_: function() { |
| + this.searchTerm = this.queryParams.q || ''; |
| + }, |
| + |
| + /** @private */ |
| + onSelectedChanged_: function() { |
| + this.path = '/' + (this.selectedId || ''); |
| + }, |
| + |
| + /** @private */ |
| + onSearchTermChanged_: function() { |
| + this.set('queryParams.q', this.searchTerm || null); |
| + }, |
| +}) |