Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 243 var startIndex, endIndex; | 243 var startIndex, endIndex; |
| 244 if (this.anchorIndex_ == null) { | 244 if (this.anchorIndex_ == null) { |
| 245 this.anchorIndex_ = this.getIndexInList_(item); | 245 this.anchorIndex_ = this.getIndexInList_(item); |
| 246 startIndex = this.anchorIndex_; | 246 startIndex = this.anchorIndex_; |
| 247 endIndex = this.anchorIndex_; | 247 endIndex = this.anchorIndex_; |
| 248 } else { | 248 } else { |
| 249 var selectedIndex = this.getIndexInList_(item); | 249 var selectedIndex = this.getIndexInList_(item); |
| 250 startIndex = Math.min(this.anchorIndex_, selectedIndex); | 250 startIndex = Math.min(this.anchorIndex_, selectedIndex); |
| 251 endIndex = Math.max(this.anchorIndex_, selectedIndex); | 251 endIndex = Math.max(this.anchorIndex_, selectedIndex); |
| 252 } | 252 } |
| 253 for (var i = startIndex; i <= endIndex; i++) | 253 for (var i = startIndex; i <= endIndex; i++) { |
|
tsergeant
2017/02/02 03:21:01
Nit: May as well revert these {} changes for now.
jiaxi
2017/02/02 03:54:46
Done.
| |
| 254 this.set('displayedList.#' + i + '.isSelectedItem', true); | 254 this.set('displayedList.#' + i + '.isSelectedItem', true); |
| 255 } | |
| 255 }, | 256 }, |
| 256 | 257 |
| 257 /** | 258 /** |
| 258 * Selects a single item in the displayedList. | 259 * Selects a single item in the displayedList. |
| 259 * @param {BookmarkTreeNode} item | 260 * @param {BookmarkTreeNode} item |
| 260 * @private | 261 * @private |
| 261 */ | 262 */ |
| 262 selectItem_: function(item) { | 263 selectItem_: function(item) { |
| 263 this.anchorIndex_ = this.getIndexInList_(item); | 264 this.anchorIndex_ = this.getIndexInList_(item); |
| 264 this.set('displayedList.#' + this.anchorIndex_ + '.isSelectedItem', true); | 265 this.set('displayedList.#' + this.anchorIndex_ + '.isSelectedItem', true); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 353 // Deselect the old folder if defined. | 354 // Deselect the old folder if defined. |
| 354 if (this.selectedId && this.idToNodeMap_[this.selectedId]) | 355 if (this.selectedId && this.idToNodeMap_[this.selectedId]) |
| 355 this.set( | 356 this.set( |
| 356 this.idToNodeMap_[this.selectedId].path + '.isSelectedFolder', false); | 357 this.idToNodeMap_[this.selectedId].path + '.isSelectedFolder', false); |
| 357 | 358 |
| 358 // Check if the selected id is that of a defined folder. | 359 // Check if the selected id is that of a defined folder. |
| 359 var id = /** @type {string} */ (e.detail); | 360 var id = /** @type {string} */ (e.detail); |
| 360 if (!this.idToNodeMap_[id] || this.idToNodeMap_[id].url) | 361 if (!this.idToNodeMap_[id] || this.idToNodeMap_[id].url) |
| 361 id = this.rootNode.children[0].id; | 362 id = this.rootNode.children[0].id; |
| 362 | 363 |
| 363 var newFolder = this.idToNodeMap_[id]; | 364 var folder = this.idToNodeMap_[id]; |
| 364 this.set(newFolder.path + '.isSelectedFolder', true); | 365 this.set(folder.path + '.isSelectedFolder', true); |
| 365 this.selectedId = id; | 366 this.selectedId = id; |
| 367 while (folder.parentId) { | |
| 368 folder = this.idToNodeMap_[folder.parentId]; | |
| 369 if (folder.isOpen) | |
| 370 continue; | |
| 371 | |
| 372 this.fire('folder-open-changed', { | |
| 373 id: folder.id, | |
| 374 open: true, | |
| 375 }); | |
| 376 } | |
| 366 }, | 377 }, |
| 367 | 378 |
| 368 /** | 379 /** |
| 369 * Handles events that open and close folders. | 380 * Handles events that open and close folders. |
| 370 * @param {CustomEvent} e | 381 * @param {CustomEvent} e |
| 371 * @private | 382 * @private |
| 372 */ | 383 */ |
| 373 onFolderOpenChanged_: function(e) { | 384 onFolderOpenChanged_: function(e) { |
| 374 var folder = this.idToNodeMap_[e.detail.id]; | 385 var folder = this.idToNodeMap_[e.detail.id]; |
| 375 this.set(folder.path + '.isOpen', e.detail.open); | 386 this.set(folder.path + '.isOpen', e.detail.open); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 425 idToNodeMap[bookmarkNode.id] = bookmarkNode; | 436 idToNodeMap[bookmarkNode.id] = bookmarkNode; |
| 426 | 437 |
| 427 if (bookmarkNode.url) | 438 if (bookmarkNode.url) |
| 428 return; | 439 return; |
| 429 | 440 |
| 430 bookmarkNode.isSelectedFolder = false; | 441 bookmarkNode.isSelectedFolder = false; |
| 431 bookmarkNode.isOpen = true; | 442 bookmarkNode.isOpen = true; |
| 432 for (var i = 0; i < bookmarkNode.children.length; i++) | 443 for (var i = 0; i < bookmarkNode.children.length; i++) |
| 433 BookmarksStore.initNodes(bookmarkNode.children[i], idToNodeMap); | 444 BookmarksStore.initNodes(bookmarkNode.children[i], idToNodeMap); |
| 434 }; | 445 }; |
| OLD | NEW |