| 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 }.bind(this)); |
| 95 |
| 96 splitter.addEventListener('dragmove', function(e) { |
| 94 this.updateSidebarWidth_(); | 97 this.updateSidebarWidth_(); |
| 95 }.bind(this)); | 98 }.bind(this)); |
| 96 | 99 |
| 97 window.addEventListener('resize', this.boundUpdateSidebarWidth_); | 100 window.addEventListener('resize', this.boundUpdateSidebarWidth_); |
| 98 }, | 101 }, |
| 99 | 102 |
| 100 /** @private */ | 103 /** @private */ |
| 101 updateSidebarWidth_: function() { | 104 updateSidebarWidth_: function() { |
| 102 this.sidebarWidth_ = this.$.sidebar.getComputedStyleValue('width'); | 105 this.sidebarWidth_ = this.$.sidebar.getComputedStyleValue('width'); |
| 103 }, | 106 }, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 114 this.dispatch(bookmarks.actions.setSearchResults(ids)); | 117 this.dispatch(bookmarks.actions.setSearchResults(ids)); |
| 115 }.bind(this)); | 118 }.bind(this)); |
| 116 }, | 119 }, |
| 117 | 120 |
| 118 /** @private */ | 121 /** @private */ |
| 119 closedFoldersStateChanged_: function() { | 122 closedFoldersStateChanged_: function() { |
| 120 window.localStorage[LOCAL_STORAGE_CLOSED_FOLDERS_KEY] = | 123 window.localStorage[LOCAL_STORAGE_CLOSED_FOLDERS_KEY] = |
| 121 JSON.stringify(Array.from(this.closedFoldersState_)); | 124 JSON.stringify(Array.from(this.closedFoldersState_)); |
| 122 }, | 125 }, |
| 123 }); | 126 }); |
| OLD | NEW |