diff --git a/src/wp-admin/js/common.js b/src/wp-admin/js/common.js index 53891d4017..c6c6466fe1 100644 --- a/src/wp-admin/js/common.js +++ b/src/wp-admin/js/common.js @@ -701,15 +701,4 @@ $(document).ready( function() { } })(); -// internal use -$(document).bind( 'wp_CloseOnEscape', function( e, data ) { - if ( typeof(data.cb) != 'function' ) - return; - - if ( typeof(data.condition) != 'function' || data.condition() ) - data.cb(); - - return true; -}); - }( jQuery, window )); diff --git a/src/wp-admin/js/wp-fullscreen.js b/src/wp-admin/js/wp-fullscreen.js index 91c2c5ea4a..70cb353853 100644 --- a/src/wp-admin/js/wp-fullscreen.js +++ b/src/wp-admin/js/wp-fullscreen.js @@ -477,23 +477,6 @@ a = e.altKey; // Alt key for Win & Linux } - if ( 27 == c ) { // Esc - data = { - event: e, - what: 'dfw', - cb: api.off, - condition: function(){ - if ( $('#TB_window').is(':visible') || $('.wp-dialog').is(':visible') ) - return false; - return true; - } - }; - - if ( ! $(document).triggerHandler( 'wp_CloseOnEscape', [data] ) ) { - api.off(); - } - } - if ( a && (61 == c || 107 == c || 187 == c) ) { // + api.dfwWidth( 25 ); e.preventDefault(); @@ -510,6 +493,13 @@ } }); + $document.on( 'keydown.wp-fullscreen', function( event ) { + if ( 27 === event.which && s.visible ) { // Esc + api.off(); + event.stopImmediatePropagation(); + } + }); + toolbar.on( 'mouseenter', function() { toggleUI('show'); }).on( 'mouseleave', function() { diff --git a/src/wp-includes/js/media-views.js b/src/wp-includes/js/media-views.js index 4c4aee2def..745bf86f59 100644 --- a/src/wp-includes/js/media-views.js +++ b/src/wp-includes/js/media-views.js @@ -2347,10 +2347,9 @@ */ keydown: function( event ) { // Close the modal when escape is pressed. - if ( 27 === event.which ) { - event.preventDefault(); + if ( 27 === event.which && this.$el.is(':visible') ) { this.escape(); - return; + event.stopImmediatePropagation(); } } }); diff --git a/src/wp-includes/js/thickbox/thickbox.js b/src/wp-includes/js/thickbox/thickbox.js index e874446b80..0371bd28d0 100644 --- a/src/wp-includes/js/thickbox/thickbox.js +++ b/src/wp-includes/js/thickbox/thickbox.js @@ -156,11 +156,8 @@ function tb_show(caption, url, imageGroup) {//function called when the user clic } jQuery(document).bind('keydown.thickbox', function(e){ - e.stopImmediatePropagation(); - if ( e.which == 27 ){ // close - if ( ! jQuery(document).triggerHandler( 'wp_CloseOnEscape', [{ event: e, what: 'thickbox', cb: tb_remove }] ) ) - tb_remove(); + tb_remove(); } else if ( e.which == 190 ){ // display previous image if(!(TB_NextHTML == "")){ @@ -244,13 +241,9 @@ function tb_show(caption, url, imageGroup) {//function called when the user clic } if(!params['modal']){ - jQuery(document).bind('keyup.thickbox', function(e){ - + jQuery(document).bind('keydown.thickbox', function(e){ if ( e.which == 27 ){ // close - e.stopImmediatePropagation(); - if ( ! jQuery(document).triggerHandler( 'wp_CloseOnEscape', [{ event: e, what: 'thickbox', cb: tb_remove }] ) ) - tb_remove(); - + tb_remove(); return false; } }); diff --git a/src/wp-includes/js/wplink.js b/src/wp-includes/js/wplink.js index 93caa38444..c798547f27 100644 --- a/src/wp-includes/js/wplink.js +++ b/src/wp-includes/js/wplink.js @@ -304,6 +304,11 @@ var wpLink; keydown: function( event ) { var fn, key = $.ui.keyCode; + if ( key.ESCAPE === event.which ) { + wpLink.close(); + event.stopImmediatePropagation(); + } + if ( event.which !== key.UP && event.which !== key.DOWN ) { return; } @@ -318,13 +323,6 @@ var wpLink; keyup: function( event ) { var key = $.ui.keyCode; - if ( event.which === key.ESCAPE ) { - event.stopImmediatePropagation(); - if ( ! $(document).triggerHandler( 'wp_CloseOnEscape', [{ event: event, what: 'wplink', cb: wpLink.close }] ) ) - wpLink.close(); - return false; - } - if ( event.which === key.UP || event.which === key.DOWN ) { clearInterval( wpLink.keyInterval ); event.preventDefault();