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

Unified Diff: ui/webui/resources/cr_elements/cr_search_field/cr_search_field_behavior.js

Issue 2449663002: MD Settings: Implement search URLs. (Closed)
Patch Set: Rebase Created 4 years, 2 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: ui/webui/resources/cr_elements/cr_search_field/cr_search_field_behavior.js
diff --git a/ui/webui/resources/cr_elements/cr_search_field/cr_search_field_behavior.js b/ui/webui/resources/cr_elements/cr_search_field/cr_search_field_behavior.js
index a5bcce9f121355e9aef608f6519e87b5988f82f6..1ee9de85c30c95cd4f13d6f0a46d9ea56f21197c 100644
--- a/ui/webui/resources/cr_elements/cr_search_field/cr_search_field_behavior.js
+++ b/ui/webui/resources/cr_elements/cr_search_field/cr_search_field_behavior.js
@@ -51,12 +51,14 @@ var CrSearchFieldBehavior = {
/**
* Sets the value of the search field.
* @param {string} value
+ * @param {boolean=} opt_noEvent Whether to prevent a 'search-changed' event
+ * firing for this change.
*/
- setValue: function(value) {
+ setValue: function(value, opt_noEvent) {
// Use bindValue when setting the input value so that changes propagate
// correctly.
this.getSearchInput().bindValue = value;
- this.onValueChanged_(value);
+ this.onValueChanged_(value, opt_noEvent || false);
},
showAndFocus: function() {
@@ -70,21 +72,25 @@ var CrSearchFieldBehavior = {
},
onSearchTermSearch: function() {
- this.onValueChanged_(this.getValue());
+ this.onValueChanged_(this.getValue(), false);
},
/**
* Updates the internal state of the search field based on a change that has
* already happened.
* @param {string} newValue
+ * @param {boolean} noEvent Whether to prevent a 'search-changed' event firing
+ * for this change.
* @private
*/
- onValueChanged_: function(newValue) {
+ onValueChanged_: function(newValue, noEvent) {
if (newValue == this.lastValue_)
return;
this.lastValue_ = newValue;
- this.fire('search-changed', newValue);
+
+ if (!noEvent)
+ this.fire('search-changed', newValue);
},
onSearchTermKeydown: function(e) {

Powered by Google App Engine
This is Rietveld 408576698