OLD | NEW |
---|---|
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 attached: function() { | 9 attached: function() { |
10 // isRTL() only works after i18n_template.js runs to set <html dir>. | 10 // isRTL() only works after i18n_template.js runs to set <html dir>. |
(...skipping 27 matching lines...) Expand all Loading... | |
38 /** @return {boolean} Whether "Clear all" should be allowed. */ | 38 /** @return {boolean} Whether "Clear all" should be allowed. */ |
39 canClearAll: function() { | 39 canClearAll: function() { |
40 return !this.$['search-input'].getValue() && this.downloadsShowing; | 40 return !this.$['search-input'].getValue() && this.downloadsShowing; |
41 }, | 41 }, |
42 | 42 |
43 onFindCommand: function() { | 43 onFindCommand: function() { |
44 this.$['search-input'].showAndFocus(); | 44 this.$['search-input'].showAndFocus(); |
45 }, | 45 }, |
46 | 46 |
47 /** @private */ | 47 /** @private */ |
48 onClearAllTap_: function() { | 48 closeMoreActions_: function(e) { |
tsergeant
2016/07/18 01:53:19
You need to get rid of this `e` to fix the compile
Dan Beam
2016/07/18 07:09:40
Done.
| |
49 assert(this.canClearAll()); | 49 this.$.more.close(); |
50 downloads.ActionService.getInstance().clearAll(); | |
51 }, | 50 }, |
52 | 51 |
53 /** @private */ | 52 /** @private */ |
54 downloadsShowingChanged_: function() { | 53 downloadsShowingChanged_: function() { |
55 this.updateClearAll_(); | 54 this.updateClearAll_(); |
56 }, | 55 }, |
57 | 56 |
58 /** @private */ | 57 /** @private */ |
58 onClearAllTap_: function() { | |
59 assert(this.canClearAll()); | |
60 downloads.ActionService.getInstance().clearAll(); | |
61 }, | |
62 | |
63 /** @private */ | |
59 onPaperDropdownClose_: function() { | 64 onPaperDropdownClose_: function() { |
60 window.removeEventListener('resize', assert(this.boundResize_)); | 65 window.removeEventListener('resize', assert(this.boundClose_)); |
66 }, | |
67 | |
68 /** | |
69 * @param {!Event} e | |
70 * @private | |
71 */ | |
72 onItemBlur_: function(e) { | |
73 if (this.$$('paper-menu').items.indexOf(e.relatedTarget) >= 0) | |
74 return; | |
75 | |
76 // This can be this.$.more.restoreFocusOnClose = false when this lands: | |
77 // https://github.com/PolymerElements/paper-menu-button/pull/94 | |
78 this.$.more.$.dropdown.restoreFocusOnClose = false; | |
79 this.closeMoreActions_(); | |
80 this.$.more.$.dropdown.restoreFocusOnClose = true; | |
61 }, | 81 }, |
62 | 82 |
63 /** @private */ | 83 /** @private */ |
64 onPaperDropdownOpen_: function() { | 84 onPaperDropdownOpen_: function() { |
65 this.boundResize_ = this.boundResize_ || function() { | 85 this.boundClose_ = this.boundClose_ || this.closeMoreActions_.bind(this); |
66 this.$.more.close(); | 86 window.addEventListener('resize', this.boundClose_); |
67 }.bind(this); | |
68 window.addEventListener('resize', this.boundResize_); | |
69 }, | 87 }, |
70 | 88 |
71 /** | 89 /** |
72 * @param {!CustomEvent} event | 90 * @param {!CustomEvent} event |
73 * @private | 91 * @private |
74 */ | 92 */ |
75 onSearchChanged_: function(event) { | 93 onSearchChanged_: function(event) { |
76 downloads.ActionService.getInstance().search( | 94 downloads.ActionService.getInstance().search( |
77 /** @type {string} */ (event.detail)); | 95 /** @type {string} */ (event.detail)); |
78 this.updateClearAll_(); | 96 this.updateClearAll_(); |
(...skipping 12 matching lines...) Expand all Loading... | |
91 }); | 109 }); |
92 | 110 |
93 return {Toolbar: Toolbar}; | 111 return {Toolbar: Toolbar}; |
94 }); | 112 }); |
95 | 113 |
96 // TODO(dbeam): https://github.com/PolymerElements/iron-dropdown/pull/16/files | 114 // TODO(dbeam): https://github.com/PolymerElements/iron-dropdown/pull/16/files |
97 /** @suppress {checkTypes} */ | 115 /** @suppress {checkTypes} */ |
98 (function() { | 116 (function() { |
99 Polymer.IronDropdownScrollManager.pushScrollLock = function() {}; | 117 Polymer.IronDropdownScrollManager.pushScrollLock = function() {}; |
100 })(); | 118 })(); |
OLD | NEW |