Created
February 5, 2013 06:31
-
-
Save arghav/4712669 to your computer and use it in GitHub Desktop.
Load typekit on EpicEditor
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
editor.on('load', function () { | |
// Step 1: Grab the editor element | |
var editorDoc = editor.getElement('editor'); | |
// Step 2: Create the script tag | |
var script = editorDoc.createElement('script'); | |
script.type = 'text/javascript'; | |
script.innerHTML = "(function() {var config = {kitId: '<yourKitID>'}; var d = false; var tk = document.createElement('script'); tk.src = '//use.typekit.net/' + config.kitId + '.js'; tk.type = 'text/javascript'; tk.async = 'true'; tk.onload = tk.onreadystatechange = function() {var rs = this.readyState; if (d || rs && rs != 'complete' && rs != 'loaded') return; d = true; try { Typekit.load(config); } catch (e) {} }; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(tk, s); })();"; | |
// Step 3: Add it to the editor's <head> | |
var editorHead = editorDoc.getElementsByTagName('head')[0]; | |
editorHead.appendChild(script); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment