wikijs-fork/client/js/app.js

63 lines
1.5 KiB
JavaScript
Raw Normal View History

2017-02-09 01:52:37 +00:00
'use strict'
2017-03-27 02:07:40 +00:00
/* global alertsData */
import $ from 'jquery'
2017-03-27 02:07:40 +00:00
import _ from 'lodash'
import io from 'socket.io-client'
import Alerts from './components/alerts.js'
import 'jquery-smooth-scroll'
import Sticky from 'sticky-js'
$(() => {
// ====================================
// Scroll
// ====================================
2016-08-28 01:46:10 +00:00
2017-02-09 01:52:37 +00:00
$('a').smoothScroll({
speed: 400,
offset: -70
})
var sticky = new Sticky('.stickyscroll') // eslint-disable-line no-unused-vars
// ====================================
// Notifications
// ====================================
2016-08-28 15:27:05 +00:00
2017-02-09 01:52:37 +00:00
$(window).bind('beforeunload', () => {
$('#notifload').addClass('active')
})
$(document).ajaxSend(() => {
$('#notifload').addClass('active')
}).ajaxComplete(() => {
$('#notifload').removeClass('active')
})
2016-08-28 01:46:10 +00:00
2017-02-09 01:52:37 +00:00
var alerts = new Alerts()
if (alertsData) {
_.forEach(alertsData, (alertRow) => {
alerts.push(alertRow)
})
}
2016-08-24 01:09:09 +00:00
// ====================================
// Establish WebSocket connection
// ====================================
var socket = io(window.location.origin)
require('./components/search.js')(socket)
// ====================================
// Pages logic
// ====================================
2016-08-28 15:27:05 +00:00
require('./pages/view.js')(alerts)
require('./pages/all.js')(alerts, socket)
require('./pages/create.js')(alerts, socket)
require('./pages/edit.js')(alerts, socket)
require('./pages/source.js')(alerts)
require('./pages/admin.js')(alerts)
2017-02-09 01:52:37 +00:00
})