From 9c80f135d0c0b958ace6d4c987c422bf4ee5d283 Mon Sep 17 00:00:00 2001 From: Mark Jaquith Date: Fri, 29 Mar 2013 07:46:24 +0000 Subject: [PATCH] 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 --- wp-admin/js/post-formats.js | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/wp-admin/js/post-formats.js b/wp-admin/js/post-formats.js index 8f582616dc..f389da93c2 100644 --- a/wp-admin/js/post-formats.js +++ b/wp-admin/js/post-formats.js @@ -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 () {