base.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /* global MathJax */
  2. /* eslint-disable
  3. camelcase,
  4. max-len,
  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. import './libraries'
  18. import './utils/sentry'
  19. import './modules/recursionHelper'
  20. import './modules/errorCatcher'
  21. import './modules/localStorage'
  22. import './modules/sessionStorage'
  23. // Configure dynamically loaded assets (via webpack) to be downloaded from CDN
  24. // See: https://webpack.js.org/guides/public-path/#on-the-fly
  25. // eslint-disable-next-line no-undef
  26. __webpack_public_path__ = window.baseAssetPath
  27. const App = angular
  28. .module('SharelatexApp', [
  29. 'ui.bootstrap',
  30. 'autocomplete',
  31. 'RecursionHelper',
  32. 'ng-context-menu',
  33. 'ngSanitize',
  34. 'ipCookie',
  35. 'ErrorCatcher',
  36. 'localStorage',
  37. 'sessionStorage',
  38. 'ngTagsInput',
  39. 'ui.select'
  40. ])
  41. .config(function($qProvider, $httpProvider, uiSelectConfig) {
  42. $qProvider.errorOnUnhandledRejections(false)
  43. uiSelectConfig.spinnerClass = 'fa fa-refresh ui-select-spin'
  44. return __guard__(
  45. typeof MathJax !== 'undefined' && MathJax !== null
  46. ? MathJax.Hub
  47. : undefined,
  48. x =>
  49. x.Config({
  50. messageStyle: 'none',
  51. imageFont: null,
  52. 'HTML-CSS': {
  53. availableFonts: ['TeX'],
  54. // MathJax's automatic font scaling does not work well when we render math
  55. // that isn't yet on the page, so we disable it and set a global font
  56. // scale factor
  57. scale: 110,
  58. matchFontHeight: false
  59. },
  60. TeX: {
  61. equationNumbers: { autoNumber: 'AMS' },
  62. useLabelIDs: false
  63. },
  64. skipStartupTypeset: true,
  65. tex2jax: {
  66. processEscapes: true,
  67. // Dollar delimiters are added by the mathjax directive
  68. inlineMath: [['\\(', '\\)']],
  69. displayMath: [['$$', '$$'], ['\\[', '\\]']]
  70. }
  71. })
  72. )
  73. })
  74. App.run($templateCache =>
  75. // UI Select templates are hard-coded and use Glyphicon icons (which we don't import).
  76. // The line below simply overrides the hard-coded template with our own, which is
  77. // basically the same but using Font Awesome icons.
  78. $templateCache.put(
  79. 'bootstrap/match.tpl.html',
  80. '<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>'
  81. )
  82. )
  83. const sl_debugging =
  84. __guard__(window.location != null ? window.location.search : undefined, x =>
  85. x.match(/debug=true/)
  86. ) != null
  87. var sl_console_last_log = null
  88. window.sl_debugging = sl_debugging // make a global flag for debugging code
  89. window.sl_console = {
  90. log(...args) {
  91. if (sl_debugging) {
  92. sl_console_last_log = null
  93. return console.log(...Array.from(args || []))
  94. }
  95. },
  96. logOnce(...args) {
  97. if (sl_debugging && args[0] !== sl_console_last_log) {
  98. sl_console_last_log = args[0]
  99. return console.log(...Array.from(args || []))
  100. }
  101. }
  102. }
  103. export default App
  104. function __guard__(value, transform) {
  105. return typeof value !== 'undefined' && value !== null
  106. ? transform(value)
  107. : undefined
  108. }