| 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 ], |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 initializeSplitter_: function() { | 79 initializeSplitter_: function() { |
| 80 var splitter = this.$.splitter; | 80 var splitter = this.$.splitter; |
| 81 cr.ui.Splitter.decorate(splitter); | 81 cr.ui.Splitter.decorate(splitter); |
| 82 var splitterTarget = this.$.sidebar; | 82 var splitterTarget = this.$.sidebar; |
| 83 | 83 |
| 84 // The splitter persists the size of the left component in the local store. | 84 // The splitter persists the size of the left component in the local store. |
| 85 if (LOCAL_STORAGE_TREE_WIDTH_KEY in window.localStorage) { | 85 if (LOCAL_STORAGE_TREE_WIDTH_KEY in window.localStorage) { |
| 86 splitterTarget.style.width = | 86 splitterTarget.style.width = |
| 87 window.localStorage[LOCAL_STORAGE_TREE_WIDTH_KEY]; | 87 window.localStorage[LOCAL_STORAGE_TREE_WIDTH_KEY]; |
| 88 } | 88 } |
| 89 this.sidebarWidth_ = splitterTarget.getComputedStyleValue('width'); | 89 this.sidebarWidth_ = |
| 90 /** @type {string} */ (getComputedStyle(splitterTarget).width); |
| 90 | 91 |
| 91 splitter.addEventListener('resize', function(e) { | 92 splitter.addEventListener('resize', function(e) { |
| 92 window.localStorage[LOCAL_STORAGE_TREE_WIDTH_KEY] = | 93 window.localStorage[LOCAL_STORAGE_TREE_WIDTH_KEY] = |
| 93 splitterTarget.style.width; | 94 splitterTarget.style.width; |
| 94 this.updateSidebarWidth_(); | 95 this.updateSidebarWidth_(); |
| 95 }.bind(this)); | 96 }.bind(this)); |
| 96 | 97 |
| 97 splitter.addEventListener('dragmove', this.boundUpdateSidebarWidth_); | 98 splitter.addEventListener('dragmove', this.boundUpdateSidebarWidth_); |
| 98 window.addEventListener('resize', this.boundUpdateSidebarWidth_); | 99 window.addEventListener('resize', this.boundUpdateSidebarWidth_); |
| 99 }, | 100 }, |
| 100 | 101 |
| 101 /** @private */ | 102 /** @private */ |
| 102 updateSidebarWidth_: function() { | 103 updateSidebarWidth_: function() { |
| 103 this.sidebarWidth_ = this.$.sidebar.getComputedStyleValue('width'); | 104 this.sidebarWidth_ = |
| 105 /** @type {string} */ (getComputedStyle(this.$.sidebar).width); |
| 104 }, | 106 }, |
| 105 | 107 |
| 106 /** @private */ | 108 /** @private */ |
| 107 searchTermChanged_: function() { | 109 searchTermChanged_: function() { |
| 108 if (!this.searchTerm_) | 110 if (!this.searchTerm_) |
| 109 return; | 111 return; |
| 110 | 112 |
| 111 chrome.bookmarks.search(this.searchTerm_, function(results) { | 113 chrome.bookmarks.search(this.searchTerm_, function(results) { |
| 112 var ids = results.map(function(node) { | 114 var ids = results.map(function(node) { |
| 113 return node.id; | 115 return node.id; |
| 114 }); | 116 }); |
| 115 this.dispatch(bookmarks.actions.setSearchResults(ids)); | 117 this.dispatch(bookmarks.actions.setSearchResults(ids)); |
| 116 }.bind(this)); | 118 }.bind(this)); |
| 117 }, | 119 }, |
| 118 | 120 |
| 119 /** @private */ | 121 /** @private */ |
| 120 closedFoldersStateChanged_: function() { | 122 closedFoldersStateChanged_: function() { |
| 121 window.localStorage[LOCAL_STORAGE_CLOSED_FOLDERS_KEY] = | 123 window.localStorage[LOCAL_STORAGE_CLOSED_FOLDERS_KEY] = |
| 122 JSON.stringify(Array.from(this.closedFoldersState_)); | 124 JSON.stringify(Array.from(this.closedFoldersState_)); |
| 123 }, | 125 }, |
| 124 }); | 126 }); |
| OLD | NEW |