mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 03:45:46 +00:00
Bug 228904 Preference panel load event handling cleanup p=gautheri@noos.fr r=me sr=alecf
This commit is contained in:
parent
26dc5d8c08
commit
12b0dce117
@ -27,7 +27,9 @@ const _DEBUG = false;
|
||||
* =>> CHANGES MUST BE REVIEWED BY ben@netscape.com!! <<=
|
||||
**/
|
||||
|
||||
var hPrefWindow = null;
|
||||
var queuedTag;
|
||||
|
||||
function initPanel ( aPrefTag )
|
||||
{
|
||||
if( hPrefWindow )
|
||||
@ -35,9 +37,17 @@ function initPanel ( aPrefTag )
|
||||
else
|
||||
queuedTag = aPrefTag;
|
||||
}
|
||||
|
||||
window.doneLoading = false;
|
||||
|
||||
|
||||
function onLoad()
|
||||
{
|
||||
hPrefWindow = new nsPrefWindow('panelFrame');
|
||||
|
||||
if (!hPrefWindow)
|
||||
throw "failed to create prefwindow";
|
||||
else
|
||||
hPrefWindow.init();
|
||||
}
|
||||
|
||||
function nsPrefWindow( frame_id )
|
||||
{
|
||||
if ( !frame_id )
|
||||
@ -84,22 +94,18 @@ nsPrefWindow.prototype =
|
||||
function ()
|
||||
{
|
||||
if( window.queuedTag )
|
||||
{
|
||||
this.onpageload( window.queuedTag );
|
||||
}
|
||||
|
||||
if( window.arguments[1] )
|
||||
this.openBranch( window.arguments[1], window.arguments[2] );
|
||||
},
|
||||
|
||||
onOK:
|
||||
onAccept:
|
||||
function ()
|
||||
{
|
||||
var tag = document.getElementById( hPrefWindow.contentFrame ).getAttribute("tag");
|
||||
if( tag == "" )
|
||||
{
|
||||
tag = document.getElementById( hPrefWindow.contentFrame ).getAttribute("src");
|
||||
}
|
||||
hPrefWindow.wsm.savePageData( tag );
|
||||
for( var i = 0; i < hPrefWindow.okHandlers.length; i++ )
|
||||
try {
|
||||
@ -108,6 +114,8 @@ nsPrefWindow.prototype =
|
||||
dump("some silly ok handler /*"+hPrefWindow.okHandlers[i]+"*/ failed: "+ e);
|
||||
}
|
||||
hPrefWindow.savePrefs();
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
onCancel:
|
||||
@ -119,6 +127,8 @@ nsPrefWindow.prototype =
|
||||
} catch (e) {
|
||||
dump("some silly cancel handler /*"+hPrefWindow.cancelHandlers[i]+"*/ failed: "+ e);
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
registerOKCallbackFunc:
|
||||
@ -254,9 +264,7 @@ nsPrefWindow.prototype =
|
||||
case "localizedstring":
|
||||
default:
|
||||
if( typeof(value) != "string" )
|
||||
{
|
||||
value = toString(value);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@ -264,9 +272,7 @@ nsPrefWindow.prototype =
|
||||
// changed or the pref is locked.
|
||||
if( !this.getPrefIsLocked(itemObject.prefstring) &&
|
||||
(value != this.getPref( preftype, itemObject.prefstring)))
|
||||
{
|
||||
this.setPref( preftype, itemObject.prefstring, value );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -301,9 +307,7 @@ nsPrefWindow.prototype =
|
||||
|
||||
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");
|
||||
@ -359,9 +363,7 @@ nsPrefWindow.prototype =
|
||||
}
|
||||
var prefvalue = this.getPref( preftype, prefstring );
|
||||
if( prefvalue == "!/!ERROR_UNDEFINED_PREF!/!" )
|
||||
{
|
||||
prefvalue = prefdefval;
|
||||
}
|
||||
var root = this.wsm.dataManager.getItemData( aPageTag, prefid );
|
||||
root[prefattribute] = prefvalue;
|
||||
var isPrefLocked = this.getPrefIsLocked(prefstring);
|
||||
@ -378,9 +380,8 @@ nsPrefWindow.prototype =
|
||||
this.wsm.setPageData( aPageTag ); // do not set extra elements, accept hard coded defaults
|
||||
|
||||
if( 'Startup' in window.frames[ this.contentFrame ])
|
||||
{
|
||||
window.frames[ this.contentFrame ].Startup();
|
||||
}
|
||||
|
||||
this.wsm.dataManager.pageData[aPageTag].initialized=true;
|
||||
},
|
||||
|
||||
@ -400,4 +401,3 @@ nsPrefWindow.prototype =
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
@ -33,7 +33,7 @@
|
||||
|
||||
<page xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
xmlns:html="http://www.w3.org/1999/xhtml"
|
||||
onload="parent.initPanel('chrome://communicator/content/pref/pref-themes.xul'); Startup()"
|
||||
onload="parent.initPanel('chrome://communicator/content/pref/pref-themes.xul');"
|
||||
headertitle="&lHeader;">
|
||||
|
||||
<stringbundle id="bundle_prefutilities"
|
||||
|
@ -18,38 +18,12 @@
|
||||
style="&prefWindow.size;"
|
||||
windowtype="mozilla:preferences"
|
||||
buttons="accept,cancel,help"
|
||||
onload="Startup();"
|
||||
ondialogaccept="return hPrefWindow.onOK(event);"
|
||||
ondialogcancel="return hPrefWindow.onCancel(event);"
|
||||
ondialoghelp="return doHelpButton(event)"
|
||||
onload="onLoad();"
|
||||
ondialogaccept="return hPrefWindow.onAccept();"
|
||||
ondialogcancel="return hPrefWindow.onCancel();"
|
||||
ondialoghelp="doHelpButton();"
|
||||
persist="screenX screenY">
|
||||
|
||||
<script>
|
||||
<![CDATA[
|
||||
|
||||
var hPrefWindow = null;
|
||||
|
||||
/** General startup routine for preferences dialog.
|
||||
* Place all necessary modifications to pref tree here.
|
||||
**/
|
||||
function Startup()
|
||||
{
|
||||
hPrefWindow = new nsPrefWindow('panelFrame');
|
||||
|
||||
if( !hPrefWindow )
|
||||
throw "failed to create prefwindow";
|
||||
|
||||
hPrefWindow.init();
|
||||
|
||||
// If this call worked, we could center the window here:
|
||||
// centerWindowOnScreen();
|
||||
|
||||
}
|
||||
|
||||
]]>
|
||||
|
||||
</script>
|
||||
|
||||
<stringbundle id="bundle_prefutilities"
|
||||
src="chrome://communicator/locale/pref/prefutilities.properties"/>
|
||||
<script type="application/x-javascript" src="chrome://global/content/nsWidgetStateManager.js"/>
|
||||
@ -81,5 +55,5 @@
|
||||
}
|
||||
]]>
|
||||
</script>
|
||||
|
||||
|
||||
</dialog>
|
||||
|
Loading…
Reference in New Issue
Block a user