Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Commit

Permalink
Merge pull request #6 from christianwach/master
Browse files Browse the repository at this point in the history
comments may contain lists
  • Loading branch information
christianwach committed Jul 25, 2012
2 parents fcfb940 + 3994fdc commit 5605fd2
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 21 deletions.
29 changes: 19 additions & 10 deletions cp-ajax-comments-page.dev.js
Expand Up @@ -3,7 +3,7 @@
CommentPress AJAX Comment Submission (in page)
===============================================================
AUTHOR : Christian Wach <needle@haystack.co.uk>
LAST MODIFIED : 16/09/2010
LAST MODIFIED : 25/07/2012
DEPENDENCIES : jquery.js
---------------------------------------------------------------
NOTES
Expand Down Expand Up @@ -140,9 +140,9 @@ jQuery(document).ready(function($) {

cpac_nice_append(
response,
parent_id + ' .children:first li:last',
parent_id + ' .children:first > li:last',
child_list,
parent_id + ' .children:first li:last'
parent_id + ' .children:first > li:last'
);

} else {
Expand All @@ -151,7 +151,7 @@ jQuery(document).ready(function($) {
response,
parent_id + ' .children:first',
parent_id,
parent_id + ' .children:first li:last'
parent_id + ' .children:first > li:last'
);

}
Expand All @@ -164,9 +164,9 @@ jQuery(document).ready(function($) {

cpac_nice_append(
response,
'ol.commentlist:first li:last',
'ol.commentlist:first > li:last',
comm_list,
'ol.commentlist:first li:last'
'ol.commentlist:first > li:last'
);

} else {
Expand All @@ -175,7 +175,7 @@ jQuery(document).ready(function($) {
response,
'ol.commentlist:first',
'div.comments_container',
'ol.commentlist:first li:last'
'ol.commentlist:first > li:last'
);

}
Expand All @@ -201,7 +201,7 @@ jQuery(document).ready(function($) {





/**
* @description: do comment append
Expand All @@ -210,6 +210,10 @@ jQuery(document).ready(function($) {
*/
function cpac_nice_append( response, content, target, last ) {

// test for undefined, which may happen on replies to comments
// which have lost their original context
if ( response === undefined || response === null ) { return; }

response.find(content)
.hide()
.appendTo(target);
Expand All @@ -231,10 +235,14 @@ jQuery(document).ready(function($) {
*/
function cpac_nice_prepend( response, content, target, last ) {

// test for undefined, which may happen on replies to comments
// which have lost their original context
if ( response === undefined || response === null ) { return; }

response.find(content)
.hide()
.prependTo(target);

// clean up
cpac_cleanup( content, last );

Expand All @@ -254,7 +262,7 @@ jQuery(document).ready(function($) {

// get the id of the last list item
var last_id = jQuery(last).attr('id');

// construct new comment id
var new_comm_id = '#comment-' + last_id.split('-')[2];
var comment = jQuery(new_comm_id);
Expand Down Expand Up @@ -405,6 +413,7 @@ jQuery(document).ready(function($) {

// get our data as object
var response = jQuery(data);
//console.log( data );

// add comment
cpac_add_comment( response );
Expand Down
2 changes: 1 addition & 1 deletion cp-ajax-comments-page.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions cp-ajax-comments.dev.js
Expand Up @@ -3,14 +3,14 @@
CommentPress AJAX Comment Submission
===============================================================
AUTHOR : Christian Wach <needle@haystack.co.uk>
LAST MODIFIED : 16/09/2010
LAST MODIFIED : 25/07/2012
DEPENDENCIES : jquery.js
---------------------------------------------------------------
NOTES
This script enables AJAX comment posting when the CommentPress theme is active.
Based on the 'Ajax Comment Posting' WordPress plugin (version 2.0)
Based loosely on the 'Ajax Comment Posting' WordPress plugin (version 2.0)
---------------------------------------------------------------
*/
Expand Down Expand Up @@ -493,9 +493,9 @@ jQuery(document).ready(function($) {

cpac_nice_append(
response,
parent_id + ' > ol.children:first li:last',
parent_id + ' > ol.children:first > li:last',
child_list,
parent_id + ' > ol.children:first li:last'
parent_id + ' > ol.children:first > li:last'
);

} else {
Expand All @@ -504,7 +504,7 @@ jQuery(document).ready(function($) {
response,
parent_id + ' > ol.children:first',
parent_id,
parent_id + ' > ol.children:first li:last'
parent_id + ' > ol.children:first > li:last'
);

}
Expand All @@ -520,9 +520,9 @@ jQuery(document).ready(function($) {

cpac_nice_append(
response,
para_id + ' > ol.commentlist:first li:last',
para_id + ' > ol.commentlist:first > li:last',
comm_list,
para_id + ' > ol.commentlist:first li:last'
para_id + ' > ol.commentlist:first > li:last'
);

} else {
Expand All @@ -531,7 +531,7 @@ jQuery(document).ready(function($) {
response,
para_id + ' > ol.commentlist:first',
para_id,
para_id + ' > ol.commentlist:first li:last'
para_id + ' > ol.commentlist:first > li:last'
);

}
Expand Down

0 comments on commit 5605fd2

Please sign in to comment.