appBootstrap.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * Copyright (C) 2016 - present Instructure, Inc.
  3. *
  4. * This file is part of Canvas.
  5. *
  6. * Canvas is free software: you can redistribute it and/or modify it under
  7. * the terms of the GNU Affero General Public License as published by the Free
  8. * Software Foundation, version 3 of the License.
  9. *
  10. * Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
  11. * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. * A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
  13. * details.
  14. *
  15. * You should have received a copy of the GNU Affero General Public License along
  16. * with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. import { canvas } from 'instructure-ui/lib/themes'
  19. import moment from 'moment'
  20. import tz from 'timezone_core'
  21. import './fakeRequireJSFallback'
  22. // we already put a <script> tag for the locale corresponding ENV.MOMENT_LOCALE
  23. // on the page from rails, so this should not cause a new network request.
  24. moment().locale(ENV.MOMENT_LOCALE)
  25. // These timezones and locales should already be put on the page as <script>
  26. // tags from rails. this block should not create any network requests.
  27. if (typeof ENV !== 'undefined') {
  28. if (ENV.TIMEZONE) tz.changeZone(ENV.TIMEZONE)
  29. if (ENV.CONTEXT_TIMEZONE) tz.preload(ENV.CONTEXT_TIMEZONE)
  30. if (ENV.BIGEASY_LOCALE) tz.changeLocale(ENV.BIGEASY_LOCALE, ENV.MOMENT_LOCALE)
  31. }
  32. // setup the inst-ui default theme
  33. if (ENV.use_high_contrast) {
  34. canvas.use({ accessible: true })
  35. } else {
  36. const brandvars = window.CANVAS_ACTIVE_BRAND_VARIABLES || {}
  37. canvas.use({ overrides: brandvars })
  38. }