Ticket #33029: 33029.3.diff
File 33029.3.diff, 1.5 KB (added by , 6 years ago) |
---|
-
wp-admin/js/common.js
385 385 var $this = $( this ), 386 386 $button = $( '<button type="button" class="notice-dismiss"><span class="screen-reader-text"></span></button>' ), 387 387 btnText = commonL10n.dismiss || ''; 388 focusedElementAtt = 'data-wp-focused-element'; 388 389 389 390 // Ensure plain text 390 391 $button.find( '.screen-reader-text' ).text( btnText ); … … 391 392 392 393 $this.append( $button ); 393 394 395 // Note currently focused element before removing focus for click event. 396 $button.on( 'mousedown.wp-dismiss-notice', function( event ) { 397 $( ':focus' ).attr( focusedElementAtt, '' ); 398 }); 399 394 400 $button.on( 'click.wp-dismiss-notice', function( event ) { 395 401 event.preventDefault(); 396 402 $this.fadeTo( 100 , 0, function() { … … 398 404 $(this).remove(); 399 405 }); 400 406 }); 407 408 // Restore focus to prevously focused element if available, otherwise 409 // restore focus to the content area & move caret to the end of the content. 410 var previouslyFocusedElement = $( '[' + focusedElementAtt + ']' ); 411 if ( previouslyFocusedElement.length > 0 ) { 412 previouslyFocusedElement.focus().removeAttr( focusedElementAtt ); 413 } else { 414 tinyMCE.activeEditor.focus(); 415 tinyMCE.activeEditor.selection.select( tinyMCE.activeEditor.getBody(), true ); 416 tinyMCE.activeEditor.selection.collapse( false ); 417 } 401 418 }); 419 420 402 421 }); 403 422 404 423 // Init screen meta