Bug 1335905 Hiding the searchbar and button
MozReview-Commit-ID: BVMziRniqCT
--- a/browser/components/preferences/in-content/SearchEach.js
+++ b/browser/components/preferences/in-content/SearchEach.js
@@ -1,55 +1,61 @@
console.log('in the SearchEach file');
-let mainSeachEmelemt = document.getElementById('searchTextIMF');
+let mainSeachEmelemt = document.querySelectorAll('#searchTextIMF');
function hideShowSearch () {
let mainSearchEnable = Services.prefs.getBoolPref('browser.preference.search')
- let vis = mainSeachEmelemt.style;
+ mainSeachEmelemt.forEach(function (node){
+ let vis = node.style;
- if (mainSearchEnable)
- {
- vis.display = 'block';
- }
- else
- {
- vis.display = 'none';
- }
+ if (mainSearchEnable)
+ {
+ vis.display = 'block';
+ }
+ else
+ {
+ vis.display = 'none';
+ }
+ });
+
}
function searchFunc(element) {
- console.time('SearchTime');
+ if(mainSeachEmelemt.value){
+ console.time('SearchTime');
- //Controller
- let controller = getSelectionController();
- let findSelection = controller.getSelection(Ci.nsISelectionController.SELECTION_FIND);
+ //Controller
+ let controller = getSelectionController();
+ let findSelection = controller.getSelection(Ci.nsISelectionController.SELECTION_FIND);
- //Building the range for highlighted areas
- let range = document.createRange();
- let rootPreferences = document.getElementById('mainPrefPane')//.querySelectorAll('*')
- let rootPreferencesChildren = rootPreferences.childNodes
- //Remove later, used for the debugs
- let foundCounter = 0;
+ //Building the range for highlighted areas
+ let range = document.createRange();
+ 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++){
- if(nodeRecursion(rootPreferencesChildren[i], mainSeachEmelemt.value, range)){
- foundCounter++; //<Remove this
- rootPreferencesChildren[i].setAttribute('hidden', 'false');
- }else{
- rootPreferencesChildren[i].setAttribute('hidden', 'true');
- }
+ for (let i = 0; i<rootPreferences.childElementCount; i++){
+ if(nodeRecursion(rootPreferencesChildren[i], mainSeachEmelemt.value, range)){
+ foundCounter++; //<Remove this
+ rootPreferencesChildren[i].setAttribute('hidden', 'false');
+ }else{
+ rootPreferencesChildren[i].setAttribute('hidden', 'true');
+ }
+ }
+ findSelection.addRange(range); // Select it all ones done searching
+ console.log('found and highlighted: ', foundCounter) //<Remove later
+ console.timeEnd('SearchTime')
+ } else{
+ console.log("Empty string not searching")
}
- findSelection.addRange(range); // Select it all ones done searching
- console.log('found and highlighted: ', foundCounter) //<Remove later
- console.timeEnd('SearchTime')
}
mainSeachEmelemt.innerHTML = ''
hideShowSearch();
/**
@@ -79,30 +85,31 @@ hideShowSearch();
//getLabelAttribute(nodeObject,searchPhrase))
)) {
//Drill down deeper
//if(nodeObject.boxObject){
// getRangeObject(nodeObject.boxObject, searchPhrase.trim().split(), range);
//}
// Finding Text nodes in leaf node
let leaf = textNodesUnder(nodeObject)
-
+ let listOfWords = searchPhrase.trim().split()
leaf.forEach(function (node) {
listOfWords.forEach(function (word){
searchWord(node,node.textContent,word,range)
});
});
let anonymous = textNodesUnder(nodeObject.boxObject)
let anonymousTextContent = ''
leaf.forEach(function (node) {
anonymousTextContent += node.textContent
});
-
+ console.log("anonymousTextContent")
+ console.log(anonymousTextContent)
/*
allTextNodes.forEach(function (node) {
listOfWords.forEach(function (word){
searchWord(node,node.textContent,word,range)
});
});
--- a/browser/components/preferences/in-content/preferences.xul
+++ b/browser/components/preferences/in-content/preferences.xul
@@ -187,17 +187,17 @@
<key key="&focusSearch1.key;" modifiers="accel" id="focusSearch1" oncommand=";"/>
</keyset>
<vbox class="main-content" flex="1">
<div align="right">
<input xmlns="http://www.w3.org/1999/xhtml" name="q" value="" id="searchTextIMF" maxlength="500"
placeholder="Search" type="text"></input>
- <button onclick="searchFunc(this)" type="button">Click Me!</button>
+ <button id="searchTextIMF" onclick="searchFunc(this)" type="button">Click Me!</button>
</div>
<prefpane id="mainPrefPane">
#include main.xul
#include search.xul
#include privacy.xul
#include containers.xul
#include advanced.xul
#include applications.xul