| 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 Polymer({ | 5 Polymer({ |
| 6 is: 'bookmarks-app', | 6 is: 'bookmarks-app', |
| 7 | 7 |
| 8 behaviors: [ | 8 behaviors: [ |
| 9 bookmarks.StoreClient, | 9 bookmarks.StoreClient, |
| 10 ], | 10 ], |
| 11 | 11 |
| 12 properties: { | 12 properties: { |
| 13 /** @private */ | 13 /** @private */ |
| 14 searchTerm_: { | 14 searchTerm_: { |
| 15 type: String, | 15 type: String, |
| 16 observer: 'searchTermChanged_', | 16 observer: 'searchTermChanged_', |
| 17 }, | 17 }, |
| 18 | 18 |
| 19 /** @type {ClosedFolderState} */ |
| 19 closedFoldersState_: { | 20 closedFoldersState_: { |
| 20 type: Object, | 21 type: Object, |
| 21 observer: 'closedFoldersStateChanged_', | 22 observer: 'closedFoldersStateChanged_', |
| 22 }, | 23 }, |
| 23 | 24 |
| 24 /** @private */ | 25 /** @private */ |
| 25 sidebarWidth_: String, | 26 sidebarWidth_: String, |
| 26 }, | 27 }, |
| 27 | 28 |
| 28 /** @private{?function(!Event)} */ | 29 /** @private{?function(!Event)} */ |
| (...skipping 13 matching lines...) Expand all Loading... |
| 42 }); | 43 }); |
| 43 | 44 |
| 44 chrome.bookmarks.getTree(function(results) { | 45 chrome.bookmarks.getTree(function(results) { |
| 45 var nodeList = bookmarks.util.normalizeNodes(results[0]); | 46 var nodeList = bookmarks.util.normalizeNodes(results[0]); |
| 46 var initialState = bookmarks.util.createEmptyState(); | 47 var initialState = bookmarks.util.createEmptyState(); |
| 47 initialState.nodes = nodeList; | 48 initialState.nodes = nodeList; |
| 48 initialState.selectedFolder = nodeList[ROOT_NODE_ID].children[0]; | 49 initialState.selectedFolder = nodeList[ROOT_NODE_ID].children[0]; |
| 49 var closedFoldersString = | 50 var closedFoldersString = |
| 50 window.localStorage[LOCAL_STORAGE_CLOSED_FOLDERS_KEY]; | 51 window.localStorage[LOCAL_STORAGE_CLOSED_FOLDERS_KEY]; |
| 51 initialState.closedFolders = closedFoldersString ? | 52 initialState.closedFolders = closedFoldersString ? |
| 52 /** @type {!Object<string,boolean>} */ ( | 53 new Set( |
| 53 JSON.parse(closedFoldersString)) : | 54 /** @type Array<string> */ (JSON.parse(closedFoldersString))) : |
| 54 {}; | 55 new Set(); |
| 55 | 56 |
| 56 bookmarks.Store.getInstance().init(initialState); | 57 bookmarks.Store.getInstance().init(initialState); |
| 57 bookmarks.ApiListener.init(); | 58 bookmarks.ApiListener.init(); |
| 58 | 59 |
| 59 }.bind(this)); | 60 }.bind(this)); |
| 60 | 61 |
| 61 this.boundUpdateSidebarWidth_ = this.updateSidebarWidth_.bind(this); | 62 this.boundUpdateSidebarWidth_ = this.updateSidebarWidth_.bind(this); |
| 62 | 63 |
| 63 this.initializeSplitter_(); | 64 this.initializeSplitter_(); |
| 64 | 65 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 var ids = results.map(function(node) { | 111 var ids = results.map(function(node) { |
| 111 return node.id; | 112 return node.id; |
| 112 }); | 113 }); |
| 113 this.dispatch(bookmarks.actions.setSearchResults(ids)); | 114 this.dispatch(bookmarks.actions.setSearchResults(ids)); |
| 114 }.bind(this)); | 115 }.bind(this)); |
| 115 }, | 116 }, |
| 116 | 117 |
| 117 /** @private */ | 118 /** @private */ |
| 118 closedFoldersStateChanged_: function() { | 119 closedFoldersStateChanged_: function() { |
| 119 window.localStorage[LOCAL_STORAGE_CLOSED_FOLDERS_KEY] = | 120 window.localStorage[LOCAL_STORAGE_CLOSED_FOLDERS_KEY] = |
| 120 JSON.stringify(this.closedFoldersState_); | 121 JSON.stringify(Array.from(this.closedFoldersState_)); |
| 121 }, | 122 }, |
| 122 }); | 123 }); |
| OLD | NEW |