|
Lines 37-46
WebInspector.SearchController = function
Source/WebCore/inspector/front-end/SearchController.js_sec1
|
| 37 |
this.element = document.getElementById("search"); |
37 |
this.element = document.getElementById("search"); |
| 38 |
this._matchesElement = document.getElementById("search-results-matches"); |
38 |
this._matchesElement = document.getElementById("search-results-matches"); |
| 39 |
this._toolbarLabelElement = document.getElementById("search-toolbar-label"); |
39 |
this._toolbarLabelElement = document.getElementById("search-toolbar-label"); |
|
|
40 |
this._searchControlBoxElement = document.getElementById("toolbar-search-nav-ctrl"); |
| 40 |
|
41 |
|
| 41 |
this.element.addEventListener("search", this._onSearch.bind(this), false); // when the search is emptied |
42 |
this.element.addEventListener("search", this._onSearch.bind(this), false); // when the search is emptied |
| 42 |
this.element.addEventListener("mousedown", this._onSearchFieldManualFocus.bind(this), false); // when the search field is manually selected |
43 |
this.element.addEventListener("mousedown", this._onSearchFieldManualFocus.bind(this), false); // when the search field is manually selected |
| 43 |
this.element.addEventListener("keydown", this._onKeyDown.bind(this), true); |
44 |
this.element.addEventListener("keydown", this._onKeyDown.bind(this), true); |
|
|
45 |
|
| 46 |
this._populateSearchNavButtons(); |
| 44 |
} |
47 |
} |
| 45 |
|
48 |
|
| 46 |
WebInspector.SearchController.prototype = { |
49 |
WebInspector.SearchController.prototype = { |
|
Lines 151-156
WebInspector.SearchController.prototype
Source/WebCore/inspector/front-end/SearchController.js_sec2
|
| 151 |
} |
154 |
} |
| 152 |
}, |
155 |
}, |
| 153 |
|
156 |
|
|
|
157 |
_updateSearchNavigationButtonState: function(visible) |
| 158 |
{ |
| 159 |
if (visible) { |
| 160 |
this._searchNavigationNext.removeStyleClass("hidden"); |
| 161 |
this._searchNavigationPrev.removeStyleClass("hidden"); |
| 162 |
} else { |
| 163 |
this._searchNavigationNext.addStyleClass("hidden"); |
| 164 |
this._searchNavigationPrev.addStyleClass("hidden"); |
| 165 |
} |
| 166 |
}, |
| 167 |
|
| 154 |
/** |
168 |
/** |
| 155 |
* @param {?number=} matches |
169 |
* @param {?number=} matches |
| 156 |
* @param {number=} currentMatchIndex |
170 |
* @param {number=} currentMatchIndex |
|
Lines 159-164
WebInspector.SearchController.prototype
Source/WebCore/inspector/front-end/SearchController.js_sec3
|
| 159 |
{ |
173 |
{ |
| 160 |
if (matches == null) { |
174 |
if (matches == null) { |
| 161 |
this._matchesElement.addStyleClass("hidden"); |
175 |
this._matchesElement.addStyleClass("hidden"); |
|
|
176 |
// Make Search Nav key non-accessible when there is no active search. |
| 177 |
this._updateSearchNavigationButtonState(false); |
| 162 |
return; |
178 |
return; |
| 163 |
} |
179 |
} |
| 164 |
|
180 |
|
|
Lines 173-181
WebInspector.SearchController.prototype
Source/WebCore/inspector/front-end/SearchController.js_sec4
|
| 173 |
var matchesString = WebInspector.UIString("%d of %d matches", currentMatchIndex + 1, matches); |
189 |
var matchesString = WebInspector.UIString("%d of %d matches", currentMatchIndex + 1, matches); |
| 174 |
else |
190 |
else |
| 175 |
var matchesString = WebInspector.UIString("%d matches", matches); |
191 |
var matchesString = WebInspector.UIString("%d matches", matches); |
|
|
192 |
// Make search nav key accessible when there are more than 1 search results found. |
| 193 |
this._updateSearchNavigationButtonState(true); |
| 176 |
} |
194 |
} |
| 177 |
} else |
195 |
} else { |
| 178 |
var matchesString = WebInspector.UIString("Not Found"); |
196 |
var matchesString = WebInspector.UIString("Not Found"); |
|
|
197 |
// Make search nav key non-accessible when there is no match found. |
| 198 |
this._updateSearchNavigationButtonState(false); |
| 199 |
} |
| 179 |
|
200 |
|
| 180 |
this._matchesElement.removeStyleClass("hidden"); |
201 |
this._matchesElement.removeStyleClass("hidden"); |
| 181 |
this._matchesElement.textContent = matchesString; |
202 |
this._matchesElement.textContent = matchesString; |
|
Lines 234-239
WebInspector.SearchController.prototype
Source/WebCore/inspector/front-end/SearchController.js_sec5
|
| 234 |
this._performSearch(event.target.value, forceSearch, event.shiftKey, false); |
255 |
this._performSearch(event.target.value, forceSearch, event.shiftKey, false); |
| 235 |
}, |
256 |
}, |
| 236 |
|
257 |
|
|
|
258 |
_onNextBtnSearch: function(event) |
| 259 |
{ |
| 260 |
// Simulate next search on search-nav-btn click. |
| 261 |
this._performSearch(this.element.value, true, false, false); |
| 262 |
}, |
| 263 |
|
| 264 |
_onPrevBtnSearch: function(event) |
| 265 |
{ |
| 266 |
// Simulate previous search on search-nav-btn click. |
| 267 |
this._performSearch(this.element.value, true, true, false); |
| 268 |
}, |
| 269 |
|
| 237 |
/** |
270 |
/** |
| 238 |
* @param {boolean=} forceSearch |
271 |
* @param {boolean=} forceSearch |
| 239 |
* @param {boolean=} isBackwardSearch |
272 |
* @param {boolean=} isBackwardSearch |
|
Lines 295-300
WebInspector.SearchController.prototype
Source/WebCore/inspector/front-end/SearchController.js_sec6
|
| 295 |
|
328 |
|
| 296 |
currentPanel.currentQuery = query; |
329 |
currentPanel.currentQuery = query; |
| 297 |
currentPanel.performSearch(query); |
330 |
currentPanel.performSearch(query); |
|
|
331 |
}, |
| 332 |
|
| 333 |
/** |
| 334 |
* @param {string=} direction |
| 335 |
*/ |
| 336 |
_createSearchNavBtn: function(direction) { |
| 337 |
var searchNavControlElement = document.createElement("div"); |
| 338 |
var searchNavIconElement = document.createElement("div"); |
| 339 |
searchNavControlElement.className = "toolbar-search-nav-label hidden"; |
| 340 |
switch(direction) { |
| 341 |
case "prev": |
| 342 |
searchNavControlElement.setAttribute("title" , "Search Previous"); |
| 343 |
searchNavIconElement.className = "toolbar-search-nav-icon-prev"; |
| 344 |
this._searchNavigationPrev = searchNavControlElement; |
| 345 |
this._searchNavigationPrev.addEventListener("mousedown", this._onPrevBtnSearch.bind(this), false); |
| 346 |
break; |
| 347 |
case "next": |
| 348 |
searchNavControlElement.setAttribute("title" , "Search Next"); |
| 349 |
searchNavIconElement.className = "toolbar-search-nav-icon-next"; |
| 350 |
this._searchNavigationNext = searchNavControlElement; |
| 351 |
this._searchNavigationNext.addEventListener("mousedown", this._onNextBtnSearch.bind(this), false); |
| 352 |
break; |
| 353 |
|
| 354 |
} |
| 355 |
searchNavControlElement.appendChild(searchNavIconElement); |
| 356 |
this._searchControlBoxElement.appendChild(searchNavControlElement); |
| 357 |
}, |
| 358 |
|
| 359 |
_populateSearchNavButtons: function() { |
| 360 |
// Lazily adding search navigation keys to dom. |
| 361 |
this._createSearchNavBtn("prev"); |
| 362 |
this._createSearchNavBtn("next"); |
| 298 |
} |
363 |
} |
| 299 |
} |
364 |
} |
| 300 |
|
365 |
|