2006-05-17 06:24:52 +04:00
|
|
|
/* -*- Mode: Java; tab-width: 4; c-basic-offset: 4; -*-
|
|
|
|
*
|
2006-05-17 06:39:15 +04:00
|
|
|
* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
2006-05-17 06:24:52 +04:00
|
|
|
*
|
2006-05-17 06:39:15 +04:00
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
2006-05-17 06:24:52 +04:00
|
|
|
* for the specific language governing rights and limitations under the
|
2006-05-17 06:39:15 +04:00
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is mozilla.org Code.
|
2006-05-17 06:24:52 +04:00
|
|
|
*
|
2006-05-17 06:39:15 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
2006-05-17 06:24:52 +04:00
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
* Ben "Count XULula" Goodger <ben@netscape.com>
|
2006-05-17 06:39:15 +04:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
2006-05-17 06:24:52 +04:00
|
|
|
|
|
|
|
const _DEBUG = false;
|
|
|
|
|
|
|
|
/** PrefWindow IV
|
|
|
|
* =============
|
|
|
|
* This is a general page switcher and pref loader.
|
|
|
|
* =>> CHANGES MUST BE REVIEWED BY ben@netscape.com!! <<=
|
|
|
|
**/
|
Bookmarks Window Updates, includes fixes for
27495, 38004, 42080, 43146, 43753, 47494, 50835, 53403, 55447, 55448, 55787
r=blake, a=hyatt
2006-05-17 06:28:26 +04:00
|
|
|
|
2006-05-17 06:37:22 +04:00
|
|
|
var hPrefWindow = null;
|
Bookmarks Window Updates, includes fixes for
27495, 38004, 42080, 43146, 43753, 47494, 50835, 53403, 55447, 55448, 55787
r=blake, a=hyatt
2006-05-17 06:28:26 +04:00
|
|
|
var queuedTag;
|
2006-05-17 06:37:22 +04:00
|
|
|
|
2006-05-17 06:24:52 +04:00
|
|
|
function initPanel ( aPrefTag )
|
|
|
|
{
|
|
|
|
if( hPrefWindow )
|
Bookmarks Window Updates, includes fixes for
27495, 38004, 42080, 43146, 43753, 47494, 50835, 53403, 55447, 55448, 55787
r=blake, a=hyatt
2006-05-17 06:28:26 +04:00
|
|
|
hPrefWindow.onpageload( aPrefTag )
|
2006-05-17 06:27:43 +04:00
|
|
|
else
|
Bookmarks Window Updates, includes fixes for
27495, 38004, 42080, 43146, 43753, 47494, 50835, 53403, 55447, 55448, 55787
r=blake, a=hyatt
2006-05-17 06:28:26 +04:00
|
|
|
queuedTag = aPrefTag;
|
2006-05-17 06:24:52 +04:00
|
|
|
}
|
2006-05-17 06:37:22 +04:00
|
|
|
|
|
|
|
function onLoad()
|
|
|
|
{
|
|
|
|
hPrefWindow = new nsPrefWindow('panelFrame');
|
|
|
|
|
|
|
|
if (!hPrefWindow)
|
|
|
|
throw "failed to create prefwindow";
|
|
|
|
else
|
|
|
|
hPrefWindow.init();
|
|
|
|
}
|
|
|
|
|
2006-05-17 06:24:52 +04:00
|
|
|
function nsPrefWindow( frame_id )
|
|
|
|
{
|
|
|
|
if ( !frame_id )
|
|
|
|
throw "Error: frame_id not supplied!";
|
|
|
|
|
|
|
|
this.contentFrame = frame_id
|
|
|
|
this.wsm = new nsWidgetStateManager( frame_id );
|
2006-05-17 06:39:17 +04:00
|
|
|
this.wsm.attributes = ["preftype", "prefstring", "prefattribute", "disabled"];
|
2006-05-17 06:24:52 +04:00
|
|
|
this.pref = null;
|
2006-05-17 06:34:54 +04:00
|
|
|
this.chromeRegistry = null;
|
|
|
|
this.observerService= null;
|
2006-05-17 06:24:52 +04:00
|
|
|
|
|
|
|
this.cancelHandlers = [];
|
|
|
|
this.okHandlers = [];
|
2006-05-17 06:35:46 +04:00
|
|
|
|
|
|
|
// if there is a system pref switch
|
|
|
|
this.pagePrefChanged = false;
|
|
|
|
// the set of pages, which are updated after a system pref switch
|
|
|
|
this.pagePrefUpdated = [];
|
|
|
|
|
2006-05-17 06:24:52 +04:00
|
|
|
// set up window
|
|
|
|
this.onload();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsPrefWindow.prototype =
|
|
|
|
{
|
|
|
|
onload:
|
|
|
|
function ()
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2006-05-17 06:37:23 +04:00
|
|
|
this.pref = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch(null);
|
2006-05-17 06:39:19 +04:00
|
|
|
this.chromeRegistry = Components.classes["@mozilla.org/chrome/chrome-registry;1"].getService(Components.interfaces.nsIChromeRegistrySea);
|
2006-05-17 06:34:54 +04:00
|
|
|
this.observerService = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
|
2006-05-17 06:24:52 +04:00
|
|
|
}
|
|
|
|
catch(e)
|
|
|
|
{
|
|
|
|
dump("*** Failed to create prefs object\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2006-05-17 06:25:12 +04:00
|
|
|
init:
|
|
|
|
function ()
|
|
|
|
{
|
|
|
|
if( window.queuedTag )
|
|
|
|
this.onpageload( window.queuedTag );
|
|
|
|
|
|
|
|
if( window.arguments[1] )
|
2006-05-17 06:34:16 +04:00
|
|
|
this.openBranch( window.arguments[1], window.arguments[2] );
|
2006-05-17 06:25:12 +04:00
|
|
|
},
|
|
|
|
|
2006-05-17 06:37:22 +04:00
|
|
|
onAccept:
|
2006-05-17 06:24:52 +04:00
|
|
|
function ()
|
|
|
|
{
|
|
|
|
var tag = document.getElementById( hPrefWindow.contentFrame ).getAttribute("tag");
|
|
|
|
if( tag == "" )
|
|
|
|
tag = document.getElementById( hPrefWindow.contentFrame ).getAttribute("src");
|
|
|
|
hPrefWindow.wsm.savePageData( tag );
|
2006-05-17 06:34:52 +04:00
|
|
|
for( var i = 0; i < hPrefWindow.okHandlers.length; i++ )
|
2006-05-17 06:34:53 +04:00
|
|
|
try {
|
2006-05-17 06:34:52 +04:00
|
|
|
hPrefWindow.okHandlers[i]();
|
2006-05-17 06:34:53 +04:00
|
|
|
} catch (e) {
|
2006-05-17 06:34:55 +04:00
|
|
|
dump("some silly ok handler /*"+hPrefWindow.okHandlers[i]+"*/ failed: "+ e);
|
2006-05-17 06:34:52 +04:00
|
|
|
}
|
2006-05-17 06:24:52 +04:00
|
|
|
hPrefWindow.savePrefs();
|
2006-05-17 06:37:22 +04:00
|
|
|
|
|
|
|
return true;
|
2006-05-17 06:24:52 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
onCancel:
|
|
|
|
function ()
|
|
|
|
{
|
|
|
|
for( var i = 0; i < hPrefWindow.cancelHandlers.length; i++ )
|
2006-05-17 06:34:53 +04:00
|
|
|
try {
|
2006-05-17 06:24:52 +04:00
|
|
|
hPrefWindow.cancelHandlers[i]();
|
2006-05-17 06:34:53 +04:00
|
|
|
} catch (e) {
|
2006-05-17 06:34:55 +04:00
|
|
|
dump("some silly cancel handler /*"+hPrefWindow.cancelHandlers[i]+"*/ failed: "+ e);
|
2006-05-17 06:24:52 +04:00
|
|
|
}
|
2006-05-17 06:37:22 +04:00
|
|
|
|
|
|
|
return true;
|
2006-05-17 06:24:52 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
registerOKCallbackFunc:
|
|
|
|
function ( aFunctionReference )
|
|
|
|
{
|
|
|
|
this.okHandlers[this.okHandlers.length] = aFunctionReference;
|
|
|
|
},
|
|
|
|
|
|
|
|
registerCancelCallbackFunc:
|
|
|
|
function ( aFunctionReference )
|
|
|
|
{
|
|
|
|
this.cancelHandlers[this.cancelHandlers.length] = aFunctionReference;
|
|
|
|
},
|
2006-05-17 06:28:27 +04:00
|
|
|
getPrefIsLocked:
|
|
|
|
function ( aPrefString )
|
|
|
|
{
|
2006-05-17 06:37:23 +04:00
|
|
|
return this.pref.prefIsLocked(aPrefString);
|
2006-05-17 06:28:27 +04:00
|
|
|
},
|
2006-05-17 06:24:52 +04:00
|
|
|
getPref:
|
2006-05-17 06:37:23 +04:00
|
|
|
function ( aPrefType, aPrefString )
|
2006-05-17 06:24:52 +04:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
switch ( aPrefType )
|
|
|
|
{
|
|
|
|
case "bool":
|
2006-05-17 06:37:23 +04:00
|
|
|
return this.pref.getBoolPref( aPrefString );
|
2006-05-17 06:24:52 +04:00
|
|
|
case "int":
|
2006-05-17 06:37:23 +04:00
|
|
|
return this.pref.getIntPref( aPrefString );
|
2006-05-17 06:39:47 +04:00
|
|
|
case "localfile":
|
|
|
|
return this.pref.getComplexValue( aPrefString, Components.interfaces.nsILocalFile);
|
2006-05-17 06:28:32 +04:00
|
|
|
case "localizedstring":
|
2006-05-17 06:37:23 +04:00
|
|
|
return this.pref.getComplexValue( aPrefString, Components.interfaces.nsIPrefLocalizedString ).data;
|
2006-05-17 06:24:52 +04:00
|
|
|
case "color":
|
|
|
|
case "string":
|
|
|
|
default:
|
2006-05-17 06:37:23 +04:00
|
|
|
return this.pref.getComplexValue( aPrefString, Components.interfaces.nsISupportsString ).data;
|
2006-05-17 06:24:52 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (e)
|
|
|
|
{
|
|
|
|
if( _DEBUG )
|
|
|
|
{
|
|
|
|
dump("*** no default pref for " + aPrefType + " pref: " + aPrefString + "\n");
|
|
|
|
dump(e + "\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return "!/!ERROR_UNDEFINED_PREF!/!";
|
|
|
|
} ,
|
|
|
|
|
|
|
|
setPref:
|
|
|
|
function ( aPrefType, aPrefString, aValue )
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
switch ( aPrefType )
|
|
|
|
{
|
|
|
|
case "bool":
|
2006-05-17 06:37:23 +04:00
|
|
|
this.pref.setBoolPref( aPrefString, aValue );
|
2006-05-17 06:24:52 +04:00
|
|
|
break;
|
|
|
|
case "int":
|
2006-05-17 06:37:23 +04:00
|
|
|
this.pref.setIntPref( aPrefString, aValue );
|
2006-05-17 06:24:52 +04:00
|
|
|
break;
|
2006-05-17 06:39:47 +04:00
|
|
|
case "localfile":
|
|
|
|
this.pref.setComplexValue( aPrefString, Components.interfaces.nsILocalFile, aValue );
|
|
|
|
break;
|
2006-05-17 06:24:52 +04:00
|
|
|
case "color":
|
|
|
|
case "string":
|
2006-05-17 06:28:32 +04:00
|
|
|
case "localizedstring":
|
2006-05-17 06:24:52 +04:00
|
|
|
default:
|
2006-05-17 06:37:23 +04:00
|
|
|
var supportsString = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
|
|
|
|
supportsString.data = aValue;
|
|
|
|
this.pref.setComplexValue( aPrefString, Components.interfaces.nsISupportsString, supportsString );
|
2006-05-17 06:24:52 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (e)
|
|
|
|
{
|
|
|
|
dump(e + "\n");
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
savePrefs:
|
|
|
|
function ()
|
|
|
|
{
|
|
|
|
for( var pageTag in this.wsm.dataManager.pageData )
|
|
|
|
{
|
|
|
|
var pageData = this.wsm.dataManager.getPageData( pageTag );
|
2006-05-17 06:34:37 +04:00
|
|
|
if ("initialized" in pageData && pageData.initialized)
|
2006-05-17 06:28:31 +04:00
|
|
|
{
|
2006-07-01 16:19:53 +04:00
|
|
|
if ( "elementIDs" in pageData )
|
|
|
|
pageData = pageData.elementIDs;
|
2006-05-17 06:24:52 +04:00
|
|
|
for( var elementID in pageData )
|
|
|
|
{
|
2006-05-17 06:31:51 +04:00
|
|
|
if (elementID == "initialized") continue;
|
2006-05-17 06:24:52 +04:00
|
|
|
var itemObject = pageData[elementID];
|
2006-05-17 06:31:52 +04:00
|
|
|
if (typeof(itemObject) != "object") break;
|
2006-05-17 06:31:51 +04:00
|
|
|
if ( "prefstring" in itemObject && itemObject.prefstring )
|
2006-05-17 06:24:52 +04:00
|
|
|
{
|
107642 - XUL syntax/cleanup landing. Fixes 94470, 96008, 96019, 76800, 102637, 80399, 108303, and removes over a thousand unnecessary or nonsensical attributes. Also fixes 108302, 102366, 102367, 105815. r=sspitzer,cmanske on appropriate parts sr=ben
2006-05-17 06:31:28 +04:00
|
|
|
var elt = itemObject.localname;
|
|
|
|
var prefattribute = itemObject.prefattribute;
|
|
|
|
if (!prefattribute) {
|
|
|
|
if (elt == "radiogroup" || elt == "textbox" || elt == "menulist")
|
|
|
|
prefattribute = "value";
|
2006-05-17 06:36:52 +04:00
|
|
|
else if (elt == "checkbox" || elt == "listitem")
|
107642 - XUL syntax/cleanup landing. Fixes 94470, 96008, 96019, 76800, 102637, 80399, 108303, and removes over a thousand unnecessary or nonsensical attributes. Also fixes 108302, 102366, 102367, 105815. r=sspitzer,cmanske on appropriate parts sr=ben
2006-05-17 06:31:28 +04:00
|
|
|
prefattribute = "checked";
|
2006-05-17 06:39:22 +04:00
|
|
|
else if (elt == "colorpicker")
|
|
|
|
prefattribute = "color";
|
107642 - XUL syntax/cleanup landing. Fixes 94470, 96008, 96019, 76800, 102637, 80399, 108303, and removes over a thousand unnecessary or nonsensical attributes. Also fixes 108302, 102366, 102367, 105815. r=sspitzer,cmanske on appropriate parts sr=ben
2006-05-17 06:31:28 +04:00
|
|
|
else if (elt == "button")
|
|
|
|
prefattribute = "disabled";
|
|
|
|
}
|
|
|
|
|
|
|
|
var value = itemObject[prefattribute];
|
|
|
|
var preftype = itemObject.preftype;
|
|
|
|
if (!preftype) {
|
2006-05-17 06:39:22 +04:00
|
|
|
if (elt == "textbox" || elt == "colorpicker")
|
107642 - XUL syntax/cleanup landing. Fixes 94470, 96008, 96019, 76800, 102637, 80399, 108303, and removes over a thousand unnecessary or nonsensical attributes. Also fixes 108302, 102366, 102367, 105815. r=sspitzer,cmanske on appropriate parts sr=ben
2006-05-17 06:31:28 +04:00
|
|
|
preftype = "string";
|
2006-05-17 06:36:52 +04:00
|
|
|
else if (elt == "checkbox" || elt == "listitem" || elt == "button")
|
107642 - XUL syntax/cleanup landing. Fixes 94470, 96008, 96019, 76800, 102637, 80399, 108303, and removes over a thousand unnecessary or nonsensical attributes. Also fixes 108302, 102366, 102367, 105815. r=sspitzer,cmanske on appropriate parts sr=ben
2006-05-17 06:31:28 +04:00
|
|
|
preftype = "bool";
|
2006-05-17 06:31:30 +04:00
|
|
|
else if (elt == "radiogroup" || elt == "menulist")
|
107642 - XUL syntax/cleanup landing. Fixes 94470, 96008, 96019, 76800, 102637, 80399, 108303, and removes over a thousand unnecessary or nonsensical attributes. Also fixes 108302, 102366, 102367, 105815. r=sspitzer,cmanske on appropriate parts sr=ben
2006-05-17 06:31:28 +04:00
|
|
|
preftype = "int";
|
|
|
|
}
|
|
|
|
switch( preftype )
|
2006-05-17 06:24:52 +04:00
|
|
|
{
|
|
|
|
case "bool":
|
|
|
|
if( value == "true" && typeof(value) == "string" )
|
|
|
|
value = true;
|
|
|
|
else if( value == "false" && typeof(value) == "string" )
|
|
|
|
value = false;
|
|
|
|
break;
|
|
|
|
case "int":
|
2006-05-17 06:36:55 +04:00
|
|
|
value = parseInt(value, 10);
|
2006-05-17 06:24:52 +04:00
|
|
|
break;
|
|
|
|
case "color":
|
|
|
|
if( toString(value) == "" )
|
|
|
|
{
|
|
|
|
dump("*** ERROR CASE: illegal attempt to set an empty color pref. ignoring.\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case "string":
|
2006-05-17 06:28:32 +04:00
|
|
|
case "localizedstring":
|
2006-05-17 06:24:52 +04:00
|
|
|
default:
|
|
|
|
if( typeof(value) != "string" )
|
|
|
|
value = toString(value);
|
|
|
|
break;
|
|
|
|
}
|
107642 - XUL syntax/cleanup landing. Fixes 94470, 96008, 96019, 76800, 102637, 80399, 108303, and removes over a thousand unnecessary or nonsensical attributes. Also fixes 108302, 102366, 102367, 105815. r=sspitzer,cmanske on appropriate parts sr=ben
2006-05-17 06:31:28 +04:00
|
|
|
|
2006-05-17 06:35:46 +04:00
|
|
|
// the pref is not saved, if the pref value is not
|
|
|
|
// changed or the pref is locked.
|
|
|
|
if( !this.getPrefIsLocked(itemObject.prefstring) &&
|
|
|
|
(value != this.getPref( preftype, itemObject.prefstring)))
|
107642 - XUL syntax/cleanup landing. Fixes 94470, 96008, 96019, 76800, 102637, 80399, 108303, and removes over a thousand unnecessary or nonsensical attributes. Also fixes 108302, 102366, 102367, 105815. r=sspitzer,cmanske on appropriate parts sr=ben
2006-05-17 06:31:28 +04:00
|
|
|
this.setPref( preftype, itemObject.prefstring, value );
|
2006-05-17 06:24:52 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-05-17 06:28:31 +04:00
|
|
|
}
|
2006-05-17 06:34:23 +04:00
|
|
|
try
|
|
|
|
{
|
2006-05-17 06:37:23 +04:00
|
|
|
Components.classes["@mozilla.org/preferences-service;1"]
|
|
|
|
.getService(Components.interfaces.nsIPrefService)
|
|
|
|
.savePrefFile(null);
|
2006-05-17 06:34:23 +04:00
|
|
|
}
|
|
|
|
catch (e)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
var prefUtilBundle = document.getElementById("bundle_prefutilities");
|
|
|
|
var alertText = prefUtilBundle.getString("prefSaveFailedAlert");
|
|
|
|
var titleText = prefUtilBundle.getString("prefSaveFailedTitle");
|
|
|
|
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
|
|
|
|
.getService(Components.interfaces.nsIPromptService);
|
|
|
|
promptService.alert(window, titleText, alertText);
|
|
|
|
}
|
|
|
|
catch (e)
|
|
|
|
{
|
|
|
|
dump(e + "\n");
|
|
|
|
}
|
|
|
|
}
|
2006-05-17 06:24:52 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
switchPage:
|
|
|
|
function ()
|
|
|
|
{
|
|
|
|
var prefPanelTree = document.getElementById( "prefsTree" );
|
2006-05-17 06:34:13 +04:00
|
|
|
var selectedItem = prefPanelTree.contentView.getItemAtIndex(prefPanelTree.currentIndex);
|
2006-05-17 06:24:52 +04:00
|
|
|
|
|
|
|
var oldURL = document.getElementById( this.contentFrame ).getAttribute("tag");
|
|
|
|
if( !oldURL )
|
|
|
|
oldURL = document.getElementById( this.contentFrame ).getAttribute("src");
|
|
|
|
this.wsm.savePageData( oldURL ); // save data from the current page.
|
|
|
|
var newURL = selectedItem.firstChild.firstChild.getAttribute("url");
|
|
|
|
var newTag = selectedItem.firstChild.firstChild.getAttribute("tag");
|
|
|
|
if( newURL != oldURL )
|
|
|
|
{
|
|
|
|
document.getElementById( this.contentFrame ).setAttribute( "src", newURL );
|
|
|
|
if( !newTag )
|
2006-05-17 06:25:16 +04:00
|
|
|
document.getElementById( this.contentFrame ).removeAttribute( "tag" );
|
|
|
|
else
|
|
|
|
document.getElementById( this.contentFrame ).setAttribute( "tag", newTag );
|
2006-05-17 06:24:52 +04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
onpageload:
|
|
|
|
function ( aPageTag )
|
|
|
|
{
|
2006-05-17 06:31:51 +04:00
|
|
|
var header = document.getElementById("header");
|
|
|
|
header.setAttribute("title",
|
|
|
|
window.frames[this.contentFrame].document.documentElement.getAttribute("headertitle"));
|
2006-05-17 06:35:46 +04:00
|
|
|
|
|
|
|
// update widgets states when it is first loaded, or there are
|
|
|
|
// system pref switch. (i.e., to refect the changed lock status).
|
|
|
|
if(!(aPageTag in this.wsm.dataManager.pageData) ||
|
|
|
|
(this.pagePrefChanged && (!(aPageTag in this.pagePrefUpdated))))
|
2006-05-17 06:24:52 +04:00
|
|
|
{
|
107642 - XUL syntax/cleanup landing. Fixes 94470, 96008, 96019, 76800, 102637, 80399, 108303, and removes over a thousand unnecessary or nonsensical attributes. Also fixes 108302, 102366, 102367, 105815. r=sspitzer,cmanske on appropriate parts sr=ben
2006-05-17 06:31:28 +04:00
|
|
|
var prefElements = window.frames[this.contentFrame].document.getElementsByAttribute( "prefstring", "*" );
|
2006-05-17 06:35:46 +04:00
|
|
|
if (this.pagePrefChanged)
|
|
|
|
this.pagePrefUpdated[aPageTag] = [];
|
2006-07-01 16:19:53 +04:00
|
|
|
this.wsm.dataManager.getPageData( aPageTag );
|
2006-05-17 06:24:52 +04:00
|
|
|
for( var i = 0; i < prefElements.length; i++ )
|
|
|
|
{
|
|
|
|
var prefstring = prefElements[i].getAttribute( "prefstring" );
|
|
|
|
var prefid = prefElements[i].getAttribute( "id" );
|
|
|
|
var preftype = prefElements[i].getAttribute( "preftype" );
|
107642 - XUL syntax/cleanup landing. Fixes 94470, 96008, 96019, 76800, 102637, 80399, 108303, and removes over a thousand unnecessary or nonsensical attributes. Also fixes 108302, 102366, 102367, 105815. r=sspitzer,cmanske on appropriate parts sr=ben
2006-05-17 06:31:28 +04:00
|
|
|
var elt = prefElements[i].localName;
|
|
|
|
if (!preftype) {
|
2006-05-17 06:39:22 +04:00
|
|
|
if (elt == "textbox" || elt == "colorpicker")
|
107642 - XUL syntax/cleanup landing. Fixes 94470, 96008, 96019, 76800, 102637, 80399, 108303, and removes over a thousand unnecessary or nonsensical attributes. Also fixes 108302, 102366, 102367, 105815. r=sspitzer,cmanske on appropriate parts sr=ben
2006-05-17 06:31:28 +04:00
|
|
|
preftype = "string";
|
2006-05-17 06:36:52 +04:00
|
|
|
else if (elt == "checkbox" || elt == "listitem" || elt == "button")
|
107642 - XUL syntax/cleanup landing. Fixes 94470, 96008, 96019, 76800, 102637, 80399, 108303, and removes over a thousand unnecessary or nonsensical attributes. Also fixes 108302, 102366, 102367, 105815. r=sspitzer,cmanske on appropriate parts sr=ben
2006-05-17 06:31:28 +04:00
|
|
|
preftype = "bool";
|
2006-05-17 06:31:29 +04:00
|
|
|
else if (elt == "radiogroup" || elt == "menulist")
|
107642 - XUL syntax/cleanup landing. Fixes 94470, 96008, 96019, 76800, 102637, 80399, 108303, and removes over a thousand unnecessary or nonsensical attributes. Also fixes 108302, 102366, 102367, 105815. r=sspitzer,cmanske on appropriate parts sr=ben
2006-05-17 06:31:28 +04:00
|
|
|
preftype = "int";
|
|
|
|
}
|
2006-05-17 06:24:52 +04:00
|
|
|
var prefdefval = prefElements[i].getAttribute( "prefdefval" );
|
|
|
|
var prefattribute = prefElements[i].getAttribute( "prefattribute" );
|
107642 - XUL syntax/cleanup landing. Fixes 94470, 96008, 96019, 76800, 102637, 80399, 108303, and removes over a thousand unnecessary or nonsensical attributes. Also fixes 108302, 102366, 102367, 105815. r=sspitzer,cmanske on appropriate parts sr=ben
2006-05-17 06:31:28 +04:00
|
|
|
if (!prefattribute) {
|
|
|
|
if (elt == "radiogroup" || elt == "textbox" || elt == "menulist")
|
|
|
|
prefattribute = "value";
|
2006-05-17 06:36:52 +04:00
|
|
|
else if (elt == "checkbox" || elt == "listitem")
|
107642 - XUL syntax/cleanup landing. Fixes 94470, 96008, 96019, 76800, 102637, 80399, 108303, and removes over a thousand unnecessary or nonsensical attributes. Also fixes 108302, 102366, 102367, 105815. r=sspitzer,cmanske on appropriate parts sr=ben
2006-05-17 06:31:28 +04:00
|
|
|
prefattribute = "checked";
|
2006-05-17 06:39:22 +04:00
|
|
|
else if (elt == "colorpicker")
|
|
|
|
prefattribute = "color";
|
107642 - XUL syntax/cleanup landing. Fixes 94470, 96008, 96019, 76800, 102637, 80399, 108303, and removes over a thousand unnecessary or nonsensical attributes. Also fixes 108302, 102366, 102367, 105815. r=sspitzer,cmanske on appropriate parts sr=ben
2006-05-17 06:31:28 +04:00
|
|
|
else if (elt == "button")
|
|
|
|
prefattribute = "disabled";
|
|
|
|
}
|
2006-05-17 06:36:52 +04:00
|
|
|
var prefvalue = this.getPref( preftype, prefstring );
|
2006-05-17 06:24:52 +04:00
|
|
|
if( prefvalue == "!/!ERROR_UNDEFINED_PREF!/!" )
|
|
|
|
prefvalue = prefdefval;
|
|
|
|
var root = this.wsm.dataManager.getItemData( aPageTag, prefid );
|
|
|
|
root[prefattribute] = prefvalue;
|
2006-05-17 06:28:27 +04:00
|
|
|
var isPrefLocked = this.getPrefIsLocked(prefstring);
|
|
|
|
if (isPrefLocked)
|
2006-05-17 06:31:51 +04:00
|
|
|
root.disabled = "true";
|
107642 - XUL syntax/cleanup landing. Fixes 94470, 96008, 96019, 76800, 102637, 80399, 108303, and removes over a thousand unnecessary or nonsensical attributes. Also fixes 108302, 102366, 102367, 105815. r=sspitzer,cmanske on appropriate parts sr=ben
2006-05-17 06:31:28 +04:00
|
|
|
root.localname = prefElements[i].localName;
|
2006-05-17 06:24:52 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
this.wsm.setPageData( aPageTag ); // do not set extra elements, accept hard coded defaults
|
|
|
|
|
2006-05-17 06:27:42 +04:00
|
|
|
if( 'Startup' in window.frames[ this.contentFrame ])
|
2006-05-17 06:24:52 +04:00
|
|
|
window.frames[ this.contentFrame ].Startup();
|
2006-05-17 06:37:22 +04:00
|
|
|
|
2006-05-17 06:28:31 +04:00
|
|
|
this.wsm.dataManager.pageData[aPageTag].initialized=true;
|
2006-05-17 06:24:52 +04:00
|
|
|
},
|
|
|
|
|
2006-05-17 06:34:16 +04:00
|
|
|
openBranch:
|
Bookmarks Window Updates, includes fixes for
27495, 38004, 42080, 43146, 43753, 47494, 50835, 53403, 55447, 55448, 55787
r=blake, a=hyatt
2006-05-17 06:28:26 +04:00
|
|
|
function ( aComponentName, aSelectItem )
|
2006-05-17 06:24:52 +04:00
|
|
|
{
|
|
|
|
var panelTree = document.getElementById( "prefsTree" );
|
2006-05-17 06:34:16 +04:00
|
|
|
var selectItem = document.getElementById( aSelectItem );
|
2006-05-17 06:34:38 +04:00
|
|
|
var selectItemroot = document.getElementById( aComponentName );
|
|
|
|
var parentIndex = panelTree.contentView.getIndexOfItem( selectItemroot );
|
|
|
|
if (parentIndex != -1 && !panelTree.view.isContainerOpen(parentIndex))
|
|
|
|
panelTree.view.toggleOpenState(parentIndex);
|
|
|
|
var index = panelTree.view.getIndexOfItem( selectItem );
|
|
|
|
if (index == -1)
|
|
|
|
return;
|
2006-05-17 06:38:29 +04:00
|
|
|
panelTree.view.selection.select( index );
|
2006-05-17 06:27:44 +04:00
|
|
|
}
|
2006-05-17 06:24:52 +04:00
|
|
|
|
|
|
|
};
|