Don't close DFW when closing modal dialogs with Escape key, fixes #17399

git-svn-id: https://develop.svn.wordpress.org/trunk@18069 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz 2011-05-29 02:04:52 +00:00
parent 21aaf43a01
commit 1596867751
10 changed files with 70 additions and 38 deletions

View File

@ -343,4 +343,15 @@ $(document).ready( function() {
});
});
// internal use
$(document).bind( 'wp_ColseOnEscape', function( e, data ) {
if ( typeof(data.cb) != 'function' )
return;
if ( typeof(data.condition) != 'function' || data.condition() )
data.cb();
return true;
});
})(jQuery);

File diff suppressed because one or more lines are too long

View File

@ -476,7 +476,7 @@ PubSub.prototype.publish = function( topic, args ) {
wptitlehint('wp-fullscreen-title');
$(document).keyup(function(e){
var c = e.keyCode || e.charCode, a;
var c = e.keyCode || e.charCode, a, data;
if ( !fullscreen.settings.visible )
return true;
@ -486,8 +486,21 @@ PubSub.prototype.publish = function( topic, args ) {
else
a = e.altKey; // Alt key for Win & Linux
if ( 27 == c ) // Esc
fullscreen.off();
if ( 27 == c ) { // Esc
data = {
event: e,
what: 'dfw',
cb: fullscreen.off,
condition: function(){
if ( $('#TB_window').is(':visible') || $('.wp-dialog').is(':visible') )
return false;
return true;
}
};
if ( ! jQuery(document).triggerHandler( 'wp_ColseOnEscape', [data] ) )
fullscreen.off();
}
if ( a && (61 == c || 107 == c || 187 == c) ) // +
api.dfw_width(25);
@ -498,7 +511,7 @@ PubSub.prototype.publish = function( topic, args ) {
if ( a && 48 == c ) // 0
api.dfw_width(0);
return true;
return false;
});
// word count in HTML mode

File diff suppressed because one or more lines are too long

View File

@ -158,26 +158,26 @@ function tb_show(caption, url, imageGroup) {//function called when the user clic
}
document.onkeydown = function(e){
if (e == null) { // ie
keycode = event.keyCode;
} else { // mozilla
keycode = e.which;
}
if(keycode == 27){ // close
tb_remove();
} else if(keycode == 190){ // display previous image
jQuery(document).bind('keydown.thickbox', function(e){
e.stopImmediatePropagation();
if ( e.which == 27 ){ // close
if ( ! jQuery(document).triggerHandler( 'wp_ColseOnEscape', [{ event: e, what: 'thickbox', cb: tb_remove }] ) )
tb_remove();
} else if ( e.which == 190 ){ // display previous image
if(!(TB_NextHTML == "")){
document.onkeydown = "";
jQuery(document).unbind('thickbox');
goNext();
}
} else if(keycode == 188){ // display next image
} else if ( e.which == 188 ){ // display next image
if(!(TB_PrevHTML == "")){
document.onkeydown = "";
jQuery(document).unbind('thickbox');
goPrev();
}
}
};
return false;
});
tb_position();
jQuery("#TB_load").remove();
@ -249,16 +249,16 @@ function tb_show(caption, url, imageGroup) {//function called when the user clic
}
if(!params['modal']){
document.onkeyup = function(e){
if (e == null) { // ie
keycode = event.keyCode;
} else { // mozilla
keycode = e.which;
jQuery(document).bind('keyup.thickbox', function(e){
if ( e.which == 27 ){ // close
e.stopImmediatePropagation();
if ( ! jQuery(document).triggerHandler( 'wp_ColseOnEscape', [{ event: e, what: 'thickbox', cb: tb_remove }] ) )
tb_remove();
return false;
}
if(keycode == 27){ // close
tb_remove();
}
};
});
}
} catch(e) {
@ -281,8 +281,7 @@ function tb_remove() {
jQuery("body","html").css({height: "auto", width: "auto"});
jQuery("html").css("overflow","");
}
document.onkeydown = "";
document.onkeyup = "";
jQuery(document).unbind('.thickbox');
return false;
}

View File

@ -1,5 +1,10 @@
(function($){
$.ui.dialog.prototype.options.closeOnEscape = false;
$.widget("wp.wpdialog", $.ui.dialog, {
options: {
closeOnEscape: false
},
open: function() {
var ed;

View File

@ -1 +1 @@
(function(a){a.widget("wp.wpdialog",a.ui.dialog,{open:function(){var b;if(tinyMCEPopup&&typeof tinyMCE!="undefined"&&(b=tinyMCE.activeEditor)&&!b.isHidden()){tinyMCEPopup.init()}if(this._isOpen||false===this._trigger("beforeOpen")){return}a.ui.dialog.prototype.open.apply(this,arguments);this.element.focus();this._trigger("refresh")}})})(jQuery);
(function(a){a.ui.dialog.prototype.options.closeOnEscape=false;a.widget("wp.wpdialog",a.ui.dialog,{options:{closeOnEscape:false},open:function(){var b;if(tinyMCEPopup&&typeof tinyMCE!="undefined"&&(b=tinyMCE.activeEditor)&&!b.isHidden()){tinyMCEPopup.init()}if(this._isOpen||false===this._trigger("beforeOpen")){return}a.ui.dialog.prototype.open.apply(this,arguments);this.element.focus();this._trigger("refresh")}})})(jQuery);

View File

@ -336,7 +336,11 @@ var wpLink;
switch( event.which ) {
case key.ESCAPE:
wpLink.close();
event.stopImmediatePropagation();
if ( ! $(document).triggerHandler( 'wp_ColseOnEscape', [{ event: event, what: 'wplink', cb: wpLink.close }] ) )
wpLink.close();
return false;
break;
case key.UP:
case key.DOWN:

File diff suppressed because one or more lines are too long

View File

@ -64,7 +64,7 @@ function wp_default_scripts( &$scripts ) {
$scripts->add( 'utils', "/wp-admin/js/utils$suffix.js", false, '20101110' );
$scripts->add( 'common', "/wp-admin/js/common$suffix.js", array('jquery', 'hoverIntent', 'utils'), '20110524' );
$scripts->add( 'common', "/wp-admin/js/common$suffix.js", array('jquery', 'hoverIntent', 'utils'), '20110528' );
$scripts->add_data( 'common', 'group', 1 );
$scripts->localize( 'common', 'commonL10n', array(
'warnDelete' => __("You are about to permanently delete the selected items.\n 'Cancel' to stop, 'OK' to delete."),
@ -96,7 +96,7 @@ function wp_default_scripts( &$scripts ) {
$scripts->add( 'editor', "/wp-admin/js/editor$suffix.js", array('utils','jquery'), '20110411' );
$scripts->add_data( 'editor', 'group', 1 );
$scripts->add( 'wp-fullscreen', "/wp-admin/js/wp-fullscreen$suffix.js", array('jquery'), '20110518' );
$scripts->add( 'wp-fullscreen', "/wp-admin/js/wp-fullscreen$suffix.js", array('jquery'), '20110528' );
$scripts->add_data( 'wp-fullscreen', 'group', 1 );
$scripts->add( 'prototype', '/wp-includes/js/prototype.js', false, '1.6.1');
@ -190,7 +190,7 @@ function wp_default_scripts( &$scripts ) {
$scripts->add( 'jquery-table-hotkeys', "/wp-includes/js/jquery/jquery.table-hotkeys$suffix.js", array('jquery', 'jquery-hotkeys'), '20090102' );
$scripts->add_data( 'jquery-table-hotkeys', 'group', 1 );
$scripts->add( 'thickbox', "/wp-includes/js/thickbox/thickbox.js", array('jquery'), '3.1-20110405');
$scripts->add( 'thickbox', "/wp-includes/js/thickbox/thickbox.js", array('jquery'), '3.1-20110528');
$scripts->add_data( 'thickbox', 'group', 1 );
$scripts->localize( 'thickbox', 'thickboxL10n', array(
'next' => __('Next >'),
@ -272,7 +272,7 @@ function wp_default_scripts( &$scripts ) {
$scripts->add( 'admin-bar', "/wp-includes/js/admin-bar$suffix.js", false, '20110131' );
$scripts->add_data( 'admin-bar', 'group', 1 );
$scripts->add( 'wplink', "/wp-includes/js/tinymce/plugins/wplink/js/wplink$suffix.js", array( 'jquery', 'wpdialogs' ), '20110524' );
$scripts->add( 'wplink', "/wp-includes/js/tinymce/plugins/wplink/js/wplink$suffix.js", array( 'jquery', 'wpdialogs' ), '20110528' );
$scripts->add_data( 'wplink', 'group', 1 );
$scripts->localize( 'wplink', 'wpLinkL10n', array(
'title' => __('Insert/edit link'),
@ -283,7 +283,7 @@ function wp_default_scripts( &$scripts ) {
'l10n_print_after' => 'try{convertEntities(wpLinkL10n);}catch(e){};',
) );
$scripts->add( 'wpdialogs', "/wp-includes/js/tinymce/plugins/wpdialogs/js/wpdialog$suffix.js", array( 'jquery-ui-dialog' ), '20110421' );
$scripts->add( 'wpdialogs', "/wp-includes/js/tinymce/plugins/wpdialogs/js/wpdialog$suffix.js", array( 'jquery-ui-dialog' ), '20110528' );
$scripts->add_data( 'wpdialogs', 'group', 1 );
$scripts->add( 'wpdialogs-popup', "/wp-includes/js/tinymce/plugins/wpdialogs/js/popup$suffix.js", array( 'wpdialogs' ), '20110421' );