Skip to content

Commit

Permalink
Port localebox to TypeScript
Browse files Browse the repository at this point in the history
  • Loading branch information
pixeldesu committed Jan 14, 2022
1 parent bee7558 commit 7d14e93
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
4 changes: 0 additions & 4 deletions app/javascript/legacy/locale-box.coffee

This file was deleted.

4 changes: 3 additions & 1 deletion app/javascript/packs/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import initQuestionbox from 'retrospring/features/questionbox';
import initQuestion from 'retrospring/features/question';
import initModeration from 'retrospring/features/moderation';
import initMemes from 'retrospring/features/memes';
import initLocales from 'retrospring/features/locales';

start();
document.addEventListener('DOMContentLoaded', initAnswerbox);
Expand All @@ -22,4 +23,5 @@ document.addEventListener('DOMContentLoaded', initQuestionbox);
document.addEventListener('DOMContentLoaded', initQuestion);
document.addEventListener('DOMContentLoaded', initModeration);
document.addEventListener('DOMContentLoaded', initMemes);
document.addEventListener('turbolinks:load', initAnnouncements)
document.addEventListener('turbolinks:load', initAnnouncements);
document.addEventListener('turbolinks:load', initLocales);
1 change: 0 additions & 1 deletion app/javascript/packs/legacy.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import 'bootstrap'
import 'particleground/jquery.particleground.min'

import '../legacy/pagination'
import '../legacy/locale-box'
import '../legacy/util'

_ready = ->
Expand Down
12 changes: 12 additions & 0 deletions app/javascript/retrospring/features/locales/index.ts
Original file line number Diff line number Diff line change
@@ -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 }
]);
}

0 comments on commit 7d14e93

Please sign in to comment.