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

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

Issue 2820153003: [MD Bookmarks] Add keyboard navigation to sidebar. (Closed)
Patch Set: Created 3 years, 8 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: { 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 /** @type {ClosedFolderState} */ 19 /** @type {ClosedFolderState} */
20 closedFoldersState_: { 20 closedFoldersState_: {
21 type: Object, 21 type: Object,
22 observer: 'closedFoldersStateChanged_', 22 observer: 'closedFoldersStateChanged_',
23 }, 23 },
24 24
25 /** @private */ 25 /** @private */
26 sidebarWidth_: String, 26 sidebarWidth_: String,
27 }, 27 },
28 28
29 listeners: {
30 'folder-node-focus-changed': 'onFolderNodeFocusChanged_',
31 },
32
29 /** @private{?function(!Event)} */ 33 /** @private{?function(!Event)} */
30 boundUpdateSidebarWidth_: null, 34 boundUpdateSidebarWidth_: null,
31 35
32 /** @private {bookmarks.DNDManager} */ 36 /** @private {bookmarks.DNDManager} */
33 dndManager_: null, 37 dndManager_: null,
34 38
39 /** @private {BookmarksFolderNode} */
40 focusedFolderNode_: null,
41
35 /** @override */ 42 /** @override */
36 attached: function() { 43 attached: function() {
37 this.watch('searchTerm_', function(store) { 44 this.watch('searchTerm_', function(store) {
38 return store.search.term; 45 return store.search.term;
39 }); 46 });
40 47
41 this.watch('closedFoldersState_', function(store) { 48 this.watch('closedFoldersState_', function(store) {
42 return store.closedFolders; 49 return store.closedFolders;
43 }); 50 });
44 51
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 splitter.addEventListener('resize', function(e) { 99 splitter.addEventListener('resize', function(e) {
93 window.localStorage[LOCAL_STORAGE_TREE_WIDTH_KEY] = 100 window.localStorage[LOCAL_STORAGE_TREE_WIDTH_KEY] =
94 splitterTarget.style.width; 101 splitterTarget.style.width;
95 this.updateSidebarWidth_(); 102 this.updateSidebarWidth_();
96 }.bind(this)); 103 }.bind(this));
97 104
98 splitter.addEventListener('dragmove', this.boundUpdateSidebarWidth_); 105 splitter.addEventListener('dragmove', this.boundUpdateSidebarWidth_);
99 window.addEventListener('resize', this.boundUpdateSidebarWidth_); 106 window.addEventListener('resize', this.boundUpdateSidebarWidth_);
100 }, 107 },
101 108
109 onFolderNodeFocusChanged_: function(e) {
110 if (this.focusedFolderNode_)
111 this.focusedFolderNode_.focusable = false;
112
113 this.focusedFolderNode_ = e.detail;
114 this.focusedFolderNode_ = true;
tsergeant 2017/04/19 01:42:16 What's going on here? My guess is this was suppose
calamity 2017/04/19 04:51:02 Done.
115 },
116
102 /** @private */ 117 /** @private */
103 updateSidebarWidth_: function() { 118 updateSidebarWidth_: function() {
104 this.sidebarWidth_ = 119 this.sidebarWidth_ =
105 /** @type {string} */ (getComputedStyle(this.$.sidebar).width); 120 /** @type {string} */ (getComputedStyle(this.$.sidebar).width);
106 }, 121 },
107 122
108 /** @private */ 123 /** @private */
109 searchTermChanged_: function() { 124 searchTermChanged_: function() {
110 if (!this.searchTerm_) 125 if (!this.searchTerm_)
111 return; 126 return;
112 127
113 chrome.bookmarks.search(this.searchTerm_, function(results) { 128 chrome.bookmarks.search(this.searchTerm_, function(results) {
114 var ids = results.map(function(node) { 129 var ids = results.map(function(node) {
115 return node.id; 130 return node.id;
116 }); 131 });
117 this.dispatch(bookmarks.actions.setSearchResults(ids)); 132 this.dispatch(bookmarks.actions.setSearchResults(ids));
118 }.bind(this)); 133 }.bind(this));
119 }, 134 },
120 135
121 /** @private */ 136 /** @private */
122 closedFoldersStateChanged_: function() { 137 closedFoldersStateChanged_: function() {
123 window.localStorage[LOCAL_STORAGE_CLOSED_FOLDERS_KEY] = 138 window.localStorage[LOCAL_STORAGE_CLOSED_FOLDERS_KEY] =
124 JSON.stringify(Array.from(this.closedFoldersState_)); 139 JSON.stringify(Array.from(this.closedFoldersState_));
125 }, 140 },
126 }); 141 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698