Index: chrome/browser/resources/md_bookmarks/edit_dialog.js |
diff --git a/chrome/browser/resources/md_bookmarks/edit_dialog.js b/chrome/browser/resources/md_bookmarks/edit_dialog.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..c2a4873c3d14be119985ea00120d3158e52e2efe |
--- /dev/null |
+++ b/chrome/browser/resources/md_bookmarks/edit_dialog.js |
@@ -0,0 +1,60 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+Polymer({ |
+ is: 'bookmarks-edit-dialog', |
+ |
+ properties: { |
+ /** @private {BookmarkNode} */ |
+ editItem_: Object, |
+ |
+ /** @private */ |
+ isFolder_: Boolean, |
+ |
+ /** @private */ |
+ titleValue_: String, |
+ |
+ /** @private */ |
+ urlValue_: String, |
+ }, |
+ |
+ /** @param {BookmarkNode} editItem */ |
+ showEditDialog: function(editItem) { |
+ this.editItem_ = editItem; |
+ this.isFolder_ = !editItem.url; |
+ |
+ this.titleValue_ = editItem.title; |
+ if (!this.isFolder_) |
+ this.urlValue_ = assert(editItem.url); |
+ |
+ this.$.dialog.showModal(); |
+ }, |
+ |
+ /** |
+ * @param {boolean} isFolder |
+ * @return {string} |
+ * @private |
+ */ |
+ getDialogTitle_: function(isFolder) { |
+ return loadTimeData.getString( |
+ isFolder ? 'renameFolderTitle' : 'editBookmarkTitle'); |
+ }, |
+ |
+ /** @private */ |
+ onSaveButtonTap_: function() { |
+ // TODO(tsergeant): Save changes when enter is pressed. |
+ // TODO(tsergeant): Verify values. |
+ var edit = {'title': this.titleValue_}; |
+ if (!this.isFolder_) |
+ edit['url'] = this.urlValue_; |
+ |
+ chrome.bookmarks.update(this.editItem_.id, edit); |
+ this.$.dialog.close(); |
+ }, |
+ |
+ /** @private */ |
+ onCancelButtonTap_: function() { |
+ this.$.dialog.cancel(); |
+ }, |
+}); |