| 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 | |
| 13 /** @private {!SearchFieldDelegate} */ | |
| 14 this.searchFieldDelegate_ = new ToolbarSearchFieldDelegate(this); | |
| 15 this.$['search-input'].setDelegate(this.searchFieldDelegate_); | |
| 16 }, | 12 }, |
| 17 | 13 |
| 18 properties: { | 14 properties: { |
| 19 downloadsShowing: { | 15 downloadsShowing: { |
| 20 reflectToAttribute: true, | 16 reflectToAttribute: true, |
| 21 type: Boolean, | 17 type: Boolean, |
| 22 value: false, | 18 value: false, |
| 23 observer: 'downloadsShowingChanged_', | 19 observer: 'downloadsShowingChanged_', |
| 24 }, | 20 }, |
| 25 | 21 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 47 onClearAllTap_: function() { | 43 onClearAllTap_: function() { |
| 48 assert(this.canClearAll()); | 44 assert(this.canClearAll()); |
| 49 downloads.ActionService.getInstance().clearAll(); | 45 downloads.ActionService.getInstance().clearAll(); |
| 50 }, | 46 }, |
| 51 | 47 |
| 52 /** @private */ | 48 /** @private */ |
| 53 downloadsShowingChanged_: function() { | 49 downloadsShowingChanged_: function() { |
| 54 this.updateClearAll_(); | 50 this.updateClearAll_(); |
| 55 }, | 51 }, |
| 56 | 52 |
| 57 /** @param {string} searchTerm */ | 53 /** |
| 58 onSearchTermSearch: function(searchTerm) { | 54 * @param {!CustomEvent} event |
| 59 downloads.ActionService.getInstance().search(searchTerm); | 55 * @private |
| 56 */ |
| 57 onSearchChanged_: function(event) { |
| 58 downloads.ActionService.getInstance().search( |
| 59 /** @type {string} */ (event.detail)); |
| 60 this.updateClearAll_(); | 60 this.updateClearAll_(); |
| 61 }, | 61 }, |
| 62 | 62 |
| 63 /** @private */ | 63 /** @private */ |
| 64 onOpenDownloadsFolderTap_: function() { | 64 onOpenDownloadsFolderTap_: function() { |
| 65 downloads.ActionService.getInstance().openDownloadsFolder(); | 65 downloads.ActionService.getInstance().openDownloadsFolder(); |
| 66 }, | 66 }, |
| 67 | 67 |
| 68 /** @private */ | 68 /** @private */ |
| 69 updateClearAll_: function() { | 69 updateClearAll_: function() { |
| 70 this.$$('#actions .clear-all').hidden = !this.canClearAll(); | 70 this.$$('#actions .clear-all').hidden = !this.canClearAll(); |
| 71 this.$$('paper-menu .clear-all').hidden = !this.canClearAll(); | 71 this.$$('paper-menu .clear-all').hidden = !this.canClearAll(); |
| 72 }, | 72 }, |
| 73 }); | 73 }); |
| 74 | 74 |
| 75 /** | |
| 76 * @constructor | |
| 77 * @implements {SearchFieldDelegate} | |
| 78 */ | |
| 79 // TODO(devlin): This is a bit excessive, and it would be better to just have | |
| 80 // Toolbar implement SearchFieldDelegate. But for now, we don't know how to | |
| 81 // make that happen with closure compiler. | |
| 82 function ToolbarSearchFieldDelegate(toolbar) { | |
| 83 this.toolbar_ = toolbar; | |
| 84 } | |
| 85 | |
| 86 ToolbarSearchFieldDelegate.prototype = { | |
| 87 /** @override */ | |
| 88 onSearchTermSearch: function(searchTerm) { | |
| 89 this.toolbar_.onSearchTermSearch(searchTerm); | |
| 90 } | |
| 91 }; | |
| 92 | |
| 93 return {Toolbar: Toolbar}; | 75 return {Toolbar: Toolbar}; |
| 94 }); | 76 }); |
| 95 | 77 |
| 96 // TODO(dbeam): https://github.com/PolymerElements/iron-dropdown/pull/16/files | 78 // TODO(dbeam): https://github.com/PolymerElements/iron-dropdown/pull/16/files |
| 97 /** @suppress {checkTypes} */ | 79 /** @suppress {checkTypes} */ |
| 98 (function() { | 80 (function() { |
| 99 Polymer.IronDropdownScrollManager.pushScrollLock = function() {}; | 81 Polymer.IronDropdownScrollManager.pushScrollLock = function() {}; |
| 100 })(); | 82 })(); |
| OLD | NEW |