| [ Index ] |
PHP Cross Reference of Wordpress 2.7.1 |
[Summary view] [Print] [Text view]
1 var theList; var theExtraList; 2 (function($) { 3 4 setCommentsList = function() { 5 var dimAfter = function( r, settings ) { 6 var c = $('#' + settings.element); 7 8 if ( c.is('.unapproved') ) 9 c.find('div.comment_status').html('0') 10 else 11 c.find('div.comment_status').html('1') 12 13 $('span.pending-count').each( function() { 14 var a = $(this); 15 var n = a.html().replace(/[ ,.]+/g, ''); 16 n = parseInt(n,10); 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'); 21 n = n.toString(); 22 if ( n.length > 3 ) 23 n = n.substr(0, n.length-3)+' '+n.substr(-3); 24 a.html(n); 25 }); 26 }; 27 28 var delAfter = function( r, settings ) { 29 $('span.pending-count').each( function() { 30 var a = $(this); 31 var n = a.html().replace(/[ ,.]+/g, ''); 32 n = parseInt(n,10); 33 if ( isNaN(n) ) return; 34 if ( $('#' + settings.element).is('.unapproved') ) { // we deleted a formerly unapproved comment 35 n = n - 1; 36 } else if ( $(settings.target).parents( 'span.unapprove' ).size() ) { // we "deleted" an approved comment from the approved list by clicking "Unapprove" 37 n = n + 1; 38 } 39 if ( n < 0 ) { n = 0; } 40 $('#awaiting-mod')[ 0 == n ? 'addClass' : 'removeClass' ]('count-0'); 41 n = n.toString(); 42 if ( n.length > 3 ) 43 n = n.substr(0, n.length-3)+' '+n.substr(-3); 44 a.html(n); 45 }); 46 47 $('span.spam-count' ).each( function() { 48 var a = $(this); 49 var n = a.html().replace(/[ ,.]+/g, ''); 50 n = parseInt(n,10); 51 if ( isNaN(n) ) return; 52 if ( $(settings.target).parents( 'span.spam' ).size() ) { // we marked a comment as spam 53 n = n + 1; 54 } else if ( $('#' + settings.element).is('.spam') ) { // we approved or deleted a comment marked as spam 55 n = n - 1; 56 } 57 if ( n < 0 ) { n = 0; } 58 n = n.toString(); 59 if ( n.length > 3 ) 60 n = n.substr(0, n.length-3)+' '+n.substr(-3); 61 a.html(n); 62 }); 63 64 if ( theExtraList.size() == 0 || theExtraList.children().size() == 0 ) { 65 return; 66 } 67 68 theList.get(0).wpList.add( theExtraList.children(':eq(0)').remove().clone() ); 69 $('#get-extra-comments').submit(); 70 }; 71 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' } ); 74 75 }; 76 77 $(document).ready(function(){ 78 setCommentsList(); 79 }); 80 81 commentReply = { 82 83 init : function() { 84 var row = $('#replyrow'); 85 86 $('a.cancel', row).click(function() { return commentReply.revert(); }); 87 $('a.save', row).click(function() { return commentReply.send(this); }); 88 89 // add events 90 $('#the-comment-list .column-comment > p').dblclick(function(){ 91 commentReply.toggle($(this).parent()); 92 }); 93 94 $('#doaction, #doaction2, #post-query-submit').click(function(e){ 95 if ( $('#the-comment-list #replyrow').length > 0 ) 96 t.close(); 97 }); 98 99 }, 100 101 addEvents : function(r) { 102 r.each(function() { 103 $(this).find('.column-comment > p').dblclick(function(){ 104 commentReply.toggle($(this).parent()); 105 }); 106 }); 107 }, 108 109 toggle : function(el) { 110 if ( $(el).css('display') != 'none' ) 111 $(el).find('a.vim-q').click(); 112 }, 113 114 revert : function() { 115 116 if ( $('#the-comment-list #replyrow').length < 1 ) 117 return false; 118 119 $('#replyrow').fadeOut('fast', function(){ 120 commentReply.close(); 121 }); 122 123 return false; 124 }, 125 126 close : function() { 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'); 135 else 136 $('#replycontainer').resizable('destroy').css('height', '120px'); 137 }, 138 139 open : function(id, p, a) { 140 var t = this; 141 t.close(); 142 t.o = '#comment-'+id; 143 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'; 147 148 $('#action', editRow).val(act); 149 $('#comment_post_ID', editRow).val(p); 150 $('#comment_ID', editRow).val(id); 151 152 if ( a == 'edit' ) { 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(); 160 161 var h = $(t.o).height(); 162 if ( h > 220 ) 163 if ( $.browser.msie ) 164 $('#replycontainer, #replycontent', editRow).height(h-105); 165 else 166 $('#replycontainer', editRow).height(h-105); 167 168 $(t.o).after(editRow.hide()).fadeOut('fast', function(){ 169 $('#replyrow').fadeIn('fast'); 170 }); 171 } else { 172 $('#edithead, #savebtn', editRow).hide(); 173 $('#replyhead, #replybtn', editRow).show(); 174 $(t.o).after(editRow); 175 $('#replyrow').hide().fadeIn('fast'); 176 } 177 178 if ( ! $.browser.msie ) 179 $('#replycontainer').resizable({ 180 handles : 's', 181 axis : 'y', 182 minHeight : 80, 183 stop : function() { 184 $('#replycontainer').width('auto'); 185 } 186 }); 187 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; 194 195 if ( scrollBottom - 20 < rbottom ) 196 window.scroll(0, rbottom - vp + 35); 197 else if ( rtop - 20 < scrollTop ) 198 window.scroll(0, rtop - 35); 199 200 $('#replycontent').focus().keyup(function(e){ 201 if (e.which == 27) commentReply.revert(); // close on Escape 202 }); 203 }, 600); 204 205 return false; 206 }, 207 208 send : function() { 209 var post = {}; 210 211 $('#replysubmit .waiting').show(); 212 213 $('#replyrow input').each(function() { 214 post[ $(this).attr('name') ] = $(this).val(); 215 }); 216 217 post.content = $('#replycontent').val(); 218 post.id = post.comment_post_ID; 219 220 $.ajax({ 221 type : 'POST', 222 url : wpListL10n.url, 223 data : post, 224 success : function(x) { commentReply.show(x); }, 225 error : function(r) { commentReply.error(r); } 226 }); 227 228 return false; 229 }, 230 231 show : function(xml) { 232 233 if ( typeof(xml) == 'string' ) { 234 this.error({'responseText': xml}); 235 return false; 236 } 237 238 var r = wpAjax.parseAjaxResponse(xml); 239 if ( r.errors ) { 240 this.error({'responseText': wpAjax.broken}); 241 return false; 242 } 243 244 if ( 'edit-comment' == this.act ) 245 $(this.o).remove(); 246 247 r = r.responses[0]; 248 var c = r.data; 249 250 $(c).hide() 251 $('#replyrow').after(c); 252 this.o = id = '#comment-'+r.id; 253 $(id+' .hide-if-no-js').removeClass('hide-if-no-js'); 254 this.revert(); 255 this.addEvents($(id)); 256 var bg = $(id).hasClass('unapproved') ? '#ffffe0' : '#fff'; 257 258 $(id) 259 .animate( { 'backgroundColor':'#CCEEBB' }, 600 ) 260 .animate( { 'backgroundColor': bg }, 600 ); 261 262 $.fn.wpList.process($(id)) 263 }, 264 265 error : function(r) { 266 var er = r.statusText; 267 268 $('#replysubmit .waiting').hide(); 269 270 if ( r.responseText ) 271 er = r.responseText.replace( /<.[^<>]*?>/g, '' ); 272 273 if ( er ) 274 $('#replysubmit .error').html(er).show(); 275 276 } 277 }; 278 toggleWithKeyboard = false; 279 $(document).ready(function(){ 280 columns.init('edit-comments'); 281 commentReply.init(); 282 283 if ( typeof QTags != 'undefined' ) 284 ed_reply = new QTags('ed_reply', 'replycontent', 'replycontainer', 'more'); 285 286 if ( typeof $.table_hotkeys != 'undefined' ) { 287 var make_hotkeys_redirect = function(which) { 288 return function() { 289 var first_last = 'next' == which? 'first' : 'last'; 290 var l=$('.'+which+'.page-numbers'); 291 if (l.length) 292 window.location = l[0].href.replace(/\&hotkeys_highlight_(first|last)=1/g, '')+'&hotkeys_highlight_'+first_last+'=1'; 293 } 294 }; 295 var edit_comment = function(event, current_row) { 296 window.location = $('span.edit a', current_row).attr('href'); 297 }; 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; 303 } 304 var make_bulk = function(value) { 305 return function(event, _) { 306 $('option[value='+value+']').attr('selected', 'selected'); 307 $('form#comments-form')[0].submit(); 308 } 309 }; 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')} 316 ); 317 } 318 }); 319 320 })(jQuery);
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Mar 23 16:23:02 2009 | Cross-referenced by PHPXref 0.7 |