| 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 Polymer({ | 5 Polymer({ |
| 6 is: 'bookmarks-list', | 6 is: 'bookmarks-list', |
| 7 | 7 |
| 8 properties: { | 8 properties: { |
| 9 /** @type {BookmarkTreeNode} */ | 9 /** @type {BookmarkTreeNode} */ |
| 10 selectedNode: Object, | 10 selectedNode: Object, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 this.menuItem_ = e.detail.item; | 25 this.menuItem_ = e.detail.item; |
| 26 var menu = /** @type {!CrActionMenuElement} */ ( | 26 var menu = /** @type {!CrActionMenuElement} */ ( |
| 27 this.$.dropdown); | 27 this.$.dropdown); |
| 28 menu.showAt(/** @type {!Element} */ (e.detail.target)); | 28 menu.showAt(/** @type {!Element} */ (e.detail.target)); |
| 29 }, | 29 }, |
| 30 | 30 |
| 31 // TODO(jiaxi): change these dummy click event handlers later. | 31 // TODO(jiaxi): change these dummy click event handlers later. |
| 32 /** @private */ | 32 /** @private */ |
| 33 onEditTap_: function() { | 33 onEditTap_: function() { |
| 34 this.closeDropdownMenu_(); | 34 this.closeDropdownMenu_(); |
| 35 if (this.menuItem_.url) |
| 36 this.$.editBookmark.showModal(); |
| 35 }, | 37 }, |
| 36 | 38 |
| 37 /** @private */ | 39 /** @private */ |
| 38 onCopyURLTap_: function() { | 40 onCopyURLTap_: function() { |
| 39 var idList = [this.menuItem_.id]; | 41 var idList = [this.menuItem_.id]; |
| 40 chrome.bookmarkManagerPrivate.copy(idList, function() { | 42 chrome.bookmarkManagerPrivate.copy(idList, function() { |
| 41 // TODO(jiaxi): Add toast later. | 43 // TODO(jiaxi): Add toast later. |
| 42 }); | 44 }); |
| 43 this.closeDropdownMenu_(); | 45 this.closeDropdownMenu_(); |
| 44 }, | 46 }, |
| 45 | 47 |
| 46 /** @private */ | 48 /** @private */ |
| 47 onDeleteTap_: function() { | 49 onDeleteTap_: function() { |
| 48 if (this.menuItem_.children) { | 50 if (this.menuItem_.children) { |
| 49 chrome.bookmarks.removeTree(this.menuItem_.id, function() { | 51 chrome.bookmarks.removeTree(this.menuItem_.id, function() { |
| 50 // TODO(jiaxi): Add toast later. | 52 // TODO(jiaxi): Add toast later. |
| 51 }.bind(this)); | 53 }.bind(this)); |
| 52 } else { | 54 } else { |
| 53 chrome.bookmarks.remove(this.menuItem_.id, function() { | 55 chrome.bookmarks.remove(this.menuItem_.id, function() { |
| 54 // TODO(jiaxi): Add toast later. | 56 // TODO(jiaxi): Add toast later. |
| 55 }.bind(this)); | 57 }.bind(this)); |
| 56 } | 58 } |
| 57 this.closeDropdownMenu_(); | 59 this.closeDropdownMenu_(); |
| 58 }, | 60 }, |
| 59 | 61 |
| 60 /** @private */ | 62 /** @private */ |
| 63 onSaveEditTap_: function() { |
| 64 chrome.bookmarks.update(this.menuItem_.id, { |
| 65 'title': this.menuItem_.title, |
| 66 'url': this.menuItem_.url, |
| 67 }); |
| 68 this.$.editBookmark.close(); |
| 69 }, |
| 70 |
| 71 /** @private */ |
| 72 onCancelEditTap_: function() { |
| 73 this.$.editBookmark.cancel(); |
| 74 }, |
| 75 |
| 76 /** @private */ |
| 61 closeDropdownMenu_: function() { | 77 closeDropdownMenu_: function() { |
| 62 var menu = /** @type {!CrActionMenuElement} */ ( | 78 var menu = /** @type {!CrActionMenuElement} */ ( |
| 63 this.$.dropdown); | 79 this.$.dropdown); |
| 64 menu.close(); | 80 menu.close(); |
| 65 }, | 81 }, |
| 66 | 82 |
| 67 /** @private */ | 83 /** @private */ |
| 68 isListEmpty_: function() { | 84 isListEmpty_: function() { |
| 69 return this.selectedNode.children.length == 0; | 85 return this.selectedNode.children.length == 0; |
| 70 } | 86 } |
| 71 }); | 87 }); |
| OLD | NEW |