Chromium Code Reviews| Index: Source/devtools/front_end/FilterBar.js |
| diff --git a/Source/devtools/front_end/FilterBar.js b/Source/devtools/front_end/FilterBar.js |
| index b7cc8425fef7c1991d77aebc5f62a731c669d04e..fb660ec6520c55c20a99ad055573a85129fcb61d 100644 |
| --- a/Source/devtools/front_end/FilterBar.js |
| +++ b/Source/devtools/front_end/FilterBar.js |
| @@ -159,9 +159,13 @@ WebInspector.FilterUI.prototype = { |
| * @constructor |
| * @implements {WebInspector.FilterUI} |
| * @extends {WebInspector.Object} |
| + * @param {boolean=} supportRegex |
| */ |
| -WebInspector.TextFilterUI = function() |
| +WebInspector.TextFilterUI = function(supportRegex) |
| { |
| + this._supportRegex = !!supportRegex; |
| + this._regex = null; |
| + |
| this._filterElement = document.createElement("div"); |
| this._filterElement.className = "filter-text-filter"; |
| @@ -171,6 +175,17 @@ WebInspector.TextFilterUI = function() |
| this._filterInputElement.addEventListener("mousedown", this._onFilterFieldManualFocus.bind(this), false); // when the search field is manually selected |
| this._filterInputElement.addEventListener("input", this._onInput.bind(this), false); |
| this._filterInputElement.addEventListener("change", this._onInput.bind(this), false); |
| + |
| + if (this._supportRegex) { |
| + this._regexCheckBox = this._filterElement.createChild("input"); |
| + this._regexCheckBox.type = "checkbox"; |
| + this._regexCheckBox.id = "text-filter-regex"; |
| + this._regexCheckBox.addEventListener("change", this._onInput.bind(this), false); |
| + |
| + this._regexLabel = this._filterElement.createChild("label"); |
| + this._regexLabel.htmlFor = "text-filter-regex"; |
| + this._regexLabel.textContent = WebInspector.UIString("Regex"); |
| + } |
| } |
| WebInspector.TextFilterUI.prototype = { |
| @@ -212,10 +227,6 @@ WebInspector.TextFilterUI.prototype = { |
| */ |
| regex: function() |
| { |
| - if (this._regex !== undefined) |
| - return this._regex; |
| - var filterQuery = this.value(); |
| - this._regex = filterQuery ? createPlainTextSearchRegex(filterQuery, "i") : null; |
| return this._regex; |
| }, |
| @@ -236,7 +247,22 @@ WebInspector.TextFilterUI.prototype = { |
| }, |
| _valueChanged: function() { |
| - delete this._regex; |
| + var filterQuery = this.value(); |
| + |
| + this._regex = null |
| + this._filterInputElement.classList.remove("filter-text-invalid"); |
| + if (filterQuery) { |
|
vsevik
2013/11/28 10:29:10
nit:
if (!filterQuery)
return;
Dmitry Zvorygin
2013/11/28 13:48:33
not return but dispatchEventToListeners, so let's
|
| + if (this._supportRegex && this._regexCheckBox.checked) { |
| + try { |
| + this._regex = new RegExp(filterQuery, "i"); |
| + } catch (e) { |
| + this._filterInputElement.classList.add("filter-text-invalid"); |
| + } |
| + } else { |
| + this._regex = createPlainTextSearchRegex(filterQuery, "i"); |
| + } |
| + } |
| + |
| this.dispatchEventToListeners(WebInspector.FilterUI.Events.FilterChanged, null); |
| }, |