Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1433)

Unified Diff: chrome/browser/resources/md_bookmarks/edit_dialog.js

Issue 2742583003: MD Bookmarks: Extract bookmark editing into a <bookmark-edit-dialog> element (Closed)
Patch Set: Rename event handlers Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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();
+ },
+});
« no previous file with comments | « chrome/browser/resources/md_bookmarks/edit_dialog.html ('k') | chrome/browser/resources/md_bookmarks/list.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698