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

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

Issue 2812493002: MD Bookmarks: Restore any previously selected folder when clearing search (Closed)
Patch Set: Fix comment 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
« no previous file with comments | « no previous file | chrome/browser/resources/md_bookmarks/reducers.js » ('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-folder-node', 6 is: 'bookmarks-folder-node',
7 7
8 behaviors: [ 8 behaviors: [
9 bookmarks.StoreClient, 9 bookmarks.StoreClient,
10 ], 10 ],
(...skipping 12 matching lines...) Expand all
23 /** @type {BookmarkNode} */ 23 /** @type {BookmarkNode} */
24 item_: Object, 24 item_: Object,
25 25
26 /** @private */ 26 /** @private */
27 isClosed_: Boolean, 27 isClosed_: Boolean,
28 28
29 /** @private */ 29 /** @private */
30 selectedFolder_: String, 30 selectedFolder_: String,
31 31
32 /** @private */ 32 /** @private */
33 searchActive_: Boolean,
34
35 /** @private */
33 isSelectedFolder_: { 36 isSelectedFolder_: {
34 type: Boolean, 37 type: Boolean,
35 value: false, 38 value: false,
36 reflectToAttribute: true, 39 reflectToAttribute: true,
37 computed: 'computeIsSelected_(itemId, selectedFolder_)' 40 computed: 'computeIsSelected_(itemId, selectedFolder_, searchActive_)'
38 }, 41 },
39 }, 42 },
40 43
41 /** @override */ 44 /** @override */
42 attached: function() { 45 attached: function() {
43 this.watch('item_', function(state) { 46 this.watch('item_', function(state) {
44 return state.nodes[this.itemId]; 47 return state.nodes[this.itemId];
45 }.bind(this)); 48 }.bind(this));
46 this.watch('isClosed_', function(state) { 49 this.watch('isClosed_', function(state) {
47 return state.closedFolders.has(this.itemId); 50 return state.closedFolders.has(this.itemId);
48 }.bind(this)); 51 }.bind(this));
49 this.watch('selectedFolder_', function(state) { 52 this.watch('selectedFolder_', function(state) {
50 return state.selectedFolder; 53 return state.selectedFolder;
51 }); 54 });
55 this.watch('searchActive_', function(state) {
56 return bookmarks.util.isShowingSearch(state);
57 });
52 58
53 this.updateFromStore(); 59 this.updateFromStore();
54 }, 60 },
55 61
56 /** @return {HTMLElement} */ 62 /** @return {HTMLElement} */
57 getDropTarget: function() { 63 getDropTarget: function() {
58 return this.$.container; 64 return this.$.container;
59 }, 65 },
60 66
61 /** 67 /**
(...skipping 19 matching lines...) Expand all
81 bookmarks.actions.changeFolderOpen(this.item_.id, this.isClosed_)); 87 bookmarks.actions.changeFolderOpen(this.item_.id, this.isClosed_));
82 e.stopPropagation(); 88 e.stopPropagation();
83 }, 89 },
84 90
85 /** 91 /**
86 * @private 92 * @private
87 * @param {string} itemId 93 * @param {string} itemId
88 * @param {string} selectedFolder 94 * @param {string} selectedFolder
89 * @return {boolean} 95 * @return {boolean}
90 */ 96 */
91 computeIsSelected_: function(itemId, selectedFolder) { 97 computeIsSelected_: function(itemId, selectedFolder, searchActive) {
92 return itemId == selectedFolder; 98 return itemId == selectedFolder && !searchActive;
93 }, 99 },
94 100
95 /** 101 /**
96 * @private 102 * @private
97 * @return {boolean} 103 * @return {boolean}
98 */ 104 */
99 hasChildFolder_: function() { 105 hasChildFolder_: function() {
100 return bookmarks.util.hasChildFolders(this.itemId, this.getState().nodes); 106 return bookmarks.util.hasChildFolders(this.itemId, this.getState().nodes);
101 }, 107 },
102 108
(...skipping 20 matching lines...) Expand all
123 }, 129 },
124 130
125 /** 131 /**
126 * @private 132 * @private
127 * @return {boolean} 133 * @return {boolean}
128 */ 134 */
129 isRootFolder_: function() { 135 isRootFolder_: function() {
130 return this.depth == 0; 136 return this.depth == 0;
131 }, 137 },
132 }); 138 });
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/md_bookmarks/reducers.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698