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

Unified Diff: chrome/browser/resources/print_preview/settings/advanced_settings/advanced_settings_item.js

Issue 568973002: Print Preview Advanced settings tweaks: (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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/print_preview/settings/advanced_settings/advanced_settings_item.js
diff --git a/chrome/browser/resources/print_preview/settings/advanced_settings/advanced_settings_item.js b/chrome/browser/resources/print_preview/settings/advanced_settings/advanced_settings_item.js
index 0e3a5cf5bec7a89d2e8a502c35d63c88d20199c2..d632a0630a18be5e4e76f7d564aed2e6127a0b11 100644
--- a/chrome/browser/resources/print_preview/settings/advanced_settings/advanced_settings_item.js
+++ b/chrome/browser/resources/print_preview/settings/advanced_settings/advanced_settings_item.js
@@ -149,6 +149,16 @@ cr.define('print_preview', function() {
*/
onTextInput_: function() {
this.selectedValue_ = this.text_.value || null;
+
+ if (this.query_) {
+ var optionMatches = (this.selectedValue_ || '').match(this.query_);
+ // Even if there's no match anymore, keep the item visible to do not
+ // surprise user.
+ if (optionMatches)
+ this.showSearchBubble_(optionMatches[0]);
+ else
+ this.hideSearchBubble_();
+ }
},
/**
@@ -171,10 +181,8 @@ cr.define('print_preview', function() {
}
var matches = nameMatches || optionMatches;
- if ((!matches || !optionMatches) && this.searchBubble_) {
- this.searchBubble_.dispose();
- this.searchBubble_ = null;
- }
+ if (!matches || !optionMatches)
+ this.hideSearchBubble_();
setIsVisible(this.getElement(), matches);
if (!matches)
@@ -189,15 +197,34 @@ cr.define('print_preview', function() {
}
nameEl.title = textContent;
- if (optionMatches) {
- var element =
- this.capability_.type == 'SELECT' ? this.select_ : this.text_;
- if (!this.searchBubble_) {
- this.searchBubble_ = new print_preview.SearchBubble(optionMatches[0]);
- this.searchBubble_.attachTo(element);
- } else {
- this.searchBubble_.content = optionMatches[0];
- }
+ if (optionMatches)
+ this.showSearchBubble_(optionMatches[0]);
+ },
+
+ /**
+ * Shows search bubble for this element.
+ * @param {string} text Text to show in the search bubble.
+ * @private
+ */
+ showSearchBubble_: function(text) {
+ var element =
+ this.capability_.type == 'SELECT' ? this.select_ : this.text_;
+ if (!this.searchBubble_) {
+ this.searchBubble_ = new print_preview.SearchBubble(text);
+ this.searchBubble_.attachTo(element);
+ } else {
+ this.searchBubble_.content = text;
+ }
+ },
+
+ /**
+ * Hides search bubble associated with this element.
+ * @private
+ */
+ hideSearchBubble_: function() {
+ if (this.searchBubble_) {
+ this.searchBubble_.dispose();
+ this.searchBubble_ = null;
}
},

Powered by Google App Engine
This is Rietveld 408576698