OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
152 /** | 152 /** |
153 * @return {Element} | 153 * @return {Element} |
154 */ | 154 */ |
155 element: function() { } | 155 element: function() { } |
156 } | 156 } |
157 | 157 |
158 /** | 158 /** |
159 * @constructor | 159 * @constructor |
160 * @implements {WebInspector.FilterUI} | 160 * @implements {WebInspector.FilterUI} |
161 * @extends {WebInspector.Object} | 161 * @extends {WebInspector.Object} |
162 * @param {boolean=} supportRegex | |
162 */ | 163 */ |
163 WebInspector.TextFilterUI = function() | 164 WebInspector.TextFilterUI = function(supportRegex) |
164 { | 165 { |
166 this._supportRegex = !!supportRegex; | |
167 | |
165 this._filterElement = document.createElement("div"); | 168 this._filterElement = document.createElement("div"); |
166 this._filterElement.className = "filter-text-filter"; | 169 this._filterElement.className = "filter-text-filter"; |
167 | 170 |
168 this._filterInputElement = this._filterElement.createChild("input", "search- replace toolbar-replace-control"); | 171 this._filterInputElement = this._filterElement.createChild("input", "search- replace toolbar-replace-control"); |
169 this._filterInputElement.placeholder = WebInspector.UIString("Filter"); | 172 this._filterInputElement.placeholder = WebInspector.UIString("Filter"); |
170 this._filterInputElement.id = "filter-input-field"; | 173 this._filterInputElement.id = "filter-input-field"; |
171 this._filterInputElement.addEventListener("mousedown", this._onFilterFieldMa nualFocus.bind(this), false); // when the search field is manually selected | 174 this._filterInputElement.addEventListener("mousedown", this._onFilterFieldMa nualFocus.bind(this), false); // when the search field is manually selected |
172 this._filterInputElement.addEventListener("input", this._onInput.bind(this), false); | 175 this._filterInputElement.addEventListener("input", this._onInput.bind(this), false); |
173 this._filterInputElement.addEventListener("change", this._onInput.bind(this) , false); | 176 this._filterInputElement.addEventListener("change", this._onInput.bind(this) , false); |
177 | |
178 if (this._supportRegex) { | |
179 this._regexCheckBox = this._filterElement.createChild("input"); | |
180 this._regexCheckBox.type = "checkbox"; | |
181 this._regexCheckBox.id = "text-filter-regex"; | |
182 this._regexCheckBox.addEventListener("change", this._onInput.bind(this), f alse); | |
183 | |
184 this._regexLabel = this._filterElement.createChild("label"); | |
185 this._regexLabel.htmlFor = "text-filter-regex"; | |
186 this._regexLabel.textContent = WebInspector.UIString("Regex"); | |
187 } | |
174 } | 188 } |
175 | 189 |
176 WebInspector.TextFilterUI.prototype = { | 190 WebInspector.TextFilterUI.prototype = { |
177 /** | 191 /** |
178 * @return {boolean} | 192 * @return {boolean} |
179 */ | 193 */ |
180 isActive: function() | 194 isActive: function() |
181 { | 195 { |
182 return !!this._filterInputElement.value; | 196 return !!this._filterInputElement.value; |
183 }, | 197 }, |
(...skipping 24 matching lines...) Expand all Loading... | |
208 }, | 222 }, |
209 | 223 |
210 /** | 224 /** |
211 * @return {?RegExp} | 225 * @return {?RegExp} |
212 */ | 226 */ |
213 regex: function() | 227 regex: function() |
214 { | 228 { |
215 if (this._regex !== undefined) | 229 if (this._regex !== undefined) |
216 return this._regex; | 230 return this._regex; |
217 var filterQuery = this.value(); | 231 var filterQuery = this.value(); |
218 this._regex = filterQuery ? createPlainTextSearchRegex(filterQuery, "i") : null; | 232 |
233 this._regex = null | |
eustas
2013/11/15 05:13:32
semicolon missing
Dmitry Zvorygin
2013/11/15 10:39:12
Done.
| |
234 if (filterQuery) { | |
235 if (this._supportRegex && this._regexCheckBox.checked) { | |
236 try { | |
237 this._regex = new RegExp(filterQuery, "i"); | |
238 } catch (e) { | |
239 // Silent catch | |
eustas
2013/11/15 05:13:32
You must highlight field / show that regexp is not
Dmitry Zvorygin
2013/11/15 10:39:12
Done.
| |
240 } | |
241 } else { | |
242 this._regex = createPlainTextSearchRegex(filterQuery, "i"); | |
243 } | |
244 } | |
219 return this._regex; | 245 return this._regex; |
220 }, | 246 }, |
221 | 247 |
222 /** | 248 /** |
223 * @param {Event} event | 249 * @param {Event} event |
224 */ | 250 */ |
225 _onFilterFieldManualFocus: function(event) | 251 _onFilterFieldManualFocus: function(event) |
226 { | 252 { |
227 WebInspector.setCurrentFocusElement(event.target); | 253 WebInspector.setCurrentFocusElement(event.target); |
228 }, | 254 }, |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
546 { | 572 { |
547 this.setChecked(!this._checkElement.checked); | 573 this.setChecked(!this._checkElement.checked); |
548 } | 574 } |
549 | 575 |
550 var typeElement = label.createChild("span", "type"); | 576 var typeElement = label.createChild("span", "type"); |
551 typeElement.textContent = title; | 577 typeElement.textContent = title; |
552 }, | 578 }, |
553 | 579 |
554 __proto__: WebInspector.Object.prototype | 580 __proto__: WebInspector.Object.prototype |
555 } | 581 } |
OLD | NEW |