1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/metro/base/content/pages/config.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,632 @@ 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 +"use strict"; 1.8 + 1.9 +const {classes: Cc, interfaces: Ci, manager: Cm, utils: Cu} = Components; 1.10 +Cu.import("resource://gre/modules/Services.jsm"); 1.11 + 1.12 +const INITIAL_PAGE_DELAY = 500; // Initial pause on program start for scroll alignment 1.13 +const PREFS_BUFFER_MAX = 100; // Max prefs buffer size for getPrefsBuffer() 1.14 +const PAGE_SCROLL_TRIGGER = 200; // Triggers additional getPrefsBuffer() on user scroll-to-bottom 1.15 +const FILTER_CHANGE_TRIGGER = 200; // Delay between responses to filterInput changes 1.16 +const INNERHTML_VALUE_DELAY = 100; // Delay before providing prefs innerHTML value 1.17 + 1.18 +let gStringBundle = Services.strings.createBundle("chrome://browser/locale/config.properties"); 1.19 +let gClipboardHelper = Cc["@mozilla.org/widget/clipboardhelper;1"].getService(Ci.nsIClipboardHelper); 1.20 + 1.21 + 1.22 +/* ============================== NewPrefDialog ============================== 1.23 + * 1.24 + * New Preference Dialog Object and methods 1.25 + * 1.26 + * Implements User Interfaces for creation of a single(new) Preference setting 1.27 + * 1.28 + */ 1.29 +var NewPrefDialog = { 1.30 + 1.31 + _prefsShield: null, 1.32 + 1.33 + _newPrefsDialog: null, 1.34 + _newPrefItem: null, 1.35 + _prefNameInputElt: null, 1.36 + _prefTypeSelectElt: null, 1.37 + 1.38 + _booleanValue: null, 1.39 + _booleanToggle: null, 1.40 + _stringValue: null, 1.41 + _intValue: null, 1.42 + 1.43 + _positiveButton: null, 1.44 + 1.45 + get type() { 1.46 + return this._prefTypeSelectElt.value; 1.47 + }, 1.48 + 1.49 + set type(aType) { 1.50 + this._prefTypeSelectElt.value = aType; 1.51 + switch(this._prefTypeSelectElt.value) { 1.52 + case "boolean": 1.53 + this._prefTypeSelectElt.selectedIndex = 0; 1.54 + break; 1.55 + case "string": 1.56 + this._prefTypeSelectElt.selectedIndex = 1; 1.57 + break; 1.58 + case "int": 1.59 + this._prefTypeSelectElt.selectedIndex = 2; 1.60 + break; 1.61 + } 1.62 + 1.63 + this._newPrefItem.setAttribute("typestyle", aType); 1.64 + }, 1.65 + 1.66 + // Init the NewPrefDialog 1.67 + init: function AC_init() { 1.68 + this._prefsShield = document.getElementById("prefs-shield"); 1.69 + 1.70 + this._newPrefsDialog = document.getElementById("new-pref-container"); 1.71 + this._newPrefItem = document.getElementById("new-pref-item"); 1.72 + this._prefNameInputElt = document.getElementById("new-pref-name"); 1.73 + this._prefTypeSelectElt = document.getElementById("new-pref-type"); 1.74 + 1.75 + this._booleanValue = document.getElementById("new-pref-value-boolean"); 1.76 + this._stringValue = document.getElementById("new-pref-value-string"); 1.77 + this._intValue = document.getElementById("new-pref-value-int"); 1.78 + 1.79 + this._positiveButton = document.getElementById("positive-button"); 1.80 + }, 1.81 + 1.82 + // Called to update positive button to display text ("Create"/"Change), and enabled/disabled status 1.83 + // As new pref name is initially displayed, re-focused, or modifed during user input 1.84 + _updatePositiveButton: function AC_updatePositiveButton(aPrefName) { 1.85 + this._positiveButton.textContent = gStringBundle.GetStringFromName("newPref.createButton"); 1.86 + this._positiveButton.setAttribute("disabled", true); 1.87 + if (aPrefName == "") { 1.88 + return; 1.89 + } 1.90 + 1.91 + // If item already in list, it's being changed, else added 1.92 + let item = document.querySelector(".pref-item[name=" + aPrefName.quote() + "]"); 1.93 + if (item) { 1.94 + this._positiveButton.textContent = gStringBundle.GetStringFromName("newPref.changeButton"); 1.95 + } else { 1.96 + this._positiveButton.removeAttribute("disabled"); 1.97 + } 1.98 + }, 1.99 + 1.100 + // When we want to cancel/hide an existing, or show a new pref dialog 1.101 + toggleShowHide: function AC_toggleShowHide() { 1.102 + if (this._newPrefsDialog.classList.contains("show")) { 1.103 + this.hide(); 1.104 + } else { 1.105 + this._show(); 1.106 + } 1.107 + }, 1.108 + 1.109 + // When we want to show the new pref dialog / shield the prefs list 1.110 + _show: function AC_show() { 1.111 + this._newPrefsDialog.classList.add("show"); 1.112 + this._prefsShield.setAttribute("shown", true); 1.113 + 1.114 + // Initial default field values 1.115 + this._prefNameInputElt.value = ""; 1.116 + this._updatePositiveButton(this._prefNameInputElt.value); 1.117 + 1.118 + this.type = "boolean"; 1.119 + this._booleanValue.value = "false"; 1.120 + this._stringValue.value = ""; 1.121 + this._intValue.value = ""; 1.122 + 1.123 + this._prefNameInputElt.focus(); 1.124 + 1.125 + window.addEventListener("keypress", this.handleKeypress, false); 1.126 + }, 1.127 + 1.128 + // When we want to cancel/hide the new pref dialog / un-shield the prefs list 1.129 + hide: function AC_hide() { 1.130 + this._newPrefsDialog.classList.remove("show"); 1.131 + this._prefsShield.removeAttribute("shown"); 1.132 + 1.133 + window.removeEventListener("keypress", this.handleKeypress, false); 1.134 + }, 1.135 + 1.136 + // Watch user key input so we can provide Enter key action, commit input values 1.137 + handleKeypress: function AC_handleKeypress(aEvent) { 1.138 + // Close our VKB on new pref enter key press 1.139 + if (aEvent.keyCode == KeyEvent.DOM_VK_RETURN) 1.140 + aEvent.target.blur(); 1.141 + }, 1.142 + 1.143 + // New prefs create dialog only allows creating a non-existing preference, doesn't allow for 1.144 + // Changing an existing one on-the-fly, tap existing/displayed line item pref for that 1.145 + create: function AC_create(aEvent) { 1.146 + if (this._positiveButton.getAttribute("disabled") == "true") { 1.147 + return; 1.148 + } 1.149 + 1.150 + switch(this.type) { 1.151 + case "boolean": 1.152 + Services.prefs.setBoolPref(this._prefNameInputElt.value, (this._booleanValue.value == "true") ? true : false); 1.153 + break; 1.154 + case "string": 1.155 + Services.prefs.setCharPref(this._prefNameInputElt.value, this._stringValue.value); 1.156 + break; 1.157 + case "int": 1.158 + Services.prefs.setIntPref(this._prefNameInputElt.value, this._intValue.value); 1.159 + break; 1.160 + } 1.161 + 1.162 + this.hide(); 1.163 + }, 1.164 + 1.165 + // Display proper positive button text/state on new prefs name input focus 1.166 + focusName: function AC_focusName(aEvent) { 1.167 + this._updatePositiveButton(aEvent.target.value); 1.168 + }, 1.169 + 1.170 + // Display proper positive button text/state as user changes new prefs name 1.171 + updateName: function AC_updateName(aEvent) { 1.172 + this._updatePositiveButton(aEvent.target.value); 1.173 + }, 1.174 + 1.175 + // In new prefs dialog, bool prefs are <input type="text">, as they aren't yet tied to an 1.176 + // Actual Services.prefs.*etBoolPref() 1.177 + toggleBoolValue: function AC_toggleBoolValue() { 1.178 + this._booleanValue.value = (this._booleanValue.value == "true" ? "false" : "true"); 1.179 + } 1.180 +} 1.181 + 1.182 + 1.183 +/* ============================== AboutConfig ============================== 1.184 + * 1.185 + * Main AboutConfig object and methods 1.186 + * 1.187 + * Implements User Interfaces for maintenance of a list of Preference settings 1.188 + * 1.189 + */ 1.190 +var AboutConfig = { 1.191 + 1.192 + filterInput: null, 1.193 + _filterPrevInput: null, 1.194 + _filterChangeTimer: null, 1.195 + _prefsContainer: null, 1.196 + _loadingContainer: null, 1.197 + _list: null, 1.198 + 1.199 + // Init the main AboutConfig dialog 1.200 + init: function AC_init() { 1.201 + this.filterInput = document.getElementById("filter-input"); 1.202 + this._prefsContainer = document.getElementById("prefs-container"); 1.203 + this._loadingContainer = document.getElementById("loading-container"); 1.204 + 1.205 + let list = Services.prefs.getChildList(""); 1.206 + this._list = list.sort().map( function AC_getMapPref(aPref) { 1.207 + return new Pref(aPref); 1.208 + }, this); 1.209 + 1.210 + // Display the current prefs list (retains searchFilter value) 1.211 + this.bufferFilterInput(); 1.212 + 1.213 + // Setup the prefs observers 1.214 + Services.prefs.addObserver("", this, false); 1.215 + }, 1.216 + 1.217 + // Uninit the main AboutConfig dialog 1.218 + uninit: function AC_uninit() { 1.219 + // Remove the prefs observer 1.220 + Services.prefs.removeObserver("", this); 1.221 + }, 1.222 + 1.223 + // Clear the filterInput value, to display the entire list 1.224 + clearFilterInput: function AC_clearFilterInput() { 1.225 + this.filterInput.value = ""; 1.226 + this.bufferFilterInput(); 1.227 + }, 1.228 + 1.229 + // Buffer down rapid changes in filterInput value from keyboard 1.230 + bufferFilterInput: function AC_bufferFilterInput() { 1.231 + if (this._filterChangeTimer) { 1.232 + clearTimeout(this._filterChangeTimer); 1.233 + } 1.234 + 1.235 + this._filterChangeTimer = setTimeout((function() { 1.236 + this._filterChangeTimer = null; 1.237 + // Display updated prefs list when filterInput value settles 1.238 + this._displayNewList(); 1.239 + }).bind(this), FILTER_CHANGE_TRIGGER); 1.240 + }, 1.241 + 1.242 + // Update displayed list when filterInput value changes 1.243 + _displayNewList: function AC_displayNewList() { 1.244 + // This survives the search filter value past a page refresh 1.245 + this.filterInput.setAttribute("value", this.filterInput.value); 1.246 + 1.247 + // Don't start new filter search if same as last 1.248 + if (this.filterInput.value == this._filterPrevInput) { 1.249 + return; 1.250 + } 1.251 + this._filterPrevInput = this.filterInput.value; 1.252 + 1.253 + // Clear list item selection and prefs list, get first buffer, set scrolling on 1.254 + this.selected = ""; 1.255 + this._clearPrefsContainer(); 1.256 + this._addMorePrefsToContainer(); 1.257 + window.onscroll = this.onScroll.bind(this); 1.258 + 1.259 + // Pause for screen to settle, then ensure at top 1.260 + setTimeout((function() { 1.261 + window.scrollTo(0, 0); 1.262 + }).bind(this), INITIAL_PAGE_DELAY); 1.263 + }, 1.264 + 1.265 + // Clear the displayed preferences list 1.266 + _clearPrefsContainer: function AC_clearPrefsContainer() { 1.267 + // Quick clear the prefsContainer list 1.268 + let empty = this._prefsContainer.cloneNode(false); 1.269 + this._prefsContainer.parentNode.replaceChild(empty, this._prefsContainer); 1.270 + this._prefsContainer = empty; 1.271 + 1.272 + // Quick clear the prefs li.HTML list 1.273 + this._list.forEach(function(item) { 1.274 + delete item.li; 1.275 + }); 1.276 + }, 1.277 + 1.278 + // Get a small manageable block of prefs items, and add them to the displayed list 1.279 + _addMorePrefsToContainer: function AC_addMorePrefsToContainer() { 1.280 + // Create filter regex 1.281 + let filterExp = this.filterInput.value ? 1.282 + new RegExp(this.filterInput.value, "i") : null; 1.283 + 1.284 + // Get a new block for the display list 1.285 + let prefsBuffer = []; 1.286 + for (let i = 0; i < this._list.length && prefsBuffer.length < PREFS_BUFFER_MAX; i++) { 1.287 + if (!this._list[i].li && this._list[i].test(filterExp)) { 1.288 + prefsBuffer.push(this._list[i]); 1.289 + } 1.290 + } 1.291 + 1.292 + // Add the new block to the displayed list 1.293 + for (let i = 0; i < prefsBuffer.length; i++) { 1.294 + this._prefsContainer.appendChild(prefsBuffer[i].getOrCreateNewLINode()); 1.295 + } 1.296 + 1.297 + // Determine if anything left to add later by scrolling 1.298 + let anotherPrefsBufferRemains = false; 1.299 + for (let i = 0; i < this._list.length; i++) { 1.300 + if (!this._list[i].li && this._list[i].test(filterExp)) { 1.301 + anotherPrefsBufferRemains = true; 1.302 + break; 1.303 + } 1.304 + } 1.305 + 1.306 + if (anotherPrefsBufferRemains) { 1.307 + // If still more could be displayed, show the throbber 1.308 + this._loadingContainer.style.display = "block"; 1.309 + } else { 1.310 + // If no more could be displayed, hide the throbber, and stop noticing scroll events 1.311 + this._loadingContainer.style.display = "none"; 1.312 + window.onscroll = null; 1.313 + } 1.314 + }, 1.315 + 1.316 + // If scrolling at the bottom, maybe add some more entries 1.317 + onScroll: function AC_onScroll(aEvent) { 1.318 + if (this._prefsContainer.scrollHeight - (window.pageYOffset + window.innerHeight) < PAGE_SCROLL_TRIGGER) { 1.319 + if (!this._filterChangeTimer) { 1.320 + this._addMorePrefsToContainer(); 1.321 + } 1.322 + } 1.323 + }, 1.324 + 1.325 + // Return currently selected list item node 1.326 + get selected() { 1.327 + return document.querySelector(".pref-item.selected"); 1.328 + }, 1.329 + 1.330 + // Set list item node as selected 1.331 + set selected(aSelection) { 1.332 + let currentSelection = this.selected; 1.333 + if (aSelection == currentSelection) { 1.334 + return; 1.335 + } 1.336 + 1.337 + // Clear any previous selection 1.338 + if (currentSelection) { 1.339 + currentSelection.classList.remove("selected"); 1.340 + currentSelection.removeEventListener("keypress", this.handleKeypress, false); 1.341 + } 1.342 + 1.343 + // Set any current selection 1.344 + if (aSelection) { 1.345 + aSelection.classList.add("selected"); 1.346 + aSelection.addEventListener("keypress", this.handleKeypress, false); 1.347 + } 1.348 + }, 1.349 + 1.350 + // Watch user key input so we can provide Enter key action, commit input values 1.351 + handleKeypress: function AC_handleKeypress(aEvent) { 1.352 + if (aEvent.keyCode == KeyEvent.DOM_VK_RETURN) 1.353 + aEvent.target.blur(); 1.354 + }, 1.355 + 1.356 + // Return the target list item node of an action event 1.357 + getLINodeForEvent: function AC_getLINodeForEvent(aEvent) { 1.358 + let node = aEvent.target; 1.359 + while (node && node.nodeName != "li") { 1.360 + node = node.parentNode; 1.361 + } 1.362 + 1.363 + return node; 1.364 + }, 1.365 + 1.366 + // Return a pref of a list item node 1.367 + _getPrefForNode: function AC_getPrefForNode(aNode) { 1.368 + let pref = aNode.getAttribute("name"); 1.369 + 1.370 + return new Pref(pref); 1.371 + }, 1.372 + 1.373 + // When list item name or value are tapped 1.374 + selectOrToggleBoolPref: function AC_selectOrToggleBoolPref(aEvent) { 1.375 + let node = this.getLINodeForEvent(aEvent); 1.376 + 1.377 + // If not already selected, just do so 1.378 + if (this.selected != node) { 1.379 + this.selected = node; 1.380 + return; 1.381 + } 1.382 + 1.383 + // If already selected, and value is boolean, toggle it 1.384 + let pref = this._getPrefForNode(node); 1.385 + if (pref.type != Services.prefs.PREF_BOOL) { 1.386 + return; 1.387 + } 1.388 + 1.389 + this.toggleBoolPref(aEvent); 1.390 + }, 1.391 + 1.392 + // When finalizing list input values due to blur 1.393 + setIntOrStringPref: function AC_setIntOrStringPref(aEvent) { 1.394 + let node = this.getLINodeForEvent(aEvent); 1.395 + 1.396 + // Skip if locked 1.397 + let pref = this._getPrefForNode(node); 1.398 + if (pref.locked) { 1.399 + return; 1.400 + } 1.401 + 1.402 + // Boolean inputs blur to remove focus from "button" 1.403 + if (pref.type == Services.prefs.PREF_BOOL) { 1.404 + return; 1.405 + } 1.406 + 1.407 + // String and Int inputs change / commit on blur 1.408 + pref.value = aEvent.target.value; 1.409 + }, 1.410 + 1.411 + // When we reset a pref to it's default value (note resetting a user created pref will delete it) 1.412 + resetDefaultPref: function AC_resetDefaultPref(aEvent) { 1.413 + let node = this.getLINodeForEvent(aEvent); 1.414 + 1.415 + // If not already selected, do so 1.416 + if (this.selected != node) { 1.417 + this.selected = node; 1.418 + } 1.419 + 1.420 + // Reset will handle any locked condition 1.421 + let pref = this._getPrefForNode(node); 1.422 + pref.reset(); 1.423 + }, 1.424 + 1.425 + // When we want to toggle a bool pref 1.426 + toggleBoolPref: function AC_toggleBoolPref(aEvent) { 1.427 + let node = this.getLINodeForEvent(aEvent); 1.428 + 1.429 + // Skip if locked, or not boolean 1.430 + let pref = this._getPrefForNode(node); 1.431 + if (pref.locked) { 1.432 + return; 1.433 + } 1.434 + 1.435 + // Toggle, and blur to remove field focus 1.436 + pref.value = !pref.value; 1.437 + aEvent.target.blur(); 1.438 + }, 1.439 + 1.440 + // When Int inputs have their Up or Down arrows toggled 1.441 + incrOrDecrIntPref: function AC_incrOrDecrIntPref(aEvent, aInt) { 1.442 + let node = this.getLINodeForEvent(aEvent); 1.443 + 1.444 + // Skip if locked 1.445 + let pref = this._getPrefForNode(node); 1.446 + if (pref.locked) { 1.447 + return; 1.448 + } 1.449 + 1.450 + pref.value += aInt; 1.451 + }, 1.452 + 1.453 + // Observe preference changes 1.454 + observe: function AC_observe(aSubject, aTopic, aPrefName) { 1.455 + let pref = new Pref(aPrefName); 1.456 + 1.457 + // Ignore uninteresting changes, and avoid "private" preferences 1.458 + if (aTopic != "nsPref:changed") { 1.459 + return; 1.460 + } 1.461 + 1.462 + // If pref type invalid, refresh display as user reset/removed an item from the list 1.463 + if (pref.type == Services.prefs.PREF_INVALID) { 1.464 + document.location.reload(); 1.465 + return; 1.466 + } 1.467 + 1.468 + // If pref not already in list, refresh display as it's being added 1.469 + let item = document.querySelector(".pref-item[name=" + pref.name.quote() + "]"); 1.470 + if (!item) { 1.471 + document.location.reload(); 1.472 + return; 1.473 + } 1.474 + 1.475 + // Else we're modifying a pref 1.476 + item.setAttribute("value", pref.value); 1.477 + let input = item.querySelector("input"); 1.478 + input.setAttribute("value", pref.value); 1.479 + input.value = pref.value; 1.480 + 1.481 + pref.default ? 1.482 + item.querySelector(".reset").setAttribute("disabled", "true") : 1.483 + item.querySelector(".reset").removeAttribute("disabled"); 1.484 + } 1.485 +} 1.486 + 1.487 + 1.488 +/* ============================== Pref ============================== 1.489 + * 1.490 + * Individual Preference object / methods 1.491 + * 1.492 + * Defines a Pref object, a document list item tied to Preferences Services 1.493 + * And the methods by which they interact. 1.494 + * 1.495 + */ 1.496 +function Pref(aName) { 1.497 + this.name = aName; 1.498 +} 1.499 + 1.500 +Pref.prototype = { 1.501 + get type() { 1.502 + return Services.prefs.getPrefType(this.name); 1.503 + }, 1.504 + 1.505 + get value() { 1.506 + switch (this.type) { 1.507 + case Services.prefs.PREF_BOOL: 1.508 + return Services.prefs.getBoolPref(this.name); 1.509 + case Services.prefs.PREF_INT: 1.510 + return Services.prefs.getIntPref(this.name); 1.511 + case Services.prefs.PREF_STRING: 1.512 + default: 1.513 + return Services.prefs.getCharPref(this.name); 1.514 + } 1.515 + 1.516 + }, 1.517 + 1.518 + set value(aPrefValue) { 1.519 + switch (this.type) { 1.520 + case Services.prefs.PREF_BOOL: 1.521 + Services.prefs.setBoolPref(this.name, aPrefValue); 1.522 + break; 1.523 + case Services.prefs.PREF_INT: 1.524 + Services.prefs.setIntPref(this.name, aPrefValue); 1.525 + break; 1.526 + case Services.prefs.PREF_STRING: 1.527 + default: 1.528 + Services.prefs.setCharPref(this.name, aPrefValue); 1.529 + } 1.530 + }, 1.531 + 1.532 + get default() { 1.533 + return !Services.prefs.prefHasUserValue(this.name); 1.534 + }, 1.535 + 1.536 + get locked() { 1.537 + return Services.prefs.prefIsLocked(this.name); 1.538 + }, 1.539 + 1.540 + reset: function AC_reset() { 1.541 + Services.prefs.clearUserPref(this.name); 1.542 + }, 1.543 + 1.544 + test: function AC_test(aValue) { 1.545 + return aValue ? aValue.test(this.name) : true; 1.546 + }, 1.547 + 1.548 + // Get existing or create new LI node for the pref 1.549 + getOrCreateNewLINode: function AC_getOrCreateNewLINode() { 1.550 + if (!this.li) { 1.551 + this.li = document.createElement("li"); 1.552 + 1.553 + this.li.className = "pref-item"; 1.554 + this.li.setAttribute("name", this.name); 1.555 + 1.556 + // Click callback to ensure list item selected even on no-action tap events 1.557 + this.li.addEventListener("click", 1.558 + function(aEvent) { 1.559 + AboutConfig.selected = AboutConfig.getLINodeForEvent(aEvent); 1.560 + }, 1.561 + false 1.562 + ); 1.563 + 1.564 + // Create list item outline, bind to object actions 1.565 + this.li.innerHTML = 1.566 + "<div class='pref-name' " + 1.567 + "onclick='AboutConfig.selectOrToggleBoolPref(event);'>" + 1.568 + this.name + 1.569 + "</div>" + 1.570 + "<div class='pref-item-line'>" + 1.571 + "<input class='pref-value' value='' " + 1.572 + "onblur='AboutConfig.setIntOrStringPref(event);' " + 1.573 + "onclick='AboutConfig.selectOrToggleBoolPref(event);'>" + 1.574 + "</input>" + 1.575 + "<div class='pref-button reset' " + 1.576 + "onclick='AboutConfig.resetDefaultPref(event);'>" + 1.577 + gStringBundle.GetStringFromName("pref.resetButton") + 1.578 + "</div>" + 1.579 + "<div class='pref-button toggle' " + 1.580 + "onclick='AboutConfig.toggleBoolPref(event);'>" + 1.581 + gStringBundle.GetStringFromName("pref.toggleButton") + 1.582 + "</div>" + 1.583 + "<div class='pref-button up' " + 1.584 + "onclick='AboutConfig.incrOrDecrIntPref(event, 1);'>" + 1.585 + "</div>" + 1.586 + "<div class='pref-button down' " + 1.587 + "onclick='AboutConfig.incrOrDecrIntPref(event, -1);'>" + 1.588 + "</div>" + 1.589 + "</div>"; 1.590 + 1.591 + // Delay providing the list item values, until the LI is returned and added to the document 1.592 + setTimeout(this._valueSetup.bind(this), INNERHTML_VALUE_DELAY); 1.593 + } 1.594 + 1.595 + return this.li; 1.596 + }, 1.597 + 1.598 + // Initialize list item object values 1.599 + _valueSetup: function AC_valueSetup() { 1.600 + 1.601 + this.li.setAttribute("type", this.type); 1.602 + this.li.setAttribute("value", this.value); 1.603 + 1.604 + let valDiv = this.li.querySelector(".pref-value"); 1.605 + valDiv.value = this.value; 1.606 + 1.607 + switch(this.type) { 1.608 + case Services.prefs.PREF_BOOL: 1.609 + valDiv.setAttribute("type", "button"); 1.610 + this.li.querySelector(".up").setAttribute("disabled", true); 1.611 + this.li.querySelector(".down").setAttribute("disabled", true); 1.612 + break; 1.613 + case Services.prefs.PREF_STRING: 1.614 + valDiv.setAttribute("type", "text"); 1.615 + this.li.querySelector(".up").setAttribute("disabled", true); 1.616 + this.li.querySelector(".down").setAttribute("disabled", true); 1.617 + this.li.querySelector(".toggle").setAttribute("disabled", true); 1.618 + break; 1.619 + case Services.prefs.PREF_INT: 1.620 + valDiv.setAttribute("type", "number"); 1.621 + this.li.querySelector(".toggle").setAttribute("disabled", true); 1.622 + break; 1.623 + } 1.624 + 1.625 + this.li.setAttribute("default", this.default); 1.626 + if (this.default) { 1.627 + this.li.querySelector(".reset").setAttribute("disabled", true); 1.628 + } 1.629 + 1.630 + if (this.locked) { 1.631 + valDiv.setAttribute("disabled", this.locked); 1.632 + this.li.querySelector(".pref-name").setAttribute("locked", true); 1.633 + } 1.634 + } 1.635 +}