From 95b09aaec4949875eb784a6da443d0eaad99bc21 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Tue, 11 Feb 2020 23:45:47 -0500 Subject: [PATCH] [frio] Add loading animation on comment form submit --- mod/photos.php | 1 + src/Object/Post.php | 1 + view/theme/frio/js/theme.js | 41 ++++++++++++++++++++++ view/theme/frio/templates/comment_item.tpl | 6 ++-- 4 files changed, 46 insertions(+), 3 deletions(-) diff --git a/mod/photos.php b/mod/photos.php index c683cc086a..5e5917452c 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -1404,6 +1404,7 @@ function photos_content(App $a) '$comment' => DI::l10n()->t('Comment'), '$submit' => DI::l10n()->t('Submit'), '$preview' => DI::l10n()->t('Preview'), + '$loading' => DI::l10n()->t('Loading...'), '$sourceapp' => DI::l10n()->t($a->sourcename), '$ww' => '', '$rand_num' => Crypto::randomDigits(12) diff --git a/src/Object/Post.php b/src/Object/Post.php index f55dbde0d5..7b8f4b00d6 100644 --- a/src/Object/Post.php +++ b/src/Object/Post.php @@ -919,6 +919,7 @@ class Post '$myphoto' => DI::baseUrl()->remove($a->contact['thumb']), '$comment' => DI::l10n()->t('Comment'), '$submit' => DI::l10n()->t('Submit'), + '$loading' => DI::l10n()->t('Loading...'), '$edbold' => DI::l10n()->t('Bold'), '$editalic' => DI::l10n()->t('Italic'), '$eduline' => DI::l10n()->t('Underline'), diff --git a/view/theme/frio/js/theme.js b/view/theme/frio/js/theme.js index 29d043a6a4..2ea3aa6d2f 100644 --- a/view/theme/frio/js/theme.js +++ b/view/theme/frio/js/theme.js @@ -94,6 +94,8 @@ $(document).ready(function(){ } } + let $body = $('body'); + // show bulk deletion button at network page if checkbox is checked $("body").change("input.item-select", function(){ var checked = false; @@ -368,6 +370,45 @@ $(document).ready(function(){ showHideEventMap(this); }); + // Comment form submit + $body.on('submit', '.comment-edit-form', function(e) { + e.preventDefault(); + + let $form = $(this); + let id = $form.data('item-id'); + let $commentSubmit = $form.find('.comment-edit-submit').button('loading'); + + unpause(); + commentBusy = true; + + $.post( + 'item', + $form.serialize(), + 'json' + ) + .then(function(data) { + if (data.success) { + $('#comment-edit-wrapper-' + id).hide(); + let $textarea = $('#comment-edit-text-' + id); + $textarea.val(''); + if ($textarea.get(0)) { + commentClose($textarea.get(0), id); + } + if (timer) { + clearTimeout(timer); + } + timer = setTimeout(NavUpdate,10); + force_update = true; + update_item = id; + } + if (data.reload) { + window.location.href = data.reload; + } + }) + .always(function() { + $commentSubmit.button('reset'); + }); + }) }); function openClose(theID) { diff --git a/view/theme/frio/templates/comment_item.tpl b/view/theme/frio/templates/comment_item.tpl index b60f5c429e..d4284d39b8 100644 --- a/view/theme/frio/templates/comment_item.tpl +++ b/view/theme/frio/templates/comment_item.tpl @@ -4,7 +4,7 @@ {{else}}
{{/if}} -
+ @@ -55,9 +55,9 @@

{{if $preview}} - + {{/if}} - +

-- 2.39.5