| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 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-edit-dialog', | 6 is: 'bookmarks-edit-dialog', |
| 7 | 7 |
| 8 behaviors: [ |
| 9 Polymer.IronA11yKeysBehavior, |
| 10 ], |
| 11 |
| 8 properties: { | 12 properties: { |
| 9 /** @private {BookmarkNode} */ | 13 /** @private {BookmarkNode} */ |
| 10 editItem_: Object, | 14 editItem_: Object, |
| 11 | 15 |
| 12 /** @private */ | 16 /** @private */ |
| 13 isFolder_: Boolean, | 17 isFolder_: Boolean, |
| 14 | 18 |
| 15 /** @private */ | 19 /** @private */ |
| 16 titleValue_: String, | 20 titleValue_: String, |
| 17 | 21 |
| 18 /** @private */ | 22 /** @private */ |
| 19 urlValue_: String, | 23 urlValue_: String, |
| 20 }, | 24 }, |
| 21 | 25 |
| 26 keyBindings: { |
| 27 'enter': 'onSaveButtonTap_', |
| 28 }, |
| 29 |
| 22 /** @param {BookmarkNode} editItem */ | 30 /** @param {BookmarkNode} editItem */ |
| 23 showEditDialog: function(editItem) { | 31 showEditDialog: function(editItem) { |
| 24 this.editItem_ = editItem; | 32 this.editItem_ = editItem; |
| 25 this.isFolder_ = !editItem.url; | 33 this.isFolder_ = !editItem.url; |
| 26 | 34 |
| 27 this.titleValue_ = editItem.title; | 35 this.titleValue_ = editItem.title; |
| 28 if (!this.isFolder_) | 36 if (!this.isFolder_) |
| 29 this.urlValue_ = assert(editItem.url); | 37 this.urlValue_ = assert(editItem.url); |
| 30 | 38 |
| 31 this.$.dialog.showModal(); | 39 this.$.dialog.showModal(); |
| 32 }, | 40 }, |
| 33 | 41 |
| 34 /** | 42 /** |
| 35 * @param {boolean} isFolder | 43 * @param {boolean} isFolder |
| 36 * @return {string} | 44 * @return {string} |
| 37 * @private | 45 * @private |
| 38 */ | 46 */ |
| 39 getDialogTitle_: function(isFolder) { | 47 getDialogTitle_: function(isFolder) { |
| 40 return loadTimeData.getString( | 48 return loadTimeData.getString( |
| 41 isFolder ? 'renameFolderTitle' : 'editBookmarkTitle'); | 49 isFolder ? 'renameFolderTitle' : 'editBookmarkTitle'); |
| 42 }, | 50 }, |
| 43 | 51 |
| 44 /** @private */ | 52 /** @private */ |
| 45 onSaveButtonTap_: function() { | 53 onSaveButtonTap_: function() { |
| 46 // TODO(tsergeant): Save changes when enter is pressed. | |
| 47 // TODO(tsergeant): Verify values. | 54 // TODO(tsergeant): Verify values. |
| 48 var edit = {'title': this.titleValue_}; | 55 var edit = {'title': this.titleValue_}; |
| 49 if (!this.isFolder_) | 56 if (!this.isFolder_) |
| 50 edit['url'] = this.urlValue_; | 57 edit['url'] = this.urlValue_; |
| 51 | 58 |
| 52 chrome.bookmarks.update(this.editItem_.id, edit); | 59 chrome.bookmarks.update(this.editItem_.id, edit); |
| 53 this.$.dialog.close(); | 60 this.$.dialog.close(); |
| 54 }, | 61 }, |
| 55 | 62 |
| 56 /** @private */ | 63 /** @private */ |
| 57 onCancelButtonTap_: function() { | 64 onCancelButtonTap_: function() { |
| 58 this.$.dialog.cancel(); | 65 this.$.dialog.cancel(); |
| 59 }, | 66 }, |
| 60 }); | 67 }); |
| OLD | NEW |