Chromium Code Reviews| 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>. |
| 11 this.overflowAlign_ = isRTL() ? 'left' : 'right'; | 11 this.overflowAlign_ = isRTL() ? 'left' : 'right'; |
| 12 }, | 12 }, |
| 13 | 13 |
| 14 properties: { | 14 properties: { |
| 15 downloadsShowing: { | 15 downloadsShowing: { |
| 16 reflectToAttribute: true, | 16 reflectToAttribute: true, |
| 17 type: Boolean, | 17 type: Boolean, |
| 18 value: false, | 18 value: false, |
| 19 observer: 'downloadsShowingChanged_', | 19 observer: 'downloadsShowingChanged_', |
| 20 }, | 20 }, |
| 21 | 21 |
| 22 overflowAlign_: { | 22 overflowAlign_: { |
| 23 type: String, | 23 type: String, |
| 24 value: 'right', | 24 value: 'right', |
| 25 }, | 25 }, |
| 26 }, | 26 }, |
| 27 | 27 |
| 28 listeners: { | |
| 29 'paper-dropdown-close': 'onPaperDropdownClose_', | |
| 30 'paper-dropdown-open': 'onPaperDropdownOpen_', | |
| 31 }, | |
| 32 | |
| 28 /** @return {boolean} Whether removal can be undone. */ | 33 /** @return {boolean} Whether removal can be undone. */ |
| 29 canUndo: function() { | 34 canUndo: function() { |
| 30 return this.$['search-input'] != this.shadowRoot.activeElement; | 35 return this.$['search-input'] != this.shadowRoot.activeElement; |
| 31 }, | 36 }, |
| 32 | 37 |
| 33 /** @return {boolean} Whether "Clear all" should be allowed. */ | 38 /** @return {boolean} Whether "Clear all" should be allowed. */ |
| 34 canClearAll: function() { | 39 canClearAll: function() { |
| 35 return !this.$['search-input'].getValue() && this.downloadsShowing; | 40 return !this.$['search-input'].getValue() && this.downloadsShowing; |
| 36 }, | 41 }, |
| 37 | 42 |
| 38 onFindCommand: function() { | 43 onFindCommand: function() { |
| 39 this.$['search-input'].showAndFocus(); | 44 this.$['search-input'].showAndFocus(); |
| 40 }, | 45 }, |
| 41 | 46 |
| 42 /** @private */ | 47 /** @private */ |
| 43 onClearAllTap_: function() { | 48 onClearAllTap_: function() { |
| 44 assert(this.canClearAll()); | 49 assert(this.canClearAll()); |
| 45 downloads.ActionService.getInstance().clearAll(); | 50 downloads.ActionService.getInstance().clearAll(); |
| 46 }, | 51 }, |
| 47 | 52 |
| 48 /** @private */ | 53 /** @private */ |
| 49 downloadsShowingChanged_: function() { | 54 downloadsShowingChanged_: function() { |
| 50 this.updateClearAll_(); | 55 this.updateClearAll_(); |
| 51 }, | 56 }, |
| 52 | 57 |
| 58 /** @private */ | |
| 59 onPaperDropdownClose_: function() { | |
| 60 window.removeEventListener('resize', assert(this.boundResize_)); | |
| 61 }, | |
| 62 | |
| 63 /** @private */ | |
| 64 onPaperDropdownOpen_: function() { | |
| 65 this.boundResize_ = function() { this.$.more.close(); }.bind(this); | |
|
michaelpg
2016/06/16 00:49:40
if (!this.boundResize_) ?
Dan Beam
2016/06/16 01:07:24
Done.
| |
| 66 window.addEventListener('resize', this.boundResize_); | |
| 67 }, | |
| 68 | |
| 53 /** | 69 /** |
| 54 * @param {!CustomEvent} event | 70 * @param {!CustomEvent} event |
| 55 * @private | 71 * @private |
| 56 */ | 72 */ |
| 57 onSearchChanged_: function(event) { | 73 onSearchChanged_: function(event) { |
| 58 downloads.ActionService.getInstance().search( | 74 downloads.ActionService.getInstance().search( |
| 59 /** @type {string} */ (event.detail)); | 75 /** @type {string} */ (event.detail)); |
| 60 this.updateClearAll_(); | 76 this.updateClearAll_(); |
| 61 }, | 77 }, |
| 62 | 78 |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 73 }); | 89 }); |
| 74 | 90 |
| 75 return {Toolbar: Toolbar}; | 91 return {Toolbar: Toolbar}; |
| 76 }); | 92 }); |
| 77 | 93 |
| 78 // TODO(dbeam): https://github.com/PolymerElements/iron-dropdown/pull/16/files | 94 // TODO(dbeam): https://github.com/PolymerElements/iron-dropdown/pull/16/files |
| 79 /** @suppress {checkTypes} */ | 95 /** @suppress {checkTypes} */ |
| 80 (function() { | 96 (function() { |
| 81 Polymer.IronDropdownScrollManager.pushScrollLock = function() {}; | 97 Polymer.IronDropdownScrollManager.pushScrollLock = function() {}; |
| 82 })(); | 98 })(); |
| OLD | NEW |