| 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 /** @param {!downloads.ActionService} actionService */ | 9 /** @param {!downloads.ActionService} actionService */ |
| 10 setActionService: function(actionService) { | 10 setActionService: function(actionService) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 }, | 25 }, |
| 26 }, | 26 }, |
| 27 | 27 |
| 28 /** @return {boolean} Whether removal can be undone. */ | 28 /** @return {boolean} Whether removal can be undone. */ |
| 29 canUndo: function() { | 29 canUndo: function() { |
| 30 return !this.$['search-term'].shadowRoot.activeElement; | 30 return !this.$['search-term'].shadowRoot.activeElement; |
| 31 }, | 31 }, |
| 32 | 32 |
| 33 /** @return {boolean} Whether "Clear all" should be allowed. */ | 33 /** @return {boolean} Whether "Clear all" should be allowed. */ |
| 34 canClearAll: function() { | 34 canClearAll: function() { |
| 35 return !this.$['search-term'].value && this.downloadsShowing; | 35 return !this.$['search-input'].value && this.downloadsShowing; |
| 36 }, | |
| 37 | |
| 38 ready: function() { | |
| 39 var term = this.$['search-term']; | |
| 40 term.addEventListener('input', this.onSearchTermInput_.bind(this)); | |
| 41 term.addEventListener('keydown', this.onSearchTermKeydown_.bind(this)); | |
| 42 }, | 36 }, |
| 43 | 37 |
| 44 /** @private */ | 38 /** @private */ |
| 45 onClearAllClick_: function() { | 39 onClearAllClick_: function() { |
| 46 assert(this.canClearAll()); | 40 assert(this.canClearAll()); |
| 47 this.actionService_.clearAll(); | 41 this.actionService_.clearAll(); |
| 48 }, | 42 }, |
| 49 | 43 |
| 50 /** @private */ | 44 /** @private */ |
| 51 onDownloadsShowingChange_: function() { | 45 onDownloadsShowingChange_: function() { |
| 52 this.updateClearAll_(); | 46 this.updateClearAll_(); |
| 53 }, | 47 }, |
| 54 | 48 |
| 55 /** @private */ | 49 /** @private */ |
| 56 onSearchTermInput_: function() { | 50 onSearchTermSearch_: function() { |
| 57 this.actionService_.search(this.$['search-term'].value); | 51 this.actionService_.search(this.$['search-input'].value); |
| 58 this.updateClearAll_(); | 52 this.updateClearAll_(); |
| 59 }, | 53 }, |
| 60 | 54 |
| 61 /** @private */ | 55 /** @private */ |
| 62 onSearchTermKeydown_: function(e) { | 56 onSearchTermKeydown_: function(e) { |
| 63 assert(this.showingSearch_); | 57 assert(this.showingSearch_); |
| 64 if (e.keyIdentifier == 'U+001B') // Escape. | 58 if (e.keyIdentifier == 'U+001B') // Escape. |
| 65 this.toggleShowingSearch_(); | 59 this.toggleShowingSearch_(); |
| 66 }, | 60 }, |
| 67 | 61 |
| 68 /** @private */ | 62 /** @private */ |
| 69 onOpenDownloadsFolderClick_: function() { | 63 onOpenDownloadsFolderClick_: function() { |
| 70 this.actionService_.openDownloadsFolder(); | 64 this.actionService_.openDownloadsFolder(); |
| 71 }, | 65 }, |
| 72 | 66 |
| 73 /** @private */ | 67 /** @private */ |
| 74 toggleShowingSearch_: function() { | 68 toggleShowingSearch_: function() { |
| 75 this.showingSearch_ = !this.showingSearch_; | 69 this.showingSearch_ = !this.showingSearch_; |
| 76 | 70 |
| 77 if (this.showingSearch_) { | 71 if (this.showingSearch_) { |
| 78 this.$['search-term'].focus(); | 72 this.$['search-input'].focus(); |
| 79 } else { | 73 } else { |
| 80 this.$['search-term'].value = ''; | 74 this.$['search-input'].value = ''; |
| 81 this.onSearchTermInput_(); | 75 this.onSearchTermSearch_(); |
| 82 } | 76 } |
| 83 }, | 77 }, |
| 84 | 78 |
| 85 /** @private */ | 79 /** @private */ |
| 86 updateClearAll_: function() { | 80 updateClearAll_: function() { |
| 87 this.$$('#actions .clear-all').hidden = !this.canClearAll(); | 81 this.$$('#actions .clear-all').hidden = !this.canClearAll(); |
| 88 this.$$('paper-menu .clear-all').hidden = !this.canClearAll(); | 82 this.$$('paper-menu .clear-all').hidden = !this.canClearAll(); |
| 89 }, | 83 }, |
| 90 }); | 84 }); |
| 91 | 85 |
| 92 return {Toolbar: Toolbar}; | 86 return {Toolbar: Toolbar}; |
| 93 }); | 87 }); |
| 94 | 88 |
| 95 // TODO(dbeam): https://github.com/PolymerElements/iron-dropdown/pull/16/files | 89 // TODO(dbeam): https://github.com/PolymerElements/iron-dropdown/pull/16/files |
| 96 /** @suppress {checkTypes} */ | 90 /** @suppress {checkTypes} */ |
| 97 (function() { | 91 (function() { |
| 98 Polymer.IronDropdownScrollManager.pushScrollLock = function() {}; | 92 Polymer.IronDropdownScrollManager.pushScrollLock = function() {}; |
| 99 })(); | 93 })(); |
| OLD | NEW |