2017-02-09 01:52:37 +00:00
|
|
|
'use strict'
|
2016-08-20 21:20:53 +00:00
|
|
|
|
2017-09-10 05:41:22 +00:00
|
|
|
/* global siteConfig */
|
2017-05-21 03:21:16 +00:00
|
|
|
/* eslint-disable no-new */
|
2017-03-27 02:07:40 +00:00
|
|
|
|
2017-10-01 03:47:14 +00:00
|
|
|
import CONSTANTS from './constants'
|
|
|
|
|
2017-05-21 03:21:16 +00:00
|
|
|
import Vue from 'vue'
|
2017-05-21 20:43:58 +00:00
|
|
|
import VueResource from 'vue-resource'
|
2017-05-22 17:32:52 +00:00
|
|
|
import VueClipboards from 'vue-clipboards'
|
2017-10-09 04:16:08 +00:00
|
|
|
import VeeValidate from 'vee-validate'
|
2017-09-25 03:22:33 +00:00
|
|
|
import { ApolloClient, createBatchingNetworkInterface } from 'apollo-client'
|
2017-05-21 20:43:58 +00:00
|
|
|
import store from './store'
|
2017-09-25 03:22:33 +00:00
|
|
|
|
|
|
|
// ====================================
|
|
|
|
// Load Modules
|
|
|
|
// ====================================
|
|
|
|
|
|
|
|
import localization from './modules/localization'
|
2017-10-22 17:30:16 +00:00
|
|
|
import telemetry from './modules/telemetry'
|
2017-02-10 01:24:28 +00:00
|
|
|
|
2017-05-26 00:54:03 +00:00
|
|
|
// ====================================
|
|
|
|
// Load Helpers
|
|
|
|
// ====================================
|
|
|
|
|
|
|
|
import helpers from './helpers'
|
|
|
|
|
2017-05-21 03:21:16 +00:00
|
|
|
// ====================================
|
|
|
|
// Load Vue Components
|
|
|
|
// ====================================
|
|
|
|
|
2017-05-21 20:43:58 +00:00
|
|
|
import alertComponent from './components/alert.vue'
|
2017-05-21 03:21:16 +00:00
|
|
|
import anchorComponent from './components/anchor.vue'
|
|
|
|
import colorPickerComponent from './components/color-picker.vue'
|
2017-05-28 02:24:46 +00:00
|
|
|
import editorCodeblockComponent from './components/editor-codeblock.vue'
|
2017-06-05 03:16:00 +00:00
|
|
|
import editorFileComponent from './components/editor-file.vue'
|
2017-05-29 00:30:58 +00:00
|
|
|
import editorVideoComponent from './components/editor-video.vue'
|
2017-06-24 19:54:31 +00:00
|
|
|
import historyComponent from './components/history.vue'
|
2017-05-21 03:21:16 +00:00
|
|
|
import loadingSpinnerComponent from './components/loading-spinner.vue'
|
2017-09-25 03:22:33 +00:00
|
|
|
import loginComponent from './components/login.vue'
|
2017-05-23 04:27:16 +00:00
|
|
|
import modalCreatePageComponent from './components/modal-create-page.vue'
|
|
|
|
import modalCreateUserComponent from './components/modal-create-user.vue'
|
2017-10-10 01:43:43 +00:00
|
|
|
import modalDeletePageComponent from './components/modal-delete-page.vue'
|
2017-05-30 01:58:33 +00:00
|
|
|
import modalDeleteUserComponent from './components/modal-delete-user.vue'
|
2017-05-27 22:03:24 +00:00
|
|
|
import modalDiscardPageComponent from './components/modal-discard-page.vue'
|
2017-05-27 02:23:05 +00:00
|
|
|
import modalMovePageComponent from './components/modal-move-page.vue'
|
2017-06-12 01:11:01 +00:00
|
|
|
import modalProfile2faComponent from './components/modal-profile-2fa.vue'
|
2017-06-10 14:41:15 +00:00
|
|
|
import modalUpgradeSystemComponent from './components/modal-upgrade-system.vue'
|
2017-05-26 04:12:38 +00:00
|
|
|
import pageLoaderComponent from './components/page-loader.vue'
|
2017-05-21 03:21:16 +00:00
|
|
|
import searchComponent from './components/search.vue'
|
2017-06-25 02:45:23 +00:00
|
|
|
import toggleComponent from './components/toggle.vue'
|
2017-05-21 22:58:19 +00:00
|
|
|
import treeComponent from './components/tree.vue'
|
2017-05-21 03:21:16 +00:00
|
|
|
|
2017-06-10 02:33:33 +00:00
|
|
|
import adminEditUserComponent from './pages/admin-edit-user.component.js'
|
2017-05-21 03:21:16 +00:00
|
|
|
import adminProfileComponent from './pages/admin-profile.component.js'
|
|
|
|
import adminSettingsComponent from './pages/admin-settings.component.js'
|
2017-07-02 02:23:40 +00:00
|
|
|
import adminThemeComponent from './pages/admin-theme.component.js'
|
2017-10-08 21:21:36 +00:00
|
|
|
import configManagerComponent from './components/config-manager.component.js'
|
2017-05-23 04:27:16 +00:00
|
|
|
import contentViewComponent from './pages/content-view.component.js'
|
2017-05-27 22:03:24 +00:00
|
|
|
import editorComponent from './components/editor.component.js'
|
2017-05-23 04:27:16 +00:00
|
|
|
import sourceViewComponent from './pages/source-view.component.js'
|
2017-05-21 03:21:16 +00:00
|
|
|
|
2017-10-01 03:47:14 +00:00
|
|
|
// ====================================
|
|
|
|
// Initialize Global Vars
|
|
|
|
// ====================================
|
|
|
|
|
|
|
|
window.wiki = null
|
|
|
|
window.CONSTANTS = CONSTANTS
|
|
|
|
|
2017-09-25 03:22:33 +00:00
|
|
|
// ====================================
|
|
|
|
// Initialize Apollo Client (GraphQL)
|
|
|
|
// ====================================
|
|
|
|
|
2017-10-01 03:47:14 +00:00
|
|
|
window.graphQL = new ApolloClient({
|
2017-09-25 03:22:33 +00:00
|
|
|
networkInterface: createBatchingNetworkInterface({
|
|
|
|
uri: window.location.protocol + '//' + window.location.host + siteConfig.path + '/graphql'
|
|
|
|
}),
|
|
|
|
connectToDevTools: true
|
|
|
|
})
|
|
|
|
|
2017-05-21 03:21:16 +00:00
|
|
|
// ====================================
|
2017-05-21 20:43:58 +00:00
|
|
|
// Initialize Vue Modules
|
2017-05-21 03:21:16 +00:00
|
|
|
// ====================================
|
|
|
|
|
2017-05-21 20:43:58 +00:00
|
|
|
Vue.use(VueResource)
|
2017-05-22 17:32:52 +00:00
|
|
|
Vue.use(VueClipboards)
|
2017-09-25 03:22:33 +00:00
|
|
|
Vue.use(localization.VueI18Next)
|
2017-05-26 04:12:38 +00:00
|
|
|
Vue.use(helpers)
|
2017-10-09 04:16:08 +00:00
|
|
|
Vue.use(VeeValidate, {
|
|
|
|
enableAutoClasses: true,
|
|
|
|
classNames: {
|
|
|
|
touched: 'is-touched', // the control has been blurred
|
|
|
|
untouched: 'is-untouched', // the control hasn't been blurred
|
|
|
|
valid: 'is-valid', // model is valid
|
|
|
|
invalid: 'is-invalid', // model is invalid
|
|
|
|
pristine: 'is-pristine', // control has not been interacted with
|
|
|
|
dirty: 'is-dirty' // control has been interacted with
|
|
|
|
}
|
|
|
|
})
|
2017-05-21 03:21:16 +00:00
|
|
|
|
2017-07-02 02:23:40 +00: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)
|
2017-10-08 21:21:36 +00:00
|
|
|
Vue.component('configManager', configManagerComponent)
|
2017-07-02 02:23:40 +00:00
|
|
|
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)
|
2017-09-25 03:22:33 +00:00
|
|
|
Vue.component('login', loginComponent)
|
2017-07-02 02:23:40 +00:00
|
|
|
Vue.component('modalCreatePage', modalCreatePageComponent)
|
|
|
|
Vue.component('modalCreateUser', modalCreateUserComponent)
|
2017-10-10 01:43:43 +00:00
|
|
|
Vue.component('modalDeletePage', modalDeletePageComponent)
|
2017-07-02 02:23:40 +00:00
|
|
|
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)
|
|
|
|
|
2017-09-10 05:41:22 +00:00
|
|
|
document.addEventListener('DOMContentLoaded', ev => {
|
2017-02-10 01:24:28 +00:00
|
|
|
// ====================================
|
|
|
|
// Notifications
|
|
|
|
// ====================================
|
2016-08-28 15:27:05 +00:00
|
|
|
|
2017-09-10 05:41:22 +00:00
|
|
|
window.addEventListener('beforeunload', () => {
|
2017-05-21 20:43:58 +00:00
|
|
|
store.dispatch('startLoading')
|
2017-02-09 01:52:37 +00:00
|
|
|
})
|
2016-09-05 04:39:59 +00:00
|
|
|
|
2017-05-21 03:21:16 +00:00
|
|
|
// ====================================
|
|
|
|
// Bootstrap Vue
|
|
|
|
// ====================================
|
|
|
|
|
2017-09-25 03:22:33 +00:00
|
|
|
const i18n = localization.init()
|
2017-09-10 05:41:22 +00:00
|
|
|
window.wiki = new Vue({
|
2017-05-26 00:54:03 +00:00
|
|
|
mixins: [helpers],
|
2017-07-02 02:23:40 +00:00
|
|
|
components: {},
|
2017-05-21 03:21:16 +00:00
|
|
|
store,
|
|
|
|
i18n,
|
2017-09-25 03:22:33 +00:00
|
|
|
el: '#app',
|
2017-07-02 16:51:39 +00: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 20:43:58 +00:00
|
|
|
mounted() {
|
2017-09-10 05:41:22 +00:00
|
|
|
|
2017-05-21 20:43:58 +00:00
|
|
|
}
|
2017-05-21 03:21:16 +00:00
|
|
|
})
|
2017-02-09 01:52:37 +00:00
|
|
|
})
|