app.js 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. 'use strict'
  2. /* global siteLang */
  3. /* eslint-disable no-new */
  4. import $ from 'jquery'
  5. import Vue from 'vue'
  6. import VueResource from 'vue-resource'
  7. import store from './store'
  8. import io from 'socket.io-client'
  9. import i18next from 'i18next'
  10. import i18nextXHR from 'i18next-xhr-backend'
  11. import VueI18Next from '@panter/vue-i18next'
  12. import 'jquery-smooth-scroll'
  13. import 'jquery-sticky'
  14. // ====================================
  15. // Load Vue Components
  16. // ====================================
  17. import alertComponent from './components/alert.vue'
  18. import anchorComponent from './components/anchor.vue'
  19. import colorPickerComponent from './components/color-picker.vue'
  20. import loadingSpinnerComponent from './components/loading-spinner.vue'
  21. import searchComponent from './components/search.vue'
  22. import treeComponent from './components/tree.vue'
  23. import adminUsersCreateComponent from './modals/admin-users-create.vue'
  24. import adminProfileComponent from './pages/admin-profile.component.js'
  25. import adminSettingsComponent from './pages/admin-settings.component.js'
  26. // ====================================
  27. // Initialize Vue Modules
  28. // ====================================
  29. Vue.use(VueResource)
  30. Vue.use(VueI18Next)
  31. i18next
  32. .use(i18nextXHR)
  33. .init({
  34. backend: {
  35. loadPath: '/js/i18n/{{lng}}.json'
  36. },
  37. lng: siteLang,
  38. fallbackLng: siteLang
  39. })
  40. $(() => {
  41. // ====================================
  42. // Notifications
  43. // ====================================
  44. $(window).bind('beforeunload', () => {
  45. store.dispatch('startLoading')
  46. })
  47. $(document).ajaxSend(() => {
  48. store.dispatch('startLoading')
  49. }).ajaxComplete(() => {
  50. store.dispatch('stopLoading')
  51. })
  52. // ====================================
  53. // Establish WebSocket connection
  54. // ====================================
  55. let socket = io(window.location.origin)
  56. window.socket = socket
  57. // ====================================
  58. // Bootstrap Vue
  59. // ====================================
  60. const i18n = new VueI18Next(i18next)
  61. new Vue({
  62. components: {
  63. alert: alertComponent,
  64. adminProfile: adminProfileComponent,
  65. adminSettings: adminSettingsComponent,
  66. adminUsersCreate: adminUsersCreateComponent,
  67. anchor: anchorComponent,
  68. colorPicker: colorPickerComponent,
  69. loadingSpinner: loadingSpinnerComponent,
  70. search: searchComponent,
  71. tree: treeComponent
  72. },
  73. store,
  74. i18n,
  75. el: '#root',
  76. mounted() {
  77. $('a').smoothScroll({ speed: 500, offset: -50 })
  78. $('#header').sticky({ topSpacing: 0 })
  79. $('.sidebar-pagecontents').sticky({ topSpacing: 15, bottomSpacing: 75 })
  80. }
  81. })
  82. })