* Wire up button disabling in the new UI; user feedback during synchronous API calls.

Cette révision appartient à :
Anthony Lieuallen 2008-04-30 00:59:23 +00:00
Parent 2d0422d5bb
révision b46d54453b
2 fichiers modifiés avec 27 ajouts et 18 suppressions

Voir le fichier

@ -6,6 +6,7 @@
<dialog id="resurrect-select-mirror" <dialog id="resurrect-select-mirror"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="&resurrect.title;" title="&resurrect.title;"
buttons="cancel" buttons="cancel"
persist="width height screenX screenY" persist="width height screenX screenY"
@ -23,31 +24,31 @@
<label value='&resurrect.fromMirror;' /> <label value='&resurrect.fromMirror;' />
<vbox id='resurrect' onclick='resurrect.clickedXul(event);'> <vbox id='resurrect' onclick='resurrect.clickedXul(event);'>
<button <xul:button
value='coralcdn' label=' &resurrect.coralcdn;' value='coralcdn' label=' &resurrect.coralcdn;'
image='chrome://resurrect/skin/cacheicons/coralcdn.png' image='chrome://resurrect/skin/cacheicons/coralcdn.png'
/> />
<button <xul:button
value='google' label=' &resurrect.google;' value='google' label=' &resurrect.google;'
image='chrome://resurrect/skin/cacheicons/google.png' image='chrome://resurrect/skin/cacheicons/google.png'
/> />
<button <xul:button
value='googletext' label=' &resurrect.google;&resurrect.textonly;' value='googletext' label=' &resurrect.google;&resurrect.textonly;'
image='chrome://resurrect/skin/cacheicons/google.png' image='chrome://resurrect/skin/cacheicons/google.png'
/> />
<button <xul:button
value='yahoo' label=' &resurrect.yahoo;' value='yahoo' label=' &resurrect.yahoo;'
image='chrome://resurrect/skin/cacheicons/yahoo.png' image='chrome://resurrect/skin/cacheicons/yahoo.png'
/> />
<button <xul:button
value='archive' label=' &resurrect.archive;' value='archive' label=' &resurrect.archive;'
image='chrome://resurrect/skin/cacheicons/archive.png' image='chrome://resurrect/skin/cacheicons/archive.png'
/> />
<button <xul:button
value='msn' label=' &resurrect.msn;' value='msn' label=' &resurrect.msn;'
image='chrome://resurrect/skin/cacheicons/msn.png' image='chrome://resurrect/skin/cacheicons/msn.png'
/> />
<button <xul:button
value='gigablast' label=' &resurrect.gigablast;' value='gigablast' label=' &resurrect.gigablast;'
image='chrome://resurrect/skin/cacheicons/gigablast.png' image='chrome://resurrect/skin/cacheicons/gigablast.png'
/> />

Voir le fichier

@ -1,7 +1,6 @@
var resurrect={ var resurrect={
originalDoc:null, originalDoc:null,
disabled:false,
// // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // //
@ -31,9 +30,9 @@ var resurrect={
}, },
attachClickEvent:function(event) { attachClickEvent:function(event) {
resurrect.disabled=false;
var contentDoc=event.target; var contentDoc=event.target;
var contentWin=contentDoc.defaultView;
if (contentDoc.documentURI.match(/^about:neterror/)) { if (contentDoc.documentURI.match(/^about:neterror/)) {
contentDoc.getElementById('resurrect').addEventListener( contentDoc.getElementById('resurrect').addEventListener(
'click', resurrect.clickedHtml, false 'click', resurrect.clickedHtml, false
@ -41,6 +40,14 @@ var resurrect={
} }
}, },
disableButtons:function(doc) {
var bs=doc.getElementById('resurrect')
.getElementsByTagName('xul:button');
for (var i=0, b=null; b=bs[i]; i++) {
b.setAttribute('disabled', 'true');
}
},
// // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // //
page:function(event) { page:function(event) {
@ -85,10 +92,13 @@ var resurrect={
}, },
clickedHtml:function(event) { clickedHtml:function(event) {
if ('true'==event.target.getAttribute('disabled')) {
return;
}
return resurrect.clickHandler( return resurrect.clickHandler(
event, event,
event.target.ownerDocument, event.target.ownerDocument,
event.target.ownerDocument,
event.target.ownerDocument.location.href event.target.ownerDocument.location.href
); );
}, },
@ -96,20 +106,20 @@ var resurrect={
clickedXul:function(event) { clickedXul:function(event) {
return resurrect.clickHandler( return resurrect.clickHandler(
event, event,
event.target.ownerDocument,
window.arguments[0], window.arguments[0],
window.arguments[1] window.arguments[1]
); );
}, },
clickHandler:function(event, ownerDoc, contentDoc, rawUrl) { clickHandler:function(event, contentDoc, rawUrl) {
if (resurrect.disabled) return; resurrect.disableButtons(event.target.ownerDocument);
resurrect.disabled=true;
// Run the actual code. After timeout for UI repaint. // Run the actual code. After timeout for UI repaint.
setTimeout( setTimeout(
resurrect.selectMirror, 1, resurrect.selectMirror, 1,
event.target.getAttribute('value'), ownerDoc, contentDoc, rawUrl event.target.getAttribute('value'),
event.target.ownerDocument,
contentDoc, rawUrl
); );
}, },
@ -217,8 +227,6 @@ var resurrect={
// setTimeout avoids errors because the window is gone // setTimeout avoids errors because the window is gone
setTimeout(window.close, 0); setTimeout(window.close, 0);
} }
} else {
resurrect.disabled=false;
} }
} }