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 | 16 |
17 spinnerActive: { | 17 spinnerActive: { |
18 type: Boolean, | 18 type: Boolean, |
19 notify: true, | 19 notify: true, |
20 }, | 20 }, |
21 }, | 21 }, |
22 | 22 |
23 /** @return {boolean} Whether removal can be undone. */ | 23 /** @return {boolean} Whether removal can be undone. */ |
24 canUndo: function() { | 24 canUndo: function() { |
25 return !this.$.toolbar.getSearchField().isSearchFocused(); | 25 return !this.$.toolbar.getSearchField().isSearchFocused(); |
26 }, | 26 }, |
27 | 27 |
28 /** @return {boolean} Whether "Clear all" should be allowed. */ | 28 /** @return {boolean} Whether "Clear all" should be allowed. */ |
29 canClearAll: function() { | 29 canClearAll: function() { |
30 return !this.$.toolbar.getSearchField().getValue() && | 30 return this.getSearchText().length == 0 && this.downloadsShowing; |
31 this.downloadsShowing; | 31 }, |
| 32 |
| 33 /** @return {string} The full text being searched. */ |
| 34 getSearchText: function() { |
| 35 return this.$.toolbar.getSearchField().getValue(); |
32 }, | 36 }, |
33 | 37 |
34 onFindCommand: function() { | 38 onFindCommand: function() { |
35 this.$.toolbar.getSearchField().showAndFocus(); | 39 this.$.toolbar.getSearchField().showAndFocus(); |
36 }, | 40 }, |
37 | 41 |
38 /** @private */ | 42 /** @private */ |
39 downloadsShowingChanged_: function() { | 43 downloadsShowingChanged_: function() { |
40 this.updateClearAll_(); | 44 this.updateClearAll_(); |
41 }, | 45 }, |
(...skipping 28 matching lines...) Expand all Loading... |
70 }, | 74 }, |
71 | 75 |
72 /** @private */ | 76 /** @private */ |
73 updateClearAll_: function() { | 77 updateClearAll_: function() { |
74 this.$$('.clear-all').hidden = !this.canClearAll(); | 78 this.$$('.clear-all').hidden = !this.canClearAll(); |
75 }, | 79 }, |
76 }); | 80 }); |
77 | 81 |
78 return {Toolbar: Toolbar}; | 82 return {Toolbar: Toolbar}; |
79 }); | 83 }); |
OLD | NEW |