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

Side by Side Diff: chrome/browser/resources/md_bookmarks/toolbar.js

Issue 2670473002: [MD Bookmarks] Implement adding folders and bookmarks from toolbar menu. (Closed)
Patch Set: Fix store to insert node instead of push and update tests. Created 3 years, 10 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 unified diff | Download patch
OLDNEW
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-toolbar', 6 is: 'bookmarks-toolbar',
7 7
8 properties: { 8 properties: {
9 searchTerm: { 9 searchTerm: {
10 type: String, 10 type: String,
11 observer: 'onSearchTermChanged_', 11 observer: 'onSearchTermChanged_',
12 }, 12 },
13
14 createdNode: Object,
13 }, 15 },
14 16
15 /** @return {CrToolbarSearchFieldElement} */ 17 /** @return {CrToolbarSearchFieldElement} */
16 get searchField() { 18 get searchField() {
17 return /** @type {CrToolbarElement} */ (this.$$('cr-toolbar')) 19 return /** @type {CrToolbarElement} */ (this.$$('cr-toolbar'))
18 .getSearchField(); 20 .getSearchField();
19 }, 21 },
20 22
21 /** 23 /**
22 * @param {Event} e 24 * @param {Event} e
23 * @private 25 * @private
24 */ 26 */
25 onMenuButtonOpenTap_: function(e) { 27 onMenuButtonOpenTap_: function(e) {
26 var menu = /** @type {!CrActionMenuElement} */ (this.$.dropdown); 28 var menu = /** @type {!CrActionMenuElement} */ (this.$.dropdown);
27 menu.showAt(/** @type {!Element} */ (e.target)); 29 menu.showAt(/** @type {!Element} */ (e.target));
28 }, 30 },
29 31
30 /** @private */ 32 /** @private */
31 onBulkEditTap_: function() { 33 onBulkEditTap_: function() {
32 this.closeDropdownMenu_(); 34 this.closeDropdownMenu_();
33 }, 35 },
34 36
35 /** @private */ 37 /** @private */
36 onSortTap_: function() { 38 onSortTap_: function() {
37 this.closeDropdownMenu_(); 39 this.closeDropdownMenu_();
38 }, 40 },
39 41
40 /** @private */ 42 /** @private */
41 onAddBookmarkTap_: function() { 43 onAddBookmarkTap_: function() {
44 this.createdNode = {isFolder: false};
45 this.$.addBookmark.showModal();
42 this.closeDropdownMenu_(); 46 this.closeDropdownMenu_();
43 }, 47 },
44 48
49 onAddFolderTap_: function() {
50 this.createdNode = {isFolder: true};
51 this.$.addBookmark.showModal();
52 this.closeDropdownMenu_();
53 },
54
45 /** @private */ 55 /** @private */
46 onAddImportTap_: function() { 56 onAddImportTap_: function() {
47 this.closeDropdownMenu_(); 57 this.closeDropdownMenu_();
48 }, 58 },
49 59
50 /** @private */ 60 /** @private */
51 onAddExportTap_: function() { 61 onAddExportTap_: function() {
52 this.closeDropdownMenu_(); 62 this.closeDropdownMenu_();
53 }, 63 },
54 64
55 /** @private */ 65 /** @private */
56 closeDropdownMenu_: function() { 66 closeDropdownMenu_: function() {
57 var menu = /** @type {!CrActionMenuElement} */ (this.$.dropdown); 67 var menu = /** @type {!CrActionMenuElement} */ (this.$.dropdown);
58 menu.close(); 68 menu.close();
59 }, 69 },
60 70
71 /** @private */
72 onSaveAddTap_: function() {
73 delete this.createdNode['isFolder'];
74 this.fire('node-added', this.createdNode);
75 this.$.addBookmark.close();
76 },
77
78 /** @private */
79 onCancelAddTap_: function() {
80 this.$.addBookmark.close();
81 },
82
83 /** @private */
84 getModalTitle_: function() {
85 var title =
86 this.createdNode.isFolder ? 'addFolderTitle' : 'addBookmarkTitle';
87 return loadTimeData.getString(title);
88 },
89
61 /** 90 /**
62 * @param {Event} e 91 * @param {Event} e
63 * @private 92 * @private
64 */ 93 */
65 onSearchChanged_: function(e) { 94 onSearchChanged_: function(e) {
66 var searchTerm = /** @type {string} */ (e.detail); 95 var searchTerm = /** @type {string} */ (e.detail);
67 this.fire('search-term-changed', searchTerm); 96 this.fire('search-term-changed', searchTerm);
68 }, 97 },
69 98
70 /** @private */ 99 /** @private */
71 onSearchTermChanged_: function() { 100 onSearchTermChanged_: function() {
72 this.searchField.setValue(this.searchTerm || ''); 101 this.searchField.setValue(this.searchTerm || '');
73 }, 102 },
74 }); 103 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698