(function ($) { $(function () { var $title = $('#title'); var $visibility = $('#visibility'); $visibility.hide(); // set required fields var required = [$title]; for (var i in required) { if (!required.hasOwnProperty(i)) continue; required[i].prop('required', true); } // init input label actions var subtitlehint = function(id) { var input = $('#' + id), prompt = $('#' + id + '-prompt-text'); if ('' === input.val()) { prompt.removeClass('screen-reader-text'); } prompt.click(function() { $(this).addClass('screen-reader-text'); input.focus(); }); input.blur(function() { if ( '' === this.value ) { prompt.removeClass('screen-reader-text'); } }).focus(function() { prompt.addClass('screen-reader-text'); }).keydown(function(e) { prompt.addClass('screen-reader-text'); $(this).unbind(e); }); }; subtitlehint('subtitle'); var fixtabindex = function(e) { var keyCode = e.keyCode || e.which; if (9 === keyCode) { var target = ''; switch ($(this).attr('id')) { case 'title': target = '#subtitle'; break; case 'subtitle': target = 'textarea#content'; break; } if ('' !== target) { e.preventDefault(); if ( (target !== 'textarea#content') || $('#wp-content-wrap').hasClass('html-active') ) { $(target).focus(); } else { tinymce.execCommand('mceFocus', false, 'content'); } } } }; $(document).on('keydown', '#title, #subtitle', fixtabindex); }); })(jQuery);