WordPress.org

Make WordPress Core

Changeset 28455


Ignore:
Timestamp:
05/16/2014 06:16:59 PM (7 years ago)
Author:
azaozz
Message:

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

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/js/wp-fullscreen.js

    r28443 r28455  
    511511            });
    512512
    513             $( window ).on( 'keyup', function( event ) {
     513            $( window ).on( 'keydown.wp-fullscreen', function( event ) {
    514514                // Turn fullscreen off when Esc is pressed.
    515515                if ( 27 === event.keyCode && s.visible ) {
    516516                    api.off();
     517                    event.stopImmediatePropagation();
    517518                }
    518519            });
  • trunk/src/wp-includes/js/tinymce/plugins/wpfullscreen/plugin.js

    r28443 r28455  
    6464    editor.addCommand( 'wpFullScreenOff', fullscreenOff );
    6565
     66    function getExtAPI() {
     67        return ( typeof wp !== 'undefined' && wp.editor && wp.editor.fullscreen );
     68    }
     69
     70    // Toggle DFW mode. For use from inside the editor.
    6671    function toggleFullscreen() {
    67         // Toggle DFW mode. For use from inside the editor.
    68         if ( typeof wp === 'undefined' || ! wp.editor || ! wp.editor.fullscreen ) {
    69             return;
    70         }
     72        var fullscreen = getExtAPI();
    7173
    72         if ( editor.getParam('wp_fullscreen') ) {
    73             wp.editor.fullscreen.off();
    74         } else {
    75             wp.editor.fullscreen.on();
     74        if ( fullscreen ) {
     75            if ( editor.getParam('wp_fullscreen') ) {
     76                fullscreen.off();
     77            } else {
     78                fullscreen.on();
     79            }
    7680        }
    7781    }
     
    7983    editor.addCommand( 'wpFullScreen', toggleFullscreen );
    8084
    81     editor.on( 'keyup', function( event ) {
     85    editor.on( 'keydown', function( event ) {
     86        var fullscreen;
     87
    8288        // Turn fullscreen off when Esc is pressed.
    83         if ( event.keyCode === 27 && wp.editor.fullscreen.settings.visible ) {
    84             wp.editor.fullscreen.off();
     89        if ( event.keyCode === 27 && ( fullscreen = getExtAPI() ) && fullscreen.settings.visible ) {
     90            fullscreen.off();
    8591        }
    86     } );
     92    });
    8793
    8894    editor.on( 'init', function() {
Note: See TracChangeset for help on using the changeset viewer.