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

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

Issue 2650303003: MD Downloads: convert <paper-dropdown-menu> to <dialog is="cr-action-menu"> (Closed)
Patch Set: browser test fixes Created 3 years, 11 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 cr.define('downloads', function() { 5 cr.define('downloads', function() {
6 var Toolbar = Polymer({ 6 var Toolbar = Polymer({
7 is: 'downloads-toolbar', 7 is: 'downloads-toolbar',
8 8
9 properties: { 9 properties: {
10 downloadsShowing: { 10 downloadsShowing: {
11 reflectToAttribute: true, 11 reflectToAttribute: true,
12 type: Boolean, 12 type: Boolean,
13 value: false, 13 value: false,
14 observer: 'downloadsShowingChanged_', 14 observer: 'downloadsShowingChanged_',
15 }, 15 },
16 16
17 spinnerActive: { 17 spinnerActive: {
18 type: Boolean, 18 type: Boolean,
19 notify: true, 19 notify: true,
20 }, 20 },
21 }, 21 },
22 22
23 listeners: {
24 'paper-dropdown-close': 'onPaperDropdownClose_',
25 'paper-dropdown-open': 'onPaperDropdownOpen_',
26 },
27
28 /** @return {boolean} Whether removal can be undone. */ 23 /** @return {boolean} Whether removal can be undone. */
29 canUndo: function() { 24 canUndo: function() {
30 return !this.$.toolbar.getSearchField().isSearchFocused(); 25 return !this.$.toolbar.getSearchField().isSearchFocused();
31 }, 26 },
32 27
33 /** @return {boolean} Whether "Clear all" should be allowed. */ 28 /** @return {boolean} Whether "Clear all" should be allowed. */
34 canClearAll: function() { 29 canClearAll: function() {
35 return !this.$.toolbar.getSearchField().getValue() && 30 return !this.$.toolbar.getSearchField().getValue() &&
36 this.downloadsShowing; 31 this.downloadsShowing;
37 }, 32 },
38 33
39 onFindCommand: function() { 34 onFindCommand: function() {
40 this.$.toolbar.getSearchField().showAndFocus(); 35 this.$.toolbar.getSearchField().showAndFocus();
41 }, 36 },
42 37
43 /** @private */ 38 /** @private */
44 closeMoreActions_: function() {
45 this.$.more.close();
46 },
47
48 /** @private */
49 downloadsShowingChanged_: function() { 39 downloadsShowingChanged_: function() {
50 this.updateClearAll_(); 40 this.updateClearAll_();
51 }, 41 },
52 42
53 /** @private */ 43 /** @private */
54 onClearAllTap_: function() { 44 onClearAllTap_: function() {
55 assert(this.canClearAll()); 45 assert(this.canClearAll());
56 downloads.ActionService.getInstance().clearAll(); 46 downloads.ActionService.getInstance().clearAll();
47 this.$.moreActionsMenu.close();
57 }, 48 },
58 49
59 /** @private */ 50 /** @private */
60 onPaperDropdownClose_: function() { 51 onMoreActionsTap_: function() {
61 window.removeEventListener('resize', assert(this.boundClose_)); 52 this.$.moreActionsMenu.showAt(this.$.moreActions);
62 }, 53 },
63 54
64 /** 55 /**
65 * @param {!Event} e
66 * @private
67 */
68 onItemBlur_: function(e) {
69 var menu = /** @type {PaperMenuElement} */(this.$$('paper-menu'));
70 if (menu.items.indexOf(e.relatedTarget) >= 0)
71 return;
72
73 this.$.more.restoreFocusOnClose = false;
74 this.closeMoreActions_();
75 this.$.more.restoreFocusOnClose = true;
76 },
77
78 /** @private */
79 onPaperDropdownOpen_: function() {
80 this.boundClose_ = this.boundClose_ || this.closeMoreActions_.bind(this);
81 window.addEventListener('resize', this.boundClose_);
82 },
83
84 /**
85 * @param {!CustomEvent} event 56 * @param {!CustomEvent} event
86 * @private 57 * @private
87 */ 58 */
88 onSearchChanged_: function(event) { 59 onSearchChanged_: function(event) {
89 var actionService = downloads.ActionService.getInstance(); 60 var actionService = downloads.ActionService.getInstance();
90 if (actionService.search(/** @type {string} */ (event.detail))) 61 if (actionService.search(/** @type {string} */ (event.detail)))
91 this.spinnerActive = actionService.isSearching(); 62 this.spinnerActive = actionService.isSearching();
92 this.updateClearAll_(); 63 this.updateClearAll_();
93 }, 64 },
94 65
95 /** @private */ 66 /** @private */
96 onOpenDownloadsFolderTap_: function() { 67 onOpenDownloadsFolderTap_: function() {
97 downloads.ActionService.getInstance().openDownloadsFolder(); 68 downloads.ActionService.getInstance().openDownloadsFolder();
69 this.$.moreActionsMenu.close();
98 }, 70 },
99 71
100 /** @private */ 72 /** @private */
101 updateClearAll_: function() { 73 updateClearAll_: function() {
102 this.$$('paper-menu .clear-all').hidden = !this.canClearAll(); 74 this.$$('.clear-all').hidden = !this.canClearAll();
103 }, 75 },
104 }); 76 });
105 77
106 return {Toolbar: Toolbar}; 78 return {Toolbar: Toolbar};
107 }); 79 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/md_downloads/toolbar.html ('k') | chrome/browser/resources/md_downloads/vulcanized.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698