Bug 314551. Click window.close does pref Sync with preferences service.

This commit is contained in:
mgalli%geckonnection.com 2005-10-31 21:33:43 +00:00
Родитель 96189fedde
Коммит 21334989ec
2 изменённых файлов: 35 добавлений и 24 удалений

Просмотреть файл

@ -78,6 +78,8 @@ function sanitizeAll()
* ===================================================================================
*/
var gPrefQueue=new Array();
var gCancelSync=false;
var gPaneSelected=null;
var gToolbarButtonSelected=null;
var gPrefArray=null;
@ -111,6 +113,16 @@ function prefStartup() {
}
/*
* This is called with onclose onunload event
* This may be canceled if user clicks cancel
*/
function prefShutdown() {
if(!gCancelSync) {
syncPrefSaveDOM();
}
}
/* General Access keyboard handler */
function keyInitHandler() {
@ -154,7 +166,7 @@ function eventHandlerMenu(e) {
var outnavTarget=document.commandDispatcher.focusedElement.getAttribute("accessrule");
if(!outnavTarget && (e.keyCode==40||e.keyCode==38)) {
e.preventDefault();
e.preventDefault();
if(e.keyCode==38) {
document.commandDispatcher.rewindFocus();
}
@ -207,8 +219,6 @@ function findRuleById(outnavTarget,ruleattribute) {
* and sync with pref service.
*/
var gPrefQueue=new Array();
function syncPref(refElement) {
var refElementPref=refElement.getAttribute("preference");
if(refElementPref!="") {
@ -219,10 +229,24 @@ function syncPref(refElement) {
/*
* OKAY Sync with prefService
* Okay, just close the window with sync mode.
*/
function PrefOkay() {
window.close();
}
/*
* Cancel, close window but do not sync.
*/
function PrefCancel() {
gCancelSync=true;
window.close();
}
function syncPrefSaveDOM() {
for(var strCurKey in gPrefQueue) {
var elRef=gPrefQueue[strCurKey];
@ -231,16 +255,14 @@ function PrefOkay() {
var prefSETValue=null;
if(transValidator!="") {
prefSETValue=eval(transValidator);
} else {
// Checkbox is always true so far. XUL spec says it should flip value property based on checkbox state.
// The following conditional chunk may be considered workaround code - bug 314538
} else {
if(elRef.nodeName=="checkbox") {
if(elRef.checked) {
elRef.value=true;
} else {
elRef.value=false;
}
if(elRef.checked) {
elRef.value=true;
} else {
elRef.value=false;
}
}
prefSETValue=elRef.value;
}
@ -256,19 +278,8 @@ function PrefOkay() {
gPref.setBoolPref(prefName, prefSETValue);
}
}
window.close();
}
/*
* Cancel - nothing to do, close window
*/
function PrefCancel() {
window.close();
}
function syncPrefLoadDOM(elementList) {
for(var strCurKey in elementList) {

Просмотреть файл

@ -62,7 +62,7 @@
windowtype="Browser:page-preferences-mini"
title="Minimo Preferences"
onload="prefStartup()"
onunload="" >
onunload="prefShutdown()" >
<script type="application/x-javascript" src="chrome://minimo/content/preferences/preferences.js"/>
<script type="application/x-javascript" src="chrome://minimo/content/common.js"/>