<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[27035] trunk/src/wp-admin/js/post.js: Fix tabbing order when opening/closing post status and visibility in the Publish postbox and cache some of the jQuery selectors.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/27035">27035</a></dd>
<dt>Author</dt> <dd>azaozz</dd>
<dt>Date</dt> <dd>2014-01-26 03:06:52 +0000 (Sun, 26 Jan 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Fix tabbing order when opening/closing post status and visibility in the Publish postbox and cache some of the jQuery selectors. Part-props atimmer, fixes <a href="http://core.trac.wordpress.org/ticket/25460">#25460</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpadminjspostjs">trunk/src/wp-admin/js/post.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpadminjspostjs"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-admin/js/post.js (27034 => 27035)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-admin/js/post.js    2014-01-26 00:28:49 UTC (rev 27034)
+++ trunk/src/wp-admin/js/post.js       2014-01-26 03:06:52 UTC (rev 27035)
</span><span class="lines">@@ -375,7 +375,10 @@
</span><span class="cx">          $editSlugWrap = $('#edit-slug-box'),
</span><span class="cx">          postId = $('#post_ID').val() || 0,
</span><span class="cx">          $submitpost = $('#submitpost'),
</span><del>-               releaseLock = true;
</del><ins>+                releaseLock = true,
+               $postVisibilitySelect = $('#post-visibility-select'),
+               $timestampdiv = $('#timestampdiv'),
+               $postStatusSelect = $('#post-status-select');
</ins><span class="cx"> 
</span><span class="cx">  postboxes.add_postbox_toggles(pagenow);
</span><span class="cx"> 
</span><span class="lines">@@ -646,14 +649,13 @@
</span><span class="cx">          visibility = $('#post-visibility-display').html();
</span><span class="cx"> 
</span><span class="cx">          updateVisibility = function() {
</span><del>-                       var pvSelect = $('#post-visibility-select');
-                       if ( $('input:radio:checked', pvSelect).val() != 'public' ) {
</del><ins>+                        if ( $postVisibilitySelect.find('input:radio:checked').val() != 'public' ) {
</ins><span class="cx">                           $('#sticky').prop('checked', false);
</span><span class="cx">                          $('#sticky-span').hide();
</span><span class="cx">                  } else {
</span><span class="cx">                          $('#sticky-span').show();
</span><span class="cx">                  }
</span><del>-                       if ( $('input:radio:checked', pvSelect).val() != 'password' ) {
</del><ins>+                        if ( $postVisibilitySelect.find('input:radio:checked').val() != 'password' ) {
</ins><span class="cx">                           $('#password-span').hide();
</span><span class="cx">                  } else {
</span><span class="cx">                          $('#password-span').show();
</span><span class="lines">@@ -662,7 +664,7 @@
</span><span class="cx"> 
</span><span class="cx">          updateText = function() {
</span><span class="cx"> 
</span><del>-                       if ( ! $('#timestampdiv').length )
</del><ins>+                        if ( ! $timestampdiv.length )
</ins><span class="cx">                           return true;
</span><span class="cx"> 
</span><span class="cx">                  var attemptedDate, originalDate, currentDate, publishOn, postStatus = $('#post_status'),
</span><span class="lines">@@ -674,10 +676,10 @@
</span><span class="cx">                  currentDate = new Date( $('#cur_aa').val(), $('#cur_mm').val() -1, $('#cur_jj').val(), $('#cur_hh').val(), $('#cur_mn').val() );
</span><span class="cx"> 
</span><span class="cx">                  if ( attemptedDate.getFullYear() != aa || (1 + attemptedDate.getMonth()) != mm || attemptedDate.getDate() != jj || attemptedDate.getMinutes() != mn ) {
</span><del>-                               $('.timestamp-wrap', '#timestampdiv').addClass('form-invalid');
</del><ins>+                                $timestampdiv.find('.timestamp-wrap').addClass('form-invalid');
</ins><span class="cx">                           return false;
</span><span class="cx">                  } else {
</span><del>-                               $('.timestamp-wrap', '#timestampdiv').removeClass('form-invalid');
</del><ins>+                                $timestampdiv.find('.timestamp-wrap').removeClass('form-invalid');
</ins><span class="cx">                   }
</span><span class="cx"> 
</span><span class="cx">                  if ( attemptedDate > currentDate && $('#original_post_status').val() != 'future' ) {
</span><span class="lines">@@ -704,7 +706,7 @@
</span><span class="cx">                          );
</span><span class="cx">                  }
</span><span class="cx"> 
</span><del>-                       if ( $('input:radio:checked', '#post-visibility-select').val() == 'private' ) {
</del><ins>+                        if ( $postVisibilitySelect.find('input:radio:checked').val() == 'private' ) {
</ins><span class="cx">                           $('#publish').val( postL10n.update );
</span><span class="cx">                          if ( 0 === optPublish.length ) {
</span><span class="cx">                                  postStatus.append('<option value="publish">' + postL10n.privatelyPublished + '</option>');
</span><span class="lines">@@ -712,7 +714,7 @@
</span><span class="cx">                                  optPublish.html( postL10n.privatelyPublished );
</span><span class="cx">                          }
</span><span class="cx">                          $('option[value="publish"]', postStatus).prop('selected', true);
</span><del>-                               $('.edit-post-status', '#misc-publishing-actions').hide();
</del><ins>+                                $('#misc-publishing-actions .edit-post-status').hide();
</ins><span class="cx">                   } else {
</span><span class="cx">                          if ( $('#original_post_status').val() == 'future' || $('#original_post_status').val() == 'draft' ) {
</span><span class="cx">                                  if ( optPublish.length ) {
</span><span class="lines">@@ -723,7 +725,7 @@
</span><span class="cx">                                  optPublish.html( postL10n.published );
</span><span class="cx">                          }
</span><span class="cx">                          if ( postStatus.is(':hidden') )
</span><del>-                                       $('.edit-post-status', '#misc-publishing-actions').show();
</del><ins>+                                        $('#misc-publishing-actions .edit-post-status').show();
</ins><span class="cx">                   }
</span><span class="cx">                  $('#post-status-display').html($('option:selected', postStatus).text());
</span><span class="cx">                  if ( $('option:selected', postStatus).val() == 'private' || $('option:selected', postStatus).val() == 'publish' ) {
</span><span class="lines">@@ -739,34 +741,32 @@
</span><span class="cx">                  return true;
</span><span class="cx">          };
</span><span class="cx"> 
</span><del>-               $('.edit-visibility', '#visibility').click(function () {
-                       if ( $( '#post-visibility-select' ).is( ':hidden' ) ) {
</del><ins>+                $( '#visibility .edit-visibility').click( function () {
+                       if ( $postVisibilitySelect.is(':hidden') ) {
</ins><span class="cx">                           updateVisibility();
</span><del>-                               $('#post-visibility-select').slideDown('fast');
</del><ins>+                                $postVisibilitySelect.slideDown('fast').find('input[type="radio"]').first().focus();
</ins><span class="cx">                           $(this).hide();
</span><span class="cx">                  }
</span><span class="cx">                  return false;
</span><span class="cx">          });
</span><span class="cx"> 
</span><del>-               $('.cancel-post-visibility', '#post-visibility-select').click(function () {
-                       $('#post-visibility-select').slideUp('fast');
</del><ins>+                $postVisibilitySelect.find('.cancel-post-visibility').click( function( event ) {
+                       $postVisibilitySelect.slideUp('fast');
</ins><span class="cx">                   $('#visibility-radio-' + $('#hidden-post-visibility').val()).prop('checked', true);
</span><span class="cx">                  $('#post_password').val($('#hidden-post-password').val());
</span><span class="cx">                  $('#sticky').prop('checked', $('#hidden-post-sticky').prop('checked'));
</span><span class="cx">                  $('#post-visibility-display').html(visibility);
</span><del>-                       $('.edit-visibility', '#visibility').show();
</del><ins>+                        $('#visibility .edit-visibility').show().focus();
</ins><span class="cx">                   updateText();
</span><del>-                       return false;
</del><ins>+                        event.preventDefault();
</ins><span class="cx">           });
</span><span class="cx"> 
</span><del>-               $('.save-post-visibility', '#post-visibility-select').click(function () { // crazyhorse - multiple ok cancels
-                       var pvSelect = $('#post-visibility-select');
-
-                       pvSelect.slideUp('fast');
-                       $('.edit-visibility', '#visibility').show();
</del><ins>+                $postVisibilitySelect.find('.save-post-visibility').click( function( event ) { // crazyhorse - multiple ok cancels
+                       $postVisibilitySelect.slideUp('fast');
+                       $('#visibility .edit-visibility').show();
</ins><span class="cx">                   updateText();
</span><span class="cx"> 
</span><del>-                       if ( $('input:radio:checked', pvSelect).val() != 'public' ) {
</del><ins>+                        if ( $postVisibilitySelect.find('input:radio:checked').val() != 'public' ) {
</ins><span class="cx">                           $('#sticky').prop('checked', false);
</span><span class="cx">                  } // WEAPON LOCKED
</span><span class="cx"> 
</span><span class="lines">@@ -776,74 +776,74 @@
</span><span class="cx">                          sticky = '';
</span><span class="cx">                  }
</span><span class="cx"> 
</span><del>-                       $('#post-visibility-display').html(     postL10n[$('input:radio:checked', pvSelect).val() + sticky]     );
-                       return false;
</del><ins>+                        $('#post-visibility-display').html(     postL10n[ $postVisibilitySelect.find('input:radio:checked').val() + sticky ]    );
+                       event.preventDefault();
</ins><span class="cx">           });
</span><span class="cx"> 
</span><del>-               $('input:radio', '#post-visibility-select').change(function() {
</del><ins>+                $postVisibilitySelect.find('input:radio').change( function() {
</ins><span class="cx">                   updateVisibility();
</span><span class="cx">          });
</span><span class="cx"> 
</span><del>-               $('#timestampdiv').siblings('a.edit-timestamp').click(function() {
-                       if ( $( '#timestampdiv' ).is( ':hidden' ) ) {
-                               $('#timestampdiv').slideDown('fast');
</del><ins>+                $timestampdiv.siblings('a.edit-timestamp').click( function( event ) {
+                       if ( $timestampdiv.is( ':hidden' ) ) {
+                               $timestampdiv.slideDown('fast');
</ins><span class="cx">                           $('#mm').focus();
</span><span class="cx">                          $(this).hide();
</span><span class="cx">                  }
</span><del>-                       return false;
</del><ins>+                        event.preventDefault();
</ins><span class="cx">           });
</span><span class="cx"> 
</span><del>-               $('.cancel-timestamp', '#timestampdiv').click(function() {
-                       $('#timestampdiv').slideUp('fast');
</del><ins>+                $timestampdiv.find('.cancel-timestamp').click( function( event ) {
+                       $timestampdiv.slideUp('fast').siblings('a.edit-timestamp').show().focus();
</ins><span class="cx">                   $('#mm').val($('#hidden_mm').val());
</span><span class="cx">                  $('#jj').val($('#hidden_jj').val());
</span><span class="cx">                  $('#aa').val($('#hidden_aa').val());
</span><span class="cx">                  $('#hh').val($('#hidden_hh').val());
</span><span class="cx">                  $('#mn').val($('#hidden_mn').val());
</span><del>-                       $('#timestampdiv').siblings('a.edit-timestamp').show();
</del><span class="cx">                   updateText();
</span><del>-                       return false;
</del><ins>+                        event.preventDefault();
</ins><span class="cx">           });
</span><span class="cx"> 
</span><del>-               $('.save-timestamp', '#timestampdiv').click(function () { // crazyhorse - multiple ok cancels
</del><ins>+                $timestampdiv.find('.save-timestamp').click( function( event ) { // crazyhorse - multiple ok cancels
</ins><span class="cx">                   if ( updateText() ) {
</span><del>-                               $('#timestampdiv').slideUp('fast');
-                               $('#timestampdiv').siblings('a.edit-timestamp').show();
</del><ins>+                                $timestampdiv.slideUp('fast');
+                               $timestampdiv.siblings('a.edit-timestamp').show();
</ins><span class="cx">                   }
</span><del>-                       return false;
</del><ins>+                        event.preventDefault();
</ins><span class="cx">           });
</span><span class="cx"> 
</span><del>-               $('#post').on( 'submit', function(e){
</del><ins>+                $('#post').on( 'submit', function( event ) {
</ins><span class="cx">                   if ( ! updateText() ) {
</span><del>-                               e.preventDefault();
-                               $('#timestampdiv').show();
</del><ins>+                                event.preventDefault();
+                               $timestampdiv.show();
+
+                               if ( typeof wp !== 'undefined' && wp.autosave ) {
+                                       wp.autosave.enableButtons();
+                               }
+
</ins><span class="cx">                           $('#publishing-action .spinner').hide();
</span><del>-                               $('#publish').prop('disabled', false).removeClass('button-primary-disabled');
-                               return false;
</del><span class="cx">                   }
</span><span class="cx">          });
</span><span class="cx"> 
</span><del>-               $('#post-status-select').siblings('a.edit-post-status').click(function() {
-                       if ( $( '#post-status-select' ).is( ':hidden' ) ) {
-                               $('#post-status-select').slideDown('fast');
</del><ins>+                $postStatusSelect.siblings('a.edit-post-status').click( function( event ) {
+                       if ( $postStatusSelect.is( ':hidden' ) ) {
+                               $postStatusSelect.slideDown('fast').find('select').focus();
</ins><span class="cx">                           $(this).hide();
</span><span class="cx">                  }
</span><del>-                       return false;
</del><ins>+                        event.preventDefault();
</ins><span class="cx">           });
</span><span class="cx"> 
</span><del>-               $('.save-post-status', '#post-status-select').click(function() {
-                       $('#post-status-select').slideUp('fast');
-                       $('#post-status-select').siblings('a.edit-post-status').show();
</del><ins>+                $postStatusSelect.find('.save-post-status').click( function( event ) {
+                       $postStatusSelect.slideUp('fast').siblings('a.edit-post-status').show();
</ins><span class="cx">                   updateText();
</span><del>-                       return false;
</del><ins>+                        event.preventDefault();
</ins><span class="cx">           });
</span><span class="cx"> 
</span><del>-               $('.cancel-post-status', '#post-status-select').click(function() {
-                       $('#post-status-select').slideUp('fast');
-                       $('#post_status').val($('#hidden_post_status').val());
-                       $('#post-status-select').siblings('a.edit-post-status').show();
</del><ins>+                $postStatusSelect.find('.cancel-post-status').click( function( event ) {
+                       $('#post-status-select').slideUp('fast').siblings( 'a.edit-post-status' ).show().focus();
+                       $('#post_status').val( $('#hidden_post_status').val() );
</ins><span class="cx">                   updateText();
</span><del>-                       return false;
</del><ins>+                        event.preventDefault();
</ins><span class="cx">           });
</span><span class="cx">  } // end submitdiv
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>