mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
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>
This commit is contained in:
parent
8328223a5e
commit
54d812ec79
4 changed files with 45 additions and 0 deletions
|
@ -124,6 +124,12 @@
|
|||
opacity: 1;
|
||||
}
|
||||
|
||||
.ajax-loader {
|
||||
float: right;
|
||||
position: relative;
|
||||
top: 4px;
|
||||
}
|
||||
|
||||
legend {
|
||||
padding: 1em 0;
|
||||
}
|
||||
|
|
BIN
web/html/images/ajax-loader.gif
Normal file
BIN
web/html/images/ajax-loader.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 723 B |
|
@ -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");
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Add table
Reference in a new issue