app.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. 'use strict'
  2. /* global siteLang */
  3. /* eslint-disable no-new */
  4. import $ from 'jquery'
  5. import _ from 'lodash'
  6. import Vue from 'vue'
  7. import VueResource from 'vue-resource'
  8. import VueClipboards from 'vue-clipboards'
  9. import VueLodash from 'vue-lodash'
  10. import store from './store'
  11. import io from 'socket-io-client'
  12. import i18next from 'i18next'
  13. import i18nextXHR from 'i18next-xhr-backend'
  14. import VueI18Next from '@panter/vue-i18next'
  15. import 'jquery-smooth-scroll'
  16. import 'jquery-sticky'
  17. // ====================================
  18. // Load Helpers
  19. // ====================================
  20. import helpers from './helpers'
  21. // ====================================
  22. // Load Vue Components
  23. // ====================================
  24. import alertComponent from './components/alert.vue'
  25. import anchorComponent from './components/anchor.vue'
  26. import colorPickerComponent from './components/color-picker.vue'
  27. import loadingSpinnerComponent from './components/loading-spinner.vue'
  28. import modalCreatePageComponent from './components/modal-create-page.vue'
  29. import modalCreateUserComponent from './components/modal-create-user.vue'
  30. import pageLoaderComponent from './components/page-loader.vue'
  31. import searchComponent from './components/search.vue'
  32. import treeComponent from './components/tree.vue'
  33. import adminProfileComponent from './pages/admin-profile.component.js'
  34. import adminSettingsComponent from './pages/admin-settings.component.js'
  35. import contentViewComponent from './pages/content-view.component.js'
  36. import sourceViewComponent from './pages/source-view.component.js'
  37. // ====================================
  38. // Initialize Vue Modules
  39. // ====================================
  40. Vue.use(VueResource)
  41. Vue.use(VueClipboards)
  42. Vue.use(VueI18Next)
  43. Vue.use(VueLodash, _)
  44. Vue.use(helpers)
  45. i18next
  46. .use(i18nextXHR)
  47. .init({
  48. backend: {
  49. loadPath: '/js/i18n/{{lng}}.json'
  50. },
  51. lng: siteLang,
  52. fallbackLng: siteLang
  53. })
  54. $(() => {
  55. // ====================================
  56. // Notifications
  57. // ====================================
  58. $(window).bind('beforeunload', () => {
  59. store.dispatch('startLoading')
  60. })
  61. $(document).ajaxSend(() => {
  62. store.dispatch('startLoading')
  63. }).ajaxComplete(() => {
  64. store.dispatch('stopLoading')
  65. })
  66. // ====================================
  67. // Establish WebSocket connection
  68. // ====================================
  69. let socket = io(window.location.origin)
  70. window.socket = socket
  71. // ====================================
  72. // Bootstrap Vue
  73. // ====================================
  74. const i18n = new VueI18Next(i18next)
  75. new Vue({
  76. mixins: [helpers],
  77. components: {
  78. alert: alertComponent,
  79. adminProfile: adminProfileComponent,
  80. adminSettings: adminSettingsComponent,
  81. anchor: anchorComponent,
  82. colorPicker: colorPickerComponent,
  83. contentView: contentViewComponent,
  84. loadingSpinner: loadingSpinnerComponent,
  85. modalCreatePage: modalCreatePageComponent,
  86. modalCreateUser: modalCreateUserComponent,
  87. pageLoader: pageLoaderComponent,
  88. search: searchComponent,
  89. sourceView: sourceViewComponent,
  90. tree: treeComponent
  91. },
  92. store,
  93. i18n,
  94. el: '#root',
  95. mounted() {
  96. $('a:not(.toc-anchor)').smoothScroll({ speed: 500, offset: -50 })
  97. $('#header').sticky({ topSpacing: 0 })
  98. $('.sidebar-pagecontents').sticky({ topSpacing: 15, bottomSpacing: 75 })
  99. }
  100. })
  101. })