| 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 4123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4134 | 4134 |
| 4135 /** @this {ActionLink} */ | 4135 /** @this {ActionLink} */ |
| 4136 createdCallback: function() { | 4136 createdCallback: function() { |
| 4137 // Action links can start disabled (e.g. <a is="action-link" disabled>). | 4137 // Action links can start disabled (e.g. <a is="action-link" disabled>). |
| 4138 this.tabIndex = this.disabled ? -1 : 0; | 4138 this.tabIndex = this.disabled ? -1 : 0; |
| 4139 | 4139 |
| 4140 if (!this.hasAttribute('role')) | 4140 if (!this.hasAttribute('role')) |
| 4141 this.setAttribute('role', 'link'); | 4141 this.setAttribute('role', 'link'); |
| 4142 | 4142 |
| 4143 this.addEventListener('keydown', function(e) { | 4143 this.addEventListener('keydown', function(e) { |
| 4144 if (!this.disabled && e.key == 'Enter' && !this.href) { | 4144 if (!this.disabled && e.keyIdentifier == 'Enter' && !this.href) { |
| 4145 // Schedule a click asynchronously because other 'keydown' handlers | 4145 // Schedule a click asynchronously because other 'keydown' handlers |
| 4146 // may still run later (e.g. document.addEventListener('keydown')). | 4146 // may still run later (e.g. document.addEventListener('keydown')). |
| 4147 // Specifically options dialogs break when this timeout isn't here. | 4147 // Specifically options dialogs break when this timeout isn't here. |
| 4148 // NOTE: this affects the "trusted" state of the ensuing click. I | 4148 // NOTE: this affects the "trusted" state of the ensuing click. I |
| 4149 // haven't found anything that breaks because of this (yet). | 4149 // haven't found anything that breaks because of this (yet). |
| 4150 window.setTimeout(this.click.bind(this), 0); | 4150 window.setTimeout(this.click.bind(this), 0); |
| 4151 } | 4151 } |
| 4152 }); | 4152 }); |
| 4153 | 4153 |
| 4154 function preventDefault(e) { | 4154 function preventDefault(e) { |
| (...skipping 7065 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11220 value: false, | 11220 value: false, |
| 11221 observer: 'downloadsShowingChanged_', | 11221 observer: 'downloadsShowingChanged_', |
| 11222 }, | 11222 }, |
| 11223 | 11223 |
| 11224 overflowAlign_: { | 11224 overflowAlign_: { |
| 11225 type: String, | 11225 type: String, |
| 11226 value: 'right', | 11226 value: 'right', |
| 11227 }, | 11227 }, |
| 11228 }, | 11228 }, |
| 11229 | 11229 |
| 11230 listeners: { |
| 11231 'paper-dropdown-close': 'onPaperDropdownClose_', |
| 11232 'paper-dropdown-open': 'onPaperDropdownOpen_', |
| 11233 }, |
| 11234 |
| 11230 /** @return {boolean} Whether removal can be undone. */ | 11235 /** @return {boolean} Whether removal can be undone. */ |
| 11231 canUndo: function() { | 11236 canUndo: function() { |
| 11232 return this.$['search-input'] != this.shadowRoot.activeElement; | 11237 return this.$['search-input'] != this.shadowRoot.activeElement; |
| 11233 }, | 11238 }, |
| 11234 | 11239 |
| 11235 /** @return {boolean} Whether "Clear all" should be allowed. */ | 11240 /** @return {boolean} Whether "Clear all" should be allowed. */ |
| 11236 canClearAll: function() { | 11241 canClearAll: function() { |
| 11237 return !this.$['search-input'].getValue() && this.downloadsShowing; | 11242 return !this.$['search-input'].getValue() && this.downloadsShowing; |
| 11238 }, | 11243 }, |
| 11239 | 11244 |
| 11240 onFindCommand: function() { | 11245 onFindCommand: function() { |
| 11241 this.$['search-input'].showAndFocus(); | 11246 this.$['search-input'].showAndFocus(); |
| 11242 }, | 11247 }, |
| 11243 | 11248 |
| 11244 /** @private */ | 11249 /** @private */ |
| 11245 onClearAllTap_: function() { | 11250 onClearAllTap_: function() { |
| 11246 assert(this.canClearAll()); | 11251 assert(this.canClearAll()); |
| 11247 downloads.ActionService.getInstance().clearAll(); | 11252 downloads.ActionService.getInstance().clearAll(); |
| 11248 }, | 11253 }, |
| 11249 | 11254 |
| 11250 /** @private */ | 11255 /** @private */ |
| 11251 downloadsShowingChanged_: function() { | 11256 downloadsShowingChanged_: function() { |
| 11252 this.updateClearAll_(); | 11257 this.updateClearAll_(); |
| 11253 }, | 11258 }, |
| 11254 | 11259 |
| 11260 /** @private */ |
| 11261 onPaperDropdownClose_: function() { |
| 11262 window.removeEventListener('resize', assert(this.boundResize_)); |
| 11263 }, |
| 11264 |
| 11265 /** @private */ |
| 11266 onPaperDropdownOpen_: function() { |
| 11267 this.boundResize_ = this.boundResize_ || function() { |
| 11268 this.$.more.close(); |
| 11269 }.bind(this); |
| 11270 window.addEventListener('resize', this.boundResize_); |
| 11271 }, |
| 11272 |
| 11255 /** | 11273 /** |
| 11256 * @param {!CustomEvent} event | 11274 * @param {!CustomEvent} event |
| 11257 * @private | 11275 * @private |
| 11258 */ | 11276 */ |
| 11259 onSearchChanged_: function(event) { | 11277 onSearchChanged_: function(event) { |
| 11260 downloads.ActionService.getInstance().search(event.detail); | 11278 downloads.ActionService.getInstance().search( |
| 11279 /** @type {string} */ (event.detail)); |
| 11261 this.updateClearAll_(); | 11280 this.updateClearAll_(); |
| 11262 }, | 11281 }, |
| 11263 | 11282 |
| 11264 /** @private */ | 11283 /** @private */ |
| 11265 onOpenDownloadsFolderTap_: function() { | 11284 onOpenDownloadsFolderTap_: function() { |
| 11266 downloads.ActionService.getInstance().openDownloadsFolder(); | 11285 downloads.ActionService.getInstance().openDownloadsFolder(); |
| 11267 }, | 11286 }, |
| 11268 | 11287 |
| 11269 /** @private */ | 11288 /** @private */ |
| 11270 updateClearAll_: function() { | 11289 updateClearAll_: function() { |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11462 Manager.updateItem = function(index, data) { | 11481 Manager.updateItem = function(index, data) { |
| 11463 Manager.get().updateItem_(index, data); | 11482 Manager.get().updateItem_(index, data); |
| 11464 }; | 11483 }; |
| 11465 | 11484 |
| 11466 return {Manager: Manager}; | 11485 return {Manager: Manager}; |
| 11467 }); | 11486 }); |
| 11468 // Copyright 2015 The Chromium Authors. All rights reserved. | 11487 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 11469 // Use of this source code is governed by a BSD-style license that can be | 11488 // Use of this source code is governed by a BSD-style license that can be |
| 11470 // found in the LICENSE file. | 11489 // found in the LICENSE file. |
| 11471 | 11490 |
| 11472 window.addEventListener('load', downloads.Manager.onLoad); | 11491 window.addEventListener('load', downloads.Manager.onLoad); |
| OLD | NEW |