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

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

Issue 2924953003: [MD Bookmarks] Scroll list to top on folder change. (Closed)
Patch Set: Created 3 years, 6 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 | no next file » | 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-list', 6 is: 'bookmarks-list',
7 7
8 behaviors: [ 8 behaviors: [
9 bookmarks.StoreClient, 9 bookmarks.StoreClient,
10 ], 10 ],
(...skipping 14 matching lines...) Expand all
25 }, 25 },
26 }, 26 },
27 27
28 /** @private {Array<string>} */ 28 /** @private {Array<string>} */
29 displayedIds_: { 29 displayedIds_: {
30 type: Array, 30 type: Array,
31 observer: 'onDisplayedIdsChanged_', 31 observer: 'onDisplayedIdsChanged_',
32 }, 32 },
33 33
34 /** @private */ 34 /** @private */
35 searchTerm_: String, 35 searchTerm_: {
36 type: String,
37 observer: 'onDisplayedListSourceChange_',
38 },
39
40 /** @private */
41 selectedFolder_: {
42 type: String,
43 observer: 'onDisplayedListSourceChange_',
44 },
36 }, 45 },
37 46
38 listeners: { 47 listeners: {
39 'click': 'deselectItems_', 48 'click': 'deselectItems_',
40 }, 49 },
41 50
42 attached: function() { 51 attached: function() {
43 var list = /** @type {IronListElement} */ (this.$.bookmarksCard); 52 var list = /** @type {IronListElement} */ (this.$.bookmarksCard);
44 list.scrollTarget = this; 53 list.scrollTarget = this;
45 54
46 this.watch('displayedIds_', function(state) { 55 this.watch('displayedIds_', function(state) {
47 return bookmarks.util.getDisplayedList(state); 56 return bookmarks.util.getDisplayedList(state);
48 }); 57 });
49 this.watch('searchTerm_', function(state) { 58 this.watch('searchTerm_', function(state) {
50 return state.search.term; 59 return state.search.term;
51 }); 60 });
61 this.watch('selectedFolder_', function(state) {
62 return state.selectedFolder;
63 });
52 this.updateFromStore(); 64 this.updateFromStore();
53 65
54 this.$.bookmarksCard.addEventListener( 66 this.$.bookmarksCard.addEventListener(
55 'keydown', this.onItemKeydown_.bind(this), true); 67 'keydown', this.onItemKeydown_.bind(this), true);
56 }, 68 },
57 69
58 /** @return {HTMLElement} */ 70 /** @return {HTMLElement} */
59 getDropTarget: function() { 71 getDropTarget: function() {
60 return this.$.message; 72 return this.$.message;
61 }, 73 },
(...skipping 22 matching lines...) Expand all
84 return {id: id}; 96 return {id: id};
85 }); 97 });
86 this.splice.apply(this, [ 98 this.splice.apply(this, [
87 'displayedList_', splice.index, splice.removed.length 99 'displayedList_', splice.index, splice.removed.length
88 ].concat(additions)); 100 ].concat(additions));
89 }.bind(this)); 101 }.bind(this));
90 } 102 }
91 }, 103 },
92 104
93 /** @private */ 105 /** @private */
106 onDisplayedListSourceChange_: function() {
107 this.scrollTop = 0;
108 },
109
110 /** @private */
94 emptyListMessage_: function() { 111 emptyListMessage_: function() {
95 var emptyListMessage = this.searchTerm_ ? 'noSearchResults' : 'emptyList'; 112 var emptyListMessage = this.searchTerm_ ? 'noSearchResults' : 'emptyList';
96 return loadTimeData.getString(emptyListMessage); 113 return loadTimeData.getString(emptyListMessage);
97 }, 114 },
98 115
99 /** @private */ 116 /** @private */
100 isEmptyList_: function() { 117 isEmptyList_: function() {
101 return this.displayedList_.length == 0; 118 return this.displayedList_.length == 0;
102 }, 119 },
103 120
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 202
186 if (!handled) { 203 if (!handled) {
187 handled = bookmarks.CommandManager.getInstance().handleKeyEvent( 204 handled = bookmarks.CommandManager.getInstance().handleKeyEvent(
188 e, this.getState().selection.items); 205 e, this.getState().selection.items);
189 } 206 }
190 207
191 if (handled) 208 if (handled)
192 e.stopPropagation(); 209 e.stopPropagation();
193 }, 210 },
194 }); 211 });
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698