add gif button to award modal

master
Aevann 2023-10-06 17:57:11 +03:00
parent a57016b1ad
commit ef4096b849
3 changed files with 19 additions and 10 deletions

View File

@ -27,8 +27,8 @@ gifModal.addEventListener('shown.bs.modal', function () {
}, 1000);
});
async function show_gif_categories(form) {
commentFormID = form;
async function show_gif_categories(t, form) {
if (form) commentFormID = form;
gifSearchBar.value = null;
noGIFs.classList.add("d-none");
@ -112,14 +112,22 @@ async function show_gif_categories(form) {
element.addEventListener('click', () => {searchGifs(element.firstElementChild.innerHTML)});
}
gifModal.addEventListener('hide.bs.modal', () => {
setTimeout(() => {
document.getElementById(commentFormID).focus();
}, 200);
}, {once : true});
if (t) {
if (t.dataset.previousModal) {
gifModal.addEventListener('hide.bs.modal', () => {
bootstrap.Modal.getOrCreateInstance(document.getElementById(t.dataset.previousModal)).show()
}, {once : true});
}
gifModal.addEventListener('hide.bs.modal', () => {
setTimeout(() => {
document.getElementById(commentFormID).focus();
}, 200);
}, {once : true});
}
}
document.getElementById('gifs-back-btn').addEventListener('click', show_gif_categories);
document.getElementById('gifs-back-btn').addEventListener('click', () => show_gif_categories(null, null));
async function searchGifs(searchTerm) {

View File

@ -57,6 +57,7 @@
<label id="notelabel" for="note" class="pt-4">Note (optional):</label>
<textarea autocomplete="off" id="note" maxlength="200" class="form-control" placeholder="Note to include in award notification..."></textarea>
{{macros.emoji_btn('note', 'awardModal')}}
{{macros.gif_btn('note', 'awardModal')}}
</div>
<input autocomplete="off" id="giveaward" class="awardbtn btn btn-primary mt-3 fl-r" type="submit" data-nonce="{{g.nonce}}" data-onclick="giveaward(this)" value="Give Award" data-bs-dismiss="modal" disabled>

View File

@ -114,8 +114,8 @@
</button>
{% endmacro %}
{% macro gif_btn(textarea_id) %}
<button type="button" class="btn btn-secondary format m-0 mr-1 font-weight-bolder text-uppercase" data-nonce="{{g.nonce}}" data-onclick="show_gif_categories('{{textarea_id}}')" data-bs-toggle="modal" data-bs-target="#gifModal" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Add GIF">GIF</button>
{% macro gif_btn(textarea_id, previous_modal) %}
<button type="button" class="btn btn-secondary format m-0 mr-1 font-weight-bolder text-uppercase" data-nonce="{{g.nonce}}" data-onclick="show_gif_categories(this, '{{textarea_id}}')" data-bs-toggle="modal" data-bs-target="#gifModal" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Add GIF" {% if previous_modal %}data-previous-modal="{{previous_modal}}"{% endif %}>GIF</button>
{% endmacro %}
{% macro file_btn(input_id, disabled, image_only) %}