diff options
| author | Magnus Hagander | 2025-06-16 09:06:50 +0000 |
|---|---|---|
| committer | Magnus Hagander | 2025-06-16 09:16:55 +0000 |
| commit | 2a74077d8edad5d45fb56fcb14456967d678232b (patch) | |
| tree | c573b6a5b0f838630610b9e9da31d108faeadde1 | |
| parent | 616a02a79fa2bf4804adf5b73bf94c55343bc6df (diff) | |
Rewrite javascript snippets to be native javascript instead of jquery
Unfortunately at this time we still cannot drop the jquery dependency as
it's needed by the menubar from bootstrap.
| -rw-r--r-- | django/media/js/main.js | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/django/media/js/main.js b/django/media/js/main.js index d25a86a..e3d4d8e 100644 --- a/django/media/js/main.js +++ b/django/media/js/main.js @@ -1,15 +1,20 @@ -$(function(){ - /* Callback from main message view when a message is picked in dropdown */ - $('#thread_select').change(function(e) { - document.location.href = '/message-id/' + $(this).val(); - }); +document.addEventListener('DOMContentLoaded', (event) => { + const threadselect = document.getElementById('thread_select'); + if (threadselect) { + threadselect.addEventListener('change', (event) => { + document.location.href = '/message-id/' + event.target.value; + event.preventDefault(); + }); + } /* Callback for viewing protected versions */ - $('a.post-link').click(function(e) { - if ($(this).data('ref')) { - $('#mail_other_options_form').attr('action', $(this).data('ref')); - $('#mail_other_options_form').submit(); - } + const postlinkform = document.getElementById('mail_other_options_form'); + document.querySelectorAll('a.post-link').forEach((link) => { + link.addEventListener('click', (event) => { + postlinkform.action = event.target.dataset.ref; + postlinkform.submit(); + event.preventDefault(); + }); }); @@ -17,11 +22,10 @@ $(function(){ * For flat message view, redirect to the anchor of the messageid we're watching, * unless we happen to be the first one. */ - $('#flatMsgSubject[data-isfirst=False]').each(function(i, e) { + document.querySelectorAll('#flatMsgSubject[data-isfirst=False]').forEach((e) => { if (document.location.href.indexOf('#') < 0) { - document.location.href = document.location.href + '#' + $(e).data('msgid'); - return; - } + document.location.href = document.location.href + '#' + e.dataset.msgid; + } }); }); |
