base.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /* eslint-disable
  2. camelcase,
  3. max-len,
  4. no-undef,
  5. no-useless-escape,
  6. */
  7. // TODO: This file was created by bulk-decaffeinate.
  8. // Fix any style issues and re-enable lint.
  9. /*
  10. * decaffeinate suggestions:
  11. * DS101: Remove unnecessary use of Array.from
  12. * DS102: Remove unnecessary code created because of implicit returns
  13. * DS103: Rewrite code to no longer use __guard__
  14. * DS207: Consider shorter variations of null checks
  15. * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  16. */
  17. // Configure dynamically loaded assets (via webpack) to be downloaded from CDN
  18. // See: https://webpack.js.org/guides/public-path/#on-the-fly
  19. __webpack_public_path__ = window.baseAssetPath
  20. define([
  21. 'libraries',
  22. 'libs/polyfills/symbol',
  23. 'libs/polyfills/array-fill',
  24. 'libs/polyfills/array-includes',
  25. 'modules/recursionHelper',
  26. 'modules/errorCatcher',
  27. 'modules/localStorage',
  28. 'modules/sessionStorage',
  29. 'utils/underscore'
  30. ], function() {
  31. const App = angular
  32. .module('SharelatexApp', [
  33. 'ui.bootstrap',
  34. 'autocomplete',
  35. 'RecursionHelper',
  36. 'ng-context-menu',
  37. 'underscore',
  38. 'ngSanitize',
  39. 'ipCookie',
  40. 'ErrorCatcher',
  41. 'localStorage',
  42. 'sessionStorage',
  43. 'ngTagsInput',
  44. 'ui.select'
  45. ])
  46. .config(function($qProvider, $httpProvider, uiSelectConfig) {
  47. $qProvider.errorOnUnhandledRejections(false)
  48. uiSelectConfig.spinnerClass = 'fa fa-refresh ui-select-spin'
  49. return __guard__(
  50. typeof MathJax !== 'undefined' && MathJax !== null
  51. ? MathJax.Hub
  52. : undefined,
  53. x =>
  54. x.Config({
  55. messageStyle: 'none',
  56. imageFont: null,
  57. 'HTML-CSS': {
  58. availableFonts: ['TeX'],
  59. // MathJax's automatic font scaling does not work well when we render math
  60. // that isn't yet on the page, so we disable it and set a global font
  61. // scale factor
  62. scale: 110,
  63. matchFontHeight: false
  64. },
  65. TeX: {
  66. equationNumbers: { autoNumber: 'AMS' },
  67. useLabelIDs: false
  68. },
  69. skipStartupTypeset: true,
  70. tex2jax: {
  71. processEscapes: true,
  72. // Dollar delimiters are added by the mathjax directive
  73. inlineMath: [['\\(', '\\)']],
  74. displayMath: [['$$', '$$'], ['\\[', '\\]']]
  75. }
  76. })
  77. )
  78. })
  79. App.run($templateCache =>
  80. // UI Select templates are hard-coded and use Glyphicon icons (which we don't import).
  81. // The line below simply overrides the hard-coded template with our own, which is
  82. // basically the same but using Font Awesome icons.
  83. $templateCache.put(
  84. 'bootstrap/match.tpl.html',
  85. '<div class="ui-select-match" ng-hide="$select.open && $select.searchEnabled" ng-disabled="$select.disabled" ng-class="{\'btn-default-focus\':$select.focus}"><span tabindex="-1" class="btn btn-default form-control ui-select-toggle" aria-label="{{ $select.baseTitle }} activate" ng-disabled="$select.disabled" ng-click="$select.activate()" style="outline: 0;"><span ng-show="$select.isEmpty()" class="ui-select-placeholder text-muted">{{$select.placeholder}}</span> <span ng-hide="$select.isEmpty()" class="ui-select-match-text pull-left" ng-class="{\'ui-select-allow-clear\': $select.allowClear && !$select.isEmpty()}" ng-transclude=""></span> <i class="caret pull-right" ng-click="$select.toggle($event)"></i> <a ng-show="$select.allowClear && !$select.isEmpty() && ($select.disabled !== true)" aria-label="{{ $select.baseTitle }} clear" style="margin-right: 10px" ng-click="$select.clear($event)" class="btn btn-xs btn-link pull-right"><i class="fa fa-times" aria-hidden="true"></i></a></span></div>'
  86. )
  87. )
  88. const sl_debugging =
  89. __guard__(window.location != null ? window.location.search : undefined, x =>
  90. x.match(/debug=true/)
  91. ) != null
  92. var sl_console_last_log = null
  93. window.sl_debugging = sl_debugging // make a global flag for debugging code
  94. window.sl_console = {
  95. log(...args) {
  96. if (sl_debugging) {
  97. sl_console_last_log = null
  98. return console.log(...Array.from(args || []))
  99. }
  100. },
  101. logOnce(...args) {
  102. if (sl_debugging && args[0] !== sl_console_last_log) {
  103. sl_console_last_log = args[0]
  104. return console.log(...Array.from(args || []))
  105. }
  106. }
  107. }
  108. return App
  109. })
  110. function __guard__(value, transform) {
  111. return typeof value !== 'undefined' && value !== null
  112. ? transform(value)
  113. : undefined
  114. }