Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Side by Side Diff: chrome/browser/resources/md_bookmarks/app.js

Issue 2722083002: [MD Bookmarks] Flatten sidebar. (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/resources/md_bookmarks/folder_node.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 searchTerm: { 13 searchTerm: {
14 type: String, 14 type: String,
15 observer: 'searchTermChanged_', 15 observer: 'searchTermChanged_',
16 }, 16 },
17 }, 17 },
18 18
19 /** @override */ 19 /** @override */
20 attached: function() { 20 attached: function() {
21 this.observe('searchTerm', function(store) { 21 this.observe('searchTerm', function(store) {
22 return store.search.term; 22 return store.search.term;
23 }); 23 });
24 24
25 chrome.bookmarks.getTree(function(results) { 25 chrome.bookmarks.getTree(function(results) {
26 var nodeList = bookmarks.util.normalizeNodes(results[0]); 26 var rootNode = results[0];
27 var nodeList = bookmarks.util.normalizeNodes(rootNode);
27 var initialState = bookmarks.util.createEmptyState(); 28 var initialState = bookmarks.util.createEmptyState();
28 initialState.nodes = nodeList; 29 initialState.nodes = nodeList;
29 initialState.selectedFolder = nodeList['0'].children[0]; 30 initialState.selectedFolder = nodeList[rootNode.id].children[0];
31 initialState.sidebar =
32 bookmarks.util.initializeSidebar(rootNode.id, nodeList);
30 33
31 // TODO(tsergeant): The below ends up slightly duplicating logic from 34 // TODO(tsergeant): The below ends up slightly duplicating logic from
32 // elsewhere. Consider trying to use actions/reducers to simplify this. 35 // elsewhere. Consider trying to use actions/reducers to simplify this.
33 var router = this.$.router; 36 var router = this.$.router;
34 if (router.searchTerm) { 37 if (router.searchTerm) {
35 initialState.selectedFolder = null; 38 initialState.selectedFolder = null;
36 initialState.search.term = router.searchTerm; 39 initialState.search.term = router.searchTerm;
37 initialState.search.inProgress = true; 40 initialState.search.inProgress = true;
38 } else if (router.selectedId) { 41 } else if (router.selectedId) {
39 initialState.selectedFolder = router.selectedId; 42 initialState.selectedFolder = router.selectedId;
40 } 43 }
41 44
42 bookmarks.Store.getInstance().init(initialState); 45 bookmarks.Store.getInstance().init(initialState);
43 bookmarks.ApiListener.init(); 46 bookmarks.ApiListener.init();
44 }.bind(this)); 47 }.bind(this));
45 }, 48 },
46 49
47 searchTermChanged_: function() { 50 searchTermChanged_: function() {
48 if (this.searchTerm) { 51 if (this.searchTerm) {
49 chrome.bookmarks.search(this.searchTerm, function(results) { 52 chrome.bookmarks.search(this.searchTerm, function(results) {
50 this.dispatch(bookmarks.actions.setSearchResults(results)); 53 this.dispatch(bookmarks.actions.setSearchResults(results));
51 }.bind(this)); 54 }.bind(this));
52 } 55 }
53 }, 56 },
54 }); 57 });
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/md_bookmarks/folder_node.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698