DFW: fix closing only the wpLink or media modal when pressing Esc.

git-svn-id: https://develop.svn.wordpress.org/trunk@28455 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz 2014-05-16 18:16:59 +00:00
parent 0d92bb2552
commit 6fa89637e5
2 changed files with 21 additions and 14 deletions

View File

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

View File

@ -63,27 +63,33 @@ tinymce.PluginManager.add( 'wpfullscreen', function( editor ) {
editor.addCommand( 'wpFullScreenOn', fullscreenOn );
editor.addCommand( 'wpFullScreenOff', fullscreenOff );
function toggleFullscreen() {
// Toggle DFW mode. For use from inside the editor.
if ( typeof wp === 'undefined' || ! wp.editor || ! wp.editor.fullscreen ) {
return;
}
function getExtAPI() {
return ( typeof wp !== 'undefined' && wp.editor && wp.editor.fullscreen );
}
if ( editor.getParam('wp_fullscreen') ) {
wp.editor.fullscreen.off();
} else {
wp.editor.fullscreen.on();
// Toggle DFW mode. For use from inside the editor.
function toggleFullscreen() {
var fullscreen = getExtAPI();
if ( fullscreen ) {
if ( editor.getParam('wp_fullscreen') ) {
fullscreen.off();
} else {
fullscreen.on();
}
}
}
editor.addCommand( 'wpFullScreen', toggleFullscreen );
editor.on( 'keyup', function( event ) {
editor.on( 'keydown', function( event ) {
var fullscreen;
// Turn fullscreen off when Esc is pressed.
if ( event.keyCode === 27 && wp.editor.fullscreen.settings.visible ) {
wp.editor.fullscreen.off();
if ( event.keyCode === 27 && ( fullscreen = getExtAPI() ) && fullscreen.settings.visible ) {
fullscreen.off();
}
} );
});
editor.on( 'init', function() {
// Set the editor when initializing from whitin DFW