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

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

Issue 2614703003: [MD Bookmarks] Add search. (Closed)
Patch Set: Created 3 years, 11 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
Index: chrome/browser/resources/md_bookmarks/store.js
diff --git a/chrome/browser/resources/md_bookmarks/store.js b/chrome/browser/resources/md_bookmarks/store.js
index 7a9817817b0991fe590a6f28add51eabb1c1b0b1..01d113bf60fcffff75e0a95bbb396a3acb7f1b59 100644
--- a/chrome/browser/resources/md_bookmarks/store.js
+++ b/chrome/browser/resources/md_bookmarks/store.js
@@ -26,6 +26,18 @@ Polymer({
},
idToNodeMap_: Object,
+
+ searchTerm: {
+ type: String,
+ observer: 'updateSearchResult_',
+ notify: true,
+ },
+
+ searchResult: {
+ type: Array,
+ value: [],
+ notify: true,
+ },
},
/** @private {Object} */
@@ -36,6 +48,7 @@ Polymer({
this.documentListeners_ = {
'selected-folder-changed': this.onSelectedFolderChanged_.bind(this),
'folder-open-changed': this.onFolderOpenChanged_.bind(this),
+ 'search-term-changed': this.onSearchTermChanged_.bind(this),
};
for (var event in this.documentListeners_)
document.addEventListener(event, this.documentListeners_[event]);
@@ -76,6 +89,9 @@ Polymer({
* @private
*/
onSelectedFolderChanged_: function(e) {
+ // Clear search and thus set the sidebar to active.
+ this.set('searchTerm', '');
+
// Deselect the old folder if defined.
if (this.selectedId)
this.set(this.idToNodeMap_[this.selectedId].path + '.isSelected', false);
@@ -135,4 +151,19 @@ Polymer({
this.initNodes_(bookmarkNode.children[i]);
}
},
+
+ /**
+ * @param {Event} e
+ * @private
+ */
+ onSearchTermChanged_: function(e) {
+ this.searchTerm = /** @type {string} */ (e.detail);
+ },
+
+ /** @private */
+ updateSearchResult_: function() {
+ chrome.bookmarks.search(this.searchTerm, function(results) {
+ this.searchResult = results;
+ }.bind(this));
+ },
});

Powered by Google App Engine
This is Rietveld 408576698