2008-02-28 01:50:25 -05:00
|
|
|
var theList; var theExtraList;
|
2008-08-29 01:07:40 -04:00
|
|
|
(function($) {
|
|
|
|
|
|
|
|
setCommentsList = function() {
|
|
|
|
var dimAfter = function( r, settings ) {
|
|
|
|
$('li span.comment-count').each( function() {
|
|
|
|
var a = $(this);
|
|
|
|
var n = parseInt(a.html(),10);
|
|
|
|
n = n + ( $('#' + settings.element).is('.' + settings.dimClass) ? 1 : -1 );
|
|
|
|
if ( n < 0 ) { n = 0; }
|
|
|
|
a.html( n.toString() );
|
|
|
|
$('#awaiting-mod')[ 0 == n ? 'addClass' : 'removeClass' ]('count-0');
|
|
|
|
});
|
|
|
|
$('.post-com-count span.comment-count').each( function() {
|
|
|
|
var a = $(this);
|
|
|
|
var n = parseInt(a.html(),10);
|
2008-03-04 12:07:47 -05:00
|
|
|
var t = parseInt(a.parent().attr('title'), 10);
|
2008-08-29 01:07:40 -04:00
|
|
|
if ( $('#' + settings.element).is('.unapproved') ) { // we unapproved a formerly approved comment
|
|
|
|
n = n - 1;
|
|
|
|
t = t + 1;
|
|
|
|
} else { // we approved a formerly unapproved comment
|
|
|
|
n = n + 1;
|
|
|
|
t = t - 1;
|
|
|
|
}
|
|
|
|
if ( n < 0 ) { n = 0; }
|
|
|
|
if ( t < 0 ) { t = 0; }
|
|
|
|
if ( t >= 0 ) { a.parent().attr('title', adminCommentsL10n.pending.replace( /%i%/, t.toString() ) ); }
|
2008-03-04 12:07:47 -05:00
|
|
|
if ( 0 === t ) { a.parents('strong:first').replaceWith( a.parents('strong:first').html() ); }
|
2008-08-29 01:07:40 -04:00
|
|
|
a.html( n.toString() );
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
var delAfter = function( r, settings ) {
|
|
|
|
$('li span.comment-count').each( function() {
|
|
|
|
var a = $(this);
|
|
|
|
var n = parseInt(a.html(),10);
|
|
|
|
if ( $('#' + settings.element).is('.unapproved') ) { // we deleted a formerly unapproved comment
|
|
|
|
n = n - 1;
|
|
|
|
} else if ( $(settings.target).parents( 'span.unapprove' ).size() ) { // we "deleted" an approved comment from the approved list by clicking "Unapprove"
|
|
|
|
n = n + 1;
|
|
|
|
}
|
|
|
|
if ( n < 0 ) { n = 0; }
|
|
|
|
a.html( n.toString() );
|
|
|
|
$('#awaiting-mod')[ 0 == n ? 'addClass' : 'removeClass' ]('count-0');
|
|
|
|
});
|
|
|
|
$('.post-com-count span.comment-count').each( function() {
|
|
|
|
var a = $(this);
|
|
|
|
if ( $('#' + settings.element).is('.unapproved') ) { // we deleted a formerly unapproved comment
|
|
|
|
var t = parseInt(a.parent().attr('title'), 10);
|
|
|
|
if ( t < 1 ) { return; }
|
|
|
|
t = t - 1;
|
|
|
|
a.parent().attr('title', adminCommentsL10n.pending.replace( /%i%/, t.toString() ) );
|
|
|
|
if ( 0 === t ) { a.parents('strong:first').replaceWith( a.parents('strong:first').html() ); }
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
var n = parseInt(a.html(),10) - 1;
|
|
|
|
a.html( n.toString() );
|
|
|
|
});
|
|
|
|
$('li span.spam-comment-count' ).each( function() {
|
|
|
|
var a = $(this);
|
|
|
|
var n = parseInt(a.html(),10);
|
|
|
|
if ( $(settings.target).parents( 'span.spam' ).size() ) { // we marked a comment as spam
|
|
|
|
n = n + 1;
|
|
|
|
} else if ( $('#' + settings.element).is('.spam') ) { // we approved or deleted a comment marked as spam
|
|
|
|
n = n - 1;
|
|
|
|
}
|
|
|
|
if ( n < 0 ) { n = 0; }
|
|
|
|
a.html( n.toString() );
|
|
|
|
});
|
|
|
|
|
|
|
|
if ( theExtraList.size() == 0 || theExtraList.children().size() == 0 ) {
|
2008-03-04 12:07:47 -05:00
|
|
|
return;
|
|
|
|
}
|
2008-08-29 01:07:40 -04:00
|
|
|
|
|
|
|
theList.get(0).wpList.add( theExtraList.children(':eq(0)').remove().clone() );
|
|
|
|
$('#get-extra-comments').submit();
|
|
|
|
};
|
2007-03-27 17:20:16 -04:00
|
|
|
|
2008-08-29 01:07:40 -04:00
|
|
|
theExtraList = $('#the-extra-comment-list').wpList( { alt: '', delColor: 'none', addColor: 'none' } );
|
|
|
|
theList = $('#the-comment-list').wpList( { alt: '', dimAfter: dimAfter, delAfter: delAfter, addColor: 'none' } );
|
|
|
|
};
|
2006-06-06 00:14:04 -04:00
|
|
|
|
2008-08-29 01:07:40 -04:00
|
|
|
$(document).ready(function(){
|
|
|
|
setCommentsList();
|
2008-08-24 02:56:22 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
commentReply = {
|
|
|
|
|
|
|
|
open : function(c, p) {
|
|
|
|
var d = $('#comment-'+c).offset(), H = $('#replydiv').height(), top = 200, left = 100, h = 120;
|
|
|
|
|
|
|
|
if ( d && H ) {
|
|
|
|
top = (d.top - H) < 10 ? 10 : d.top - H - 5;
|
|
|
|
left = d.left;
|
|
|
|
}
|
|
|
|
|
|
|
|
$('#replydiv #comment_post_ID').val(p);
|
|
|
|
$('#replydiv #comment_ID').val(c);
|
|
|
|
|
|
|
|
$('#replydiv').draggable({
|
|
|
|
handle : '#replyhandle',
|
|
|
|
containment : '#wpwrap'
|
2008-08-29 01:07:40 -04:00
|
|
|
}).resizable({
|
2008-08-24 02:56:22 -04:00
|
|
|
handles : 'se',
|
|
|
|
minHeight : 200,
|
|
|
|
minWidth : 400,
|
|
|
|
containment : '#wpwrap',
|
|
|
|
resize : function(e,o) {
|
|
|
|
h = o.size.height - 80 - $('#ed_reply_qtags').height();
|
|
|
|
$('#replycontainer').height(h);
|
|
|
|
},
|
|
|
|
stop : function(e,o) {
|
|
|
|
if ( $.browser.msie )
|
|
|
|
$('#replycontent').height(h);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$('.ui-resizable-se').css({
|
|
|
|
border: '0 none',
|
|
|
|
width: '11px',
|
|
|
|
height: '12px',
|
|
|
|
background: 'transparent url(images/se.png) no-repeat scroll 0 0'
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#replydiv').css({
|
|
|
|
'position' : 'absolute',
|
|
|
|
'top' : top,
|
|
|
|
'left' : left
|
2008-08-29 01:07:40 -04:00
|
|
|
}).show();
|
2008-08-24 02:56:22 -04:00
|
|
|
|
|
|
|
$('#replycontent').focus().keyup(function(e){
|
|
|
|
if (e.which == 27) commentReply.close(); // close on Escape
|
|
|
|
});
|
|
|
|
|
|
|
|
// emulate the Safari/Opera scrollIntoView
|
|
|
|
var to = $('#replydiv').offset();
|
|
|
|
var scr = document.documentElement.scrollTop ? document.documentElement.scrollTop : 0;
|
|
|
|
|
|
|
|
if ( scr - 20 > to.top )
|
|
|
|
window.scroll(0, to.top - 100);
|
|
|
|
},
|
|
|
|
|
|
|
|
close : function() {
|
|
|
|
$('#replycontent').val('');
|
|
|
|
$('#replyerror').hide();
|
|
|
|
|
|
|
|
$('#replydiv').draggable('destroy').resizable('destroy').css('position','relative');
|
|
|
|
$('#replydiv').hide();
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
|
|
|
|
send : function() {
|
|
|
|
var post = {};
|
|
|
|
|
|
|
|
$('#replyform input').each(function() {
|
|
|
|
post[ $(this).attr('name') ] = $(this).val();
|
|
|
|
});
|
|
|
|
|
|
|
|
post.comment = $('#replycontent').val();
|
|
|
|
post.id = post.comment_post_ID;
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
type : 'POST',
|
|
|
|
url : wpListL10n.url,
|
|
|
|
data : post,
|
|
|
|
success : function(x) { commentReply.show(x); },
|
|
|
|
error : function(r) { commentReply.error(r); }
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
show : function(xml) {
|
|
|
|
|
|
|
|
if ( typeof(xml) == 'string' ) {
|
|
|
|
this.error({'responseText': xml});
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var r = wpAjax.parseAjaxResponse(xml);
|
|
|
|
if ( r.errors )
|
|
|
|
this.error({'responseText': wpAjax.broken});
|
|
|
|
|
|
|
|
r = r.responses[0];
|
|
|
|
this.close();
|
|
|
|
// var scr1 = $('#the-comment-list').offset(), scr2 = $('#the-comment-list').height();
|
|
|
|
|
|
|
|
if ( r.position == -1 ) {
|
|
|
|
// window.scroll(0, scr1.top - 100); // Scroll to the new comment? Seems annoing..
|
|
|
|
$('#the-comment-list').prepend(r.data);
|
|
|
|
} else {
|
|
|
|
// window.scroll(0, scr1.top + scr2 + 200);
|
|
|
|
$('#the-comment-list').append(r.data);
|
|
|
|
}
|
|
|
|
|
2008-09-05 15:11:41 -04:00
|
|
|
$('#comment-'+r.id+' .hide-if-no-js').removeClass('hide-if-no-js');
|
|
|
|
|
2008-08-24 02:56:22 -04:00
|
|
|
$('#comment-'+r.id)
|
2008-09-05 15:11:41 -04:00
|
|
|
.animate( { backgroundColor:"#CCEEBB" }, 600 )
|
2008-08-24 02:56:22 -04:00
|
|
|
.animate( { backgroundColor:"transparent" }, 600 );
|
2008-08-29 01:07:40 -04:00
|
|
|
|
|
|
|
setCommentsList();
|
2008-08-24 02:56:22 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
error : function(r) {
|
|
|
|
var er = r.statusText;
|
|
|
|
|
|
|
|
if ( r.responseText )
|
|
|
|
er = r.responseText.replace( /<.[^<>]*?>/g, '' );
|
|
|
|
|
|
|
|
if ( er ) {
|
|
|
|
var o = $('#replydiv').offset();
|
|
|
|
$('#replydiv').hide();
|
|
|
|
|
|
|
|
$('#replyerror').css({
|
|
|
|
'top' : o.top + 60 + 'px',
|
|
|
|
'left' : o.left + 'px'
|
|
|
|
}).show().draggable();
|
|
|
|
|
|
|
|
$('#replyerrtext').html(er)
|
|
|
|
$('#close-button').css('outline','none').focus().keyup(function(e) {
|
|
|
|
if (e.which == 27) commentReply.close(); // close on Escape
|
|
|
|
});
|
|
|
|
}
|
2008-08-29 01:07:40 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
back : function() {
|
|
|
|
if ( $('#replydiv').is(':hidden') && $('#replyerror').is(':visible') ) {
|
|
|
|
$('#replyerror').hide();
|
|
|
|
$('#replydiv').show();
|
|
|
|
}
|
2008-08-24 02:56:22 -04:00
|
|
|
}
|
2008-08-29 01:07:40 -04:00
|
|
|
};
|
2008-08-24 02:56:22 -04:00
|
|
|
|
|
|
|
$(document).ready(function(){
|
2008-09-25 21:05:52 -04:00
|
|
|
columns.init('comment');
|
|
|
|
|
2008-08-24 02:56:22 -04:00
|
|
|
if ( typeof QTags != 'undefined' )
|
|
|
|
ed_reply = new QTags('ed_reply', 'replycontent', 'replycontainer', 'more');
|
2008-09-05 15:11:41 -04:00
|
|
|
|
2008-09-01 01:28:41 -04:00
|
|
|
if ( typeof $.table_hotkeys != 'undefined' ) {
|
|
|
|
var make_hotkeys_redirect = function(which) {
|
|
|
|
return function() {
|
|
|
|
var first_last = 'next' == which? 'first' : 'last';
|
|
|
|
var l=$('.'+which+'.page-numbers');
|
|
|
|
if (l.length)
|
|
|
|
window.location = l[0].href.replace(/\&hotkeys_highlight_(first|last)=1/g, '')+'&hotkeys_highlight_'+first_last+'=1';
|
|
|
|
}
|
2008-09-04 13:53:14 -04:00
|
|
|
};
|
|
|
|
var edit_comment = function(event, current_row) {
|
|
|
|
window.location = $('span.edit a', current_row).attr('href');
|
|
|
|
};
|
|
|
|
var toggle_all = function() {
|
|
|
|
var master_checkbox = $('form#comments-form .check-column :checkbox:first');
|
|
|
|
master_checkbox.attr('checked', master_checkbox.attr('checked')? '' : 'checked');
|
|
|
|
checkAll('form#comments-form');
|
2008-09-01 01:28:41 -04:00
|
|
|
}
|
2008-09-04 13:53:14 -04:00
|
|
|
var make_bulk = function(value) {
|
|
|
|
return function(event, _) {
|
|
|
|
$('option[value='+value+']').attr('selected', 'selected');
|
|
|
|
$('form#comments-form')[0].submit();
|
2008-09-01 01:28:41 -04:00
|
|
|
}
|
2008-09-04 13:53:14 -04:00
|
|
|
};
|
|
|
|
$.table_hotkeys($('table.widefat'),['a', 'u', 's', 'd', 'r', ['e', edit_comment],
|
|
|
|
['shift+a', make_bulk('approve')], ['shift+s', make_bulk('markspam')],
|
|
|
|
['shift+d', make_bulk('delete')], ['shift+x', toggle_all]],
|
|
|
|
{highlight_first: adminCommentsL10n.hotkeys_highlight_first, highlight_last: adminCommentsL10n.hotkeys_highlight_last,
|
|
|
|
prev_page_link_cb: make_hotkeys_redirect('prev'), next_page_link_cb: make_hotkeys_redirect('next')}
|
2008-09-01 01:28:41 -04:00
|
|
|
);
|
|
|
|
}
|
2008-08-24 02:56:22 -04:00
|
|
|
});
|
|
|
|
|
2008-09-05 15:11:41 -04:00
|
|
|
})(jQuery);
|