| Index: chrome/browser/resources/settings/printing_page/cups_add_printer_dialog_util.js
|
| diff --git a/chrome/browser/resources/settings/printing_page/cups_add_printer_dialog_util.js b/chrome/browser/resources/settings/printing_page/cups_add_printer_dialog_util.js
|
| index d27c65f58a8384b4ef2a1f0e96dc2630d86f095d..bb8a51898bf91f981d54e2f6462e2c9c34c856bb 100644
|
| --- a/chrome/browser/resources/settings/printing_page/cups_add_printer_dialog_util.js
|
| +++ b/chrome/browser/resources/settings/printing_page/cups_add_printer_dialog_util.js
|
| @@ -29,6 +29,78 @@ Polymer({
|
| },
|
| });
|
|
|
| +/** 'drop-down-search-box' implements a search box with suggestions dropdown. */
|
| +Polymer({
|
| + is: 'drop-down-search-box',
|
| +
|
| + properties: {
|
| + /** @type {!Array<string>} */
|
| + items: {
|
| + type: Array,
|
| + },
|
| +
|
| + /** @type {string} */
|
| + selectedItem: {
|
| + type: String,
|
| + notify: true,
|
| + },
|
| +
|
| + /** @private {string} */
|
| + searchTerm_: String,
|
| + },
|
| +
|
| + /** @private */
|
| + ready: function() {
|
| + this.$$('input').value = this.selectedItem;
|
| + },
|
| +
|
| + /**
|
| + * @param {Event} event
|
| + * @private
|
| + */
|
| + onTap_: function(event) {
|
| + this.$$('iron-dropdown').open();
|
| + this.$.searchIcon.hidden = false;
|
| + this.$.dropdownIcon.hidden = true;
|
| + // Prevent the closing of the dropdown menu.
|
| + event.stopPropagation();
|
| + },
|
| +
|
| + /** @private */
|
| + onInputValueChanged_: function() {
|
| + this.searchTerm_ = this.$$('input').value;
|
| + },
|
| +
|
| + /**
|
| + * @param {{model:Object}} event
|
| + * @private
|
| + */
|
| + onSelect_: function(event) {
|
| + this.$$('iron-dropdown').close();
|
| + this.$.searchIcon.hidden = true;
|
| + this.$.dropdownIcon.hidden = false;
|
| +
|
| + this.selectedItem = event.model.item;
|
| + this.searchTerm_ = '';
|
| + this.$$('input').value = this.selectedItem;
|
| + },
|
| +
|
| + /** @private */
|
| + onBlur_: function() {
|
| + this.$.searchIcon.hidden = true;
|
| + this.$.dropdownIcon.hidden = false;
|
| + },
|
| +
|
| + /** @private */
|
| + filterItems_: function(searchTerm) {
|
| + if (!searchTerm)
|
| + return null;
|
| + return function(item) {
|
| + return item.toLowerCase().includes(searchTerm.toLowerCase());
|
| + };
|
| + },
|
| +});
|
| +
|
| /** 'add-printer-dialog' is the template of the Add Printer dialog. */
|
| Polymer({
|
| is: 'add-printer-dialog',
|
|
|