Port localebox to TypeScript

This commit is contained in:
Andreas Nedbal 2022-01-13 23:43:35 +01:00 committed by Andreas Nedbal
parent bee75584d0
commit 7d14e93ada
4 changed files with 15 additions and 6 deletions

View File

@ -1,4 +0,0 @@
$(document).on 'click', '#locale-switch', (event) ->
event.preventDefault()
$('#locales-panel').slideToggle()
$("html, body").animate({ scrollTop: $(document).height() }, 1000)

View File

@ -11,6 +11,7 @@ import initQuestionbox from 'retrospring/features/questionbox';
import initQuestion from 'retrospring/features/question'; import initQuestion from 'retrospring/features/question';
import initModeration from 'retrospring/features/moderation'; import initModeration from 'retrospring/features/moderation';
import initMemes from 'retrospring/features/memes'; import initMemes from 'retrospring/features/memes';
import initLocales from 'retrospring/features/locales';
start(); start();
document.addEventListener('DOMContentLoaded', initAnswerbox); document.addEventListener('DOMContentLoaded', initAnswerbox);
@ -22,4 +23,5 @@ document.addEventListener('DOMContentLoaded', initQuestionbox);
document.addEventListener('DOMContentLoaded', initQuestion); document.addEventListener('DOMContentLoaded', initQuestion);
document.addEventListener('DOMContentLoaded', initModeration); document.addEventListener('DOMContentLoaded', initModeration);
document.addEventListener('DOMContentLoaded', initMemes); document.addEventListener('DOMContentLoaded', initMemes);
document.addEventListener('turbolinks:load', initAnnouncements) document.addEventListener('turbolinks:load', initAnnouncements);
document.addEventListener('turbolinks:load', initLocales);

View File

@ -7,7 +7,6 @@ import 'bootstrap'
import 'particleground/jquery.particleground.min' import 'particleground/jquery.particleground.min'
import '../legacy/pagination' import '../legacy/pagination'
import '../legacy/locale-box'
import '../legacy/util' import '../legacy/util'
_ready = -> _ready = ->

View File

@ -0,0 +1,12 @@
import registerEvents from 'utilities/registerEvents';
function localeSwitchHandler(event: Event): void {
event.preventDefault();
document.querySelector('#locales-panel').classList.toggle('d-block');
}
export default (): void => {
registerEvents([
{ type: 'click', target: document.querySelector('#locale-switch'), handler: localeSwitchHandler }
]);
}