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

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

Issue 2745593004: [MD Bookmarks] Add draggable sidebar. (Closed)
Patch Set: rebase, comments 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
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: {
13 /** @private */
14 sidebarWidth_: String,
15 },
16
12 /** @override */ 17 /** @override */
13 attached: function() { 18 attached: function() {
14 chrome.bookmarks.getTree(function(results) { 19 chrome.bookmarks.getTree(function(results) {
15 var nodeList = bookmarks.util.normalizeNodes(results[0]); 20 var nodeList = bookmarks.util.normalizeNodes(results[0]);
16 var initialState = bookmarks.util.createEmptyState(); 21 var initialState = bookmarks.util.createEmptyState();
17 initialState.nodes = nodeList; 22 initialState.nodes = nodeList;
18 initialState.selectedFolder = nodeList['0'].children[0]; 23 initialState.selectedFolder = nodeList['0'].children[0];
19 24
20 bookmarks.Store.getInstance().init(initialState); 25 bookmarks.Store.getInstance().init(initialState);
21 bookmarks.ApiListener.init(); 26 bookmarks.ApiListener.init();
27
28 }.bind(this));
29
30 this.initializeSplitter_();
31 },
32
33 /**
34 * Set up the splitter and set the initial width from localStorage.
35 * @private
36 */
37 initializeSplitter_: function() {
38 var splitter = this.$.splitter;
39 cr.ui.Splitter.decorate(splitter);
40 var splitterTarget = splitter.previousElementSibling;
41
42 // The splitter persists the size of the left component in the local store.
43 if ('treeWidth' in window.localStorage) {
44 splitterTarget.style.width = window.localStorage['treeWidth'];
45 this.sidebarWidth_ = splitterTarget.getComputedStyleValue('width');
46 }
47
48 splitter.addEventListener('resize', function(e) {
49 window.localStorage['treeWidth'] = splitterTarget.style.width;
50 // TODO(calamity): This only fires when the resize is complete. This
51 // should be updated on every width change.
52 this.sidebarWidth_ = splitterTarget.getComputedStyleValue('width');
22 }.bind(this)); 53 }.bind(this));
23 }, 54 },
24 }); 55 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698