443 a.attr('href', 'comment.php?action=un' + action + 'comment&c=' + id + '&_wpnonce=' + settings.data._ajax_nonce); |
443 a.attr('href', 'comment.php?action=un' + action + 'comment&c=' + id + '&_wpnonce=' + settings.data._ajax_nonce); |
444 a.attr('data-wp-lists', 'delete:the-comment-list:comment-' + id + '::un' + action + '=1'); |
444 a.attr('data-wp-lists', 'delete:the-comment-list:comment-' + id + '::un' + action + '=1'); |
445 a.attr('class', 'vim-z vim-destructive aria-button-if-js'); |
445 a.attr('class', 'vim-z vim-destructive aria-button-if-js'); |
446 $('.avatar', el).first().clone().prependTo('#undo-' + id + ' .' + action + '-undo-inside'); |
446 $('.avatar', el).first().clone().prependTo('#undo-' + id + ' .' + action + '-undo-inside'); |
447 |
447 |
448 a.click(function( e ){ |
448 a.on( 'click', function( e ){ |
449 e.preventDefault(); |
449 e.preventDefault(); |
450 e.stopPropagation(); // Ticket #35904. |
450 e.stopPropagation(); // Ticket #35904. |
451 list.wpList.del(this); |
451 list.wpList.del(this); |
452 $('#undo-' + id).css( {backgroundColor:'#ceb'} ).fadeOut(350, function(){ |
452 $('#undo-' + id).css( {backgroundColor:'#ceb'} ).fadeOut(350, function(){ |
453 $(this).remove(); |
453 $(this).remove(); |
760 * Globally available jQuery object referring to the comments list. |
760 * Globally available jQuery object referring to the comments list. |
761 * |
761 * |
762 * @global |
762 * @global |
763 */ |
763 */ |
764 window.theList = $('#the-comment-list').wpList( { alt: '', delBefore: delBefore, dimAfter: dimAfter, delAfter: delAfter, addColor: 'none' } ) |
764 window.theList = $('#the-comment-list').wpList( { alt: '', delBefore: delBefore, dimAfter: dimAfter, delAfter: delAfter, addColor: 'none' } ) |
765 .bind('wpListDelEnd', function(e, s){ |
765 .on('wpListDelEnd', function(e, s){ |
766 var wpListsData = $(s.target).attr('data-wp-lists'), id = s.element.replace(/[^0-9]+/g, ''); |
766 var wpListsData = $(s.target).attr('data-wp-lists'), id = s.element.replace(/[^0-9]+/g, ''); |
767 |
767 |
768 if ( wpListsData.indexOf(':trash=1') != -1 || wpListsData.indexOf(':spam=1') != -1 ) |
768 if ( wpListsData.indexOf(':trash=1') != -1 || wpListsData.indexOf(':spam=1') != -1 ) |
769 $('#undo-' + id).fadeIn(300, function(){ $(this).show(); }); |
769 $('#undo-' + id).fadeIn(300, function(){ $(this).show(); }); |
770 }); |
770 }); |
791 * @memberof commentReply |
791 * @memberof commentReply |
792 */ |
792 */ |
793 init : function() { |
793 init : function() { |
794 var row = $('#replyrow'); |
794 var row = $('#replyrow'); |
795 |
795 |
796 $( '.cancel', row ).click( function() { return commentReply.revert(); } ); |
796 $( '.cancel', row ).on( 'click', function() { return commentReply.revert(); } ); |
797 $( '.save', row ).click( function() { return commentReply.send(); } ); |
797 $( '.save', row ).on( 'click', function() { return commentReply.send(); } ); |
798 $( 'input#author-name, input#author-email, input#author-url', row ).keypress( function( e ) { |
798 $( 'input#author-name, input#author-email, input#author-url', row ).on( 'keypress', function( e ) { |
799 if ( e.which == 13 ) { |
799 if ( e.which == 13 ) { |
800 commentReply.send(); |
800 commentReply.send(); |
801 e.preventDefault(); |
801 e.preventDefault(); |
802 return false; |
802 return false; |
803 } |
803 } |
804 }); |
804 }); |
805 |
805 |
806 // Add events. |
806 // Add events. |
807 $('#the-comment-list .column-comment > p').dblclick(function(){ |
807 $('#the-comment-list .column-comment > p').on( 'dblclick', function(){ |
808 commentReply.toggle($(this).parent()); |
808 commentReply.toggle($(this).parent()); |
809 }); |
809 }); |
810 |
810 |
811 $('#doaction, #doaction2, #post-query-submit').click(function(){ |
811 $('#doaction, #post-query-submit').on( 'click', function(){ |
812 if ( $('#the-comment-list #replyrow').length > 0 ) |
812 if ( $('#the-comment-list #replyrow').length > 0 ) |
813 commentReply.close(); |
813 commentReply.close(); |
814 }); |
814 }); |
815 |
815 |
816 this.comments_listing = $('#comments-form > input[name="comment_status"]').val() || ''; |
816 this.comments_listing = $('#comments-form > input[name="comment_status"]').val() || ''; |
848 * |
848 * |
849 * @return {void} |
849 * @return {void} |
850 */ |
850 */ |
851 toggle : function(el) { |
851 toggle : function(el) { |
852 if ( 'none' !== $( el ).css( 'display' ) && ( $( '#replyrow' ).parent().is('#com-reply') || window.confirm( __( 'Are you sure you want to edit this comment?\nThe changes you made will be lost.' ) ) ) ) { |
852 if ( 'none' !== $( el ).css( 'display' ) && ( $( '#replyrow' ).parent().is('#com-reply') || window.confirm( __( 'Are you sure you want to edit this comment?\nThe changes you made will be lost.' ) ) ) ) { |
853 $( el ).find( 'button.vim-q' ).click(); |
853 $( el ).find( 'button.vim-q' ).trigger( 'click' ); |
854 } |
854 } |
855 }, |
855 }, |
856 |
856 |
857 /** |
857 /** |
858 * Closes the comment quick edit or reply form and undoes any changes. |
858 * Closes the comment quick edit or reply form and undoes any changes. |
903 commentRow.fadeIn( 300, function() { |
903 commentRow.fadeIn( 300, function() { |
904 commentRow |
904 commentRow |
905 .show() |
905 .show() |
906 .find( '.vim-q' ) |
906 .find( '.vim-q' ) |
907 .attr( 'aria-expanded', 'false' ) |
907 .attr( 'aria-expanded', 'false' ) |
908 .focus(); |
908 .trigger( 'focus' ); |
909 } ).css( 'backgroundColor', '' ); |
909 } ).css( 'backgroundColor', '' ); |
910 } |
910 } |
911 |
911 |
912 // When closing the Reply form, move focus back to the Reply button. |
912 // When closing the Reply form, move focus back to the Reply button. |
913 if ( 'replyto-comment' === this.act ) { |
913 if ( 'replyto-comment' === this.act ) { |
914 commentRow.find( '.vim-r' ) |
914 commentRow.find( '.vim-r' ) |
915 .attr( 'aria-expanded', 'false' ) |
915 .attr( 'aria-expanded', 'false' ) |
916 .focus(); |
916 .trigger( 'focus' ); |
917 } |
917 } |
918 |
918 |
919 // Reset the Quicktags buttons. |
919 // Reset the Quicktags buttons. |
920 if ( typeof QTags != 'undefined' ) |
920 if ( typeof QTags != 'undefined' ) |
921 QTags.closeAllTags('replycontent'); |
921 QTags.closeAllTags('replycontent'); |
1030 if ( scrollBottom - 20 < rbottom ) |
1030 if ( scrollBottom - 20 < rbottom ) |
1031 window.scroll(0, rbottom - vp + 35); |
1031 window.scroll(0, rbottom - vp + 35); |
1032 else if ( rtop - 20 < scrollTop ) |
1032 else if ( rtop - 20 < scrollTop ) |
1033 window.scroll(0, rtop - 35); |
1033 window.scroll(0, rtop - 35); |
1034 |
1034 |
1035 $('#replycontent').focus().keyup(function(e){ |
1035 $('#replycontent').trigger( 'focus' ).on( 'keyup', function(e){ |
1036 if ( e.which == 27 ) |
1036 if ( e.which == 27 ) |
1037 commentReply.revert(); // Close on Escape. |
1037 commentReply.revert(); // Close on Escape. |
1038 }); |
1038 }); |
1039 }, 600); |
1039 }, 600); |
1040 |
1040 |
1133 updateInModerationText( r.supplemental ); |
1133 updateInModerationText( r.supplemental ); |
1134 updateApproved( 1, r.supplemental.parent_post_id ); |
1134 updateApproved( 1, r.supplemental.parent_post_id ); |
1135 updateCountText( 'span.all-count', 1 ); |
1135 updateCountText( 'span.all-count', 1 ); |
1136 } |
1136 } |
1137 |
1137 |
1138 c = $.trim(r.data); // Trim leading whitespaces. |
1138 r.data = r.data || ''; |
|
1139 c = r.data.toString().trim(); // Trim leading whitespaces. |
1139 $(c).hide(); |
1140 $(c).hide(); |
1140 $('#replyrow').after(c); |
1141 $('#replyrow').after(c); |
1141 |
1142 |
1142 id = $(id); |
1143 id = $(id); |
1143 t.addEvents(id); |
1144 t.addEvents(id); |
1222 |
1223 |
1223 return window.confirm( __( 'Are you sure you want to do this?\nThe comment changes you made will be lost.' ) ); |
1224 return window.confirm( __( 'Are you sure you want to do this?\nThe comment changes you made will be lost.' ) ); |
1224 } |
1225 } |
1225 }; |
1226 }; |
1226 |
1227 |
1227 $(document).ready(function(){ |
1228 $( function(){ |
1228 var make_hotkeys_redirect, edit_comment, toggle_all, make_bulk; |
1229 var make_hotkeys_redirect, edit_comment, toggle_all, make_bulk; |
1229 |
1230 |
1230 setCommentsList(); |
1231 setCommentsList(); |
1231 commentReply.init(); |
1232 commentReply.init(); |
1232 |
1233 |