| OLD | NEW |
| 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 isAncestorOfSelected_: function(folder) { | 109 isAncestorOfSelected_: function(folder) { |
| 109 if (!this.selectedId) | 110 if (!this.selectedId) |
| 110 return false; | 111 return false; |
| 111 | 112 |
| 112 var selectedNode = this.idToNodeMap_[this.selectedId]; | 113 var selectedNode = this.idToNodeMap_[this.selectedId]; |
| 113 return selectedNode.path.startsWith(folder.path); | 114 return selectedNode.path.startsWith(folder.path); |
| 114 }, | 115 }, |
| 115 | 116 |
| 116 /** @private */ | 117 /** @private */ |
| 117 updateSearchDisplay_: function() { | 118 updateSearchDisplay_: function() { |
| 119 if (!this.rootNode) |
| 120 return; |
| 121 |
| 118 if (!this.searchTerm) { | 122 if (!this.searchTerm) { |
| 119 this.fire('selected-folder-changed', this.rootNode.children[0].id); | 123 this.fire('selected-folder-changed', this.rootNode.children[0].id); |
| 120 } else { | 124 } else { |
| 121 chrome.bookmarks.search(this.searchTerm, function(results) { | 125 chrome.bookmarks.search(this.searchTerm, function(results) { |
| 122 if (this.selectedId) | 126 if (this.selectedId) |
| 123 this.deselectFolders_(); | 127 this.deselectFolders_(); |
| 124 | 128 |
| 125 this._setDisplayedList(results); | 129 this._setDisplayedList(results); |
| 126 }.bind(this)); | 130 }.bind(this)); |
| 127 } | 131 } |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 idToNodeMap[bookmarkNode.id] = bookmarkNode; | 279 idToNodeMap[bookmarkNode.id] = bookmarkNode; |
| 276 | 280 |
| 277 if (bookmarkNode.url) | 281 if (bookmarkNode.url) |
| 278 return; | 282 return; |
| 279 | 283 |
| 280 bookmarkNode.isSelected = false; | 284 bookmarkNode.isSelected = false; |
| 281 bookmarkNode.isOpen = true; | 285 bookmarkNode.isOpen = true; |
| 282 for (var i = 0; i < bookmarkNode.children.length; i++) | 286 for (var i = 0; i < bookmarkNode.children.length; i++) |
| 283 BookmarksStore.initNodes(bookmarkNode.children[i], idToNodeMap); | 287 BookmarksStore.initNodes(bookmarkNode.children[i], idToNodeMap); |
| 284 }; | 288 }; |
| OLD | NEW |