Chromium Code Reviews| 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 /** @private */ | 19 /** @private */ |
| 20 sidebarWidth_: String, | 20 sidebarWidth_: String, |
| 21 }, | 21 }, |
| 22 | 22 |
| 23 /** @private{?function(!Event)} */ | 23 /** @private{?function(!Event)} */ |
| 24 boundUpdateSidebarWidth_: null, | 24 boundUpdateSidebarWidth_: null, |
| 25 | 25 |
| 26 /** @private {bookmarks.DNDManager} */ | |
| 27 dnd_manager_: null, | |
|
tsergeant
2017/03/23 00:28:23
camelCase for member names
calamity
2017/03/23 06:12:33
Done.
| |
| 28 | |
| 26 /** @override */ | 29 /** @override */ |
| 27 attached: function() { | 30 attached: function() { |
| 28 this.watch('searchTerm_', function(store) { | 31 this.watch('searchTerm_', function(store) { |
| 29 return store.search.term; | 32 return store.search.term; |
| 30 }); | 33 }); |
| 31 | 34 |
| 32 chrome.bookmarks.getTree(function(results) { | 35 chrome.bookmarks.getTree(function(results) { |
| 33 var nodeList = bookmarks.util.normalizeNodes(results[0]); | 36 var nodeList = bookmarks.util.normalizeNodes(results[0]); |
| 34 var initialState = bookmarks.util.createEmptyState(); | 37 var initialState = bookmarks.util.createEmptyState(); |
| 35 initialState.nodes = nodeList; | 38 initialState.nodes = nodeList; |
| 36 initialState.selectedFolder = nodeList['0'].children[0]; | 39 initialState.selectedFolder = |
| 40 nodeList[bookmarks.util.ROOT_NODE_ID].children[0]; | |
| 37 | 41 |
| 38 bookmarks.Store.getInstance().init(initialState); | 42 bookmarks.Store.getInstance().init(initialState); |
| 39 bookmarks.ApiListener.init(); | 43 bookmarks.ApiListener.init(); |
| 40 | 44 |
| 41 }.bind(this)); | 45 }.bind(this)); |
| 42 | 46 |
| 43 this.boundUpdateSidebarWidth_ = this.updateSidebarWidth_.bind(this); | 47 this.boundUpdateSidebarWidth_ = this.updateSidebarWidth_.bind(this); |
| 44 | 48 |
| 45 this.initializeSplitter_(); | 49 this.initializeSplitter_(); |
| 50 | |
| 51 this.dnd_manager_ = new bookmarks.DNDManager(); | |
| 52 this.dnd_manager_.init(); | |
| 46 }, | 53 }, |
| 47 | 54 |
| 48 detached: function() { | 55 detached: function() { |
| 49 window.removeEventListener('resize', this.boundUpdateSidebarWidth_); | 56 window.removeEventListener('resize', this.boundUpdateSidebarWidth_); |
| 57 this.dnd_manager_.destroy(); | |
| 50 }, | 58 }, |
| 51 | 59 |
| 52 /** | 60 /** |
| 53 * Set up the splitter and set the initial width from localStorage. | 61 * Set up the splitter and set the initial width from localStorage. |
| 54 * @private | 62 * @private |
| 55 */ | 63 */ |
| 56 initializeSplitter_: function() { | 64 initializeSplitter_: function() { |
| 57 var splitter = this.$.splitter; | 65 var splitter = this.$.splitter; |
| 58 cr.ui.Splitter.decorate(splitter); | 66 cr.ui.Splitter.decorate(splitter); |
| 59 var splitterTarget = this.$.sidebar; | 67 var splitterTarget = this.$.sidebar; |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 84 return; | 92 return; |
| 85 | 93 |
| 86 chrome.bookmarks.search(this.searchTerm_, function(results) { | 94 chrome.bookmarks.search(this.searchTerm_, function(results) { |
| 87 var ids = results.map(function(node) { | 95 var ids = results.map(function(node) { |
| 88 return node.id; | 96 return node.id; |
| 89 }); | 97 }); |
| 90 this.dispatch(bookmarks.actions.setSearchResults(ids)); | 98 this.dispatch(bookmarks.actions.setSearchResults(ids)); |
| 91 }.bind(this)); | 99 }.bind(this)); |
| 92 }, | 100 }, |
| 93 }); | 101 }); |
| OLD | NEW |