Skip to content

Commit

Permalink
Small refactor on modal dialog event
Browse files Browse the repository at this point in the history
  • Loading branch information
rschiang committed May 7, 2024
1 parent 66c7443 commit 75bda16
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 30 deletions.
13 changes: 0 additions & 13 deletions src/assets/js/agenda.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,16 +145,3 @@ $('#tag-group-toggle').on('click', function (e) {
e.preventDefault()
$('#tag-group').toggleClass('show')
})

$('#modal .modal-close').on('click', function (e) {
e.preventDefault()
$('body').removeClass('overflow-hidden')
$('#modal').removeClass('show')
history.replaceState(null, null, window.location.pathname);
})

$(document).on('keydown', function (e) {
if (e.key === 'Escape') {
$('#modal .modal-close').click()
}
});
23 changes: 19 additions & 4 deletions src/assets/js/base.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Global preferences
const storage = window.sessionStorage
const i18n = $.i18n()
const setLocale = (function (lang) {
Expand All @@ -14,10 +15,6 @@ $('#cookie-notice button').on('click', function (e) {
$('#cookie-notice').addClass('hidden')
})

$('header .offcanvas-toggler').on('click', function (e) {
$('header .offcanvas-box').toggleClass('show')
})

$('select#lang-select').on('change', function (e) {
let lang = $(this).val()
setLocale(lang)
Expand Down Expand Up @@ -64,10 +61,28 @@ $(function () {
})
})

// UI interactions & events
$(window).on('load', function (e) {
$('body').css('overflow', 'unset')
$('#loading').addClass('scale')
setTimeout(function () {
$('#loading').addClass('fadeout')
}, 1000)
})

$('header .offcanvas-toggler').on('click', function (e) {
$('header .offcanvas-box').toggleClass('show')
})

$('#modal .modal-close').on('click', function (e) {
e.preventDefault()
$('body').removeClass('overflow-hidden')
$('#modal').removeClass('show')
history.replaceState(null, null, window.location.pathname);
})

$(document).on('keydown', function (e) {
if (e.key === 'Escape' && $('#modal').hasClass('show')) {
$('#modal .modal-close').click()
}
})
13 changes: 0 additions & 13 deletions src/assets/js/speakers.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,3 @@ $(function () {
}
})
})

$('#modal .modal-close').on('click', function (e) {
e.preventDefault()
$('body').removeClass('overflow-hidden')
$('#modal').removeClass('show')
history.replaceState(null, null, window.location.pathname);
})

$(document).on('keydown', function (e) {
if (e.key === 'Escape') {
$('#modal .modal-close').click()
}
});

0 comments on commit 75bda16

Please sign in to comment.