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

props avryl.
fixes #28279.
Built from https://develop.svn.wordpress.org/trunk@28443


git-svn-id: http://core.svn.wordpress.org/trunk@28270 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2014-05-16 10:43:14 +00:00
parent d970ac80c6
commit abc830ca9d
5 changed files with 12 additions and 5 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();
}
});

File diff suppressed because one or more lines are too long

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') ) {

View File

@ -1 +1 @@
tinymce.PluginManager.add("wpfullscreen",function(a){function b(c){var d,e,f=a.getDoc(),h=f.body,i=tinymce.DOM,j=250;c&&"setcontent"===c.type&&c.initial||a.settings.inline||(e=tinymce.Env.ie?h.scrollHeight:tinymce.Env.webkit&&0===h.clientHeight?0:h.offsetHeight,e>250&&(j=e),h.scrollTop=0,j!==g&&(d=j-g,i.setStyle(i.get(a.id+"_ifr"),"height",j+"px"),g=j,tinymce.isWebKit&&0>d&&b(c)))}function c(){f.wp_fullscreen=!0,a.dom.addClass(a.getDoc().documentElement,"wp-fullscreen"),a.on("change setcontent paste keyup",b)}function d(){f.wp_fullscreen=!1,a.dom.removeClass(a.getDoc().documentElement,"wp-fullscreen"),a.off("change setcontent paste keyup",b),g=0}function e(){"undefined"!=typeof wp&&wp.editor&&wp.editor.fullscreen&&(a.getParam("wp_fullscreen")?wp.editor.fullscreen.off():wp.editor.fullscreen.on())}var f=a.settings,g=0;a.addCommand("wpAutoResize",b),a.addCommand("wpFullScreenOn",c),a.addCommand("wpFullScreenOff",d),a.addCommand("wpFullScreen",e),a.on("init",function(){a.getParam("wp_fullscreen")&&c(),a.addShortcut("alt+shift+w","","wpFullScreen")}),a.addButton("wp_fullscreen",{tooltip:"Distraction Free Writing",shortcut:"Alt+Shift+W",onclick:e,classes:"wp-fullscreen btn widget"}),a.addMenuItem("wp_fullscreen",{text:"Distraction Free Writing",icon:"wp_fullscreen",shortcut:"Alt+Shift+W",context:"view",onclick:e})});
tinymce.PluginManager.add("wpfullscreen",function(a){function b(c){var d,e,f=a.getDoc(),h=f.body,i=tinymce.DOM,j=250;c&&"setcontent"===c.type&&c.initial||a.settings.inline||(e=tinymce.Env.ie?h.scrollHeight:tinymce.Env.webkit&&0===h.clientHeight?0:h.offsetHeight,e>250&&(j=e),h.scrollTop=0,j!==g&&(d=j-g,i.setStyle(i.get(a.id+"_ifr"),"height",j+"px"),g=j,tinymce.isWebKit&&0>d&&b(c)))}function c(){f.wp_fullscreen=!0,a.dom.addClass(a.getDoc().documentElement,"wp-fullscreen"),a.on("change setcontent paste keyup",b)}function d(){f.wp_fullscreen=!1,a.dom.removeClass(a.getDoc().documentElement,"wp-fullscreen"),a.off("change setcontent paste keyup",b),g=0}function e(){"undefined"!=typeof wp&&wp.editor&&wp.editor.fullscreen&&(a.getParam("wp_fullscreen")?wp.editor.fullscreen.off():wp.editor.fullscreen.on())}var f=a.settings,g=0;a.addCommand("wpAutoResize",b),a.addCommand("wpFullScreenOn",c),a.addCommand("wpFullScreenOff",d),a.addCommand("wpFullScreen",e),a.on("keyup",function(a){27===a.keyCode&&wp.editor.fullscreen.settings.visible&&wp.editor.fullscreen.off()}),a.on("init",function(){a.getParam("wp_fullscreen")&&c(),a.addShortcut("alt+shift+w","","wpFullScreen")}),a.addButton("wp_fullscreen",{tooltip:"Distraction Free Writing",shortcut:"Alt+Shift+W",onclick:e,classes:"wp-fullscreen btn widget"}),a.addMenuItem("wp_fullscreen",{text:"Distraction Free Writing",icon:"wp_fullscreen",shortcut:"Alt+Shift+W",context:"view",onclick:e})});