diff options
Diffstat (limited to 'modules/comment/views')
-rw-r--r-- | modules/comment/views/comment_form.html.php | 61 | ||||
-rw-r--r-- | modules/comment/views/comment_list.html.php | 26 | ||||
-rw-r--r-- | modules/comment/views/show_comments.html.php | 4 |
3 files changed, 53 insertions, 38 deletions
diff --git a/modules/comment/views/comment_form.html.php b/modules/comment/views/comment_form.html.php index 1561035f..cc2c4028 100644 --- a/modules/comment/views/comment_form.html.php +++ b/modules/comment/views/comment_form.html.php @@ -1,25 +1,40 @@ <? defined("SYSPATH") or die("No direct script access."); ?> -<form id="gCommentAdd"> - <fieldset> - <legend>Add comment</legend> - <ul> - <li> - <label for="gCommentAuthor"><?= _("Your Name") ?></label> - <input type="text" name="author" id="gCommentAuthor" /> - </li> - <li> - <label for="gCommentEmail"><?= _("Your Email (not displayed)") ?></label> - <input type="text" name="email" id="gCommentEmail" /> - </li> - <li> - <label for="gCommentText"><?= _("Comment") ?></label> - <textarea name="text" id="gCommentText"></textarea> - </li> - <li> - <input type="hidden" id="gItemId" name="item_id" value="<?= $item_id ?>" /> - <input type="submit" id="gCommentSubmit" value="<?= _("Add") ?>" /> - </li> - </ul> - </fieldset> -</form> +<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> diff --git a/modules/comment/views/comment_list.html.php b/modules/comment/views/comment_list.html.php index ea824597..81c5691e 100644 --- a/modules/comment/views/comment_list.html.php +++ b/modules/comment/views/comment_list.html.php @@ -1,15 +1,13 @@ <? defined("SYSPATH") or die("No direct script access."); ?> -<ul id="gCommentThread"> - <? foreach (array_reverse($comments) as $index => $comment): ?> - <li id="gComment-<?= $index; ?>" class="gComment <?= $index % 2 ? 'gOdd' : 'gEven' ?>"> - <p> - <a href="#" class="gAuthor"><?= $comment->author ?></a> - <?= comment::format_elapsed_time($comment->datetime) ?>, - <span class="gUnderstate"><?= strftime('%c', $comment->datetime) ?></span> - </p> - <div> - <?= $comment->text ?> - </div> - </li> - <? endforeach; ?> -</ul> +<? foreach (array_reverse($comments) as $index => $comment): ?> +<li id="gComment-<?= $index; ?>" class="gComment <?= $index % 2 ? 'gOdd' : 'gEven' ?>"> + <p> + <a href="#" class="gAuthor"><?= $comment->author ?></a> + <?= comment::format_elapsed_time($comment->datetime) ?>, + <span class="gUnderstate"><?= strftime('%c', $comment->datetime) ?></span> + </p> + <div> + <?= $comment->text ?> + </div> +</li> +<? endforeach; ?> diff --git a/modules/comment/views/show_comments.html.php b/modules/comment/views/show_comments.html.php index 5ba45883..35b2c67a 100644 --- a/modules/comment/views/show_comments.html.php +++ b/modules/comment/views/show_comments.html.php @@ -2,7 +2,9 @@ <div id="gComments"> <? if ($comment_list): ?> <h2><?= _("Comments") ?></h2> - <?= $comment_list ?> + <ul id="gCommentThread"> + <?= $comment_list ?> + </ul> <? endif ?> <?= $comment_form ?> |