1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/components/preferences/in-content/preferences.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,60 @@ 1.4 +/* - This Source Code Form is subject to the terms of the Mozilla Public 1.5 + - License, v. 2.0. If a copy of the MPL was not distributed with this file, 1.6 + - You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +"use strict"; 1.9 + 1.10 +const Cc = Components.classes; 1.11 +const Ci = Components.interfaces; 1.12 +const Cu = Components.utils; 1.13 +const Cr = Components.results; 1.14 + 1.15 +Cu.import("resource://gre/modules/XPCOMUtils.jsm"); 1.16 +Cu.import("resource://gre/modules/Services.jsm"); 1.17 + 1.18 +addEventListener("DOMContentLoaded", function onLoad() { 1.19 + removeEventListener("DOMContentLoaded", onLoad); 1.20 + init_all(); 1.21 +}); 1.22 + 1.23 +function init_all() { 1.24 + document.documentElement.instantApply = true; 1.25 + gMainPane.init(); 1.26 + gPrivacyPane.init(); 1.27 + gAdvancedPane.init(); 1.28 + gApplicationsPane.init(); 1.29 + gContentPane.init(); 1.30 + gSyncPane.init(); 1.31 + gSecurityPane.init(); 1.32 + var initFinished = document.createEvent("Event"); 1.33 + initFinished.initEvent("Initialized", true, true); 1.34 + document.dispatchEvent(initFinished); 1.35 + 1.36 + let categories = document.getElementById("categories"); 1.37 + categories.addEventListener("select", event => gotoPref(event.target.value)); 1.38 + 1.39 + if (history.length > 1 && history.state) { 1.40 + selectCategory(history.state); 1.41 + } else { 1.42 + history.replaceState("paneGeneral", document.title); 1.43 + } 1.44 +} 1.45 + 1.46 +function selectCategory(name) { 1.47 + let categories = document.getElementById("categories"); 1.48 + let item = categories.querySelector(".category[value=" + name + "]"); 1.49 + categories.selectedItem = item; 1.50 +} 1.51 + 1.52 +function gotoPref(page) { 1.53 + window.history.replaceState(page, document.title); 1.54 + search(page, "data-category"); 1.55 +} 1.56 + 1.57 +function search(aQuery, aAttribute) { 1.58 + let elements = document.getElementById("mainPrefPane").children; 1.59 + for (let element of elements) { 1.60 + let attributeValue = element.getAttribute(aAttribute); 1.61 + element.hidden = (attributeValue != aQuery); 1.62 + } 1.63 +}