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', function(e) { | |
98 this.updateSidebarWidth_(); | |
99 }.bind(this)); | |
Dan Beam
2017/04/11 01:27:02
nit: could also be
splitter.addEventListener('dra
calamity
2017/04/11 03:31:39
Done.
| |
100 | |
97 window.addEventListener('resize', this.boundUpdateSidebarWidth_); | 101 window.addEventListener('resize', this.boundUpdateSidebarWidth_); |
98 }, | 102 }, |
99 | 103 |
100 /** @private */ | 104 /** @private */ |
101 updateSidebarWidth_: function() { | 105 updateSidebarWidth_: function() { |
102 this.sidebarWidth_ = this.$.sidebar.getComputedStyleValue('width'); | 106 this.sidebarWidth_ = this.$.sidebar.getComputedStyleValue('width'); |
103 }, | 107 }, |
104 | 108 |
105 /** @private */ | 109 /** @private */ |
106 searchTermChanged_: function() { | 110 searchTermChanged_: function() { |
107 if (!this.searchTerm_) | 111 if (!this.searchTerm_) |
108 return; | 112 return; |
109 | 113 |
110 chrome.bookmarks.search(this.searchTerm_, function(results) { | 114 chrome.bookmarks.search(this.searchTerm_, function(results) { |
111 var ids = results.map(function(node) { | 115 var ids = results.map(function(node) { |
112 return node.id; | 116 return node.id; |
113 }); | 117 }); |
114 this.dispatch(bookmarks.actions.setSearchResults(ids)); | 118 this.dispatch(bookmarks.actions.setSearchResults(ids)); |
115 }.bind(this)); | 119 }.bind(this)); |
116 }, | 120 }, |
117 | 121 |
118 /** @private */ | 122 /** @private */ |
119 closedFoldersStateChanged_: function() { | 123 closedFoldersStateChanged_: function() { |
120 window.localStorage[LOCAL_STORAGE_CLOSED_FOLDERS_KEY] = | 124 window.localStorage[LOCAL_STORAGE_CLOSED_FOLDERS_KEY] = |
121 JSON.stringify(Array.from(this.closedFoldersState_)); | 125 JSON.stringify(Array.from(this.closedFoldersState_)); |
122 }, | 126 }, |
123 }); | 127 }); |
OLD | NEW |