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

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

Issue 2668693007: [MD Bookmarks] Double Click (Closed)
Patch Set: change the loop and add tab changes 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 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 // Deselect the old folder if defined. 350 // Deselect the old folder if defined.
351 if (this.selectedId && this.idToNodeMap_[this.selectedId]) 351 if (this.selectedId && this.idToNodeMap_[this.selectedId])
352 this.set( 352 this.set(
353 this.idToNodeMap_[this.selectedId].path + '.isSelectedFolder', false); 353 this.idToNodeMap_[this.selectedId].path + '.isSelectedFolder', false);
354 354
355 // Check if the selected id is that of a defined folder. 355 // Check if the selected id is that of a defined folder.
356 var id = /** @type {string} */ (e.detail); 356 var id = /** @type {string} */ (e.detail);
357 if (!this.idToNodeMap_[id] || this.idToNodeMap_[id].url) 357 if (!this.idToNodeMap_[id] || this.idToNodeMap_[id].url)
358 id = this.rootNode.children[0].id; 358 id = this.rootNode.children[0].id;
359 359
360 var newFolder = this.idToNodeMap_[id]; 360 var folder = this.idToNodeMap_[id];
361 this.set(newFolder.path + '.isSelectedFolder', true); 361 this.set(folder.path + '.isSelectedFolder', true);
362 this.selectedId = id; 362 this.selectedId = id;
363
364 if (folder.id == this.rootNode.id)
365 return;
366
367 var parent = this.idToNodeMap_[folder.parentId];
368 while (parent) {
369 if (!parent.isOpen) {
370 this.fire('folder-open-changed', {
371 id: parent.id,
372 open: true,
373 });
374 }
375
376 parent = this.idToNodeMap_[parent.parentId];
377 }
363 }, 378 },
364 379
365 /** 380 /**
366 * Handles events that open and close folders. 381 * Handles events that open and close folders.
367 * @param {CustomEvent} e 382 * @param {CustomEvent} e
368 * @private 383 * @private
369 */ 384 */
370 onFolderOpenChanged_: function(e) { 385 onFolderOpenChanged_: function(e) {
371 var folder = this.idToNodeMap_[e.detail.id]; 386 var folder = this.idToNodeMap_[e.detail.id];
372 this.set(folder.path + '.isOpen', e.detail.open); 387 this.set(folder.path + '.isOpen', e.detail.open);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 idToNodeMap[bookmarkNode.id] = bookmarkNode; 437 idToNodeMap[bookmarkNode.id] = bookmarkNode;
423 438
424 if (bookmarkNode.url) 439 if (bookmarkNode.url)
425 return; 440 return;
426 441
427 bookmarkNode.isSelectedFolder = false; 442 bookmarkNode.isSelectedFolder = false;
428 bookmarkNode.isOpen = true; 443 bookmarkNode.isOpen = true;
429 for (var i = 0; i < bookmarkNode.children.length; i++) 444 for (var i = 0; i < bookmarkNode.children.length; i++)
430 BookmarksStore.initNodes(bookmarkNode.children[i], idToNodeMap); 445 BookmarksStore.initNodes(bookmarkNode.children[i], idToNodeMap);
431 }; 446 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698