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

Unified Diff: chrome/browser/resources/md_bookmarks/router.js

Issue 2745993002: MD Bookmarks: Update URL router to work in new data binding system (Closed)
Patch Set: calamity@ review Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/resources/md_bookmarks/router.html ('k') | chrome/browser/resources/md_bookmarks/toolbar.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
index 38b16f1602b66411ddf12a73668bcad0cd2e54e0..11d1d40104c5a4cc6d9409b5f11687d5b9715b6c 100644
--- a/chrome/browser/resources/md_bookmarks/router.js
+++ b/chrome/browser/resources/md_bookmarks/router.js
@@ -10,45 +10,68 @@ Polymer({
*/
is: 'bookmarks-router',
+ behaviors: [
+ bookmarks.StoreClient,
+ ],
+
properties: {
- // Parameter q is routed to the searchTerm.
- // Parameter id is routed to the selectedId.
+ /**
+ * Parameter q is routed to the searchTerm.
+ * Parameter id is routed to the selectedId.
+ * @private
+ */
queryParams_: Object,
- searchTerm: {
- type: String,
- observer: 'onSearchTermChanged_',
- },
+ /** @private */
+ searchTerm_: String,
- /** @type {?string} */
- selectedId: {
- type: String,
- observer: 'onSelectedIdChanged_',
- },
+ /** @private {?string} */
+ selectedId_: String,
},
observers: [
- 'onQueryChanged_(queryParams_.*)',
+ 'onQueryChanged_(queryParams_.q)',
+ 'onFolderChanged_(queryParams_.id)',
+ 'onStateChanged_(searchTerm_, selectedId_)',
],
+ attached: function() {
+ this.watch('selectedId_', function(state) {
+ return state.selectedFolder;
+ });
+ this.watch('searchTerm_', function(state) {
+ return state.search.term;
+ });
+ },
+
/** @private */
onQueryChanged_: function() {
- this.searchTerm = this.queryParams_.q || '';
- this.selectedId = this.queryParams_.id;
+ var searchTerm = this.queryParams_.q || '';
+ if (searchTerm && searchTerm != this.searchTerm_) {
+ this.searchTerm_ = searchTerm;
+ this.dispatch(bookmarks.actions.setSearchTerm(searchTerm));
+ }
+ },
- if (this.searchTerm)
- this.fire('search-term-changed', this.searchTerm);
- else
- this.fire('selected-folder-changed', this.selectedId);
+ /** @private */
+ onFolderChanged_: function() {
+ var selectedId = this.queryParams_.id;
+ if (selectedId && selectedId != this.selectedId_) {
+ this.selectedId_ = selectedId;
+ this.dispatch(bookmarks.actions.selectFolder(selectedId));
+ }
},
/** @private */
- onSelectedIdChanged_: function() {
- this.set('queryParams_.id', this.selectedId || null);
+ onStateChanged_: function() {
+ this.debounce('updateQueryParams', this.updateQueryParams_.bind(this));
},
/** @private */
- onSearchTermChanged_: function() {
- this.set('queryParams_.q', this.searchTerm || null);
+ updateQueryParams_: function() {
+ if (this.searchTerm_)
+ this.queryParams_ = {q: this.searchTerm_};
+ else
+ this.queryParams_ = {id: this.selectedId_};
},
});
« no previous file with comments | « chrome/browser/resources/md_bookmarks/router.html ('k') | chrome/browser/resources/md_bookmarks/toolbar.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698