michael@0: michael@0: michael@0: michael@0: %preferencesDTD; michael@0: michael@0: %globalKeysDTD; michael@0: ]> michael@0: michael@0: michael@0: michael@0: # michael@0: # = Preferences Window Framework michael@0: # michael@0: # The syntax for use looks something like: michael@0: # michael@0: # michael@0: # michael@0: # michael@0: # michael@0: # michael@0: # michael@0: # michael@0: # michael@0: # michael@0: # michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: Components.classes["@mozilla.org/preferences-service;1"] michael@0: .getService(Components.interfaces.nsIPrefService); michael@0: michael@0: michael@0: Components.classes["@mozilla.org/preferences-service;1"] michael@0: .getService(Components.interfaces.nsIPrefBranch); michael@0: michael@0: michael@0: this.service.getDefaultBranch(""); michael@0: michael@0: michael@0: Components.classes["@mozilla.org/preferences-service;1"] michael@0: .getService(Components.interfaces.nsIPrefBranchInternal); michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: this.preferences.rootBranchInternal michael@0: .removeObserver(this.name, this.preferences); michael@0: michael@0: michael@0: michael@0: michael@0: return this.getAttribute("instantApply") == "true" || this.preferences.instantApply; michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: if (val == this.name) michael@0: return val; michael@0: michael@0: this.preferences.rootBranchInternal michael@0: .removeObserver(this.name, this.preferences); michael@0: this.setAttribute('name', val); michael@0: this.preferences.rootBranchInternal michael@0: .addObserver(val, this.preferences, false); michael@0: michael@0: return val; michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: null michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: return this.preferences.rootBranch.prefIsLocked(this.name); michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: return this.getAttribute("disabled") == "true"; michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: return parseInt(this.getAttribute("tabindex")); michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: // defer reset until preference update michael@0: this.value = undefined; michael@0: michael@0: michael@0: michael@0: false michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: return this._useDefault ? this.preferences.defaultBranch : this.preferences.rootBranch; michael@0: michael@0: michael@0: michael@0: false michael@0: michael@0: michael@0: michael@0: with id='" + this.id + "' and name='" + michael@0: this.name + "' has unknown type '" + this.type + "'."; michael@0: consoleService.logStringMessage(msg); michael@0: ]]> michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: this.updateElements(); michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: #else michael@0: title="&preferencesDefaultTitleMac.title;"> michael@0: #endif michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: #ifdef XP_UNIX michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: false michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: this.setAttribute("lastSelected", val); michael@0: document.persist(this.id, "lastSelected"); michael@0: return val; michael@0: michael@0: michael@0: michael@0: michael@0: if (!this._currentPane) michael@0: this._currentPane = this.preferencePanes[0]; michael@0: michael@0: return this._currentPane; michael@0: michael@0: michael@0: null michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: false michael@0: michael@0: michael@0: michael@0: 1) michael@0: aPaneElement.removeAttribute("flex"); michael@0: // Calling sizeToContent after the first prefpane is loaded michael@0: // will size the windows contents so style information is michael@0: // available to calculate correct sizing. michael@0: if (!this._initialized && prefpanes.length > 1) { michael@0: if (this._shouldAnimate) michael@0: this.style.minHeight = 0; michael@0: window.sizeToContent(); michael@0: } michael@0: michael@0: var oldPane = this.lastSelected ? document.getElementById(this.lastSelected) : this.preferencePanes[0]; michael@0: oldPane.selected = !(aPaneElement.selected = true); michael@0: this.lastSelected = aPaneElement.id; michael@0: this.currentPane = aPaneElement; michael@0: this._initialized = true; michael@0: michael@0: // Only animate if we've switched between prefpanes michael@0: if (this._shouldAnimate && oldPane.id != aPaneElement.id) { michael@0: aPaneElement.style.opacity = 0.0; michael@0: this.animate(oldPane, aPaneElement); michael@0: } michael@0: else if (!this._shouldAnimate && prefpanes.length > 1) { michael@0: var targetHeight = parseInt(window.getComputedStyle(this._paneDeckContainer, "").height); michael@0: var verticalPadding = parseInt(window.getComputedStyle(aPaneElement, "").paddingTop); michael@0: verticalPadding += parseInt(window.getComputedStyle(aPaneElement, "").paddingBottom); michael@0: if (aPaneElement.contentHeight > targetHeight - verticalPadding) { michael@0: // To workaround the bottom border of a groupbox from being michael@0: // cutoff an hbox with a class of bottomBox may enclose it. michael@0: // This needs to include its padding to resize properly. michael@0: // See bug 394433 michael@0: var bottomPadding = 0; michael@0: var bottomBox = aPaneElement.getElementsByAttribute("class", "bottomBox")[0]; michael@0: if (bottomBox) michael@0: bottomPadding = parseInt(window.getComputedStyle(bottomBox, "").paddingBottom); michael@0: window.innerHeight += bottomPadding + verticalPadding + aPaneElement.contentHeight - targetHeight; michael@0: } michael@0: michael@0: // XXX rstrong - extend the contents of the prefpane to michael@0: // prevent elements from being cutoff (see bug 349098). michael@0: if (aPaneElement.contentHeight + verticalPadding < targetHeight) michael@0: aPaneElement._content.style.height = targetHeight - verticalPadding + "px"; michael@0: } michael@0: } michael@0: break; michael@0: } michael@0: } michael@0: ]]> michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: oldHeight ? 1 : -1; michael@0: var sizeDelta = Math.abs(oldHeight - aNewPane.contentHeight); michael@0: this._animateRemainder = sizeDelta % this._animateIncrement; michael@0: michael@0: this._setUpAnimationTimer(oldHeight); michael@0: ]]> michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: 0 && this._currentHeight >= lastSelectedPane.contentHeight) || michael@0: (this._multiplier < 0 && this._currentHeight <= lastSelectedPane.contentHeight)) michael@0: return 0; michael@0: michael@0: if ((this._multiplier > 0 && newHeight > lastSelectedPane.contentHeight) || michael@0: (this._multiplier < 0 && newHeight < lastSelectedPane.contentHeight)) michael@0: increment = this._animateRemainder * this._multiplier; michael@0: return increment; michael@0: ]]> michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: null michael@0: null michael@0: 15 michael@0: 40 michael@0: 5 michael@0: 0.40 michael@0: 0 michael@0: 0 michael@0: 0 michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: return openDialog(aURL, "", "modal,centerscreen,resizable=no" + (aFeatures != "" ? ("," + aFeatures) : ""), aParams); michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: if (event.originalTarget.hasAttribute("pane")) { michael@0: var pane = document.getElementById(event.originalTarget.getAttribute("pane")); michael@0: this.showPane(pane); michael@0: } michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: false michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: return document.getElementById(aElement.getAttribute("preference")); michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: var targetHeight = parseInt(window.getComputedStyle(this._content, "").height); michael@0: targetHeight += parseInt(window.getComputedStyle(this._content, "").marginTop); michael@0: targetHeight += parseInt(window.getComputedStyle(this._content, "").marginBottom); michael@0: return targetHeight; michael@0: michael@0: michael@0: michael@0: document.getAnonymousElementByAttribute(this, "class", "content-box"); michael@0: michael@0: michael@0: michael@0: michael@0: // This "command" event handler tracks changes made to preferences by michael@0: // the user in this window. michael@0: if (event.sourceEvent) michael@0: event = event.sourceEvent; michael@0: this.userChangedValue(event.target); michael@0: michael@0: michael@0: // This "select" event handler tracks changes made to colorpicker michael@0: // preferences by the user in this window. michael@0: if (event.target.localName == "colorpicker") michael@0: this.userChangedValue(event.target); michael@0: michael@0: michael@0: // This "change" event handler tracks changes made to preferences by michael@0: // the user in this window. michael@0: this.userChangedValue(event.target); michael@0: michael@0: michael@0: // This "input" event handler tracks changes made to preferences by michael@0: // the user in this window. michael@0: this.userChangedValue(event.target); michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: # -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- michael@0: # This Source Code Form is subject to the terms of the Mozilla Public michael@0: # License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: # file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: # michael@0: # This is PrefWindow 6. The Code Could Well Be Ready, Are You? michael@0: # michael@0: # Historical References: michael@0: # PrefWindow V (February 1, 2003) michael@0: # PrefWindow IV (April 24, 2000) michael@0: # PrefWindow III (January 6, 2000) michael@0: # PrefWindow II (???) michael@0: # PrefWindow I (June 4, 1999) michael@0: #