base.js 4.4 KB

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