loader.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. var baseURL = window.location.hostname.indexOf('github.') !== -1 ? '//rawcdn.githack.com/Alex-D/Trumbowyg/v2.12.0/' : '../../../';
  2. var styleLoadingContainer = document.querySelector('.loading-head');
  3. var scriptLoadingContainer = document.querySelector('.loading-body');
  4. function loadStyle(stylePath, comment) {
  5. 'use strict';
  6. document.write('<link rel="stylesheet" href="' + baseURL + stylePath + '"/>');
  7. styleLoadingContainer.innerHTML = styleLoadingContainer.innerHTML.trim();
  8. if (styleLoadingContainer.innerHTML.length > 0) {
  9. styleLoadingContainer.innerHTML = '\n' + styleLoadingContainer.innerHTML;
  10. }
  11. if (comment !== undefined) {
  12. styleLoadingContainer.innerText += '\n<!-- ' + comment + ' -->';
  13. }
  14. styleLoadingContainer.innerText += '\n<link rel="stylesheet" href="node_modules/trumbowyg/' + stylePath + '">\n\n';
  15. }
  16. function loadScript(scriptPath, comment) {
  17. 'use strict';
  18. document.write('<script src="' + baseURL + scriptPath + '"></script>');
  19. scriptLoadingContainer.innerHTML = scriptLoadingContainer.innerHTML.trim();
  20. if (scriptLoadingContainer.innerHTML.length > 0) {
  21. scriptLoadingContainer.innerHTML = '\n' + scriptLoadingContainer.innerHTML;
  22. }
  23. if (comment !== undefined) {
  24. scriptLoadingContainer.innerText += '\n<!-- ' + comment + ' -->';
  25. }
  26. scriptLoadingContainer.innerText += '\n<script src="node_modules/trumbowyg/' + scriptPath + '"></script>\n\n';
  27. }
  28. (function($) {
  29. 'use strict';
  30. $('a').click(function() {
  31. window.top.location = $(this).attr('href');
  32. return false;
  33. });
  34. })(jQuery);