Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Side by Side Diff: chrome/browser/resources/md_downloads/toolbar.js

Issue 2074483003: MD Downloads: hide ... (more options) menu on resize (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: michaelpg review Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 }, 12 },
13 13
14 properties: { 14 properties: {
15 downloadsShowing: { 15 downloadsShowing: {
16 reflectToAttribute: true, 16 reflectToAttribute: true,
17 type: Boolean, 17 type: Boolean,
18 value: false, 18 value: false,
19 observer: 'downloadsShowingChanged_', 19 observer: 'downloadsShowingChanged_',
20 }, 20 },
21 21
22 overflowAlign_: { 22 overflowAlign_: {
23 type: String, 23 type: String,
24 value: 'right', 24 value: 'right',
25 }, 25 },
26 }, 26 },
27 27
28 listeners: {
29 'paper-dropdown-close': 'onPaperDropdownClose_',
30 'paper-dropdown-open': 'onPaperDropdownOpen_',
31 },
32
28 /** @return {boolean} Whether removal can be undone. */ 33 /** @return {boolean} Whether removal can be undone. */
29 canUndo: function() { 34 canUndo: function() {
30 return this.$['search-input'] != this.shadowRoot.activeElement; 35 return this.$['search-input'] != this.shadowRoot.activeElement;
31 }, 36 },
32 37
33 /** @return {boolean} Whether "Clear all" should be allowed. */ 38 /** @return {boolean} Whether "Clear all" should be allowed. */
34 canClearAll: function() { 39 canClearAll: function() {
35 return !this.$['search-input'].getValue() && this.downloadsShowing; 40 return !this.$['search-input'].getValue() && this.downloadsShowing;
36 }, 41 },
37 42
38 onFindCommand: function() { 43 onFindCommand: function() {
39 this.$['search-input'].showAndFocus(); 44 this.$['search-input'].showAndFocus();
40 }, 45 },
41 46
42 /** @private */ 47 /** @private */
43 onClearAllTap_: function() { 48 onClearAllTap_: function() {
44 assert(this.canClearAll()); 49 assert(this.canClearAll());
45 downloads.ActionService.getInstance().clearAll(); 50 downloads.ActionService.getInstance().clearAll();
46 }, 51 },
47 52
48 /** @private */ 53 /** @private */
49 downloadsShowingChanged_: function() { 54 downloadsShowingChanged_: function() {
50 this.updateClearAll_(); 55 this.updateClearAll_();
51 }, 56 },
52 57
58 /** @private */
59 onPaperDropdownClose_: function() {
60 window.removeEventListener('resize', assert(this.boundResize_));
61 },
62
63 /** @private */
64 onPaperDropdownOpen_: function() {
65 this.boundResize_ = this.boundResize_ || function() {
66 this.$.more.close();
67 }.bind(this);
68 window.addEventListener('resize', this.boundResize_);
69 },
70
53 /** 71 /**
54 * @param {!CustomEvent} event 72 * @param {!CustomEvent} event
55 * @private 73 * @private
56 */ 74 */
57 onSearchChanged_: function(event) { 75 onSearchChanged_: function(event) {
58 downloads.ActionService.getInstance().search( 76 downloads.ActionService.getInstance().search(
59 /** @type {string} */ (event.detail)); 77 /** @type {string} */ (event.detail));
60 this.updateClearAll_(); 78 this.updateClearAll_();
61 }, 79 },
62 80
(...skipping 10 matching lines...) Expand all
73 }); 91 });
74 92
75 return {Toolbar: Toolbar}; 93 return {Toolbar: Toolbar};
76 }); 94 });
77 95
78 // TODO(dbeam): https://github.com/PolymerElements/iron-dropdown/pull/16/files 96 // TODO(dbeam): https://github.com/PolymerElements/iron-dropdown/pull/16/files
79 /** @suppress {checkTypes} */ 97 /** @suppress {checkTypes} */
80 (function() { 98 (function() {
81 Polymer.IronDropdownScrollManager.pushScrollLock = function() {}; 99 Polymer.IronDropdownScrollManager.pushScrollLock = function() {};
82 })(); 100 })();
OLDNEW
« no previous file with comments | « chrome/browser/resources/md_downloads/crisper.js ('k') | chrome/browser/resources/md_downloads/vulcanized.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698