base.js 4.3 KB

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