app.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. "use strict";
  2. jQuery( document ).ready(function( $ ) {
  3. // ====================================
  4. // Scroll
  5. // ====================================
  6. $('a').smoothScroll({
  7. speed: 400,
  8. offset: -20
  9. });
  10. var sticky = new Sticky('.stickyscroll');
  11. // ====================================
  12. // Notifications
  13. // ====================================
  14. $(window).bind('beforeunload', () => {
  15. $('#notifload').addClass('active');
  16. });
  17. $(document).ajaxSend(() => {
  18. $('#notifload').addClass('active');
  19. }).ajaxComplete(() => {
  20. $('#notifload').removeClass('active');
  21. });
  22. var alerts = new Alerts();
  23. if(alertsData) {
  24. _.forEach(alertsData, (alertRow) => {
  25. alerts.push(alertRow);
  26. });
  27. }
  28. // ====================================
  29. // Markdown Editor
  30. // ====================================
  31. if($('#mk-editor').length === 1) {
  32. var mde = new SimpleMDE({
  33. autofocus: true,
  34. autoDownloadFontAwesome: false,
  35. element: $("#mk-editor").get(0),
  36. hideIcons: ['heading', 'quote'],
  37. placeholder: 'Enter Markdown formatted content here...',
  38. showIcons: ['strikethrough', 'heading-1', 'heading-2', 'heading-3', 'code', 'table', 'horizontal-rule'],
  39. spellChecker: false,
  40. status: false
  41. });
  42. }
  43. // ====================================
  44. // Establish WebSocket connection
  45. // ====================================
  46. var socket = io(ioHost);
  47. var vueHeader = new Vue({
  48. el: '#header-container',
  49. data: {
  50. searchq: '',
  51. searchres: []
  52. },
  53. watch: {
  54. searchq: (val, oldVal) => {
  55. if(val.length >= 3) {
  56. socket.emit('search', { terms: val }, (data) => {
  57. vueHeader.$set('searchres', data);
  58. });
  59. }
  60. }
  61. },
  62. methods: {
  63. }
  64. });
  65. // ====================================
  66. // Pages logic
  67. // ====================================
  68. //=include pages/view.js
  69. //=include pages/create.js
  70. //=include pages/edit.js
  71. //=include pages/source.js
  72. });
  73. //=include helpers/form.js
  74. //=include helpers/pages.js