app.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. 'use strict'
  2. /* global alertsData */
  3. import jQuery from 'jquery'
  4. import _ from 'lodash'
  5. import Sticky from 'sticky-js'
  6. import io from 'socket.io-client'
  7. import Alerts from './components/alerts.js'
  8. /* eslint-disable spaced-comment */
  9. jQuery(document).ready(function ($) {
  10. // ====================================
  11. // Scroll
  12. // ====================================
  13. $('a').smoothScroll({
  14. speed: 400,
  15. offset: -70
  16. })
  17. var sticky = new Sticky('.stickyscroll') // eslint-disable-line no-unused-vars
  18. // ====================================
  19. // Notifications
  20. // ====================================
  21. $(window).bind('beforeunload', () => {
  22. $('#notifload').addClass('active')
  23. })
  24. $(document).ajaxSend(() => {
  25. $('#notifload').addClass('active')
  26. }).ajaxComplete(() => {
  27. $('#notifload').removeClass('active')
  28. })
  29. var alerts = new Alerts()
  30. if (alertsData) {
  31. _.forEach(alertsData, (alertRow) => {
  32. alerts.push(alertRow)
  33. })
  34. }
  35. // ====================================
  36. // Establish WebSocket connection
  37. // ====================================
  38. var socket = io(window.location.origin) // eslint-disable-line no-unused-vars
  39. //=include components/search.js
  40. // ====================================
  41. // Pages logic
  42. // ====================================
  43. //=include pages/view.js
  44. //=include pages/create.js
  45. //=include pages/edit.js
  46. //=include pages/source.js
  47. //=include pages/admin.js
  48. })
  49. //=include helpers/form.js
  50. //=include helpers/pages.js
  51. //=include components/alerts.js
  52. /* eslint-enable spaced-comment */