browser/components/preferences/in-content/preferences.js

Wed, 31 Dec 2014 13:27:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 13:27:57 +0100
branch
TOR_BUG_3246
changeset 6
8bccb770b82d
permissions
-rw-r--r--

Ignore runtime configuration files generated during quality assurance.

michael@0 1 /* - This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 - License, v. 2.0. If a copy of the MPL was not distributed with this file,
michael@0 3 - You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 "use strict";
michael@0 6
michael@0 7 const Cc = Components.classes;
michael@0 8 const Ci = Components.interfaces;
michael@0 9 const Cu = Components.utils;
michael@0 10 const Cr = Components.results;
michael@0 11
michael@0 12 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
michael@0 13 Cu.import("resource://gre/modules/Services.jsm");
michael@0 14
michael@0 15 addEventListener("DOMContentLoaded", function onLoad() {
michael@0 16 removeEventListener("DOMContentLoaded", onLoad);
michael@0 17 init_all();
michael@0 18 });
michael@0 19
michael@0 20 function init_all() {
michael@0 21 document.documentElement.instantApply = true;
michael@0 22 gMainPane.init();
michael@0 23 gPrivacyPane.init();
michael@0 24 gAdvancedPane.init();
michael@0 25 gApplicationsPane.init();
michael@0 26 gContentPane.init();
michael@0 27 gSyncPane.init();
michael@0 28 gSecurityPane.init();
michael@0 29 var initFinished = document.createEvent("Event");
michael@0 30 initFinished.initEvent("Initialized", true, true);
michael@0 31 document.dispatchEvent(initFinished);
michael@0 32
michael@0 33 let categories = document.getElementById("categories");
michael@0 34 categories.addEventListener("select", event => gotoPref(event.target.value));
michael@0 35
michael@0 36 if (history.length > 1 && history.state) {
michael@0 37 selectCategory(history.state);
michael@0 38 } else {
michael@0 39 history.replaceState("paneGeneral", document.title);
michael@0 40 }
michael@0 41 }
michael@0 42
michael@0 43 function selectCategory(name) {
michael@0 44 let categories = document.getElementById("categories");
michael@0 45 let item = categories.querySelector(".category[value=" + name + "]");
michael@0 46 categories.selectedItem = item;
michael@0 47 }
michael@0 48
michael@0 49 function gotoPref(page) {
michael@0 50 window.history.replaceState(page, document.title);
michael@0 51 search(page, "data-category");
michael@0 52 }
michael@0 53
michael@0 54 function search(aQuery, aAttribute) {
michael@0 55 let elements = document.getElementById("mainPrefPane").children;
michael@0 56 for (let element of elements) {
michael@0 57 let attributeValue = element.getAttribute(aAttribute);
michael@0 58 element.hidden = (attributeValue != aQuery);
michael@0 59 }
michael@0 60 }

mercurial