Update broken references to image assets
[chromium-blink-merge.git] / chrome / browser / resources / md_downloads / toolbar.js
blob86a22deb243b216f3e8dcd9e6fe14f025ef02633
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
3 // found in the LICENSE file.
5 cr.define('downloads', function() {
6   var Toolbar = Polymer({
7     is: 'downloads-toolbar',
9     /** @param {!downloads.ActionService} actionService */
10     setActionService: function(actionService) {
11       /** @private {!downloads.ActionService} */
12       this.actionService_ = actionService;
13     },
15     properties: {
16       downloadsShowing: {
17         type: Boolean,
18         value: false,
19         observer: 'onDownloadsShowingChange_',
20       },
22       showingSearch_: {
23         type: Boolean,
24         value: false,
25       },
26     },
28     /** @return {boolean} Whether removal can be undone. */
29     canUndo: function() {
30       return !this.$['search-term'].shadowRoot.activeElement;
31     },
33     /** @return {boolean} Whether "Clear all" should be allowed. */
34     canClearAll: function() {
35       return !this.$['search-input'].value && this.downloadsShowing;
36     },
38     /** @private */
39     onClearAllClick_: function() {
40       assert(this.canClearAll());
41       this.actionService_.clearAll();
42     },
44     /** @private */
45     onDownloadsShowingChange_: function() {
46       this.updateClearAll_();
47     },
49     /** @private */
50     onSearchTermSearch_: function() {
51       this.actionService_.search(this.$['search-input'].value);
52       this.updateClearAll_();
53     },
55     /** @private */
56     onSearchTermKeydown_: function(e) {
57       assert(this.showingSearch_);
58       if (e.keyIdentifier == 'U+001B')  // Escape.
59         this.toggleShowingSearch_();
60     },
62     /** @private */
63     onOpenDownloadsFolderClick_: function() {
64       this.actionService_.openDownloadsFolder();
65     },
67     /** @private */
68     toggleShowingSearch_: function() {
69       this.showingSearch_ = !this.showingSearch_;
71       if (this.showingSearch_) {
72         this.$['search-input'].focus();
73       } else {
74         this.$['search-input'].value = '';
75         this.onSearchTermSearch_();
76       }
77     },
79     /** @private */
80     updateClearAll_: function() {
81       this.$$('#actions .clear-all').hidden = !this.canClearAll();
82       this.$$('paper-menu .clear-all').hidden = !this.canClearAll();
83     },
84   });
86   return {Toolbar: Toolbar};
87 });
89 // TODO(dbeam): https://github.com/PolymerElements/iron-dropdown/pull/16/files
90 /** @suppress {checkTypes} */
91 (function() {
92 Polymer.IronDropdownScrollManager.pushScrollLock = function() {};
93 })();