-
+ 6DA73765CFED73371EE21F3859092CA22F84DB3018B80D23169DE1EAA8A507863D4B48228546F2C4E9ADD0BDEBC9225D283989214EA6BB1056B32957E5F82BC4mp-wp/wp-admin/js/edit-comments.js(0 . 0)(1 . 320)
48973 var theList; var theExtraList;
48974 (function($) {
48975
48976 setCommentsList = function() {
48977 var dimAfter = function( r, settings ) {
48978 var c = $('#' + settings.element);
48979
48980 if ( c.is('.unapproved') )
48981 c.find('div.comment_status').html('0')
48982 else
48983 c.find('div.comment_status').html('1')
48984
48985 $('span.pending-count').each( function() {
48986 var a = $(this);
48987 var n = a.html().replace(/[ ,.]+/g, '');
48988 n = parseInt(n,10);
48989 if ( isNaN(n) ) return;
48990 n = n + ( $('#' + settings.element).is('.' + settings.dimClass) ? 1 : -1 );
48991 if ( n < 0 ) { n = 0; }
48992 $('#awaiting-mod')[ 0 == n ? 'addClass' : 'removeClass' ]('count-0');
48993 n = n.toString();
48994 if ( n.length > 3 )
48995 n = n.substr(0, n.length-3)+' '+n.substr(-3);
48996 a.html(n);
48997 });
48998 };
48999
49000 var delAfter = function( r, settings ) {
49001 $('span.pending-count').each( function() {
49002 var a = $(this);
49003 var n = a.html().replace(/[ ,.]+/g, '');
49004 n = parseInt(n,10);
49005 if ( isNaN(n) ) return;
49006 if ( $('#' + settings.element).is('.unapproved') ) { // we deleted a formerly unapproved comment
49007 n = n - 1;
49008 } else if ( $(settings.target).parents( 'span.unapprove' ).size() ) { // we "deleted" an approved comment from the approved list by clicking "Unapprove"
49009 n = n + 1;
49010 }
49011 if ( n < 0 ) { n = 0; }
49012 $('#awaiting-mod')[ 0 == n ? 'addClass' : 'removeClass' ]('count-0');
49013 n = n.toString();
49014 if ( n.length > 3 )
49015 n = n.substr(0, n.length-3)+' '+n.substr(-3);
49016 a.html(n);
49017 });
49018
49019 $('span.spam-count' ).each( function() {
49020 var a = $(this);
49021 var n = a.html().replace(/[ ,.]+/g, '');
49022 n = parseInt(n,10);
49023 if ( isNaN(n) ) return;
49024 if ( $(settings.target).parents( 'span.spam' ).size() ) { // we marked a comment as spam
49025 n = n + 1;
49026 } else if ( $('#' + settings.element).is('.spam') ) { // we approved or deleted a comment marked as spam
49027 n = n - 1;
49028 }
49029 if ( n < 0 ) { n = 0; }
49030 n = n.toString();
49031 if ( n.length > 3 )
49032 n = n.substr(0, n.length-3)+' '+n.substr(-3);
49033 a.html(n);
49034 });
49035
49036 if ( theExtraList.size() == 0 || theExtraList.children().size() == 0 ) {
49037 return;
49038 }
49039
49040 theList.get(0).wpList.add( theExtraList.children(':eq(0)').remove().clone() );
49041 $('#get-extra-comments').submit();
49042 };
49043
49044 theExtraList = $('#the-extra-comment-list').wpList( { alt: '', delColor: 'none', addColor: 'none' } );
49045 theList = $('#the-comment-list').wpList( { alt: '', dimAfter: dimAfter, delAfter: delAfter, addColor: 'none' } );
49046
49047 };
49048
49049 $(document).ready(function(){
49050 setCommentsList();
49051 });
49052
49053 commentReply = {
49054
49055 init : function() {
49056 var row = $('#replyrow');
49057
49058 $('a.cancel', row).click(function() { return commentReply.revert(); });
49059 $('a.save', row).click(function() { return commentReply.send(this); });
49060
49061 // add events
49062 $('#the-comment-list .column-comment > p').dblclick(function(){
49063 commentReply.toggle($(this).parent());
49064 });
49065
49066 $('#doaction, #doaction2, #post-query-submit').click(function(e){
49067 if ( $('#the-comment-list #replyrow').length > 0 )
49068 t.close();
49069 });
49070
49071 },
49072
49073 addEvents : function(r) {
49074 r.each(function() {
49075 $(this).find('.column-comment > p').dblclick(function(){
49076 commentReply.toggle($(this).parent());
49077 });
49078 });
49079 },
49080
49081 toggle : function(el) {
49082 if ( $(el).css('display') != 'none' )
49083 $(el).find('a.vim-q').click();
49084 },
49085
49086 revert : function() {
49087
49088 if ( $('#the-comment-list #replyrow').length < 1 )
49089 return false;
49090
49091 $('#replyrow').fadeOut('fast', function(){
49092 commentReply.close();
49093 });
49094
49095 return false;
49096 },
49097
49098 close : function() {
49099 $(this.o).fadeIn('fast').css('backgroundColor', '');
49100 $('#com-reply').append( $('#replyrow') );
49101 $('#replycontent').val('');
49102 $('#edithead input').val('');
49103 $('#replysubmit .error').html('').hide();
49104 $('#replysubmit .waiting').hide();
49105 if ( $.browser.msie )
49106 $('#replycontainer, #replycontent').css('height', '120px');
49107 else
49108 $('#replycontainer').resizable('destroy').css('height', '120px');
49109 },
49110
49111 open : function(id, p, a) {
49112 var t = this;
49113 t.close();
49114 t.o = '#comment-'+id;
49115
49116 $('#replyrow td').attr('colspan', $('.widefat thead th:visible').length);
49117 var editRow = $('#replyrow'), rowData = $('#inline-'+id);
49118 var act = t.act = (a == 'edit') ? 'edit-comment' : 'replyto-comment';
49119
49120 $('#action', editRow).val(act);
49121 $('#comment_post_ID', editRow).val(p);
49122 $('#comment_ID', editRow).val(id);
49123
49124 if ( a == 'edit' ) {
49125 $('#author', editRow).val( $('div.author', rowData).text() );
49126 $('#author-email', editRow).val( $('div.author-email', rowData).text() );
49127 $('#author-url', editRow).val( $('div.author-url', rowData).text() );
49128 $('#status', editRow).val( $('div.comment_status', rowData).text() );
49129 $('#replycontent', editRow).val( $('textarea.comment', rowData).val() );
49130 $('#edithead, #savebtn', editRow).show();
49131 $('#replyhead, #replybtn', editRow).hide();
49132
49133 var h = $(t.o).height();
49134 if ( h > 220 )
49135 if ( $.browser.msie )
49136 $('#replycontainer, #replycontent', editRow).height(h-105);
49137 else
49138 $('#replycontainer', editRow).height(h-105);
49139
49140 $(t.o).after(editRow.hide()).fadeOut('fast', function(){
49141 $('#replyrow').fadeIn('fast');
49142 });
49143 } else {
49144 $('#edithead, #savebtn', editRow).hide();
49145 $('#replyhead, #replybtn', editRow).show();
49146 $(t.o).after(editRow);
49147 $('#replyrow').hide().fadeIn('fast');
49148 }
49149
49150 if ( ! $.browser.msie )
49151 $('#replycontainer').resizable({
49152 handles : 's',
49153 axis : 'y',
49154 minHeight : 80,
49155 stop : function() {
49156 $('#replycontainer').width('auto');
49157 }
49158 });
49159
49160 setTimeout(function() {
49161 var rtop = $('#replyrow').offset().top;
49162 var rbottom = rtop + $('#replyrow').height();
49163 var scrollTop = window.pageYOffset || document.documentElement.scrollTop;
49164 var vp = document.documentElement.clientHeight || self.innerHeight || 0;
49165 var scrollBottom = scrollTop + vp;
49166
49167 if ( scrollBottom - 20 < rbottom )
49168 window.scroll(0, rbottom - vp + 35);
49169 else if ( rtop - 20 < scrollTop )
49170 window.scroll(0, rtop - 35);
49171
49172 $('#replycontent').focus().keyup(function(e){
49173 if (e.which == 27) commentReply.revert(); // close on Escape
49174 });
49175 }, 600);
49176
49177 return false;
49178 },
49179
49180 send : function() {
49181 var post = {};
49182
49183 $('#replysubmit .waiting').show();
49184
49185 $('#replyrow input').each(function() {
49186 post[ $(this).attr('name') ] = $(this).val();
49187 });
49188
49189 post.content = $('#replycontent').val();
49190 post.id = post.comment_post_ID;
49191
49192 $.ajax({
49193 type : 'POST',
49194 url : wpListL10n.url,
49195 data : post,
49196 success : function(x) { commentReply.show(x); },
49197 error : function(r) { commentReply.error(r); }
49198 });
49199
49200 return false;
49201 },
49202
49203 show : function(xml) {
49204
49205 if ( typeof(xml) == 'string' ) {
49206 this.error({'responseText': xml});
49207 return false;
49208 }
49209
49210 var r = wpAjax.parseAjaxResponse(xml);
49211 if ( r.errors ) {
49212 this.error({'responseText': wpAjax.broken});
49213 return false;
49214 }
49215
49216 if ( 'edit-comment' == this.act )
49217 $(this.o).remove();
49218
49219 r = r.responses[0];
49220 var c = r.data;
49221
49222 $(c).hide()
49223 $('#replyrow').after(c);
49224 this.o = id = '#comment-'+r.id;
49225 $(id+' .hide-if-no-js').removeClass('hide-if-no-js');
49226 this.revert();
49227 this.addEvents($(id));
49228 var bg = $(id).hasClass('unapproved') ? '#ffffe0' : '#fff';
49229
49230 $(id)
49231 .animate( { 'backgroundColor':'#CCEEBB' }, 600 )
49232 .animate( { 'backgroundColor': bg }, 600 );
49233
49234 $.fn.wpList.process($(id))
49235 },
49236
49237 error : function(r) {
49238 var er = r.statusText;
49239
49240 $('#replysubmit .waiting').hide();
49241
49242 if ( r.responseText )
49243 er = r.responseText.replace( /<.[^<>]*?>/g, '' );
49244
49245 if ( er )
49246 $('#replysubmit .error').html(er).show();
49247
49248 }
49249 };
49250 toggleWithKeyboard = false;
49251 $(document).ready(function(){
49252 columns.init('edit-comments');
49253 commentReply.init();
49254
49255 if ( typeof QTags != 'undefined' )
49256 ed_reply = new QTags('ed_reply', 'replycontent', 'replycontainer', 'more');
49257
49258 if ( typeof $.table_hotkeys != 'undefined' ) {
49259 var make_hotkeys_redirect = function(which) {
49260 return function() {
49261 var first_last = 'next' == which? 'first' : 'last';
49262 var l=$('.'+which+'.page-numbers');
49263 if (l.length)
49264 window.location = l[0].href.replace(/\&hotkeys_highlight_(first|last)=1/g, '')+'&hotkeys_highlight_'+first_last+'=1';
49265 }
49266 };
49267 var edit_comment = function(event, current_row) {
49268 window.location = $('span.edit a', current_row).attr('href');
49269 };
49270 var toggle_all = function() {
49271 toggleWithKeyboard = true;
49272 var master_checkbox = $('form#comments-form .check-column :checkbox:first');
49273 master_checkbox.click().attr('checked', '');
49274 toggleWithKeyboard = false;
49275 }
49276 var make_bulk = function(value) {
49277 return function(event, _) {
49278 $('option[value='+value+']').attr('selected', 'selected');
49279 $('form#comments-form')[0].submit();
49280 }
49281 };
49282 $.table_hotkeys($('table.widefat'),['a', 'u', 's', 'd', 'r', 'q', ['e', edit_comment],
49283 ['shift+a', make_bulk('approve')], ['shift+s', make_bulk('markspam')],
49284 ['shift+d', make_bulk('delete')], ['shift+x', toggle_all],
49285 ['shift+u', make_bulk('unapprove')]],
49286 {highlight_first: adminCommentsL10n.hotkeys_highlight_first, highlight_last: adminCommentsL10n.hotkeys_highlight_last,
49287 prev_page_link_cb: make_hotkeys_redirect('prev'), next_page_link_cb: make_hotkeys_redirect('next')}
49288 );
49289 }
49290 });
49291
49292 })(jQuery);