Tabbing in Editors: Prevent certain browsers from Tabbing out of the field. Props filosofo. Fixes #12424

git-svn-id: http://svn.automattic.com/wordpress/trunk@13548 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
dd32 2010-03-02 11:49:06 +00:00
parent 65b22dcf9c
commit 4c7070fb41
3 changed files with 16 additions and 5 deletions

View File

@ -269,14 +269,15 @@ jQuery(document).ready( function($) {
});
// tab in textareas
$('textarea#newcontent').keydown(function(e) {
$('#newcontent').keydown(function(e) {
if ( e.keyCode != 9 )
return true;
var el = e.target, selStart = el.selectionStart, selEnd = el.selectionEnd, val = el.value, scroll, sel;
e.stopPropagation();
e.preventDefault();
try {
this.lastKey = 9; // not a standard DOM property, lastKey is to help stop Opera tab event. See blur handler below.
} catch(err) {}
if ( document.selection ) {
el.focus();
@ -288,6 +289,16 @@ jQuery(document).ready( function($) {
el.selectionStart = el.selectionEnd = selStart + 1;
this.scrollTop = scroll;
}
if ( e.stopPropagation )
e.stopPropagation();
if ( e.preventDefault )
e.preventDefault();
});
$('#newcontent').blur(function(e) {
if ( this.lastKey && 9 == this.lastKey )
this.focus();
});
});

File diff suppressed because one or more lines are too long

View File

@ -60,7 +60,7 @@ function wp_default_scripts( &$scripts ) {
$scripts->add( 'utils', "/wp-admin/js/utils$suffix.js", false, '20090102' );
$scripts->add( 'common', "/wp-admin/js/common$suffix.js", array('jquery', 'hoverIntent', 'utils'), '20100218' );
$scripts->add( 'common', "/wp-admin/js/common$suffix.js", array('jquery', 'hoverIntent', 'utils'), '20100302' );
$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."),