From ed15f6a01e5b57f450371eb4de9cb9d628478417 Mon Sep 17 00:00:00 2001 From: Justin Kopepasah Date: Sun, 10 Aug 2014 19:57:05 +0900 Subject: [PATCH] Correct tabbing on post edit screen. This fixes #23 and allows tabbing from the title to the subtitle and from the subtitle to the post content. --- admin/assets/js/subtitles.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/admin/assets/js/subtitles.js b/admin/assets/js/subtitles.js index b1ca0ec..6ebe9ba 100644 --- a/admin/assets/js/subtitles.js +++ b/admin/assets/js/subtitles.js @@ -45,6 +45,35 @@ prompt.removeClass( 'screen-reader-text' ); } }); + + // Tab from the title to the subtitle, rather than the post content. + $( '#title' ).on( 'keydown', function( event ) { + if ( event.keyCode === 9 && ! event.ctrlKey && ! event.altKey && ! event.shiftKey ) { + $( '#subtitle' ).focus(); + + event.preventDefault(); + } + }); + + // Tab from the subtitle directly to post content. Borrowed from post.js. + $( '#subtitle' ).on( 'keydown.editor-focus', function( event ) { + var editor, $textarea; + + if ( event.keyCode === 9 && ! event.ctrlKey && ! event.altKey && ! event.shiftKey ) { + editor = typeof tinymce != 'undefined' && tinymce.get( 'content' ); + $textarea = $( '#content' ); + + if ( editor && ! editor.isHidden() ) { + editor.focus(); + } else if ( $textarea.length ) { + $textarea.focus(); + } else { + return; + } + + event.preventDefault(); + } + }); }); }