2008-02-28 07:50:25 +01:00
|
|
|
var theList; var theExtraList;
|
2008-08-29 07:07:40 +02:00
|
|
|
(function($) {
|
|
|
|
|
|
|
|
setCommentsList = function() {
|
|
|
|
var dimAfter = function( r, settings ) {
|
2008-11-14 22:54:39 +01:00
|
|
|
var c = $('#' + settings.element);
|
2008-12-09 19:03:31 +01:00
|
|
|
|
2008-11-14 22:54:39 +01:00
|
|
|
if ( c.is('.unapproved') )
|
|
|
|
c.find('div.comment_status').html('0')
|
|
|
|
else
|
|
|
|
c.find('div.comment_status').html('1')
|
|
|
|
|
2008-11-15 19:57:53 +01:00
|
|
|
$('span.pending-count').each( function() {
|
2008-08-29 07:07:40 +02:00
|
|
|
var a = $(this);
|
2008-11-15 20:40:38 +01:00
|
|
|
var n = a.html().replace(/[ ,.]+/g, '');
|
|
|
|
n = parseInt(n,10);
|
2008-11-15 19:57:53 +01:00
|
|
|
if ( isNaN(n) ) return;
|
2008-08-29 07:07:40 +02:00
|
|
|
n = n + ( $('#' + settings.element).is('.' + settings.dimClass) ? 1 : -1 );
|
|
|
|
if ( n < 0 ) { n = 0; }
|
|
|
|
$('#awaiting-mod')[ 0 == n ? 'addClass' : 'removeClass' ]('count-0');
|
2008-11-15 22:58:51 +01:00
|
|
|
n = n.toString();
|
|
|
|
if ( n.length > 3 )
|
|
|
|
n = n.substr(0, n.length-3)+' '+n.substr(-3);
|
|
|
|
a.html(n);
|
2008-08-29 07:07:40 +02:00
|
|
|
});
|
|
|
|
};
|
2008-10-08 03:18:16 +02:00
|
|
|
|
2008-08-29 07:07:40 +02:00
|
|
|
var delAfter = function( r, settings ) {
|
2008-11-15 19:57:53 +01:00
|
|
|
$('span.pending-count').each( function() {
|
2008-08-29 07:07:40 +02:00
|
|
|
var a = $(this);
|
2008-11-15 20:40:38 +01:00
|
|
|
var n = a.html().replace(/[ ,.]+/g, '');
|
|
|
|
n = parseInt(n,10);
|
2008-11-15 19:57:53 +01:00
|
|
|
if ( isNaN(n) ) return;
|
2008-08-29 07:07:40 +02:00
|
|
|
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; }
|
|
|
|
$('#awaiting-mod')[ 0 == n ? 'addClass' : 'removeClass' ]('count-0');
|
2008-11-15 22:58:51 +01:00
|
|
|
n = n.toString();
|
|
|
|
if ( n.length > 3 )
|
|
|
|
n = n.substr(0, n.length-3)+' '+n.substr(-3);
|
|
|
|
a.html(n);
|
2008-08-29 07:07:40 +02:00
|
|
|
});
|
2008-11-15 19:57:53 +01:00
|
|
|
|
|
|
|
$('span.spam-count' ).each( function() {
|
2008-08-29 07:07:40 +02:00
|
|
|
var a = $(this);
|
2008-11-15 20:40:38 +01:00
|
|
|
var n = a.html().replace(/[ ,.]+/g, '');
|
|
|
|
n = parseInt(n,10);
|
2008-11-15 19:57:53 +01:00
|
|
|
if ( isNaN(n) ) return;
|
2008-08-29 07:07:40 +02:00
|
|
|
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; }
|
2008-11-15 22:58:51 +01:00
|
|
|
n = n.toString();
|
|
|
|
if ( n.length > 3 )
|
|
|
|
n = n.substr(0, n.length-3)+' '+n.substr(-3);
|
|
|
|
a.html(n);
|
2008-08-29 07:07:40 +02:00
|
|
|
});
|
2008-10-08 03:18:16 +02:00
|
|
|
|
2008-08-29 07:07:40 +02:00
|
|
|
if ( theExtraList.size() == 0 || theExtraList.children().size() == 0 ) {
|
2008-03-04 18:07:47 +01:00
|
|
|
return;
|
|
|
|
}
|
2008-10-08 03:18:16 +02:00
|
|
|
|
2008-08-29 07:07:40 +02:00
|
|
|
theList.get(0).wpList.add( theExtraList.children(':eq(0)').remove().clone() );
|
|
|
|
$('#get-extra-comments').submit();
|
|
|
|
};
|
2007-03-27 23:20:16 +02:00
|
|
|
|
2008-08-29 07:07:40 +02:00
|
|
|
theExtraList = $('#the-extra-comment-list').wpList( { alt: '', delColor: 'none', addColor: 'none' } );
|
|
|
|
theList = $('#the-comment-list').wpList( { alt: '', dimAfter: dimAfter, delAfter: delAfter, addColor: 'none' } );
|
2008-10-08 03:18:16 +02:00
|
|
|
|
2008-08-29 07:07:40 +02:00
|
|
|
};
|
2006-06-06 06:14:04 +02:00
|
|
|
|
2008-08-29 07:07:40 +02:00
|
|
|
$(document).ready(function(){
|
|
|
|
setCommentsList();
|
2008-08-24 08:56:22 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
commentReply = {
|
|
|
|
|
2008-10-08 03:18:16 +02:00
|
|
|
init : function() {
|
|
|
|
var row = $('#replyrow');
|
2008-08-24 08:56:22 +02:00
|
|
|
|
2008-10-08 03:18:16 +02:00
|
|
|
$('a.cancel', row).click(function() { return commentReply.revert(); });
|
|
|
|
$('a.save', row).click(function() { return commentReply.send(this); });
|
2008-08-24 08:56:22 +02:00
|
|
|
|
2008-10-08 03:18:16 +02:00
|
|
|
// add events
|
2008-10-31 19:09:42 +01:00
|
|
|
$('#the-comment-list .column-comment > p').dblclick(function(){
|
|
|
|
commentReply.toggle($(this).parent());
|
|
|
|
});
|
2008-10-08 03:18:16 +02:00
|
|
|
|
|
|
|
$('#doaction, #doaction2, #post-query-submit').click(function(e){
|
|
|
|
if ( $('#the-comment-list #replyrow').length > 0 )
|
|
|
|
t.close();
|
2008-08-24 08:56:22 +02:00
|
|
|
});
|
|
|
|
|
2008-10-08 03:18:16 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
addEvents : function(r) {
|
|
|
|
r.each(function() {
|
2008-10-31 19:09:42 +01:00
|
|
|
$(this).find('.column-comment > p').dblclick(function(){
|
|
|
|
commentReply.toggle($(this).parent());
|
2008-10-08 03:18:16 +02:00
|
|
|
});
|
2008-08-24 08:56:22 +02:00
|
|
|
});
|
2008-10-08 03:18:16 +02:00
|
|
|
},
|
2008-08-24 08:56:22 +02:00
|
|
|
|
2008-10-23 18:34:21 +02:00
|
|
|
toggle : function(el) {
|
|
|
|
if ( $(el).css('display') != 'none' )
|
|
|
|
$(el).find('a.vim-q').click();
|
2008-10-08 03:18:16 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
revert : function() {
|
|
|
|
|
2008-10-23 18:34:21 +02:00
|
|
|
if ( $('#the-comment-list #replyrow').length < 1 )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
$('#replyrow').fadeOut('fast', function(){
|
|
|
|
commentReply.close();
|
|
|
|
});
|
2008-08-24 08:56:22 +02:00
|
|
|
|
2008-10-08 03:18:16 +02:00
|
|
|
return false;
|
2008-08-24 08:56:22 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
close : function() {
|
2008-10-08 03:18:16 +02:00
|
|
|
$(this.o).fadeIn('fast').css('backgroundColor', '');
|
|
|
|
$('#com-reply').append( $('#replyrow') );
|
2008-08-24 08:56:22 +02:00
|
|
|
$('#replycontent').val('');
|
2008-10-08 03:18:16 +02:00
|
|
|
$('#edithead input').val('');
|
|
|
|
$('#replysubmit .error').html('').hide();
|
|
|
|
$('#replysubmit .waiting').hide();
|
|
|
|
if ( $.browser.msie )
|
|
|
|
$('#replycontainer, #replycontent').css('height', '120px');
|
|
|
|
else
|
|
|
|
$('#replycontainer').resizable('destroy').css('height', '120px');
|
|
|
|
},
|
|
|
|
|
|
|
|
open : function(id, p, a) {
|
|
|
|
var t = this;
|
2008-10-23 18:34:21 +02:00
|
|
|
t.close();
|
2008-10-08 03:18:16 +02:00
|
|
|
t.o = '#comment-'+id;
|
|
|
|
|
2008-10-30 16:50:21 +01:00
|
|
|
$('#replyrow td').attr('colspan', $('.widefat thead th:visible').length);
|
2008-10-08 03:18:16 +02:00
|
|
|
var editRow = $('#replyrow'), rowData = $('#inline-'+id);
|
|
|
|
var act = t.act = (a == 'edit') ? 'edit-comment' : 'replyto-comment';
|
|
|
|
|
|
|
|
$('#action', editRow).val(act);
|
|
|
|
$('#comment_post_ID', editRow).val(p);
|
|
|
|
$('#comment_ID', editRow).val(id);
|
|
|
|
|
|
|
|
if ( a == 'edit' ) {
|
|
|
|
$('#author', editRow).val( $('div.author', rowData).text() );
|
|
|
|
$('#author-email', editRow).val( $('div.author-email', rowData).text() );
|
|
|
|
$('#author-url', editRow).val( $('div.author-url', rowData).text() );
|
|
|
|
$('#status', editRow).val( $('div.comment_status', rowData).text() );
|
|
|
|
$('#replycontent', editRow).val( $('textarea.comment', rowData).val() );
|
|
|
|
$('#edithead, #savebtn', editRow).show();
|
|
|
|
$('#replyhead, #replybtn', editRow).hide();
|
|
|
|
|
|
|
|
var h = $(t.o).height();
|
|
|
|
if ( h > 220 )
|
|
|
|
if ( $.browser.msie )
|
|
|
|
$('#replycontainer, #replycontent', editRow).height(h-105);
|
|
|
|
else
|
|
|
|
$('#replycontainer', editRow).height(h-105);
|
|
|
|
|
|
|
|
$(t.o).after(editRow.hide()).fadeOut('fast', function(){
|
|
|
|
$('#replyrow').fadeIn('fast');
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
$('#edithead, #savebtn', editRow).hide();
|
|
|
|
$('#replyhead, #replybtn', editRow).show();
|
2008-11-02 04:40:21 +01:00
|
|
|
$(t.o).after(editRow);
|
2008-10-08 03:18:16 +02:00
|
|
|
$('#replyrow').hide().fadeIn('fast');
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( ! $.browser.msie )
|
|
|
|
$('#replycontainer').resizable({
|
|
|
|
handles : 's',
|
|
|
|
axis : 'y',
|
|
|
|
minHeight : 80,
|
|
|
|
stop : function() {
|
|
|
|
$('#replycontainer').width('auto');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
setTimeout(function() {
|
|
|
|
var rtop = $('#replyrow').offset().top;
|
|
|
|
var rbottom = rtop + $('#replyrow').height();
|
|
|
|
var scrollTop = window.pageYOffset || document.documentElement.scrollTop;
|
|
|
|
var vp = document.documentElement.clientHeight || self.innerHeight || 0;
|
|
|
|
var scrollBottom = scrollTop + vp;
|
|
|
|
|
|
|
|
if ( scrollBottom - 20 < rbottom )
|
|
|
|
window.scroll(0, rbottom - vp + 35);
|
|
|
|
else if ( rtop - 20 < scrollTop )
|
|
|
|
window.scroll(0, rtop - 35);
|
|
|
|
|
|
|
|
$('#replycontent').focus().keyup(function(e){
|
|
|
|
if (e.which == 27) commentReply.revert(); // close on Escape
|
|
|
|
});
|
|
|
|
}, 600);
|
2008-08-24 08:56:22 +02:00
|
|
|
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
|
|
|
|
send : function() {
|
|
|
|
var post = {};
|
|
|
|
|
2008-10-08 03:18:16 +02:00
|
|
|
$('#replysubmit .waiting').show();
|
|
|
|
|
|
|
|
$('#replyrow input').each(function() {
|
2008-08-24 08:56:22 +02:00
|
|
|
post[ $(this).attr('name') ] = $(this).val();
|
|
|
|
});
|
|
|
|
|
2008-10-08 03:18:16 +02:00
|
|
|
post.content = $('#replycontent').val();
|
2008-08-24 08:56:22 +02:00
|
|
|
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); }
|
|
|
|
});
|
2008-10-08 03:18:16 +02:00
|
|
|
|
|
|
|
return false;
|
2008-08-24 08:56:22 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
show : function(xml) {
|
|
|
|
|
|
|
|
if ( typeof(xml) == 'string' ) {
|
|
|
|
this.error({'responseText': xml});
|
2008-10-08 03:18:16 +02:00
|
|
|
return false;
|
2008-08-24 08:56:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
var r = wpAjax.parseAjaxResponse(xml);
|
2008-10-08 03:18:16 +02:00
|
|
|
if ( r.errors ) {
|
2008-08-24 08:56:22 +02:00
|
|
|
this.error({'responseText': wpAjax.broken});
|
2008-10-08 03:18:16 +02:00
|
|
|
return false;
|
|
|
|
}
|
2008-08-24 08:56:22 +02:00
|
|
|
|
2008-10-08 03:18:16 +02:00
|
|
|
if ( 'edit-comment' == this.act )
|
|
|
|
$(this.o).remove();
|
2008-08-24 08:56:22 +02:00
|
|
|
|
2008-10-08 03:18:16 +02:00
|
|
|
r = r.responses[0];
|
|
|
|
var c = r.data;
|
2008-08-24 08:56:22 +02:00
|
|
|
|
2008-10-08 03:18:16 +02:00
|
|
|
$(c).hide()
|
|
|
|
$('#replyrow').after(c);
|
|
|
|
this.o = id = '#comment-'+r.id;
|
|
|
|
$(id+' .hide-if-no-js').removeClass('hide-if-no-js');
|
|
|
|
this.revert();
|
|
|
|
this.addEvents($(id));
|
2008-11-14 22:54:39 +01:00
|
|
|
var bg = $(id).hasClass('unapproved') ? '#ffffe0' : '#fff';
|
2008-09-05 21:11:41 +02:00
|
|
|
|
2008-10-08 03:18:16 +02:00
|
|
|
$(id)
|
2008-11-14 22:54:39 +01:00
|
|
|
.animate( { 'backgroundColor':'#CCEEBB' }, 600 )
|
|
|
|
.animate( { 'backgroundColor': bg }, 600 );
|
2008-10-08 03:18:16 +02:00
|
|
|
|
2008-12-07 13:18:04 +01:00
|
|
|
$.fn.wpList.process($(id))
|
2008-08-24 08:56:22 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
error : function(r) {
|
|
|
|
var er = r.statusText;
|
|
|
|
|
2008-10-08 03:18:16 +02:00
|
|
|
$('#replysubmit .waiting').hide();
|
|
|
|
|
2008-08-24 08:56:22 +02:00
|
|
|
if ( r.responseText )
|
|
|
|
er = r.responseText.replace( /<.[^<>]*?>/g, '' );
|
|
|
|
|
2008-10-08 03:18:16 +02:00
|
|
|
if ( er )
|
|
|
|
$('#replysubmit .error').html(er).show();
|
2008-08-24 08:56:22 +02:00
|
|
|
|
|
|
|
}
|
2008-08-29 07:07:40 +02:00
|
|
|
};
|
2008-12-05 08:15:31 +01:00
|
|
|
toggleWithKeyboard = false;
|
2008-08-24 08:56:22 +02:00
|
|
|
$(document).ready(function(){
|
2008-11-17 20:16:26 +01:00
|
|
|
columns.init('edit-comments');
|
2008-10-08 03:18:16 +02:00
|
|
|
commentReply.init();
|
2008-09-26 03:05:52 +02:00
|
|
|
|
2008-08-24 08:56:22 +02:00
|
|
|
if ( typeof QTags != 'undefined' )
|
|
|
|
ed_reply = new QTags('ed_reply', 'replycontent', 'replycontainer', 'more');
|
2008-09-05 21:11:41 +02:00
|
|
|
|
2008-09-01 07:28:41 +02:00
|
|
|
if ( typeof $.table_hotkeys != 'undefined' ) {
|
|
|
|
var make_hotkeys_redirect = function(which) {
|
|
|
|
return function() {
|
2008-10-08 03:18:16 +02:00
|
|
|
var first_last = 'next' == which? 'first' : 'last';
|
2008-09-01 07:28:41 +02:00
|
|
|
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 19:53:14 +02:00
|
|
|
};
|
|
|
|
var edit_comment = function(event, current_row) {
|
|
|
|
window.location = $('span.edit a', current_row).attr('href');
|
|
|
|
};
|
|
|
|
var toggle_all = function() {
|
2008-12-05 08:15:31 +01:00
|
|
|
toggleWithKeyboard = true;
|
2008-09-04 19:53:14 +02:00
|
|
|
var master_checkbox = $('form#comments-form .check-column :checkbox:first');
|
2008-12-05 08:15:31 +01:00
|
|
|
master_checkbox.click().attr('checked', '');
|
|
|
|
toggleWithKeyboard = false;
|
2008-09-01 07:28:41 +02:00
|
|
|
}
|
2008-09-04 19:53:14 +02:00
|
|
|
var make_bulk = function(value) {
|
|
|
|
return function(event, _) {
|
|
|
|
$('option[value='+value+']').attr('selected', 'selected');
|
|
|
|
$('form#comments-form')[0].submit();
|
2008-09-01 07:28:41 +02:00
|
|
|
}
|
2008-09-04 19:53:14 +02:00
|
|
|
};
|
2008-10-23 18:34:21 +02:00
|
|
|
$.table_hotkeys($('table.widefat'),['a', 'u', 's', 'd', 'r', 'q', ['e', edit_comment],
|
2008-09-04 19:53:14 +02:00
|
|
|
['shift+a', make_bulk('approve')], ['shift+s', make_bulk('markspam')],
|
2008-10-17 00:23:32 +02:00
|
|
|
['shift+d', make_bulk('delete')], ['shift+x', toggle_all],
|
|
|
|
['shift+u', make_bulk('unapprove')]],
|
2008-09-04 19:53:14 +02:00
|
|
|
{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 07:28:41 +02:00
|
|
|
);
|
|
|
|
}
|
2008-08-24 08:56:22 +02:00
|
|
|
});
|
|
|
|
|
2008-09-05 21:11:41 +02:00
|
|
|
})(jQuery);
|