| 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 /** 'add-printers-list' is the list of discovered printers. */ | 5 /** 'add-printers-list' is the list of discovered printers. */ |
| 6 Polymer({ | 6 Polymer({ |
| 7 is: 'add-printer-list', | 7 is: 'add-printer-list', |
| 8 | 8 |
| 9 properties: { | 9 properties: { |
| 10 /** @type {!Array<!CupsPrinterInfo>} */ | 10 /** @type {!Array<!CupsPrinterInfo>} */ |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 /** | 23 /** |
| 24 * @param {{model:Object}} event | 24 * @param {{model:Object}} event |
| 25 * @private | 25 * @private |
| 26 */ | 26 */ |
| 27 onSelect_: function(event) { | 27 onSelect_: function(event) { |
| 28 this.selectedPrinter = event.model.item; | 28 this.selectedPrinter = event.model.item; |
| 29 }, | 29 }, |
| 30 }); | 30 }); |
| 31 | 31 |
| 32 /** 'drop-down-search-box' implements a search box with suggestions dropdown. */ |
| 33 Polymer({ |
| 34 is: 'drop-down-search-box', |
| 35 |
| 36 properties: { |
| 37 /** @type {!Array<string>} */ |
| 38 items: { |
| 39 type: Array, |
| 40 }, |
| 41 |
| 42 /** @type {string} */ |
| 43 selectedItem: { |
| 44 type: String, |
| 45 notify: true, |
| 46 }, |
| 47 |
| 48 /** @private {string} */ |
| 49 searchTerm_: String, |
| 50 }, |
| 51 |
| 52 /** @private */ |
| 53 ready: function() { |
| 54 this.$$('input').value = this.selectedItem; |
| 55 }, |
| 56 |
| 57 /** |
| 58 * @param {Event} event |
| 59 * @private |
| 60 */ |
| 61 onTap_: function(event) { |
| 62 this.$$('iron-dropdown').open(); |
| 63 this.$.searchIcon.hidden = false; |
| 64 this.$.dropdownIcon.hidden = true; |
| 65 // Prevent the closing of the dropdown menu. |
| 66 event.stopPropagation(); |
| 67 }, |
| 68 |
| 69 /** @private */ |
| 70 onInputValueChanged_: function() { |
| 71 this.searchTerm_ = this.$$('input').value; |
| 72 }, |
| 73 |
| 74 /** |
| 75 * @param {{model:Object}} event |
| 76 * @private |
| 77 */ |
| 78 onSelect_: function(event) { |
| 79 this.$$('iron-dropdown').close(); |
| 80 this.$.searchIcon.hidden = true; |
| 81 this.$.dropdownIcon.hidden = false; |
| 82 |
| 83 this.selectedItem = event.model.item; |
| 84 this.searchTerm_ = ''; |
| 85 this.$$('input').value = this.selectedItem; |
| 86 }, |
| 87 |
| 88 /** @private */ |
| 89 onBlur_: function() { |
| 90 this.$.searchIcon.hidden = true; |
| 91 this.$.dropdownIcon.hidden = false; |
| 92 }, |
| 93 |
| 94 /** @private */ |
| 95 filterItems_: function(searchTerm) { |
| 96 if (!searchTerm) |
| 97 return null; |
| 98 return function(item) { |
| 99 return item.toLowerCase().includes(searchTerm.toLowerCase()); |
| 100 }; |
| 101 }, |
| 102 }); |
| 103 |
| 32 /** 'add-printer-dialog' is the template of the Add Printer dialog. */ | 104 /** 'add-printer-dialog' is the template of the Add Printer dialog. */ |
| 33 Polymer({ | 105 Polymer({ |
| 34 is: 'add-printer-dialog', | 106 is: 'add-printer-dialog', |
| 35 | 107 |
| 36 /** @private */ | 108 /** @private */ |
| 37 attached: function() { | 109 attached: function() { |
| 38 this.$.dialog.showModal(); | 110 this.$.dialog.showModal(); |
| 39 }, | 111 }, |
| 40 | 112 |
| 41 close: function() { | 113 close: function() { |
| 42 this.$.dialog.close(); | 114 this.$.dialog.close(); |
| 43 }, | 115 }, |
| 44 }); | 116 }); |
| OLD | NEW |