Commit de07384b authored by Mike Greiling's avatar Mike Greiling

prettify main.js

parent 5728b123
...@@ -52,10 +52,14 @@ document.addEventListener('beforeunload', () => { ...@@ -52,10 +52,14 @@ document.addEventListener('beforeunload', () => {
}); });
window.addEventListener('hashchange', handleLocationHash); window.addEventListener('hashchange', handleLocationHash);
window.addEventListener('load', function onLoad() { window.addEventListener(
window.removeEventListener('load', onLoad, false); 'load',
handleLocationHash(); function onLoad() {
}, false); window.removeEventListener('load', onLoad, false);
handleLocationHash();
},
false,
);
gl.lazyLoader = new LazyLoader({ gl.lazyLoader = new LazyLoader({
scrollContainer: window, scrollContainer: window,
...@@ -89,9 +93,7 @@ document.addEventListener('DOMContentLoaded', () => { ...@@ -89,9 +93,7 @@ document.addEventListener('DOMContentLoaded', () => {
if (bootstrapBreakpoint === 'xs') { if (bootstrapBreakpoint === 'xs') {
const $rightSidebar = $('aside.right-sidebar, .layout-page'); const $rightSidebar = $('aside.right-sidebar, .layout-page');
$rightSidebar $rightSidebar.removeClass('right-sidebar-expanded').addClass('right-sidebar-collapsed');
.removeClass('right-sidebar-expanded')
.addClass('right-sidebar-collapsed');
} }
// prevent default action for disabled buttons // prevent default action for disabled buttons
...@@ -108,7 +110,8 @@ document.addEventListener('DOMContentLoaded', () => { ...@@ -108,7 +110,8 @@ document.addEventListener('DOMContentLoaded', () => {
addSelectOnFocusBehaviour('.js-select-on-focus'); addSelectOnFocusBehaviour('.js-select-on-focus');
$('.remove-row').on('ajax:success', function removeRowAjaxSuccessCallback() { $('.remove-row').on('ajax:success', function removeRowAjaxSuccessCallback() {
$(this).tooltip('destroy') $(this)
.tooltip('destroy')
.closest('li') .closest('li')
.fadeOut(); .fadeOut();
}); });
...@@ -118,7 +121,9 @@ document.addEventListener('DOMContentLoaded', () => { ...@@ -118,7 +121,9 @@ document.addEventListener('DOMContentLoaded', () => {
}); });
$('.js-remove-tr').on('ajax:success', function removeTRAjaxSuccessCallback() { $('.js-remove-tr').on('ajax:success', function removeTRAjaxSuccessCallback() {
$(this).closest('tr').fadeOut(); $(this)
.closest('tr')
.fadeOut();
}); });
// Initialize select2 selects // Initialize select2 selects
...@@ -155,7 +160,9 @@ document.addEventListener('DOMContentLoaded', () => { ...@@ -155,7 +160,9 @@ document.addEventListener('DOMContentLoaded', () => {
// Form submitter // Form submitter
$('.trigger-submit').on('change', function triggerSubmitCallback() { $('.trigger-submit').on('change', function triggerSubmitCallback() {
$(this).parents('form').submit(); $(this)
.parents('form')
.submit();
}); });
localTimeAgo($('abbr.timeago, .js-timeago'), true); localTimeAgo($('abbr.timeago, .js-timeago'), true);
...@@ -204,9 +211,15 @@ document.addEventListener('DOMContentLoaded', () => { ...@@ -204,9 +211,15 @@ document.addEventListener('DOMContentLoaded', () => {
$this.toggleClass('active'); $this.toggleClass('active');
if ($this.hasClass('active')) { if ($this.hasClass('active')) {
notesHolders.show().find('.hide, .content').show(); notesHolders
.show()
.find('.hide, .content')
.show();
} else { } else {
notesHolders.hide().find('.content').hide(); notesHolders
.hide()
.find('.content')
.hide();
} }
$(document).trigger('toggle.comments'); $(document).trigger('toggle.comments');
...@@ -247,9 +260,11 @@ document.addEventListener('DOMContentLoaded', () => { ...@@ -247,9 +260,11 @@ document.addEventListener('DOMContentLoaded', () => {
const flashContainer = document.querySelector('.flash-container'); const flashContainer = document.querySelector('.flash-container');
if (flashContainer && flashContainer.children.length) { if (flashContainer && flashContainer.children.length) {
flashContainer.querySelectorAll('.flash-alert, .flash-notice, .flash-success').forEach((flashEl) => { flashContainer
removeFlashClickListener(flashEl); .querySelectorAll('.flash-alert, .flash-notice, .flash-success')
}); .forEach(flashEl => {
removeFlashClickListener(flashEl);
});
} }
initDispatcher(); initDispatcher();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment