2017-02-09 01:52:37 +00:00
|
|
|
'use strict'
|
2016-08-20 21:20:53 +00:00
|
|
|
|
2017-06-11 21:55:06 +00:00
|
|
|
/* global $ */
|
2017-05-21 03:21:16 +00:00
|
|
|
/* eslint-disable no-new */
|
2017-03-27 02:07:40 +00:00
|
|
|
|
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-05-26 00:54:03 +00:00
|
|
|
import VueLodash from 'vue-lodash'
|
2017-05-21 20:43:58 +00:00
|
|
|
import store from './store'
|
2017-05-23 04:27:16 +00:00
|
|
|
import io from 'socket-io-client'
|
2017-05-21 03:21:16 +00:00
|
|
|
import i18next from 'i18next'
|
|
|
|
import i18nextXHR from 'i18next-xhr-backend'
|
|
|
|
import VueI18Next from '@panter/vue-i18next'
|
2017-06-05 03:16:00 +00:00
|
|
|
import 'jquery-contextmenu'
|
|
|
|
import 'jquery-simple-upload'
|
2017-04-01 21:07:01 +00:00
|
|
|
import 'jquery-smooth-scroll'
|
2017-04-30 04:05:00 +00:00
|
|
|
import 'jquery-sticky'
|
2017-02-10 01:24:28 +00:00
|
|
|
|
2017-05-28 02:24:46 +00:00
|
|
|
// ====================================
|
|
|
|
// Load minimal lodash
|
|
|
|
// ====================================
|
|
|
|
|
|
|
|
import cloneDeep from 'lodash/cloneDeep'
|
2017-06-05 03:16:00 +00:00
|
|
|
import concat from 'lodash/concat'
|
2017-05-28 02:24:46 +00:00
|
|
|
import debounce from 'lodash/debounce'
|
|
|
|
import deburr from 'lodash/deburr'
|
|
|
|
import delay from 'lodash/delay'
|
|
|
|
import filter from 'lodash/filter'
|
|
|
|
import find from 'lodash/find'
|
|
|
|
import findKey from 'lodash/findKey'
|
|
|
|
import forEach from 'lodash/forEach'
|
|
|
|
import includes from 'lodash/includes'
|
2017-06-05 03:16:00 +00:00
|
|
|
import isBoolean from 'lodash/isBoolean'
|
2017-05-28 02:24:46 +00:00
|
|
|
import isEmpty from 'lodash/isEmpty'
|
|
|
|
import isNil from 'lodash/isNil'
|
|
|
|
import join from 'lodash/join'
|
|
|
|
import kebabCase from 'lodash/kebabCase'
|
|
|
|
import last from 'lodash/last'
|
|
|
|
import map from 'lodash/map'
|
2017-06-07 23:56:18 +00:00
|
|
|
import nth from 'lodash/nth'
|
2017-05-28 02:24:46 +00:00
|
|
|
import pullAt from 'lodash/pullAt'
|
|
|
|
import reject from 'lodash/reject'
|
|
|
|
import slice from 'lodash/slice'
|
|
|
|
import split from 'lodash/split'
|
2017-06-05 03:16:00 +00:00
|
|
|
import startCase from 'lodash/startCase'
|
|
|
|
import toString from 'lodash/toString'
|
2017-05-28 02:24:46 +00:00
|
|
|
import toUpper from 'lodash/toUpper'
|
2017-06-05 03:16:00 +00:00
|
|
|
import trim from 'lodash/trim'
|
2017-05-28 02:24:46 +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-05-21 03:21:16 +00:00
|
|
|
import loadingSpinnerComponent from './components/loading-spinner.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-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-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-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-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-05-28 02:24:46 +00:00
|
|
|
// ====================================
|
|
|
|
// Build lodash object
|
|
|
|
// ====================================
|
|
|
|
|
|
|
|
const _ = {
|
|
|
|
deburr,
|
|
|
|
concat,
|
|
|
|
cloneDeep,
|
|
|
|
debounce,
|
|
|
|
delay,
|
|
|
|
filter,
|
|
|
|
find,
|
|
|
|
findKey,
|
|
|
|
forEach,
|
|
|
|
includes,
|
2017-06-05 03:16:00 +00:00
|
|
|
isBoolean,
|
2017-05-28 02:24:46 +00:00
|
|
|
isEmpty,
|
|
|
|
isNil,
|
|
|
|
join,
|
|
|
|
kebabCase,
|
|
|
|
last,
|
|
|
|
map,
|
2017-06-07 23:56:18 +00:00
|
|
|
nth,
|
2017-05-28 02:24:46 +00:00
|
|
|
pullAt,
|
|
|
|
reject,
|
|
|
|
slice,
|
|
|
|
split,
|
2017-06-05 03:16:00 +00:00
|
|
|
startCase,
|
|
|
|
toString,
|
2017-05-28 02:24:46 +00:00
|
|
|
toUpper,
|
|
|
|
trim
|
|
|
|
}
|
|
|
|
|
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-05-21 03:21:16 +00:00
|
|
|
Vue.use(VueI18Next)
|
2017-05-26 00:54:03 +00:00
|
|
|
Vue.use(VueLodash, _)
|
2017-05-26 04:12:38 +00:00
|
|
|
Vue.use(helpers)
|
2017-05-21 03:21:16 +00:00
|
|
|
|
|
|
|
i18next
|
|
|
|
.use(i18nextXHR)
|
|
|
|
.init({
|
|
|
|
backend: {
|
|
|
|
loadPath: '/js/i18n/{{lng}}.json'
|
|
|
|
},
|
|
|
|
lng: siteLang,
|
|
|
|
fallbackLng: siteLang
|
|
|
|
})
|
|
|
|
|
2017-04-01 21:07:01 +00:00
|
|
|
$(() => {
|
2017-02-10 01:24:28 +00:00
|
|
|
// ====================================
|
|
|
|
// Notifications
|
|
|
|
// ====================================
|
2016-08-28 15:27:05 +00:00
|
|
|
|
2017-02-09 01:52:37 +00:00
|
|
|
$(window).bind('beforeunload', () => {
|
2017-05-21 20:43:58 +00:00
|
|
|
store.dispatch('startLoading')
|
2017-02-09 01:52:37 +00:00
|
|
|
})
|
|
|
|
$(document).ajaxSend(() => {
|
2017-05-21 20:43:58 +00:00
|
|
|
store.dispatch('startLoading')
|
2017-02-09 01:52:37 +00:00
|
|
|
}).ajaxComplete(() => {
|
2017-05-21 20:43:58 +00:00
|
|
|
store.dispatch('stopLoading')
|
2017-02-09 01:52:37 +00:00
|
|
|
})
|
2016-08-28 01:46:10 +00:00
|
|
|
|
2017-02-10 01:24:28 +00:00
|
|
|
// ====================================
|
|
|
|
// Establish WebSocket connection
|
|
|
|
// ====================================
|
2016-09-05 04:39:59 +00:00
|
|
|
|
2017-05-21 03:21:16 +00:00
|
|
|
let socket = io(window.location.origin)
|
|
|
|
window.socket = socket
|
2016-09-05 04:39:59 +00:00
|
|
|
|
2017-05-21 03:21:16 +00:00
|
|
|
// ====================================
|
|
|
|
// Bootstrap Vue
|
|
|
|
// ====================================
|
|
|
|
|
|
|
|
const i18n = new VueI18Next(i18next)
|
2017-05-28 18:34:50 +00:00
|
|
|
window.wikijs = new Vue({
|
2017-05-26 00:54:03 +00:00
|
|
|
mixins: [helpers],
|
2017-05-21 03:21:16 +00:00
|
|
|
components: {
|
2017-05-21 20:43:58 +00:00
|
|
|
alert: alertComponent,
|
2017-06-10 02:33:33 +00:00
|
|
|
adminEditUser: adminEditUserComponent,
|
2017-05-21 03:21:16 +00:00
|
|
|
adminProfile: adminProfileComponent,
|
|
|
|
adminSettings: adminSettingsComponent,
|
|
|
|
anchor: anchorComponent,
|
|
|
|
colorPicker: colorPickerComponent,
|
2017-05-23 04:27:16 +00:00
|
|
|
contentView: contentViewComponent,
|
2017-05-27 22:03:24 +00:00
|
|
|
editor: editorComponent,
|
2017-05-28 02:24:46 +00:00
|
|
|
editorCodeblock: editorCodeblockComponent,
|
2017-06-05 03:16:00 +00:00
|
|
|
editorFile: editorFileComponent,
|
2017-05-29 00:30:58 +00:00
|
|
|
editorVideo: editorVideoComponent,
|
2017-05-21 03:21:16 +00:00
|
|
|
loadingSpinner: loadingSpinnerComponent,
|
2017-05-23 04:27:16 +00:00
|
|
|
modalCreatePage: modalCreatePageComponent,
|
|
|
|
modalCreateUser: modalCreateUserComponent,
|
2017-05-30 01:58:33 +00:00
|
|
|
modalDeleteUser: modalDeleteUserComponent,
|
2017-05-27 22:03:24 +00:00
|
|
|
modalDiscardPage: modalDiscardPageComponent,
|
2017-05-27 02:23:05 +00:00
|
|
|
modalMovePage: modalMovePageComponent,
|
2017-06-10 14:41:15 +00:00
|
|
|
modalUpgradeSystem: modalUpgradeSystemComponent,
|
2017-05-26 04:12:38 +00:00
|
|
|
pageLoader: pageLoaderComponent,
|
2017-05-21 22:58:19 +00:00
|
|
|
search: searchComponent,
|
2017-05-23 04:27:16 +00:00
|
|
|
sourceView: sourceViewComponent,
|
2017-05-21 22:58:19 +00:00
|
|
|
tree: treeComponent
|
2017-05-21 20:43:58 +00:00
|
|
|
},
|
2017-05-21 03:21:16 +00:00
|
|
|
store,
|
|
|
|
i18n,
|
2017-05-21 20:43:58 +00:00
|
|
|
el: '#root',
|
|
|
|
mounted() {
|
2017-05-22 17:32:52 +00:00
|
|
|
$('a:not(.toc-anchor)').smoothScroll({ speed: 500, offset: -50 })
|
2017-05-21 20:43:58 +00:00
|
|
|
$('#header').sticky({ topSpacing: 0 })
|
|
|
|
$('.sidebar-pagecontents').sticky({ topSpacing: 15, bottomSpacing: 75 })
|
|
|
|
}
|
2017-05-21 03:21:16 +00:00
|
|
|
})
|
2017-02-09 01:52:37 +00:00
|
|
|
})
|