Created
June 4, 2015 22:44
-
-
Save joelpittet/69c32c148e457bdd17fc to your computer and use it in GitHub Desktop.
CKEditor + Typekit (BESbswy Fix)
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
var typkitID = 'XXXXXXX'; | |
CKEDITOR.on('instanceReady', | |
function(ev) { | |
var $editor_instance = CKEDITOR.instances[ev.editor.name]; | |
(function(d) { | |
try { | |
var config = { | |
kitId: typkitID, | |
scriptTimeout: 3000 | |
}, | |
h=d.documentElement,t=setTimeout(function(){h.className=h.className.replace(/\bwf-loading\b/g,"")+" wf-inactive";},config.scriptTimeout),tk=d.createElement("script"),f=false,s=d.getElementsByTagName("script")[0],a;h.className+=" wf-loading";tk.src='//use.typekit.net/'+config.kitId+'.js';tk.async=true;tk.onload=tk.onreadystatechange=function(){a=this.readyState;if(f||a&&a!="complete"&&a!="loaded")return;f=true;clearTimeout(t);try{Typekit.load(config)}catch(e){}};s.parentNode.insertBefore(tk,s); | |
} catch(e) {} | |
})($editor_instance.document); | |
// Old method. | |
// var $script = document.createElement('script'), | |
// $editor_instance = CKEDITOR.instances[ev.editor.name]; | |
// var protocol = (('https:' == document.location.protocol) ? 'https://' : 'http://'); | |
// $script.src = protocol + 'use.typekit.com/' + typkitID + '.js'; | |
// $script.onload = function() { | |
// try { | |
// $editor_instance.window.$.Typekit.load(); | |
// } catch(e) {} | |
// }; | |
// $editor_instance.document.getHead().$.appendChild($script); | |
} | |
); |
Oh sure! I'm using TypeKit's advanced code, but the only difference is that I'm passing in the editors document
object instead of the current page's document
into the closure.
Voila it didn't have that BESbswy garbage generated.
Sorry for the delay responding, I didn't see this.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Joel, could you please explain what you are doing here? :)