| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 /** | 75 /** |
| 76 * Set up the splitter and set the initial width from localStorage. | 76 * Set up the splitter and set the initial width from localStorage. |
| 77 * @private | 77 * @private |
| 78 */ | 78 */ |
| 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 ('treeWidth' in window.localStorage) { | 85 if (LOCAL_STORAGE_TREE_WIDTH_KEY in window.localStorage) { |
| 86 splitterTarget.style.width = window.localStorage['treeWidth']; | 86 splitterTarget.style.width = |
| 87 this.sidebarWidth_ = splitterTarget.getComputedStyleValue('width'); | 87 window.localStorage[LOCAL_STORAGE_TREE_WIDTH_KEY]; |
| 88 } | 88 } |
| 89 this.sidebarWidth_ = splitterTarget.getComputedStyleValue('width'); |
| 89 | 90 |
| 90 splitter.addEventListener('resize', function(e) { | 91 splitter.addEventListener('resize', function(e) { |
| 91 window.localStorage['treeWidth'] = splitterTarget.style.width; | 92 window.localStorage[LOCAL_STORAGE_TREE_WIDTH_KEY] = |
| 92 // TODO(calamity): This only fires when the resize is complete. This | 93 splitterTarget.style.width; |
| 93 // should be updated on every width change. | |
| 94 this.updateSidebarWidth_(); | 94 this.updateSidebarWidth_(); |
| 95 }.bind(this)); | 95 }.bind(this)); |
| 96 | 96 |
| 97 splitter.addEventListener('dragmove', this.boundUpdateSidebarWidth_); |
| 97 window.addEventListener('resize', this.boundUpdateSidebarWidth_); | 98 window.addEventListener('resize', this.boundUpdateSidebarWidth_); |
| 98 }, | 99 }, |
| 99 | 100 |
| 100 /** @private */ | 101 /** @private */ |
| 101 updateSidebarWidth_: function() { | 102 updateSidebarWidth_: function() { |
| 102 this.sidebarWidth_ = this.$.sidebar.getComputedStyleValue('width'); | 103 this.sidebarWidth_ = this.$.sidebar.getComputedStyleValue('width'); |
| 103 }, | 104 }, |
| 104 | 105 |
| 105 /** @private */ | 106 /** @private */ |
| 106 searchTermChanged_: function() { | 107 searchTermChanged_: function() { |
| 107 if (!this.searchTerm_) | 108 if (!this.searchTerm_) |
| 108 return; | 109 return; |
| 109 | 110 |
| 110 chrome.bookmarks.search(this.searchTerm_, function(results) { | 111 chrome.bookmarks.search(this.searchTerm_, function(results) { |
| 111 var ids = results.map(function(node) { | 112 var ids = results.map(function(node) { |
| 112 return node.id; | 113 return node.id; |
| 113 }); | 114 }); |
| 114 this.dispatch(bookmarks.actions.setSearchResults(ids)); | 115 this.dispatch(bookmarks.actions.setSearchResults(ids)); |
| 115 }.bind(this)); | 116 }.bind(this)); |
| 116 }, | 117 }, |
| 117 | 118 |
| 118 /** @private */ | 119 /** @private */ |
| 119 closedFoldersStateChanged_: function() { | 120 closedFoldersStateChanged_: function() { |
| 120 window.localStorage[LOCAL_STORAGE_CLOSED_FOLDERS_KEY] = | 121 window.localStorage[LOCAL_STORAGE_CLOSED_FOLDERS_KEY] = |
| 121 JSON.stringify(Array.from(this.closedFoldersState_)); | 122 JSON.stringify(Array.from(this.closedFoldersState_)); |
| 122 }, | 123 }, |
| 123 }); | 124 }); |
| OLD | NEW |