Signed-off-by: Marcel Korpel <marcel.korpel@gmail.com> --- Changes since v1: * Drop the AJAX form submission, instead use a normal form. * Pass variables $base_id and $pkgbase_name that are now needed when rendering the form. * Add loading indicator. web/html/css/aurweb.css | 6 ++++++ web/html/images/ajax-loader.gif | Bin 0 -> 723 bytes web/html/index.php | 4 ++++ web/template/pkg_comments.php | 30 ++++++++++++++++++++++++++++++ 4 files changed, 40 insertions(+) create mode 100644 web/html/images/ajax-loader.gif diff --git a/web/html/css/aurweb.css b/web/html/css/aurweb.css index b33726c..4fb256f 100644 --- a/web/html/css/aurweb.css +++ b/web/html/css/aurweb.css @@ -124,6 +124,12 @@ opacity: 1; } +.ajax-loader { + float: right; + position: relative; + top: 4px; +} + legend { padding: 1em 0; } diff --git a/web/html/images/ajax-loader.gif b/web/html/images/ajax-loader.gif new file mode 100644 index 0000000000000000000000000000000000000000..df07e7ec2076177c99b53d4d29a45f0db6b06a9a GIT binary patch literal 723 zcmZ?wbhEHb6ky<H_`<;O|NnpEv{esZe7gDQ-MdfU%`;a6x#5jFXKlVxKmX+MtIz$a zw&qPbv~b7uriG_ZU4Ic+v&}4Hb>Wo5uik&V|NP^(AHU+;_dI&}>C3lYM=m|vboAbp zdv88|`N04KivPL&TtkAL9RpmA^bD98f#Qn)q@0UV6H8K46v{J8G87WC5-W1@6I1ju z^V0Ge6o0aCasyTAfJ^{6l7UrML7^`tbKa5#T#rsMt#c4)wm4&2aJl;4?H%*^*q;ct zZ+YZ!f=91--8C-PwbPuinV^!8D8ZUAZ$+j|`^0?*ZXH_r=F;-s=Wq7D-W{Q@F^9F$ zTCh`s37bYUpw-=pI*&V4IF+P$l9wbc(l{x7eoOCbBdG(^nGZDWjsAGTTd?u$#mhT{ z{bn8t<<=6J=66T{n^C4fqn2>E3WhNCJ~l~G@x1uTreFAcY2|b4S-i`cPqf%2ZE*i3 z+J9zZu_cRC<?3tQyR_y8DPl9p2ofIGHbp#h37ovc<5E&ksO!lsv5&0c-cGyCn07cm z@P#sC?}=w8Sd-^@t-ShG3aj7DA;zc_#<r~3l(a1KW^3Z~jK_<%<<5%bQ+V^YX?vpJ z17^MHzAF7QOqk+z8O+R1FWC1Why$CG^dV+F0lH_!rgy7~WK@H;@IEkI|9iVk!F29# fT}NgWw#xj9(`7JWbB<iU1Zx11Y=$)`iGTqBb+`}S literal 0 HcmV?d00001 diff --git a/web/html/index.php b/web/html/index.php index 175a533..7068d76 100644 --- a/web/html/index.php +++ b/web/html/index.php @@ -160,6 +160,10 @@ if (!empty($tokens[1]) && '/' . $tokens[1] == get_pkg_route()) { header("Content-Type: text/css"); readfile("./$path"); break; + case "/images/ajax-loader.gif": + header("Content-Type: image/gif"); + readfile("./$path"); + break; case "/css/archnavbar/archlogo.gif": case "/images/new.png": header("Content-Type: image/png"); diff --git a/web/template/pkg_comments.php b/web/template/pkg_comments.php index 26fddfd..eac0da1 100644 --- a/web/template/pkg_comments.php +++ b/web/template/pkg_comments.php @@ -72,3 +72,33 @@ $count = pkgbase_comments_count($base_id, $include_deleted); </h3> </div> <?php endif; ?> +<script> +$(document).ready(function() { + $(".edit-comment").click(function () { + var parent_element = this.parentElement, + edit_form = $(parent_element).next(), + comment_id = parent_element.id.substr(8), + _this = $(this); + add_busy_indicator(_this); + $.getJSON('<?= get_uri('/rpc') ?>', + {type: 'load-comment', + arg: comment_id, + base_id: <?= htmlspecialchars($base_id) ?>, + pkgbase_name: '<?= htmlspecialchars($pkgbase_name) ?>'}, + function (data) { + remove_busy_indicator(_this); + edit_form.html(data.form); + edit_form.find('textarea').focus(); + }); + return false; + }); + + function add_busy_indicator(sibling) { + sibling.after('<img src="/images/ajax-loader.gif" class="ajax-loader" width="16" height="11" alt="Busy…">'); + } + + function remove_busy_indicator(sibling) { + sibling.next().remove(); + } +}); +</script> -- 2.4.6