Created
April 3, 2011 14:05
-
-
Save xulapp/900437 to your computer and use it in GitHub Desktop.
document.loadOverlay
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==uc== | |
// @include * | |
// @exclude chrome://browser/content/preferences/preferences.xul | |
// ==/uc== | |
(function Bug330458() { | |
var orgLoadOverlay = document.loadOverlay; | |
var queue = []; | |
var loading = false; | |
function Observer(org) { | |
this.org = org; | |
} | |
Observer.prototype = { | |
constructor: Observer, | |
observe: function observe(subject, topic, data) { | |
try { | |
if (this.org instanceof Ci.nsIObserver) | |
this.org.observe(subject, topic, data); | |
} catch (e) { | |
Cu.reportError(e); | |
} | |
if (topic === 'xul-overlay-merged') | |
setTimeout(next, 0); | |
}, | |
QueryInterface: function(iId) { | |
if(iId.equals(Ci.nsISupports) || iId.equals(Ci.nsIObserver)) | |
return this; | |
throw Cr.NS_ERROR_NO_INTERFACE; | |
}, | |
}; | |
function next() { | |
loading = false; | |
var args = queue.shift(); | |
if (args) | |
loadOverlay.apply(document, args); | |
} | |
function loadOverlay(url, observer) { | |
if (loading) { | |
queue.push([url, observer]); | |
return; | |
} | |
loading = true; | |
orgLoadOverlay.call(this, url, new Observer(observer)); | |
} | |
document.loadOverlay = loadOverlay; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment