Bug 1335905 - Add Search Results page, Fixed text node search bugs
MozReview-Commit-ID: Dkqsy0eL0lt
--- a/browser/components/preferences/in-content/SearchEach.js
+++ b/browser/components/preferences/in-content/SearchEach.js
@@ -42,19 +42,25 @@ function hideShowSearch() {
function searchFunc(event) {
let element = event.target;
// Controller
let controller = getSelectionController();
let findSelection = controller.getSelection(Ci.nsISelectionController.SELECTION_FIND);
findSelection.removeAllRanges();
+ let srHeader = document.getElementById("header-search-results");
+ let noResults = document.getElementById("noResultsFound");
+
if (element.value.trim()) {
console.time("SearchTime");
gotoPref("paneSearchResults");
+
+ srHeader.setAttribute("hidden", "false");
+
searchResultsCategory.setAttribute("hidden", "false");
let notFound = true;
// Building the range for highlighted areas
let rootPreferences = document.getElementById("mainPrefPane")// .querySelectorAll("*")
let rootPreferencesChildren = rootPreferences.childNodes;
// Remove later, used for the debugs
// let foundCounter = 0;
@@ -66,24 +72,32 @@ function searchFunc(event) {
if (nodeRecursion(rootPreferencesChildren[i], element.value.trim(), findSelection)) {
// foundCounter++; // < Remove this
rootPreferencesChildren[i].setAttribute("hidden", "false");
notFound = false;
} else {
rootPreferencesChildren[i].setAttribute("hidden", "true");
}
}
+ srHeader.setAttribute("hidden", "false");
if(notFound){
- console.log('no results found');
+
+ noResults.setAttribute("hidden", "false");
+ //noResults.childNodes[0].innerHTML("Sorry! No results are found for '" + element.value.trim() + "'");
+ //console.log('no results found');
}
// console.log("found and highlighted: ", foundCounter) // < Remove later
console.timeEnd("SearchTime");
} else {
//console.log("Empty string not searching, clearing shit instead");
searchResultsCategory.setAttribute("hidden", "true");
+
+ srHeader.setAttribute("hidden", "true");
+ noResults.setAttribute("hidden", "true");
+
gotoPref("paneGeneral");
}
}
mainSearchElement.innerHTML = "";
mainSearchElement.value = "";
hideShowSearch();
--- a/browser/components/preferences/in-content/preferences.xul
+++ b/browser/components/preferences/in-content/preferences.xul
@@ -199,16 +199,17 @@
</keyset>
<vbox class="main-content" flex="1">
<div align="right">
<textbox type="search" name="q" value="" id="searchTextIMF" placeholder="Search" oncommand=";" onclick="searchOnClick()"/>
</div>
<prefpane id="mainPrefPane">
+#include searchResults.xul
#include main.xul
#include search.xul
#include privacy.xul
#include containers.xul
#include advanced.xul
#include applications.xul
#include content.xul
#include security.xul
new file mode 100644
--- /dev/null
+++ b/browser/components/preferences/in-content/searchResults.xul
@@ -0,0 +1,12 @@
+<hbox id="header-search-results"
+ class="header"
+ hidden="true"
+ data-category="paneSearchResults">
+ <label class="header-name" flex="1">&paneSearchResults.title;</label>
+ <html:a class="help-button" target="_blank" aria-label="&helpButton.label;"></html:a>
+</hbox>
+
+<groupbox id="noResultsFound" align="start" data-category="paneSearchResults">
+ <label >Sorry! No results are found for the searched word</label>
+ <label> Need help? Visit <a href="https://support.mozilla.org/t5/Mozilla-Support-English/ct-p/Mozilla-EN" class="text-link">Firefox Support</a></label>
+</groupbox>