2017-02-08 20:52:37 -05:00
|
|
|
'use strict'
|
2016-08-20 17:20:53 -04:00
|
|
|
|
2017-06-24 15:54:31 -04:00
|
|
|
/* global $, siteRoot */
|
2017-05-20 23:21:16 -04:00
|
|
|
/* eslint-disable no-new */
|
2017-03-26 22:07:40 -04:00
|
|
|
|
2017-05-20 23:21:16 -04:00
|
|
|
import Vue from 'vue'
|
2017-05-21 16:43:58 -04:00
|
|
|
import VueResource from 'vue-resource'
|
2017-05-22 13:32:52 -04:00
|
|
|
import VueClipboards from 'vue-clipboards'
|
2017-05-25 20:54:03 -04:00
|
|
|
import VueLodash from 'vue-lodash'
|
2017-05-21 16:43:58 -04:00
|
|
|
import store from './store'
|
2017-05-23 00:27:16 -04:00
|
|
|
import io from 'socket-io-client'
|
2017-05-20 23:21:16 -04:00
|
|
|
import i18next from 'i18next'
|
|
|
|
import i18nextXHR from 'i18next-xhr-backend'
|
|
|
|
import VueI18Next from '@panter/vue-i18next'
|
2017-06-04 23:16:00 -04:00
|
|
|
import 'jquery-contextmenu'
|
|
|
|
import 'jquery-simple-upload'
|
2017-04-01 17:07:01 -04:00
|
|
|
import 'jquery-smooth-scroll'
|
2017-04-30 00:05:00 -04:00
|
|
|
import 'jquery-sticky'
|
2017-02-09 20:24:28 -05:00
|
|
|
|
2017-05-25 20:54:03 -04:00
|
|
|
// ====================================
|
|
|
|
// Load Helpers
|
|
|
|
// ====================================
|
|
|
|
|
|
|
|
import helpers from './helpers'
|
2017-07-02 12:51:39 -04:00
|
|
|
import _ from './helpers/lodash'
|
2017-05-25 20:54:03 -04:00
|
|
|
|
2017-05-20 23:21:16 -04:00
|
|
|
// ====================================
|
|
|
|
// Load Vue Components
|
|
|
|
// ====================================
|
|
|
|
|
2017-05-21 16:43:58 -04:00
|
|
|
import alertComponent from './components/alert.vue'
|
2017-05-20 23:21:16 -04:00
|
|
|
import anchorComponent from './components/anchor.vue'
|
|
|
|
import colorPickerComponent from './components/color-picker.vue'
|
2017-05-27 22:24:46 -04:00
|
|
|
import editorCodeblockComponent from './components/editor-codeblock.vue'
|
2017-06-04 23:16:00 -04:00
|
|
|
import editorFileComponent from './components/editor-file.vue'
|
2017-05-28 20:30:58 -04:00
|
|
|
import editorVideoComponent from './components/editor-video.vue'
|
2017-06-24 15:54:31 -04:00
|
|
|
import historyComponent from './components/history.vue'
|
2017-05-20 23:21:16 -04:00
|
|
|
import loadingSpinnerComponent from './components/loading-spinner.vue'
|
2017-05-23 00:27:16 -04:00
|
|
|
import modalCreatePageComponent from './components/modal-create-page.vue'
|
|
|
|
import modalCreateUserComponent from './components/modal-create-user.vue'
|
2017-05-29 21:58:33 -04:00
|
|
|
import modalDeleteUserComponent from './components/modal-delete-user.vue'
|
2017-05-27 18:03:24 -04:00
|
|
|
import modalDiscardPageComponent from './components/modal-discard-page.vue'
|
2017-05-26 22:23:05 -04:00
|
|
|
import modalMovePageComponent from './components/modal-move-page.vue'
|
2017-06-11 21:11:01 -04:00
|
|
|
import modalProfile2faComponent from './components/modal-profile-2fa.vue'
|
2017-06-10 10:41:15 -04:00
|
|
|
import modalUpgradeSystemComponent from './components/modal-upgrade-system.vue'
|
2017-05-26 00:12:38 -04:00
|
|
|
import pageLoaderComponent from './components/page-loader.vue'
|
2017-05-20 23:21:16 -04:00
|
|
|
import searchComponent from './components/search.vue'
|
2017-06-24 22:45:23 -04:00
|
|
|
import toggleComponent from './components/toggle.vue'
|
2017-05-21 18:58:19 -04:00
|
|
|
import treeComponent from './components/tree.vue'
|
2017-05-20 23:21:16 -04:00
|
|
|
|
2017-06-09 22:33:33 -04:00
|
|
|
import adminEditUserComponent from './pages/admin-edit-user.component.js'
|
2017-05-20 23:21:16 -04:00
|
|
|
import adminProfileComponent from './pages/admin-profile.component.js'
|
|
|
|
import adminSettingsComponent from './pages/admin-settings.component.js'
|
2017-07-01 22:23:40 -04:00
|
|
|
import adminThemeComponent from './pages/admin-theme.component.js'
|
2017-05-23 00:27:16 -04:00
|
|
|
import contentViewComponent from './pages/content-view.component.js'
|
2017-05-27 18:03:24 -04:00
|
|
|
import editorComponent from './components/editor.component.js'
|
2017-05-23 00:27:16 -04:00
|
|
|
import sourceViewComponent from './pages/source-view.component.js'
|
2017-05-20 23:21:16 -04:00
|
|
|
|
|
|
|
// ====================================
|
2017-05-21 16:43:58 -04:00
|
|
|
// Initialize Vue Modules
|
2017-05-20 23:21:16 -04:00
|
|
|
// ====================================
|
|
|
|
|
2017-05-21 16:43:58 -04:00
|
|
|
Vue.use(VueResource)
|
2017-05-22 13:32:52 -04:00
|
|
|
Vue.use(VueClipboards)
|
2017-05-20 23:21:16 -04:00
|
|
|
Vue.use(VueI18Next)
|
2017-07-02 12:51:39 -04:00
|
|
|
Vue.use(VueLodash, _)
|
2017-05-26 00:12:38 -04:00
|
|
|
Vue.use(helpers)
|
2017-05-20 23:21:16 -04:00
|
|
|
|
2017-07-01 22:23:40 -04:00
|
|
|
// ====================================
|
|
|
|
// Register Vue Components
|
|
|
|
// ====================================
|
|
|
|
|
|
|
|
Vue.component('alert', alertComponent)
|
|
|
|
Vue.component('adminEditUser', adminEditUserComponent)
|
|
|
|
Vue.component('adminProfile', adminProfileComponent)
|
|
|
|
Vue.component('adminSettings', adminSettingsComponent)
|
|
|
|
Vue.component('adminTheme', adminThemeComponent)
|
|
|
|
Vue.component('anchor', anchorComponent)
|
|
|
|
Vue.component('colorPicker', colorPickerComponent)
|
|
|
|
Vue.component('contentView', contentViewComponent)
|
|
|
|
Vue.component('editor', editorComponent)
|
|
|
|
Vue.component('editorCodeblock', editorCodeblockComponent)
|
|
|
|
Vue.component('editorFile', editorFileComponent)
|
|
|
|
Vue.component('editorVideo', editorVideoComponent)
|
|
|
|
Vue.component('history', historyComponent)
|
|
|
|
Vue.component('loadingSpinner', loadingSpinnerComponent)
|
|
|
|
Vue.component('modalCreatePage', modalCreatePageComponent)
|
|
|
|
Vue.component('modalCreateUser', modalCreateUserComponent)
|
|
|
|
Vue.component('modalDeleteUser', modalDeleteUserComponent)
|
|
|
|
Vue.component('modalDiscardPage', modalDiscardPageComponent)
|
|
|
|
Vue.component('modalMovePage', modalMovePageComponent)
|
|
|
|
Vue.component('modalProfile2fa', modalProfile2faComponent)
|
|
|
|
Vue.component('modalUpgradeSystem', modalUpgradeSystemComponent)
|
|
|
|
Vue.component('pageLoader', pageLoaderComponent)
|
|
|
|
Vue.component('search', searchComponent)
|
|
|
|
Vue.component('sourceView', sourceViewComponent)
|
|
|
|
Vue.component('toggle', toggleComponent)
|
|
|
|
Vue.component('tree', treeComponent)
|
|
|
|
|
|
|
|
// ====================================
|
|
|
|
// Load Localization strings
|
|
|
|
// ====================================
|
|
|
|
|
2017-05-20 23:21:16 -04:00
|
|
|
i18next
|
|
|
|
.use(i18nextXHR)
|
|
|
|
.init({
|
|
|
|
backend: {
|
2017-06-24 15:54:31 -04:00
|
|
|
loadPath: siteRoot + '/js/i18n/{{lng}}.json'
|
2017-05-20 23:21:16 -04:00
|
|
|
},
|
|
|
|
lng: siteLang,
|
|
|
|
fallbackLng: siteLang
|
|
|
|
})
|
|
|
|
|
2017-04-01 17:07:01 -04:00
|
|
|
$(() => {
|
2017-02-09 20:24:28 -05:00
|
|
|
// ====================================
|
|
|
|
// Notifications
|
|
|
|
// ====================================
|
2016-08-28 11:27:05 -04:00
|
|
|
|
2017-02-08 20:52:37 -05:00
|
|
|
$(window).bind('beforeunload', () => {
|
2017-05-21 16:43:58 -04:00
|
|
|
store.dispatch('startLoading')
|
2017-02-08 20:52:37 -05:00
|
|
|
})
|
|
|
|
$(document).ajaxSend(() => {
|
2017-05-21 16:43:58 -04:00
|
|
|
store.dispatch('startLoading')
|
2017-02-08 20:52:37 -05:00
|
|
|
}).ajaxComplete(() => {
|
2017-05-21 16:43:58 -04:00
|
|
|
store.dispatch('stopLoading')
|
2017-02-08 20:52:37 -05:00
|
|
|
})
|
2016-08-27 21:46:10 -04:00
|
|
|
|
2017-02-09 20:24:28 -05:00
|
|
|
// ====================================
|
|
|
|
// Establish WebSocket connection
|
|
|
|
// ====================================
|
2016-09-05 00:39:59 -04:00
|
|
|
|
2017-05-20 23:21:16 -04:00
|
|
|
let socket = io(window.location.origin)
|
|
|
|
window.socket = socket
|
2016-09-05 00:39:59 -04:00
|
|
|
|
2017-05-20 23:21:16 -04:00
|
|
|
// ====================================
|
|
|
|
// Bootstrap Vue
|
|
|
|
// ====================================
|
|
|
|
|
|
|
|
const i18n = new VueI18Next(i18next)
|
2017-05-28 14:34:50 -04:00
|
|
|
window.wikijs = new Vue({
|
2017-05-25 20:54:03 -04:00
|
|
|
mixins: [helpers],
|
2017-07-01 22:23:40 -04:00
|
|
|
components: {},
|
2017-05-20 23:21:16 -04:00
|
|
|
store,
|
|
|
|
i18n,
|
2017-05-21 16:43:58 -04:00
|
|
|
el: '#root',
|
2017-07-02 12:51:39 -04:00
|
|
|
methods: {
|
|
|
|
changeTheme(opts) {
|
|
|
|
this.$el.className = `has-stickynav is-primary-${opts.primary} is-alternate-${opts.alt}`
|
|
|
|
this.$refs.header.className = `nav is-${opts.primary}`
|
|
|
|
this.$refs.footer.className = `footer is-${opts.footer}`
|
|
|
|
}
|
|
|
|
},
|
2017-05-21 16:43:58 -04:00
|
|
|
mounted() {
|
2017-05-22 13:32:52 -04:00
|
|
|
$('a:not(.toc-anchor)').smoothScroll({ speed: 500, offset: -50 })
|
2017-05-21 16:43:58 -04:00
|
|
|
$('#header').sticky({ topSpacing: 0 })
|
|
|
|
$('.sidebar-pagecontents').sticky({ topSpacing: 15, bottomSpacing: 75 })
|
|
|
|
}
|
2017-05-20 23:21:16 -04:00
|
|
|
})
|
2017-02-08 20:52:37 -05:00
|
|
|
})
|