OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 Polymer({ |
| 6 is: 'bookmarks-edit-dialog', |
| 7 |
| 8 properties: { |
| 9 /** @private {BookmarkNode} */ |
| 10 editItem_: Object, |
| 11 |
| 12 /** @private */ |
| 13 isFolder_: Boolean, |
| 14 |
| 15 /** @private */ |
| 16 titleValue_: String, |
| 17 |
| 18 /** @private */ |
| 19 urlValue_: String, |
| 20 }, |
| 21 |
| 22 /** @param {BookmarkNode} editItem */ |
| 23 showEditDialog: function(editItem) { |
| 24 this.editItem_ = editItem; |
| 25 this.isFolder_ = !editItem.url; |
| 26 |
| 27 this.titleValue_ = editItem.title; |
| 28 if (!this.isFolder_) |
| 29 this.urlValue_ = assert(editItem.url); |
| 30 |
| 31 this.$.dialog.showModal(); |
| 32 }, |
| 33 |
| 34 /** |
| 35 * @param {boolean} isFolder |
| 36 * @return {string} |
| 37 * @private |
| 38 */ |
| 39 getDialogTitle_: function(isFolder) { |
| 40 return loadTimeData.getString( |
| 41 isFolder ? 'renameFolderTitle' : 'editBookmarkTitle'); |
| 42 }, |
| 43 |
| 44 /** @private */ |
| 45 onSaveButtonTap_: function() { |
| 46 // TODO(tsergeant): Save changes when enter is pressed. |
| 47 // TODO(tsergeant): Verify values. |
| 48 var edit = {'title': this.titleValue_}; |
| 49 if (!this.isFolder_) |
| 50 edit['url'] = this.urlValue_; |
| 51 |
| 52 chrome.bookmarks.update(this.editItem_.id, edit); |
| 53 this.$.dialog.close(); |
| 54 }, |
| 55 |
| 56 /** @private */ |
| 57 onCancelButtonTap_: function() { |
| 58 this.$.dialog.cancel(); |
| 59 }, |
| 60 }); |
OLD | NEW |