Advertisement
Guest User

Untitled

a guest
May 27th, 2015
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. tinymce.PluginManager.add('typekit', function(editor) {
  2. editor.on('init', function() {
  3. var typekitId = editor.settings.typekitId;
  4. // Get the iframe.
  5. var doc = editor.getDoc();
  6. // Create the script to inject into the header asynchronously.
  7. 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); })();";
  8. // Create a DOM script element and insert the code inside of it.
  9. var script = doc.createElement("script");
  10. script.type = "text/javascript";
  11. script.appendChild(doc.createTextNode(jscript));
  12.  
  13. // Append the srcript to the header.
  14. doc.getElementsByTagName('head')[0].appendChild(script);
  15. });
  16. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement