bootstrap.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. var tslib_1 = require("tslib");
  4. /**
  5. * Kicks off less and compiles any stylesheets
  6. * used in the browser distributed version of less
  7. * to kick-start less using the browser api
  8. */
  9. var default_options_1 = tslib_1.__importDefault(require("../less/default-options"));
  10. var add_default_options_1 = tslib_1.__importDefault(require("./add-default-options"));
  11. var index_1 = tslib_1.__importDefault(require("./index"));
  12. var options = default_options_1.default();
  13. if (window.less) {
  14. for (var key in window.less) {
  15. if (Object.prototype.hasOwnProperty.call(window.less, key)) {
  16. options[key] = window.less[key];
  17. }
  18. }
  19. }
  20. add_default_options_1.default(window, options);
  21. options.plugins = options.plugins || [];
  22. if (window.LESS_PLUGINS) {
  23. options.plugins = options.plugins.concat(window.LESS_PLUGINS);
  24. }
  25. var less = index_1.default(window, options);
  26. exports.default = less;
  27. window.less = less;
  28. var css;
  29. var head;
  30. var style;
  31. // Always restore page visibility
  32. function resolveOrReject(data) {
  33. if (data.filename) {
  34. console.warn(data);
  35. }
  36. if (!options.async) {
  37. head.removeChild(style);
  38. }
  39. }
  40. if (options.onReady) {
  41. if (/!watch/.test(window.location.hash)) {
  42. less.watch();
  43. }
  44. // Simulate synchronous stylesheet loading by hiding page rendering
  45. if (!options.async) {
  46. css = 'body { display: none !important }';
  47. head = document.head || document.getElementsByTagName('head')[0];
  48. style = document.createElement('style');
  49. style.type = 'text/css';
  50. if (style.styleSheet) {
  51. style.styleSheet.cssText = css;
  52. }
  53. else {
  54. style.appendChild(document.createTextNode(css));
  55. }
  56. head.appendChild(style);
  57. }
  58. less.registerStylesheetsImmediately();
  59. less.pageLoadFinished = less.refresh(less.env === 'development').then(resolveOrReject, resolveOrReject);
  60. }
  61. //# sourceMappingURL=bootstrap.js.map