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

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

Issue 2668693007: [MD Bookmarks] Double Click (Closed)
Patch Set: clean up Created 3 years, 10 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 var BookmarksStore = Polymer({ 5 var BookmarksStore = Polymer({
6 is: 'bookmarks-store', 6 is: 'bookmarks-store',
7 7
8 properties: { 8 properties: {
9 /** @type {BookmarkTreeNode} */ 9 /** @type {BookmarkTreeNode} */
10 rootNode: { 10 rootNode: {
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 // Deselect the old folder if defined. 353 // Deselect the old folder if defined.
354 if (this.selectedId && this.idToNodeMap_[this.selectedId]) 354 if (this.selectedId && this.idToNodeMap_[this.selectedId])
355 this.set( 355 this.set(
356 this.idToNodeMap_[this.selectedId].path + '.isSelectedFolder', false); 356 this.idToNodeMap_[this.selectedId].path + '.isSelectedFolder', false);
357 357
358 // Check if the selected id is that of a defined folder. 358 // Check if the selected id is that of a defined folder.
359 var id = /** @type {string} */ (e.detail); 359 var id = /** @type {string} */ (e.detail);
360 if (!this.idToNodeMap_[id] || this.idToNodeMap_[id].url) 360 if (!this.idToNodeMap_[id] || this.idToNodeMap_[id].url)
361 id = this.rootNode.children[0].id; 361 id = this.rootNode.children[0].id;
362 362
363 var newFolder = this.idToNodeMap_[id]; 363 var folder = this.idToNodeMap_[id];
364 this.set(newFolder.path + '.isSelectedFolder', true); 364 this.set(folder.path + '.isSelectedFolder', true);
365 this.selectedId = id; 365 this.selectedId = id;
366 while (folder.parentId) {
367 folder = this.idToNodeMap_[folder.parentId];
368 if (folder.isOpen)
369 continue;
370
371 this.fire('folder-open-changed', {
372 id: folder.id,
373 open: true,
374 });
375 }
calamity 2017/02/03 04:12:22 I'm not a super fan of the loop structure here and
jiaxi 2017/02/06 05:11:03 This will return a "cannot read id of undefined" i
366 }, 376 },
367 377
368 /** 378 /**
369 * Handles events that open and close folders. 379 * Handles events that open and close folders.
370 * @param {CustomEvent} e 380 * @param {CustomEvent} e
371 * @private 381 * @private
372 */ 382 */
373 onFolderOpenChanged_: function(e) { 383 onFolderOpenChanged_: function(e) {
374 var folder = this.idToNodeMap_[e.detail.id]; 384 var folder = this.idToNodeMap_[e.detail.id];
375 this.set(folder.path + '.isOpen', e.detail.open); 385 this.set(folder.path + '.isOpen', e.detail.open);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 idToNodeMap[bookmarkNode.id] = bookmarkNode; 435 idToNodeMap[bookmarkNode.id] = bookmarkNode;
426 436
427 if (bookmarkNode.url) 437 if (bookmarkNode.url)
428 return; 438 return;
429 439
430 bookmarkNode.isSelectedFolder = false; 440 bookmarkNode.isSelectedFolder = false;
431 bookmarkNode.isOpen = true; 441 bookmarkNode.isOpen = true;
432 for (var i = 0; i < bookmarkNode.children.length; i++) 442 for (var i = 0; i < bookmarkNode.children.length; i++)
433 BookmarksStore.initNodes(bookmarkNode.children[i], idToNodeMap); 443 BookmarksStore.initNodes(bookmarkNode.children[i], idToNodeMap);
434 }; 444 };
OLDNEW
« no previous file with comments | « chrome/browser/resources/md_bookmarks/item.js ('k') | chrome/common/extensions/api/_api_features.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698