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 Polymer({ | 5 Polymer({ |
| 6 is: 'bookmarks-list', | 6 is: 'bookmarks-list', |
| 7 | 7 |
| 8 properties: { | 8 properties: { |
| 9 /** @type {BookmarkTreeNode} */ | 9 /** @type {BookmarkTreeNode} */ |
| 10 menuItem_: Object, | 10 menuItem_: Object, |
| 11 | 11 |
| 12 /** @type {Array<BookmarkTreeNode>} */ | 12 /** @type {Array<BookmarkTreeNode>} */ |
| 13 displayedList: Array, | 13 displayedList: Array, |
| 14 | 14 |
| 15 searchTerm: String, | 15 searchTerm: String, |
| 16 | |
| 17 hideUrlInput_: Boolean, | |
| 16 }, | 18 }, |
| 17 | 19 |
| 18 listeners: { | 20 listeners: { |
| 19 'open-item-menu': 'onOpenItemMenu_', | 21 'open-item-menu': 'onOpenItemMenu_', |
| 20 }, | 22 }, |
| 21 | 23 |
| 22 /** | 24 /** |
| 23 * @param {Event} e | 25 * @param {Event} e |
| 24 * @private | 26 * @private |
| 25 */ | 27 */ |
| 26 onOpenItemMenu_: function(e) { | 28 onOpenItemMenu_: function(e) { |
| 27 this.menuItem_ = e.detail.item; | 29 this.menuItem_ = e.detail.item; |
| 28 var menu = /** @type {!CrActionMenuElement} */ ( | 30 var menu = /** @type {!CrActionMenuElement} */ ( |
| 29 this.$.dropdown); | 31 this.$.dropdown); |
| 30 menu.showAt(/** @type {!Element} */ (e.detail.target)); | 32 menu.showAt(/** @type {!Element} */ (e.detail.target)); |
| 31 }, | 33 }, |
| 32 | 34 |
| 33 // TODO(jiaxi): change these dummy click event handlers later. | 35 // TODO(jiaxi): change these dummy click event handlers later. |
|
tsergeant
2017/02/01 06:04:21
Can you get rid of this TODO while you're here? It
angelayang
2017/02/01 07:19:33
Done.
| |
| 34 /** @private */ | 36 /** @private */ |
| 35 onEditTap_: function() { | 37 onEditTap_: function() { |
| 36 this.closeDropdownMenu_(); | 38 this.closeDropdownMenu_(); |
| 37 if (this.menuItem_.url) | 39 this.hideUrlInput_ = !this.menuItem_.url; |
| 38 this.$.editBookmark.showModal(); | 40 this.$.editBookmark.showModal(); |
| 39 }, | 41 }, |
| 40 | 42 |
| 41 /** @private */ | 43 /** @private */ |
| 42 onCopyURLTap_: function() { | 44 onCopyURLTap_: function() { |
| 43 var idList = [this.menuItem_.id]; | 45 var idList = [this.menuItem_.id]; |
| 44 chrome.bookmarkManagerPrivate.copy(idList, function() { | 46 chrome.bookmarkManagerPrivate.copy(idList, function() { |
| 45 // TODO(jiaxi): Add toast later. | 47 // TODO(jiaxi): Add toast later. |
| 46 }); | 48 }); |
| 47 this.closeDropdownMenu_(); | 49 this.closeDropdownMenu_(); |
| 48 }, | 50 }, |
| 49 | 51 |
| 50 /** @private */ | 52 /** @private */ |
| 51 onDeleteTap_: function() { | 53 onDeleteTap_: function() { |
| 52 if (this.menuItem_.url) { | 54 if (this.menuItem_.url) { |
| 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 } else { | 58 } else { |
| 57 chrome.bookmarks.removeTree(this.menuItem_.id, function() { | 59 chrome.bookmarks.removeTree(this.menuItem_.id, function() { |
| 58 // TODO(jiaxi): Add toast later. | 60 // TODO(jiaxi): Add toast later. |
| 59 }.bind(this)); | 61 }.bind(this)); |
| 60 } | 62 } |
| 61 this.closeDropdownMenu_(); | 63 this.closeDropdownMenu_(); |
| 62 }, | 64 }, |
| 63 | 65 |
| 64 /** @private */ | 66 /** @private */ |
| 65 onSaveEditTap_: function() { | 67 onSaveEditTap_: function() { |
| 66 chrome.bookmarks.update(this.menuItem_.id, { | 68 chrome.bookmarks.update(this.menuItem_.id, { |
|
tsergeant
2017/02/01 06:04:21
I think you need to make it so that 'url' isn't se
angelayang
2017/02/01 07:19:33
Done.
| |
| 67 'title': this.menuItem_.title, | 69 'title': this.menuItem_.title, |
| 68 'url': this.menuItem_.url, | 70 'url': this.menuItem_.url, |
| 69 }); | 71 }); |
| 70 this.$.editBookmark.close(); | 72 this.$.editBookmark.close(); |
| 71 }, | 73 }, |
| 72 | 74 |
| 73 /** @private */ | 75 /** @private */ |
| 74 onCancelEditTap_: function() { | 76 onCancelEditTap_: function() { |
| 75 this.$.editBookmark.cancel(); | 77 this.$.editBookmark.cancel(); |
| 76 }, | 78 }, |
| 77 | 79 |
| 78 /** @private */ | 80 /** @private */ |
| 79 closeDropdownMenu_: function() { | 81 closeDropdownMenu_: function() { |
| 80 var menu = /** @type {!CrActionMenuElement} */ ( | 82 var menu = /** @type {!CrActionMenuElement} */ ( |
| 81 this.$.dropdown); | 83 this.$.dropdown); |
| 82 menu.close(); | 84 menu.close(); |
| 83 }, | 85 }, |
| 84 | 86 |
| 85 /** @private */ | 87 /** @private */ |
| 88 getEditorTitle_: function() { | |
| 89 var title = this.menuItem_.url ? 'editBookmarkTitle' : 'editFolderTitle'; | |
| 90 return loadTimeData.getString(title); | |
| 91 }, | |
| 92 | |
| 93 /** @private */ | |
| 86 emptyListMessage_: function() { | 94 emptyListMessage_: function() { |
| 87 var emptyListMessage = this.searchTerm ? 'noSearchResults' : 'emptyList'; | 95 var emptyListMessage = this.searchTerm ? 'noSearchResults' : 'emptyList'; |
| 88 return loadTimeData.getString(emptyListMessage); | 96 return loadTimeData.getString(emptyListMessage); |
| 89 }, | 97 }, |
| 90 | 98 |
| 91 /** @private */ | 99 /** @private */ |
| 92 isEmptyList_: function() { | 100 isEmptyList_: function() { |
| 93 return this.displayedList.length == 0; | 101 return this.displayedList.length == 0; |
| 94 }, | 102 }, |
| 95 }); | 103 }); |
| OLD | NEW |