Bug 1335905 - Adding Search Results menu, can hide and show search results menu
MozReview-Commit-ID: ATrzumVnxA
--- a/browser/components/preferences/in-content/SearchEach.js
+++ b/browser/components/preferences/in-content/SearchEach.js
@@ -1,17 +1,22 @@
// No lint errors
// console.log("in the SearchEach file");
+var gSearchResults = {
+ init(){}
+}
let mainSearchElement = document.querySelectorAll("#searchTextIMF");
let firstTimeSearch = true;
document.getElementById("searchTextIMF").addEventListener("command", searchFunc);
+const searchResultsCategory = document.getElementById("categories").firstElementChild;
+
function searchOnClick(){
// console.log("Search was clicked on");
// Initializing all the JS for all the tabs
if (firstTimeSearch) {
firstTimeSearch = false;
gCategoryInits.forEach( function(eachTab) {
if (!eachTab.inited) {
eachTab.init();
@@ -39,38 +44,47 @@ function searchFunc(event) {
let element = event.target;
// Controller
let controller = getSelectionController();
let findSelection = controller.getSelection(Ci.nsISelectionController.SELECTION_FIND);
findSelection.removeAllRanges();
if (element.value.trim()) {
console.time("SearchTime");
+ gotoPref("paneSearchResults");
+ 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;
for (let i = 0; i < rootPreferences.childElementCount; i++) {
rootPreferencesChildren[i].setAttribute("hidden", "false");
}
for (let i = 0; i < rootPreferences.childElementCount; i++) {
if (nodeRecursion(rootPreferencesChildren[i], element.value.trim(), findSelection)) {
// foundCounter++; // < Remove this
rootPreferencesChildren[i].setAttribute("hidden", "false");
+ notFound = false;
} else {
rootPreferencesChildren[i].setAttribute("hidden", "true");
}
}
+ if(notFound){
+ 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");
+ //console.log("Empty string not searching, clearing shit instead");
+ searchResultsCategory.setAttribute("hidden", "true");
+ gotoPref("paneGeneral");
}
}
mainSearchElement.innerHTML = "";
mainSearchElement.value = "";
hideShowSearch();
--- a/browser/components/preferences/in-content/preferences.js
+++ b/browser/components/preferences/in-content/preferences.js
@@ -54,16 +54,17 @@ addEventListener("DOMContentLoaded", fun
init_all();
});
function init_all() {
document.documentElement.instantApply = true;
gSubDialog.init();
register_module("paneGeneral", gMainPane);
+ register_module("paneSearchResults", gSearchResults);
register_module("paneSearch", gSearchPane);
register_module("panePrivacy", gPrivacyPane);
register_module("paneContainers", gContainersPane);
register_module("paneAdvanced", gAdvancedPane);
register_module("paneApplications", gApplicationsPane);
register_module("paneContent", gContentPane);
register_module("paneSync", gSyncPane);
register_module("paneSecurity", gSecurityPane);
@@ -76,17 +77,17 @@ function init_all() {
categories.setAttribute("keyboard-navigation", "true");
}
});
categories.addEventListener("mousedown", function() {
this.removeAttribute("keyboard-navigation");
});
window.addEventListener("hashchange", onHashChange);
- gotoPref();
+ gotoPref("paneGeneral");
init_dynamic_padding();
var initFinished = new CustomEvent("Initialized", {
"bubbles": true,
"cancelable": true
});
document.dispatchEvent(initFinished);
--- a/browser/components/preferences/in-content/preferences.xul
+++ b/browser/components/preferences/in-content/preferences.xul
@@ -88,16 +88,27 @@
src="chrome://browser/locale/preferences/applicationManager.properties"/>
</stringbundleset>
<stack flex="1">
<hbox flex="1">
<!-- category list -->
<richlistbox id="categories">
+ <richlistitem id="category-search-results"
+ class="category"
+ value="paneSearchResults"
+ helpTopic="prefs-main"
+ tooltiptext="&paneSearchResults.title;"
+ align="center"
+ hidden="true">
+ <image class="category-icon"/>
+ <label class="category-name" flex="1">&paneSearchResults.title;</label>
+ </richlistitem>
+
<richlistitem id="category-general"
class="category"
value="paneGeneral"
helpTopic="prefs-main"
tooltiptext="&paneGeneral.title;"
align="center">
<image class="category-icon"/>
<label class="category-name" flex="1">&paneGeneral.title;</label>
--- a/browser/locales/en-US/chrome/browser/preferences/preferences.dtd
+++ b/browser/locales/en-US/chrome/browser/preferences/preferences.dtd
@@ -9,16 +9,18 @@
<!ENTITY prefWindow.titleGNOME "&brandShortName; Preferences">
<!-- When making changes to prefWindow.styleWin test both Windows Classic and
Luna since widget heights are different based on the OS theme -->
<!ENTITY prefWinMinSize.styleWin2 "width: 42em; min-height: 37.5em;">
<!ENTITY prefWinMinSize.styleMac "width: 47em; min-height: 40em;">
<!ENTITY prefWinMinSize.styleGNOME "width: 45.5em; min-height: 40.5em;">
<!ENTITY paneGeneral.title "General">
+<!-- Added for Search functionality testing -->
+<!ENTITY paneSearchResults.title "Search Results">
<!ENTITY paneTabs.title "Tabs">
<!ENTITY paneSearch.title "Search">
<!ENTITY paneContent.title "Content">
<!ENTITY paneApplications.title "Applications">
<!ENTITY panePrivacy.title "Privacy">
<!ENTITY paneContainers.title "Container Tabs">
<!ENTITY paneSecurity.title "Security">
<!ENTITY paneAdvanced.title "Advanced">
--- a/browser/themes/shared/incontentprefs/preferences.inc.css
+++ b/browser/themes/shared/incontentprefs/preferences.inc.css
@@ -96,16 +96,20 @@ treecol {
#category-sync > .category-icon {
list-style-image: url("chrome://browser/skin/preferences/in-content/icons.svg#sync");
}
#category-advanced > .category-icon {
list-style-image: url("chrome://browser/skin/preferences/in-content/icons.svg#advanced");
}
+#category-search-results > .category-icon {
+ list-style-image: url("chrome://browser/skin/preferences/in-content/icons.svg#search");
+}
+
@media (max-width: 800px) {
.category-name {
display: none;
}
}
/* header */
.header {
--- a/browser/tools/mozscreenshots/mozscreenshots/extension/configurations/Preferences.jsm
+++ b/browser/tools/mozscreenshots/mozscreenshots/extension/configurations/Preferences.jsm
@@ -13,16 +13,17 @@ Cu.import("resource://gre/modules/Task.j
Cu.import("resource://testing-common/TestUtils.jsm");
Cu.import("resource://testing-common/ContentTask.jsm");
this.Preferences = {
init(libDir) {
let panes = [
["paneGeneral", null],
+ ["paneSearchResults", null], // Search Functionality testing
["paneSearch", null],
["paneContent", null],
["paneApplications", null],
["panePrivacy", null],
["panePrivacy", null, DNTDialog],
["panePrivacy", null, clearRecentHistoryDialog],
["paneSecurity", null],
["paneSync", null],