summaryrefslogtreecommitdiff
path: root/modules/comment/views/comment_form.html.php
blob: cc2c402884158b10336406ca3a3041bce7ce02c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<? defined("SYSPATH") or die("No direct script access."); ?>
<script type="text/javascript">
  // <![CDATA[
function show_comment_add_form(url) {
  $("#gCommentAddLink").hide();
  $.get(url, function(data) {
    $("#gAddCommentFormContainer").html(data);
    ajaxify_comment_add_form();
  });
}

function ajaxify_comment_add_form() {
  $("#gLoginMenu form ul").addClass("gInline");
  $("form#gComment").ajaxForm({
    target: "#gAddCommentFormContainer",
    success: function(responseText, statusText) {
      if (!responseText) {
        reload_comments();
        $("#gCommentAddLink").show();
      } else {
        ajaxify_comment_add_form();
      }
    },
  });
}

function reload_comments() {
  $.get("<?= url::site("photo/{$item_id}/comments") ?>", function(data) {
    $("#gCommentThread").html(data);
  });
}
  // ]]>
</script>
<span id="gCommentAddLink">
  <a href="javascript:show_comment_add_form('<?= url::site("photo/{$item_id}/comments/add") ?>')">
    <?= _("Add Comment") ?>
  </a>
</span>
<div id="gAddCommentFormContainer"></div>