OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 /** | 5 /** |
6 * @fileoverview Assertion support. | 6 * @fileoverview Assertion support. |
7 */ | 7 */ |
8 | 8 |
9 /** | 9 /** |
10 * Verify |condition| is truthy and return |condition| if so. | 10 * Verify |condition| is truthy and return |condition| if so. |
(...skipping 11359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11370 /** @return {boolean} Whether "Clear all" should be allowed. */ | 11370 /** @return {boolean} Whether "Clear all" should be allowed. */ |
11371 canClearAll: function() { | 11371 canClearAll: function() { |
11372 return !this.$['search-input'].getValue() && this.downloadsShowing; | 11372 return !this.$['search-input'].getValue() && this.downloadsShowing; |
11373 }, | 11373 }, |
11374 | 11374 |
11375 onFindCommand: function() { | 11375 onFindCommand: function() { |
11376 this.$['search-input'].showAndFocus(); | 11376 this.$['search-input'].showAndFocus(); |
11377 }, | 11377 }, |
11378 | 11378 |
11379 /** @private */ | 11379 /** @private */ |
11380 onClearAllTap_: function() { | 11380 closeMoreActions_: function(e) { |
11381 assert(this.canClearAll()); | 11381 this.$.more.close(); |
11382 downloads.ActionService.getInstance().clearAll(); | |
11383 }, | 11382 }, |
11384 | 11383 |
11385 /** @private */ | 11384 /** @private */ |
11386 downloadsShowingChanged_: function() { | 11385 downloadsShowingChanged_: function() { |
11387 this.updateClearAll_(); | 11386 this.updateClearAll_(); |
11388 }, | 11387 }, |
11389 | 11388 |
11390 /** @private */ | 11389 /** @private */ |
| 11390 onClearAllTap_: function() { |
| 11391 assert(this.canClearAll()); |
| 11392 downloads.ActionService.getInstance().clearAll(); |
| 11393 }, |
| 11394 |
| 11395 /** @private */ |
11391 onPaperDropdownClose_: function() { | 11396 onPaperDropdownClose_: function() { |
11392 window.removeEventListener('resize', assert(this.boundResize_)); | 11397 window.removeEventListener('resize', assert(this.boundClose_)); |
| 11398 }, |
| 11399 |
| 11400 /** |
| 11401 * @param {!Event} e |
| 11402 * @private |
| 11403 */ |
| 11404 onItemBlur_: function(e) { |
| 11405 if (this.$$('paper-menu').items.indexOf(e.relatedTarget) >= 0) |
| 11406 return; |
| 11407 |
| 11408 // This can be this.$.more.restoreFocusOnClose = false when this lands: |
| 11409 // https://github.com/PolymerElements/paper-menu-button/pull/94 |
| 11410 this.$.more.$.dropdown.restoreFocusOnClose = false; |
| 11411 this.closeMoreActions_(); |
| 11412 this.$.more.$.dropdown.restoreFocusOnClose = true; |
11393 }, | 11413 }, |
11394 | 11414 |
11395 /** @private */ | 11415 /** @private */ |
11396 onPaperDropdownOpen_: function() { | 11416 onPaperDropdownOpen_: function() { |
11397 this.boundResize_ = this.boundResize_ || function() { | 11417 this.boundClose_ = this.boundClose_ || this.closeMoreActions_.bind(this); |
11398 this.$.more.close(); | 11418 window.addEventListener('resize', this.boundClose_); |
11399 }.bind(this); | |
11400 window.addEventListener('resize', this.boundResize_); | |
11401 }, | 11419 }, |
11402 | 11420 |
11403 /** | 11421 /** |
11404 * @param {!CustomEvent} event | 11422 * @param {!CustomEvent} event |
11405 * @private | 11423 * @private |
11406 */ | 11424 */ |
11407 onSearchChanged_: function(event) { | 11425 onSearchChanged_: function(event) { |
11408 downloads.ActionService.getInstance().search( | 11426 downloads.ActionService.getInstance().search( |
11409 /** @type {string} */ (event.detail)); | 11427 /** @type {string} */ (event.detail)); |
11410 this.updateClearAll_(); | 11428 this.updateClearAll_(); |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11612 Manager.get().updateItem_(index, data); | 11630 Manager.get().updateItem_(index, data); |
11613 }; | 11631 }; |
11614 | 11632 |
11615 return {Manager: Manager}; | 11633 return {Manager: Manager}; |
11616 }); | 11634 }); |
11617 // Copyright 2015 The Chromium Authors. All rights reserved. | 11635 // Copyright 2015 The Chromium Authors. All rights reserved. |
11618 // Use of this source code is governed by a BSD-style license that can be | 11636 // Use of this source code is governed by a BSD-style license that can be |
11619 // found in the LICENSE file. | 11637 // found in the LICENSE file. |
11620 | 11638 |
11621 window.addEventListener('load', downloads.Manager.onLoad); | 11639 window.addEventListener('load', downloads.Manager.onLoad); |
OLD | NEW |