app.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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 modalMovePageComponent from './components/modal-move-page.vue'
  31. import pageLoaderComponent from './components/page-loader.vue'
  32. import searchComponent from './components/search.vue'
  33. import treeComponent from './components/tree.vue'
  34. import adminProfileComponent from './pages/admin-profile.component.js'
  35. import adminSettingsComponent from './pages/admin-settings.component.js'
  36. import contentViewComponent from './pages/content-view.component.js'
  37. import sourceViewComponent from './pages/source-view.component.js'
  38. // ====================================
  39. // Initialize Vue Modules
  40. // ====================================
  41. Vue.use(VueResource)
  42. Vue.use(VueClipboards)
  43. Vue.use(VueI18Next)
  44. Vue.use(VueLodash, _)
  45. Vue.use(helpers)
  46. i18next
  47. .use(i18nextXHR)
  48. .init({
  49. backend: {
  50. loadPath: '/js/i18n/{{lng}}.json'
  51. },
  52. lng: siteLang,
  53. fallbackLng: siteLang
  54. })
  55. $(() => {
  56. // ====================================
  57. // Notifications
  58. // ====================================
  59. $(window).bind('beforeunload', () => {
  60. store.dispatch('startLoading')
  61. })
  62. $(document).ajaxSend(() => {
  63. store.dispatch('startLoading')
  64. }).ajaxComplete(() => {
  65. store.dispatch('stopLoading')
  66. })
  67. // ====================================
  68. // Establish WebSocket connection
  69. // ====================================
  70. let socket = io(window.location.origin)
  71. window.socket = socket
  72. // ====================================
  73. // Bootstrap Vue
  74. // ====================================
  75. const i18n = new VueI18Next(i18next)
  76. new Vue({
  77. mixins: [helpers],
  78. components: {
  79. alert: alertComponent,
  80. adminProfile: adminProfileComponent,
  81. adminSettings: adminSettingsComponent,
  82. anchor: anchorComponent,
  83. colorPicker: colorPickerComponent,
  84. contentView: contentViewComponent,
  85. loadingSpinner: loadingSpinnerComponent,
  86. modalCreatePage: modalCreatePageComponent,
  87. modalCreateUser: modalCreateUserComponent,
  88. modalMovePage: modalMovePageComponent,
  89. pageLoader: pageLoaderComponent,
  90. search: searchComponent,
  91. sourceView: sourceViewComponent,
  92. tree: treeComponent
  93. },
  94. store,
  95. i18n,
  96. el: '#root',
  97. mounted() {
  98. $('a:not(.toc-anchor)').smoothScroll({ speed: 500, offset: -50 })
  99. $('#header').sticky({ topSpacing: 0 })
  100. $('.sidebar-pagecontents').sticky({ topSpacing: 15, bottomSpacing: 75 })
  101. }
  102. })
  103. })