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

Side by Side Diff: chrome/browser/resources/md_bookmarks/store.js

Issue 2639893006: [MD Bookmarks] Add lines between items and no search results message. (Closed)
Patch Set: Empty list message reevaluates on searchTerm changing. 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 var BookmarksStore = Polymer({ 5 var BookmarksStore = Polymer({
6 is: 'bookmarks-store', 6 is: 'bookmarks-store',
7 7
8 properties: { 8 properties: {
9 /** @type {BookmarkTreeNode} */ 9 /** @type {BookmarkTreeNode} */
10 rootNode: { 10 rootNode: {
11 type: Object, 11 type: Object,
12 notify: true, 12 notify: true,
13 }, 13 },
14 14
15 /** @type {?string} */ 15 /** @type {?string} */
16 selectedId: { 16 selectedId: {
17 type: String, 17 type: String,
18 observer: 'updateSelectedDisplay_', 18 observer: 'updateSelectedDisplay_',
19 notify: true, 19 notify: true,
20 }, 20 },
21 21
22 searchTerm: { 22 searchTerm: {
23 type: String, 23 type: String,
24 value: '',
24 observer: 'updateSearchDisplay_', 25 observer: 'updateSearchDisplay_',
25 notify: true, 26 notify: true,
26 }, 27 },
27 28
28 /** 29 /**
29 * This updates to either the result of a search or the contents of the 30 * This updates to either the result of a search or the contents of the
30 * selected folder. 31 * selected folder.
31 * @type {Array<BookmarkTreeNode>} 32 * @type {Array<BookmarkTreeNode>}
32 */ 33 */
33 displayedList: { 34 displayedList: {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 isAncestorOfSelected_: function(folder) { 104 isAncestorOfSelected_: function(folder) {
104 if (!this.selectedId) 105 if (!this.selectedId)
105 return false; 106 return false;
106 107
107 var selectedNode = this.idToNodeMap_[this.selectedId]; 108 var selectedNode = this.idToNodeMap_[this.selectedId];
108 return selectedNode.path.startsWith(folder.path); 109 return selectedNode.path.startsWith(folder.path);
109 }, 110 },
110 111
111 /** @private */ 112 /** @private */
112 updateSearchDisplay_: function() { 113 updateSearchDisplay_: function() {
114 if (!this.rootNode)
115 return;
116
113 if (this.searchTerm == '') { 117 if (this.searchTerm == '') {
114 this.fire('selected-folder-changed', this.rootNode.children[0].id); 118 this.fire('selected-folder-changed', this.rootNode.children[0].id);
115 } else { 119 } else {
116 chrome.bookmarks.search(this.searchTerm, function(results) { 120 chrome.bookmarks.search(this.searchTerm, function(results) {
117 if (this.selectedId) 121 if (this.selectedId)
118 this.deselectFolders_(); 122 this.deselectFolders_();
119 123
120 this._setDisplayedList(results); 124 this._setDisplayedList(results);
121 }.bind(this)); 125 }.bind(this));
122 } 126 }
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 idToNodeMap[bookmarkNode.id] = bookmarkNode; 270 idToNodeMap[bookmarkNode.id] = bookmarkNode;
267 271
268 if (bookmarkNode.url) 272 if (bookmarkNode.url)
269 return; 273 return;
270 274
271 bookmarkNode.isSelected = false; 275 bookmarkNode.isSelected = false;
272 bookmarkNode.isOpen = true; 276 bookmarkNode.isOpen = true;
273 for (var i = 0; i < bookmarkNode.children.length; i++) 277 for (var i = 0; i < bookmarkNode.children.length; i++)
274 BookmarksStore.initNodes(bookmarkNode.children[i], idToNodeMap); 278 BookmarksStore.initNodes(bookmarkNode.children[i], idToNodeMap);
275 }; 279 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698