Skip to content

Instantly share code, notes, and snippets.

View shaunkrd's full-sized avatar

Shaun Dobson shaunkrd

View GitHub Profile
@tvgemert
tvgemert / plugin.min.js
Last active November 2, 2016 16:28 — forked from thomasgriffin/typekit.js
Typekit plugin for TinyMCE 4
tinymce.PluginManager.add('typekit', function(editor) {
editor.on('init', function() {
var typekitId = editor.settings.typekitId;
// Get the iframe.
var doc = editor.getDoc();
// Create the script to inject into the header asynchronously.
var jscript = "(function() { var config = { kitId: '"+typekitId+"' }; var d = false, 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); })();";
// Create a DOM script element and insert the code inside of it.
var script = doc.createElement("script");
script.type = "text/javascript";