wp/wp-admin/js/edit-comments.js
changeset 22 8c2e4d02f4ef
parent 21 48c4eec2b7e6
equal deleted inserted replaced
21:48c4eec2b7e6 22:8c2e4d02f4ef
  1018 			$('#replyrow').fadeIn(300, function(){ $(this).show(); });
  1018 			$('#replyrow').fadeIn(300, function(){ $(this).show(); });
  1019 		}
  1019 		}
  1020 
  1020 
  1021 		setTimeout(function() {
  1021 		setTimeout(function() {
  1022 			var rtop, rbottom, scrollTop, vp, scrollBottom,
  1022 			var rtop, rbottom, scrollTop, vp, scrollBottom,
  1023 				isComposing = false;
  1023 				isComposing = false,
       
  1024 				isContextMenuOpen = false;
  1024 
  1025 
  1025 			rtop = $('#replyrow').offset().top;
  1026 			rtop = $('#replyrow').offset().top;
  1026 			rbottom = rtop + $('#replyrow').height();
  1027 			rbottom = rtop + $('#replyrow').height();
  1027 			scrollTop = window.pageYOffset || document.documentElement.scrollTop;
  1028 			scrollTop = window.pageYOffset || document.documentElement.scrollTop;
  1028 			vp = document.documentElement.clientHeight || window.innerHeight || 0;
  1029 			vp = document.documentElement.clientHeight || window.innerHeight || 0;
  1033 			else if ( rtop - 20 < scrollTop )
  1034 			else if ( rtop - 20 < scrollTop )
  1034 				window.scroll(0, rtop - 35);
  1035 				window.scroll(0, rtop - 35);
  1035 
  1036 
  1036 			$( '#replycontent' )
  1037 			$( '#replycontent' )
  1037 				.trigger( 'focus' )
  1038 				.trigger( 'focus' )
       
  1039 				.on( 'contextmenu keydown', function ( e ) {
       
  1040 					// Check if the context menu is open and set state.
       
  1041 					if ( e.type === 'contextmenu' ) {
       
  1042 						isContextMenuOpen = true;
       
  1043 					}
       
  1044 
       
  1045 					// Update the context menu state if the Escape key is pressed.
       
  1046 					if ( e.type === 'keydown' && e.which === 27 && isContextMenuOpen ) {
       
  1047 						isContextMenuOpen = false;
       
  1048 					}
       
  1049 				} )
  1038 				.on( 'keyup', function( e ) {
  1050 				.on( 'keyup', function( e ) {
  1039 					// Close on Escape except when Input Method Editors (IMEs) are in use.
  1051 					// Close on Escape unless Input Method Editors (IMEs) are in use or the context menu is open.
  1040 					if ( e.which === 27 && ! isComposing ) {
  1052 					if ( e.which === 27 && ! isComposing && ! isContextMenuOpen ) {
  1041 						commentReply.revert();
  1053 						commentReply.revert();
  1042 					}
  1054 					}
  1043 				} )
  1055 				} )
  1044 				.on( 'compositionstart', function() {
  1056 				.on( 'compositionstart', function() {
  1045 					isComposing = true;
  1057 					isComposing = true;
  1186 			er = r.responseText.replace( /<.[^<>]*?>/g, '' );
  1198 			er = r.responseText.replace( /<.[^<>]*?>/g, '' );
  1187 
  1199 
  1188 		if ( er ) {
  1200 		if ( er ) {
  1189 			$errorNotice.removeClass( 'hidden' );
  1201 			$errorNotice.removeClass( 'hidden' );
  1190 			$error.html( er );
  1202 			$error.html( er );
       
  1203 			wp.a11y.speak( er );
  1191 		}
  1204 		}
  1192 	},
  1205 	},
  1193 
  1206 
  1194 	/**
  1207 	/**
  1195 	 * Opens the add comments form in the comments metabox on the post edit page.
  1208 	 * Opens the add comments form in the comments metabox on the post edit page.