| 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 properties: { | 9 properties: { |
| 10 downloadsShowing: { | 10 downloadsShowing: { |
| 11 reflectToAttribute: true, | 11 reflectToAttribute: true, |
| 12 type: Boolean, | 12 type: Boolean, |
| 13 value: false, | 13 value: false, |
| 14 observer: 'downloadsShowingChanged_', | 14 observer: 'downloadsShowingChanged_', |
| 15 }, | 15 }, |
| 16 |
| 17 spinnerActive: { |
| 18 type: Boolean, |
| 19 notify: true, |
| 20 }, |
| 16 }, | 21 }, |
| 17 | 22 |
| 18 listeners: { | 23 listeners: { |
| 19 'paper-dropdown-close': 'onPaperDropdownClose_', | 24 'paper-dropdown-close': 'onPaperDropdownClose_', |
| 20 'paper-dropdown-open': 'onPaperDropdownOpen_', | 25 'paper-dropdown-open': 'onPaperDropdownOpen_', |
| 21 }, | 26 }, |
| 22 | 27 |
| 23 /** @return {boolean} Whether removal can be undone. */ | 28 /** @return {boolean} Whether removal can be undone. */ |
| 24 canUndo: function() { | 29 canUndo: function() { |
| 25 return this.$['search-input'] != this.shadowRoot.activeElement; | 30 return !this.$.toolbar.getSearchField().isSearchFocused(); |
| 26 }, | 31 }, |
| 27 | 32 |
| 28 /** @return {boolean} Whether "Clear all" should be allowed. */ | 33 /** @return {boolean} Whether "Clear all" should be allowed. */ |
| 29 canClearAll: function() { | 34 canClearAll: function() { |
| 30 return !this.$['search-input'].getValue() && this.downloadsShowing; | 35 return !this.$.toolbar.getSearchField().getValue() && |
| 36 this.downloadsShowing; |
| 31 }, | 37 }, |
| 32 | 38 |
| 33 onFindCommand: function() { | 39 onFindCommand: function() { |
| 34 this.$['search-input'].showAndFocus(); | 40 this.$.toolbar.getSearchField().showAndFocus(); |
| 35 }, | 41 }, |
| 36 | 42 |
| 37 /** @private */ | 43 /** @private */ |
| 38 closeMoreActions_: function() { | 44 closeMoreActions_: function() { |
| 39 this.$.more.close(); | 45 this.$.more.close(); |
| 40 }, | 46 }, |
| 41 | 47 |
| 42 /** @private */ | 48 /** @private */ |
| 43 downloadsShowingChanged_: function() { | 49 downloadsShowingChanged_: function() { |
| 44 this.updateClearAll_(); | 50 this.updateClearAll_(); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 73 onPaperDropdownOpen_: function() { | 79 onPaperDropdownOpen_: function() { |
| 74 this.boundClose_ = this.boundClose_ || this.closeMoreActions_.bind(this); | 80 this.boundClose_ = this.boundClose_ || this.closeMoreActions_.bind(this); |
| 75 window.addEventListener('resize', this.boundClose_); | 81 window.addEventListener('resize', this.boundClose_); |
| 76 }, | 82 }, |
| 77 | 83 |
| 78 /** | 84 /** |
| 79 * @param {!CustomEvent} event | 85 * @param {!CustomEvent} event |
| 80 * @private | 86 * @private |
| 81 */ | 87 */ |
| 82 onSearchChanged_: function(event) { | 88 onSearchChanged_: function(event) { |
| 83 downloads.ActionService.getInstance().search( | 89 var actionService = downloads.ActionService.getInstance(); |
| 84 /** @type {string} */ (event.detail)); | 90 actionService.search(/** @type {string} */ (event.detail)); |
| 91 this.spinnerActive = actionService.isSearching(); |
| 85 this.updateClearAll_(); | 92 this.updateClearAll_(); |
| 86 }, | 93 }, |
| 87 | 94 |
| 88 /** @private */ | 95 /** @private */ |
| 89 onOpenDownloadsFolderTap_: function() { | 96 onOpenDownloadsFolderTap_: function() { |
| 90 downloads.ActionService.getInstance().openDownloadsFolder(); | 97 downloads.ActionService.getInstance().openDownloadsFolder(); |
| 91 }, | 98 }, |
| 92 | 99 |
| 93 /** @private */ | 100 /** @private */ |
| 94 updateClearAll_: function() { | 101 updateClearAll_: function() { |
| 95 this.$$('#actions .clear-all').hidden = !this.canClearAll(); | |
| 96 this.$$('paper-menu .clear-all').hidden = !this.canClearAll(); | 102 this.$$('paper-menu .clear-all').hidden = !this.canClearAll(); |
| 97 }, | 103 }, |
| 98 }); | 104 }); |
| 99 | 105 |
| 100 return {Toolbar: Toolbar}; | 106 return {Toolbar: Toolbar}; |
| 101 }); | 107 }); |
| OLD | NEW |