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

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:003c0ef049ca
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/. */
4
5 "use strict";
6
7 const Cc = Components.classes;
8 const Ci = Components.interfaces;
9 const Cu = Components.utils;
10 const Cr = Components.results;
11
12 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
13 Cu.import("resource://gre/modules/Services.jsm");
14
15 addEventListener("DOMContentLoaded", function onLoad() {
16 removeEventListener("DOMContentLoaded", onLoad);
17 init_all();
18 });
19
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);
32
33 let categories = document.getElementById("categories");
34 categories.addEventListener("select", event => gotoPref(event.target.value));
35
36 if (history.length > 1 && history.state) {
37 selectCategory(history.state);
38 } else {
39 history.replaceState("paneGeneral", document.title);
40 }
41 }
42
43 function selectCategory(name) {
44 let categories = document.getElementById("categories");
45 let item = categories.querySelector(".category[value=" + name + "]");
46 categories.selectedItem = item;
47 }
48
49 function gotoPref(page) {
50 window.history.replaceState(page, document.title);
51 search(page, "data-category");
52 }
53
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