base.js 4.3 KB

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