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() { |
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 var menu = /** @type {PaperMenuElement} */(this.$$('paper-menu')); |
| 74 if (menu.items.indexOf(e.relatedTarget) >= 0) |
| 75 return; |
| 76 |
| 77 // This can be this.$.more.restoreFocusOnClose = false when this lands: |
| 78 // https://github.com/PolymerElements/paper-menu-button/pull/94 |
| 79 this.$.more.$.dropdown.restoreFocusOnClose = false; |
| 80 this.closeMoreActions_(); |
| 81 this.$.more.$.dropdown.restoreFocusOnClose = true; |
61 }, | 82 }, |
62 | 83 |
63 /** @private */ | 84 /** @private */ |
64 onPaperDropdownOpen_: function() { | 85 onPaperDropdownOpen_: function() { |
65 this.boundResize_ = this.boundResize_ || function() { | 86 this.boundClose_ = this.boundClose_ || this.closeMoreActions_.bind(this); |
66 this.$.more.close(); | 87 window.addEventListener('resize', this.boundClose_); |
67 }.bind(this); | |
68 window.addEventListener('resize', this.boundResize_); | |
69 }, | 88 }, |
70 | 89 |
71 /** | 90 /** |
72 * @param {!CustomEvent} event | 91 * @param {!CustomEvent} event |
73 * @private | 92 * @private |
74 */ | 93 */ |
75 onSearchChanged_: function(event) { | 94 onSearchChanged_: function(event) { |
76 downloads.ActionService.getInstance().search( | 95 downloads.ActionService.getInstance().search( |
77 /** @type {string} */ (event.detail)); | 96 /** @type {string} */ (event.detail)); |
78 this.updateClearAll_(); | 97 this.updateClearAll_(); |
(...skipping 12 matching lines...) Expand all Loading... |
91 }); | 110 }); |
92 | 111 |
93 return {Toolbar: Toolbar}; | 112 return {Toolbar: Toolbar}; |
94 }); | 113 }); |
95 | 114 |
96 // TODO(dbeam): https://github.com/PolymerElements/iron-dropdown/pull/16/files | 115 // TODO(dbeam): https://github.com/PolymerElements/iron-dropdown/pull/16/files |
97 /** @suppress {checkTypes} */ | 116 /** @suppress {checkTypes} */ |
98 (function() { | 117 (function() { |
99 Polymer.IronDropdownScrollManager.pushScrollLock = function() {}; | 118 Polymer.IronDropdownScrollManager.pushScrollLock = function() {}; |
100 })(); | 119 })(); |
OLD | NEW |