summaryrefslogtreecommitdiff
path: root/modules/comment/views/comment_form.html.php
blob: 86c76dba8e10553fdf707005dcc82e985bb0ca9b (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
<? 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) {
    $("#gCommentAddFormContainer").html(data);
    ajaxify_comment_add_form();
  });
}

function ajaxify_comment_add_form() {
  $("form#gComment").ajaxForm({
    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();
      }
    },
  });
}
  // ]]>
</script>
<span id="gCommentAddLink">
  <a href="javascript:show_comment_add_form('<?= url::site("photo/{$item_id}/comments/add") ?>')">
    <?= _("Add Comment") ?>
  </a>
</span>
<div id="gCommentAddFormContainer"></div>