mirror of
https://github.com/Pathduck/gallery3.git
synced 2026-06-09 13:09:33 -04:00
Do comment add in a single request, some code cleanup.
This commit is contained in:
@@ -4,30 +4,26 @@
|
||||
function show_comment_add_form(url) {
|
||||
$("#gCommentAddLink").hide();
|
||||
$.get(url, function(data) {
|
||||
$("#gAddCommentFormContainer").html(data);
|
||||
$("#gCommentAddFormContainer").html(data);
|
||||
ajaxify_comment_add_form();
|
||||
});
|
||||
}
|
||||
|
||||
function ajaxify_comment_add_form() {
|
||||
$("form#gComment").ajaxForm({
|
||||
target: "#gAddCommentFormContainer",
|
||||
success: function(responseText, statusText) {
|
||||
if (!responseText) {
|
||||
reload_comments();
|
||||
dataType: 'json',
|
||||
success: function(response_data, status_text) {
|
||||
if (response_data['valid']) {
|
||||
$("#gCommentThread").html(response_data["html"]);
|
||||
$("#gCommentAddFormContainer").html("");
|
||||
$("#gCommentAddLink").show();
|
||||
} else {
|
||||
$("#gCommentAddFormContainer").html(response_data["html"]);
|
||||
ajaxify_comment_add_form();
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function reload_comments() {
|
||||
$.get("<?= url::site("photo/{$item_id}/comments") ?>", function(data) {
|
||||
$("#gCommentThread").html(data);
|
||||
});
|
||||
}
|
||||
// ]]>
|
||||
</script>
|
||||
<span id="gCommentAddLink">
|
||||
@@ -35,5 +31,5 @@ function reload_comments() {
|
||||
<?= _("Add Comment") ?>
|
||||
</a>
|
||||
</span>
|
||||
<div id="gAddCommentFormContainer"></div>
|
||||
<div id="gCommentAddFormContainer"></div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user