| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 'settings-cups-printers-list' is a component for a list of | 6 * @fileoverview 'settings-cups-printers-list' is a component for a list of |
| 7 * CUPS printers. | 7 * CUPS printers. |
| 8 */ | 8 */ |
| 9 Polymer({ | 9 Polymer({ |
| 10 is: 'settings-cups-printers-list', | 10 is: 'settings-cups-printers-list', |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 created: function() { | 34 created: function() { |
| 35 this.browserProxy_ = settings.CupsPrintersBrowserProxyImpl.getInstance(); | 35 this.browserProxy_ = settings.CupsPrintersBrowserProxyImpl.getInstance(); |
| 36 }, | 36 }, |
| 37 | 37 |
| 38 /** | 38 /** |
| 39 * @param {!{model: !{item: !CupsPrinterInfo}}} e | 39 * @param {!{model: !{item: !CupsPrinterInfo}}} e |
| 40 * @private | 40 * @private |
| 41 */ | 41 */ |
| 42 onOpenActionMenuTap_: function(e) { | 42 onOpenActionMenuTap_: function(e) { |
| 43 this.activePrinter_ = e.model.item; | 43 this.activePrinter_ = e.model.item; |
| 44 var menu = /** @type {!SettingsActionMenuElement} */ ( | 44 var menu = /** @type {!CrActionMenuElement} */ ( |
| 45 this.$$('dialog[is=settings-action-menu]')); | 45 this.$$('dialog[is=cr-action-menu]')); |
| 46 menu.showAt(/** @type {!Element} */ ( | 46 menu.showAt(/** @type {!Element} */ ( |
| 47 Polymer.dom(/** @type {!Event} */ (e)).localTarget)); | 47 Polymer.dom(/** @type {!Event} */ (e)).localTarget)); |
| 48 }, | 48 }, |
| 49 | 49 |
| 50 /** | 50 /** |
| 51 * @param {{model:Object}} event | 51 * @param {{model:Object}} event |
| 52 * @private | 52 * @private |
| 53 */ | 53 */ |
| 54 onDetailsTap_: function(event) { | 54 onDetailsTap_: function(event) { |
| 55 // Event is caught by 'settings-printing-page'. | 55 // Event is caught by 'settings-printing-page'. |
| 56 this.fire('show-cups-printer-details', this.activePrinter_); | 56 this.fire('show-cups-printer-details', this.activePrinter_); |
| 57 this.closeDropdownMenu_(); | 57 this.closeDropdownMenu_(); |
| 58 }, | 58 }, |
| 59 | 59 |
| 60 /** | 60 /** |
| 61 * @param {{model:Object}} event | 61 * @param {{model:Object}} event |
| 62 * @private | 62 * @private |
| 63 */ | 63 */ |
| 64 onRemoveTap_: function(event) { | 64 onRemoveTap_: function(event) { |
| 65 var index = this.printers.indexOf(assert(this.activePrinter_)); | 65 var index = this.printers.indexOf(assert(this.activePrinter_)); |
| 66 this.splice('printers', index, 1); | 66 this.splice('printers', index, 1); |
| 67 this.browserProxy_.removeCupsPrinter(this.activePrinter_.printerId, | 67 this.browserProxy_.removeCupsPrinter(this.activePrinter_.printerId, |
| 68 this.activePrinter_.printerName); | 68 this.activePrinter_.printerName); |
| 69 this.closeDropdownMenu_(); | 69 this.closeDropdownMenu_(); |
| 70 }, | 70 }, |
| 71 | 71 |
| 72 /** @private */ | 72 /** @private */ |
| 73 closeDropdownMenu_: function() { | 73 closeDropdownMenu_: function() { |
| 74 this.activePrinter_ = null; | 74 this.activePrinter_ = null; |
| 75 var menu = /** @type {!SettingsActionMenuElement} */ ( | 75 var menu = /** @type {!CrActionMenuElement} */ ( |
| 76 this.$$('dialog[is=settings-action-menu]')); | 76 this.$$('dialog[is=cr-action-menu]')); |
| 77 menu.close(); | 77 menu.close(); |
| 78 }, | 78 }, |
| 79 | 79 |
| 80 /** | 80 /** |
| 81 * The filter callback function to show printers based on |searchTerm|. | 81 * The filter callback function to show printers based on |searchTerm|. |
| 82 * @param {string} searchTerm | 82 * @param {string} searchTerm |
| 83 * @private | 83 * @private |
| 84 */ | 84 */ |
| 85 filterPrinter_: function(searchTerm) { | 85 filterPrinter_: function(searchTerm) { |
| 86 if (!searchTerm) | 86 if (!searchTerm) |
| 87 return null; | 87 return null; |
| 88 return function(printer) { | 88 return function(printer) { |
| 89 return printer.printerName.toLowerCase().includes( | 89 return printer.printerName.toLowerCase().includes( |
| 90 searchTerm.toLowerCase()); | 90 searchTerm.toLowerCase()); |
| 91 }; | 91 }; |
| 92 }, | 92 }, |
| 93 }); | 93 }); |
| OLD | NEW |