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: http://core.svn.wordpress.org/trunk@23854 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Mark Jaquith 2013-03-29 07:46:24 +00:00
parent fb78aa819e
commit 9c80f135d0
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);
$container.slideUp( 200, function(){
container.get(0).className = container.get(0).className.replace( /\bwp-format-[^ ]+/, '' );
container.addClass('wp-format-' + format);
$container.slideDown( 400 );
});
if ( -1 < $.inArray( format, noUIFormats ) && -1 < $.inArray( postFormats.currentPostFormat, noUIFormats ) ) {
switchFormatClass( format ); // No slide
} else {
$container.slideUp( 200, function(){
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 () {