Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5395)

Unified Diff: chrome/browser/resources/settings/printing_page/cups_add_printer_dialog_util.js

Issue 2304673002: [CUPS] Implelment Manufacturer and Model Dialog. (Closed)
Patch Set: Address michaelpg@'s comment. Rebase. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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',

Powered by Google App Engine
This is Rietveld 408576698