1 var theList; var theExtraList;
4 setCommentsList = function() {
5 var dimAfter = function( r, settings ) {
6 var c = $('#' + settings.element);
8 if ( c.is('.unapproved') )
9 c.find('div.comment_status').html('0')
11 c.find('div.comment_status').html('1')
13 $('span.pending-count').each( function() {
15 var n = a.html().replace(/[ ,.]+/g, '');
17 if ( isNaN(n) ) return;
18 n = n + ( $('#' + settings.element).is('.' + settings.dimClass) ? 1 : -1 );
19 if ( n < 0 ) { n = 0; }
20 $('#awaiting-mod')[ 0 == n ? 'addClass' : 'removeClass' ]('count-0');
23 n = n.substr(0, n.length-3)+' '+n.substr(-3);
28 var delAfter = function( r, settings ) {
29 $('span.pending-count').each( function() {
31 var n = a.html().replace(/[ ,.]+/g, '');
33 if ( isNaN(n) ) return;
34 if ( $('#' + settings.element).is('.unapproved') ) { // we deleted a formerly unapproved comment
36 } else if ( $(settings.target).parents( 'span.unapprove' ).size() ) { // we "deleted" an approved comment from the approved list by clicking "Unapprove"
39 if ( n < 0 ) { n = 0; }
40 $('#awaiting-mod')[ 0 == n ? 'addClass' : 'removeClass' ]('count-0');
43 n = n.substr(0, n.length-3)+' '+n.substr(-3);
47 $('span.spam-count' ).each( function() {
49 var n = a.html().replace(/[ ,.]+/g, '');
51 if ( isNaN(n) ) return;
52 if ( $(settings.target).parents( 'span.spam' ).size() ) { // we marked a comment as spam
54 } else if ( $('#' + settings.element).is('.spam') ) { // we approved or deleted a comment marked as spam
57 if ( n < 0 ) { n = 0; }
60 n = n.substr(0, n.length-3)+' '+n.substr(-3);
64 if ( theExtraList.size() == 0 || theExtraList.children().size() == 0 ) {
68 theList.get(0).wpList.add( theExtraList.children(':eq(0)').remove().clone() );
69 $('#get-extra-comments').submit();
72 theExtraList = $('#the-extra-comment-list').wpList( { alt: '', delColor: 'none', addColor: 'none' } );
73 theList = $('#the-comment-list').wpList( { alt: '', dimAfter: dimAfter, delAfter: delAfter, addColor: 'none' } );
77 $(document).ready(function(){
84 var row = $('#replyrow');
86 $('a.cancel', row).click(function() { return commentReply.revert(); });
87 $('a.save', row).click(function() { return commentReply.send(this); });
90 $('#the-comment-list .column-comment > p').dblclick(function(){
91 commentReply.toggle($(this).parent());
94 $('#doaction, #doaction2, #post-query-submit').click(function(e){
95 if ( $('#the-comment-list #replyrow').length > 0 )
101 addEvents : function(r) {
103 $(this).find('.column-comment > p').dblclick(function(){
104 commentReply.toggle($(this).parent());
109 toggle : function(el) {
110 if ( $(el).css('display') != 'none' )
111 $(el).find('a.vim-q').click();
114 revert : function() {
116 if ( $('#the-comment-list #replyrow').length < 1 )
119 $('#replyrow').fadeOut('fast', function(){
120 commentReply.close();
127 $(this.o).fadeIn('fast').css('backgroundColor', '');
128 $('#com-reply').append( $('#replyrow') );
129 $('#replycontent').val('');
130 $('#edithead input').val('');
131 $('#replysubmit .error').html('').hide();
132 $('#replysubmit .waiting').hide();
133 if ( $.browser.msie )
134 $('#replycontainer, #replycontent').css('height', '120px');
136 $('#replycontainer').resizable('destroy').css('height', '120px');
139 open : function(id, p, a) {
142 t.o = '#comment-'+id;
144 $('#replyrow td').attr('colspan', $('.widefat thead th:visible').length);
145 var editRow = $('#replyrow'), rowData = $('#inline-'+id);
146 var act = t.act = (a == 'edit') ? 'edit-comment' : 'replyto-comment';
148 $('#action', editRow).val(act);
149 $('#comment_post_ID', editRow).val(p);
150 $('#comment_ID', editRow).val(id);
153 $('#author', editRow).val( $('div.author', rowData).text() );
154 $('#author-email', editRow).val( $('div.author-email', rowData).text() );
155 $('#author-url', editRow).val( $('div.author-url', rowData).text() );
156 $('#status', editRow).val( $('div.comment_status', rowData).text() );
157 $('#replycontent', editRow).val( $('textarea.comment', rowData).val() );
158 $('#edithead, #savebtn', editRow).show();
159 $('#replyhead, #replybtn', editRow).hide();
161 var h = $(t.o).height();
163 if ( $.browser.msie )
164 $('#replycontainer, #replycontent', editRow).height(h-105);
166 $('#replycontainer', editRow).height(h-105);
168 $(t.o).after(editRow.hide()).fadeOut('fast', function(){
169 $('#replyrow').fadeIn('fast');
172 $('#edithead, #savebtn', editRow).hide();
173 $('#replyhead, #replybtn', editRow).show();
174 $(t.o).after(editRow);
175 $('#replyrow').hide().fadeIn('fast');
178 if ( ! $.browser.msie )
179 $('#replycontainer').resizable({
184 $('#replycontainer').width('auto');
188 setTimeout(function() {
189 var rtop = $('#replyrow').offset().top;
190 var rbottom = rtop + $('#replyrow').height();
191 var scrollTop = window.pageYOffset || document.documentElement.scrollTop;
192 var vp = document.documentElement.clientHeight || self.innerHeight || 0;
193 var scrollBottom = scrollTop + vp;
195 if ( scrollBottom - 20 < rbottom )
196 window.scroll(0, rbottom - vp + 35);
197 else if ( rtop - 20 < scrollTop )
198 window.scroll(0, rtop - 35);
200 $('#replycontent').focus().keyup(function(e){
201 if (e.which == 27) commentReply.revert(); // close on Escape
211 $('#replysubmit .waiting').show();
213 $('#replyrow input').each(function() {
214 post[ $(this).attr('name') ] = $(this).val();
217 post.content = $('#replycontent').val();
218 post.id = post.comment_post_ID;
222 url : wpListL10n.url,
224 success : function(x) { commentReply.show(x); },
225 error : function(r) { commentReply.error(r); }
231 show : function(xml) {
233 if ( typeof(xml) == 'string' ) {
234 this.error({'responseText': xml});
238 var r = wpAjax.parseAjaxResponse(xml);
240 this.error({'responseText': wpAjax.broken});
244 if ( 'edit-comment' == this.act )
251 $('#replyrow').after(c);
252 this.o = id = '#comment-'+r.id;
253 $(id+' .hide-if-no-js').removeClass('hide-if-no-js');
255 this.addEvents($(id));
256 var bg = $(id).hasClass('unapproved') ? '#ffffe0' : '#fff';
259 .animate( { 'backgroundColor':'#CCEEBB' }, 600 )
260 .animate( { 'backgroundColor': bg }, 600 );
262 $.fn.wpList.process($(id))
265 error : function(r) {
266 var er = r.statusText;
268 $('#replysubmit .waiting').hide();
270 if ( r.responseText )
271 er = r.responseText.replace( /<.[^<>]*?>/g, '' );
274 $('#replysubmit .error').html(er).show();
278 toggleWithKeyboard = false;
279 $(document).ready(function(){
280 columns.init('edit-comments');
283 if ( typeof QTags != 'undefined' )
284 ed_reply = new QTags('ed_reply', 'replycontent', 'replycontainer', 'more');
286 if ( typeof $.table_hotkeys != 'undefined' ) {
287 var make_hotkeys_redirect = function(which) {
289 var first_last = 'next' == which? 'first' : 'last';
290 var l=$('.'+which+'.page-numbers');
292 window.location = l[0].href.replace(/\&hotkeys_highlight_(first|last)=1/g, '')+'&hotkeys_highlight_'+first_last+'=1';
295 var edit_comment = function(event, current_row) {
296 window.location = $('span.edit a', current_row).attr('href');
298 var toggle_all = function() {
299 toggleWithKeyboard = true;
300 var master_checkbox = $('form#comments-form .check-column :checkbox:first');
301 master_checkbox.click().attr('checked', '');
302 toggleWithKeyboard = false;
304 var make_bulk = function(value) {
305 return function(event, _) {
306 $('option[value='+value+']').attr('selected', 'selected');
307 $('form#comments-form')[0].submit();
310 $.table_hotkeys($('table.widefat'),['a', 'u', 's', 'd', 'r', 'q', ['e', edit_comment],
311 ['shift+a', make_bulk('approve')], ['shift+s', make_bulk('markspam')],
312 ['shift+d', make_bulk('delete')], ['shift+x', toggle_all],
313 ['shift+u', make_bulk('unapprove')]],
314 {highlight_first: adminCommentsL10n.hotkeys_highlight_first, highlight_last: adminCommentsL10n.hotkeys_highlight_last,
315 prev_page_link_cb: make_hotkeys_redirect('prev'), next_page_link_cb: make_hotkeys_redirect('next')}