Skip to content

Commit

Permalink
Fixed monotype active events using the jQuery way of detecting load e…
Browse files Browse the repository at this point in the history
…vents on script tags.
  • Loading branch information
bramstein committed Dec 6, 2012
1 parent 7f635f3 commit 3dd490b
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/monotype/monotype_script.js
Expand Up @@ -45,7 +45,7 @@ webfont.MonotypeScript.prototype.supportUserAgent = function (userAgent, support

var loadWindow = this.domHelper_.getLoadWindow();

function onload(e) {
function onload() {
if (loadWindow[webfont.MonotypeScript.HOOK + projectId]) {
var mti_fnts = loadWindow[webfont.MonotypeScript.HOOK + projectId]();
if (mti_fnts && mti_fnts.length) {
Expand All @@ -58,15 +58,15 @@ webfont.MonotypeScript.prototype.supportUserAgent = function (userAgent, support
support(userAgent.isSupportingWebFont());
}

if (sc["addEventListener"]) {
sc["onload"] = onload;
} else if (sc["onreadystatechange"]) {
sc["onreadystatechange"] = function(e) {
if (sc["readyState"] === "loaded" || sc["readyState"] === "complete") {
onload(e);
}
};
}
var done = false;

sc["onload"] = sc["onreadystatechange"] = function () {
if (!done && (!this["readyState"] || this["readyState"] === "loaded" || this["readyState"] === "complete")) {
done = true;
onload();
sc["onload"] = sc["onreadystatechange"] = null;
}
};

sc["src"] = self.getScriptSrc(projectId);
this.domHelper_.insertInto('head', sc);
Expand Down

0 comments on commit 3dd490b

Please sign in to comment.