From ab8b4b95249ab0cfb364cac1dddb267005099a29 Mon Sep 17 00:00:00 2001 From: towards-a-new-leftypol Date: Sun, 27 Jun 2021 01:09:28 +0000 Subject: [PATCH] defer additional_javascript - this required a fix to file-selector --- js/file-selector.js | 41 ++++++++++++++++++++++------------------ templates/header.html | 2 +- templates/post_form.html | 10 +++++++--- 3 files changed, 31 insertions(+), 22 deletions(-) diff --git a/js/file-selector.js b/js/file-selector.js index c2b5381b..a14a9167 100644 --- a/js/file-selector.js +++ b/js/file-selector.js @@ -8,24 +8,6 @@ */ function init_file_selector(max_images) { -$(document).ready(function () { - // add options panel item - if (window.Options && Options.get_tab('general')) { - Options.extend_tab('general', ''); - - $('#file-drag-drop>input').on('click', function() { - if ($('#file-drag-drop>input').is(':checked')) { - localStorage.file_dragdrop = 'true'; - } else { - localStorage.file_dragdrop = 'false'; - } - }); - - if (typeof localStorage.file_dragdrop === 'undefined') localStorage.file_dragdrop = 'true'; - if (localStorage.file_dragdrop === 'true') $('#file-drag-drop>input').prop('checked', true); - } -}); - // disabled by user, or incompatible browser. if (localStorage.file_dragdrop == 'false' || !(window.URL.createObjectURL && window.File)) return; @@ -190,3 +172,26 @@ $(document).on('paste', function (e) { }); } + +$(document).ready(function () { + // add options panel item + if (window.Options && Options.get_tab('general')) { + Options.extend_tab('general', ''); + + $('#file-drag-drop>input').on('click', function() { + if ($('#file-drag-drop>input').is(':checked')) { + localStorage.file_dragdrop = 'true'; + } else { + localStorage.file_dragdrop = 'false'; + } + }); + + if (typeof localStorage.file_dragdrop === 'undefined') localStorage.file_dragdrop = 'true'; + if (localStorage.file_dragdrop === 'true') $('#file-drag-drop>input').prop('checked', true); + } +}); + +$(document).ready(function () { + var maxImages = document.querySelector("form[name=post]").dataset.maxImages; + init_file_selector(new Number(maxImages)); +}); diff --git a/templates/header.html b/templates/header.html index 6c1e6346..d4ef94e0 100644 --- a/templates/header.html +++ b/templates/header.html @@ -17,7 +17,7 @@ {% if not nojavascript %} {% if not config.additional_javascript_compile %} - {% for javascript in config.additional_javascript %}{% endfor %} + {% for javascript in config.additional_javascript %}{% endfor %} {% endif %} {% endif %} {% if config.recaptcha %} diff --git a/templates/post_form.html b/templates/post_form.html index 1bcd1a72..f70871d4 100644 --- a/templates/post_form.html +++ b/templates/post_form.html @@ -1,4 +1,10 @@ -
+ {{ antibot.html() }} {% if id %}{% endif %} {{ antibot.html() }} @@ -142,8 +148,6 @@ - - {% if config.allow_upload_by_url %}
: