DFW: Properly handle Esc key when the content is focused or when switching browser tabs.

props avryl.
fixes #28279.

git-svn-id: https://develop.svn.wordpress.org/trunk@28443 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2014-05-16 10:42:03 +00:00
parent e76bfbefbd
commit 6100833f0c
2 changed files with 10 additions and 3 deletions

View File

@ -510,10 +510,10 @@
}
});
$document.on( 'keydown.wp-fullscreen', function( event ) {
if ( 27 === event.which && s.visible ) { // Esc
$( window ).on( 'keyup', function( event ) {
// Turn fullscreen off when Esc is pressed.
if ( 27 === event.keyCode && s.visible ) {
api.off();
event.stopImmediatePropagation();
}
});

View File

@ -78,6 +78,13 @@ tinymce.PluginManager.add( 'wpfullscreen', function( editor ) {
editor.addCommand( 'wpFullScreen', toggleFullscreen );
editor.on( 'keyup', function( event ) {
// Turn fullscreen off when Esc is pressed.
if ( event.keyCode === 27 && wp.editor.fullscreen.settings.visible ) {
wp.editor.fullscreen.off();
}
} );
editor.on( 'init', function() {
// Set the editor when initializing from whitin DFW
if ( editor.getParam('wp_fullscreen') ) {