2017-02-08 20:52:37 -05:00
|
|
|
'use strict'
|
2016-08-20 17:20:53 -04:00
|
|
|
|
2017-09-10 01:41:22 -04:00
|
|
|
/* global siteConfig */
|
2017-03-26 22:07:40 -04:00
|
|
|
|
2017-09-30 23:47:14 -04:00
|
|
|
import CONSTANTS from './constants'
|
|
|
|
|
2017-05-20 23:21:16 -04:00
|
|
|
import Vue from 'vue'
|
2018-02-28 00:54:09 -05:00
|
|
|
import VueRouter from 'vue-router'
|
2017-05-22 13:32:52 -04:00
|
|
|
import VueClipboards from 'vue-clipboards'
|
2018-02-17 18:17:25 -05:00
|
|
|
import VueSimpleBreakpoints from 'vue-simple-breakpoints'
|
2017-10-09 00:16:08 -04:00
|
|
|
import VeeValidate from 'vee-validate'
|
2017-10-28 14:17:14 -04:00
|
|
|
import { ApolloClient } from 'apollo-client'
|
2018-01-28 00:40:25 -05:00
|
|
|
import { ApolloLink } from 'apollo-link'
|
|
|
|
import { createApolloFetch } from 'apollo-fetch'
|
|
|
|
import { BatchHttpLink } from 'apollo-link-batch-http'
|
2017-10-28 14:17:14 -04:00
|
|
|
import { InMemoryCache } from 'apollo-cache-inmemory'
|
2018-02-17 22:18:37 -05:00
|
|
|
import Vuetify from 'vuetify'
|
2018-02-25 15:54:35 -05:00
|
|
|
import Velocity from 'velocity-animate'
|
2018-02-03 16:48:25 -05:00
|
|
|
import Hammer from 'hammerjs'
|
2017-05-21 16:43:58 -04:00
|
|
|
import store from './store'
|
2017-12-24 00:34:47 -05:00
|
|
|
|
2017-09-24 23:22:33 -04:00
|
|
|
// ====================================
|
|
|
|
// Load Modules
|
|
|
|
// ====================================
|
|
|
|
|
2018-02-03 16:48:25 -05:00
|
|
|
import boot from './modules/boot'
|
2017-09-24 23:22:33 -04:00
|
|
|
import localization from './modules/localization'
|
2017-02-09 20:24:28 -05:00
|
|
|
|
2017-05-25 20:54:03 -04:00
|
|
|
// ====================================
|
|
|
|
// Load Helpers
|
|
|
|
// ====================================
|
|
|
|
|
|
|
|
import helpers from './helpers'
|
|
|
|
|
2017-09-30 23:47:14 -04:00
|
|
|
// ====================================
|
|
|
|
// Initialize Global Vars
|
|
|
|
// ====================================
|
|
|
|
|
|
|
|
window.wiki = null
|
2018-02-03 16:48:25 -05:00
|
|
|
window.boot = boot
|
2017-09-30 23:47:14 -04:00
|
|
|
window.CONSTANTS = CONSTANTS
|
2018-02-03 16:48:25 -05:00
|
|
|
window.Hammer = Hammer
|
2017-09-30 23:47:14 -04:00
|
|
|
|
2017-09-24 23:22:33 -04:00
|
|
|
// ====================================
|
|
|
|
// Initialize Apollo Client (GraphQL)
|
|
|
|
// ====================================
|
|
|
|
|
2018-01-28 00:40:25 -05:00
|
|
|
const graphQLEndpoint = window.location.protocol + '//' + window.location.host + siteConfig.path + 'graphql'
|
|
|
|
|
|
|
|
const apolloFetch = createApolloFetch({
|
|
|
|
uri: graphQLEndpoint,
|
|
|
|
constructOptions: (requestOrRequests, options) => ({
|
|
|
|
...options,
|
|
|
|
method: 'POST',
|
|
|
|
body: JSON.stringify(requestOrRequests),
|
|
|
|
credentials: 'include'
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2017-09-30 23:47:14 -04:00
|
|
|
window.graphQL = new ApolloClient({
|
2018-01-28 00:40:25 -05:00
|
|
|
link: ApolloLink.from([
|
|
|
|
new ApolloLink((operation, forward) => {
|
|
|
|
operation.setContext({
|
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/json'
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
return forward(operation)
|
|
|
|
}),
|
|
|
|
new BatchHttpLink({
|
|
|
|
fetch: apolloFetch
|
|
|
|
})
|
|
|
|
]),
|
2017-10-28 14:17:14 -04:00
|
|
|
cache: new InMemoryCache(),
|
|
|
|
connectToDevTools: (process.env.node_env === 'development')
|
2017-09-24 23:22:33 -04:00
|
|
|
})
|
|
|
|
|
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
|
|
|
// ====================================
|
|
|
|
|
2018-02-28 00:54:09 -05:00
|
|
|
Vue.use(VueRouter)
|
2017-05-22 13:32:52 -04:00
|
|
|
Vue.use(VueClipboards)
|
2018-02-17 18:17:25 -05:00
|
|
|
Vue.use(VueSimpleBreakpoints)
|
2017-09-24 23:22:33 -04:00
|
|
|
Vue.use(localization.VueI18Next)
|
2017-05-26 00:12:38 -04:00
|
|
|
Vue.use(helpers)
|
2017-10-09 00:16:08 -04: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
|
|
|
|
}
|
|
|
|
})
|
2018-02-17 22:18:37 -05:00
|
|
|
Vue.use(Vuetify)
|
2017-05-20 23:21:16 -04:00
|
|
|
|
2018-02-25 15:54:35 -05:00
|
|
|
Vue.prototype.Velocity = Velocity
|
|
|
|
|
2017-07-01 22:23:40 -04:00
|
|
|
// ====================================
|
|
|
|
// Register Vue Components
|
|
|
|
// ====================================
|
|
|
|
|
2018-02-28 00:54:09 -05:00
|
|
|
Vue.component('admin', () => import(/* webpackChunkName: "admin" */ './components/admin.vue'))
|
2018-02-11 00:20:17 -05:00
|
|
|
Vue.component('editor', () => import(/* webpackChunkName: "editor" */ './components/editor.vue'))
|
2018-02-03 16:48:25 -05:00
|
|
|
Vue.component('login', () => import(/* webpackMode: "eager" */ './components/login.vue'))
|
2018-03-03 01:32:58 -05:00
|
|
|
Vue.component('nav-header', () => import(/* webpackMode: "eager" */ './components/nav-header.vue'))
|
2018-02-03 16:48:25 -05:00
|
|
|
Vue.component('navigator', () => import(/* webpackMode: "eager" */ './components/navigator.vue'))
|
2018-01-28 13:34:37 -05:00
|
|
|
Vue.component('setup', () => import(/* webpackChunkName: "setup" */ './components/setup.vue'))
|
2018-02-03 16:48:25 -05:00
|
|
|
Vue.component('toggle', () => import(/* webpackMode: "eager" */ './components/toggle.vue'))
|
2017-07-01 22:23:40 -04:00
|
|
|
|
2018-02-03 16:48:25 -05:00
|
|
|
let bootstrap = () => {
|
2017-02-09 20:24:28 -05:00
|
|
|
// ====================================
|
|
|
|
// Notifications
|
|
|
|
// ====================================
|
2016-08-28 11:27:05 -04:00
|
|
|
|
2017-09-10 01:41:22 -04:00
|
|
|
window.addEventListener('beforeunload', () => {
|
2017-05-21 16:43:58 -04:00
|
|
|
store.dispatch('startLoading')
|
2017-02-08 20:52:37 -05:00
|
|
|
})
|
2016-09-05 00:39:59 -04:00
|
|
|
|
2017-05-20 23:21:16 -04:00
|
|
|
// ====================================
|
|
|
|
// Bootstrap Vue
|
|
|
|
// ====================================
|
|
|
|
|
2017-09-24 23:22:33 -04:00
|
|
|
const i18n = localization.init()
|
2017-09-10 01:41:22 -04:00
|
|
|
window.wiki = new Vue({
|
2018-01-28 13:34:37 -05:00
|
|
|
el: '#app',
|
2017-07-01 22:23:40 -04:00
|
|
|
components: {},
|
2018-01-28 13:34:37 -05:00
|
|
|
mixins: [helpers],
|
2017-05-20 23:21:16 -04:00
|
|
|
store,
|
2018-02-03 16:48:25 -05:00
|
|
|
i18n
|
2017-05-20 23:21:16 -04:00
|
|
|
})
|
2017-10-29 01:30:46 -04:00
|
|
|
|
2018-02-03 16:48:25 -05:00
|
|
|
// ----------------------------------
|
|
|
|
// Dispatch boot ready
|
|
|
|
// ----------------------------------
|
|
|
|
|
|
|
|
window.boot.notify('vue')
|
|
|
|
|
2017-10-29 01:30:46 -04:00
|
|
|
// ====================================
|
|
|
|
// Load Icons
|
|
|
|
// ====================================
|
|
|
|
|
2018-02-24 17:35:56 -05:00
|
|
|
import(/* webpackChunkName: "icons" */ './svg/icons.svg').then(icons => {
|
2018-01-21 17:54:43 -05:00
|
|
|
document.body.insertAdjacentHTML('beforeend', icons)
|
|
|
|
})
|
2018-02-03 16:48:25 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
window.boot.onDOMReady(bootstrap)
|