From 27e64f1dc6cc43b40592337eed360bdf7e3d7a59 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Thu, 27 Nov 2008 06:14:32 +0000 Subject: Move javascript from default theme to appropriate modules --- modules/comment/helpers/comment_block.php | 5 +++++ modules/comment/js/comment.js | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 modules/comment/js/comment.js (limited to 'modules/comment') diff --git a/modules/comment/helpers/comment_block.php b/modules/comment/helpers/comment_block.php index 58a1a416..ee05a383 100644 --- a/modules/comment/helpers/comment_block.php +++ b/modules/comment/helpers/comment_block.php @@ -19,6 +19,11 @@ */ class comment_block_Core { + public static function head($theme) { + $url = url::file("modules/comment/js/comment.js"); + return "\n"; + } + public static function photo_bottom($theme) { return comment::block($theme, true); } diff --git a/modules/comment/js/comment.js b/modules/comment/js/comment.js new file mode 100644 index 00000000..259b4826 --- /dev/null +++ b/modules/comment/js/comment.js @@ -0,0 +1,19 @@ +$("document").ready(function() { + ajaxify_comment_form(); +}); + +function ajaxify_comment_form() { + $("#gComments form").ajaxForm({ + complete: function(xhr, statusText) { + $("#gComments form").replaceWith(xhr.responseText); + if (xhr.status == 201) { + $.get(xhr.getResponseHeader("Location"), function(data, textStatus) { + $("#gComments .gBlockContent ul:first").append("
  • "+data+"
  • "); + $("#gComments .gBlockContent ul:first li:last").hide().slideDown(); + }); + $("#gComments form").clearForm(); + } + ajaxify_comment_form(); + } + }); +} -- cgit v1.2.3