Do not attempt a slide transition if the current and switched-to post

formats both have no UI. Do not slide if clicking on the current format.

see #19570

git-svn-id: https://develop.svn.wordpress.org/trunk@23854 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Mark Jaquith 2013-03-29 07:46:24 +00:00
parent cb6e2622e0
commit 6c42dea13f
1 changed files with 23 additions and 9 deletions

View File

@ -1,28 +1,44 @@
window.wp = window.wp || {};
(function($) {
var mediaFrame, lastMimeType, lastMenu, mediaPreview;
var container, mediaFrame, lastMimeType, lastMenu, mediaPreview, noUIFormats = ['standard', 'chat', 'status', 'aside'];
function switchFormatClass( format ) {
container.get(0).className = container.get(0).className.replace( /\bwp-format-[^ ]+/, '' );
container.addClass('wp-format-' + format);
}
$(function(){
var $container = $( '.post-formats-fields' );
// Post formats selection
$('.post-format-options').on( 'click', 'a', function(e){
e.preventDefault();
var $this = $(this), editor, body,
parent = $this.parent(),
format = $this.data('wp-format'),
container = $('#post-body-content'),
description = $('.post-format-description');
if ( typeof container === 'undefined' )
container = $('#post-body-content');
// Already on this post format. Bail.
if ( format === postFormats.currentPostFormat )
return;
parent.find('a.active').removeClass('active');
$this.addClass('active');
$('#icon-edit').removeClass(postFormats.currentPostFormat).addClass(format);
$('#post_format').val(format);
if ( -1 < $.inArray( format, noUIFormats ) && -1 < $.inArray( postFormats.currentPostFormat, noUIFormats ) ) {
switchFormatClass( format ); // No slide
} else {
$container.slideUp( 200, function(){
container.get(0).className = container.get(0).className.replace( /\bwp-format-[^ ]+/, '' );
container.addClass('wp-format-' + format);
switchFormatClass( format );
$container.slideDown( 400 );
});
}
$('#title').focus();
@ -43,8 +59,6 @@ window.wp = window.wp || {};
}
postFormats.currentPostFormat = format;
e.preventDefault();
}).on('mouseenter focusin', 'a', function () {
$('.post-format-tip').html( $(this).prop('title') );
}).on('mouseleave focusout', 'a', function () {