From e99ef58818f7306439c5672919051ab9aeef8d86 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Sun, 22 Jul 2012 23:05:58 +0000 Subject: [PATCH] Add tabbing from Title directly to the textarea when the Text editor is active, fixes #20834 git-svn-id: https://develop.svn.wordpress.org/trunk@21303 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/js/autosave.dev.js | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/wp-includes/js/autosave.dev.js b/wp-includes/js/autosave.dev.js index 5463364932..4e16c862a1 100644 --- a/wp-includes/js/autosave.dev.js +++ b/wp-includes/js/autosave.dev.js @@ -96,18 +96,25 @@ jQuery(document).ready( function($) { $('input#wp-preview').val(''); } - // This code is meant to allow tabbing from Title to Post if tinymce is defined. - if ( typeof tinymce != 'undefined' ) { - $('#title').bind('keydown.focus-tinymce', function(e) { - if ( e.which != 9 ) - return; + // This code is meant to allow tabbing from Title to Post content. + $('#title').bind('keydown.editor-focus', function(e) { + var ed; - if ( !e.ctrlKey && !e.altKey && !e.shiftKey && tinymce.activeEditor && !tinymce.activeEditor.isHidden() ) { - $('td.mceToolbar > a').focus(); - e.preventDefault(); - } - }); - } + if ( e.which != 9 ) + return; + + if ( !e.ctrlKey && !e.altKey && !e.shiftKey ) { + if ( typeof(tinymce) != 'undefined' ) + ed = tinymce.get('content'); + + if ( ed && !ed.isHidden() ) + $('#content_tbl td.mceToolbar > a').focus(); + else + $('#content').focus(); + + e.preventDefault(); + } + }); // autosave new posts after a title is typed but not if Publish or Save Draft is clicked if ( '1' == $('#auto_draft').val() ) {