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.

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

mercurial