diff options
author | Marcel Korpel <marcel.korpel@gmail.com> | 2015-07-21 22:53:57 +0200 |
---|---|---|
committer | Lukas Fleischer <lfleischer@archlinux.org> | 2015-08-08 12:59:24 +0200 |
commit | 54d812ec791de4b36d45cdcb853d01dc72d78669 (patch) | |
tree | da97b3ae8534d628f124da98daf55f11f9cad30f /web/template | |
parent | 8328223a5e4670fbeb62c13ef89aa345f3ccc4c8 (diff) | |
download | aurweb-54d812ec791de4b36d45cdcb853d01dc72d78669.tar.xz |
pkg_comments.php: Add JavaScript function to edit comments
Signed-off-by: Marcel Korpel <marcel.korpel@gmail.com>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
Diffstat (limited to 'web/template')
-rw-r--r-- | web/template/pkg_comments.php | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/web/template/pkg_comments.php b/web/template/pkg_comments.php index bb006b9..21ce16f 100644 --- a/web/template/pkg_comments.php +++ b/web/template/pkg_comments.php @@ -70,3 +70,38 @@ $count = pkgbase_comments_count($base_id, $include_deleted); </h3> <?php endif; ?> </div> +<script> +$(document).ready(function() { + $('.edit-comment').click(function () { + var parent_element = this.parentElement, + parent_id = parent_element.id, + comment_id = parent_id.substr(parent_id.indexOf('-') + 1), + edit_form = $(parent_element).next(), + _this = $(this); + add_busy_indicator(_this); + $.getJSON('<?= get_uri('/rpc') ?>', { + type: 'get-comment-form', + arg: comment_id, + base_id: <?= intval($base_id) ?>, + pkgbase_name: <?= json_encode($pkgbase_name) ?> + }, function (data) { + remove_busy_indicator(_this); + if (data.success) { + edit_form.html(data.form); + edit_form.find('textarea').focus(); + } else { + alert(data.error); + } + }); + 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> |