diff --git a/wp-admin/js/post-formats.js b/wp-admin/js/post-formats.js index 69729ad1fd..33f2e96ce2 100644 --- a/wp-admin/js/post-formats.js +++ b/wp-admin/js/post-formats.js @@ -1,11 +1,14 @@ window.wp = window.wp || {}; (function($) { - var container, mediaFrame, lastMimeType, mediaPreview, - noUIFormats = ['standard', 'chat', 'status', 'aside', 'gallery'], + var container, mediaFrame, lastMimeType, mediaPreview, lastHeight, content, $container = $( '.post-formats-fields' ), + shortClass = 'short-format', + shortContentFormats = ['status', 'aside'], + noUIFormats = ['standard', 'chat', 'status', 'aside', 'gallery'], $screenIcon = $( '.icon32' ); + function switchFormatClass( format ) { container.get(0).className = container.get(0).className.replace( /\s?\bwp-format-[^ ]+/g, '' ); container.addClass('wp-format-' + format); @@ -13,6 +16,18 @@ window.wp = window.wp || {}; $screenIcon.addClass('wp-format-' + format); } + function resizeContent( shorter ) { + content = content || $('#content, #content_ifr'); + if ( shorter ) { + if ( ! content.hasClass(shortClass) ) { + lastHeight = content.height(); + content.addClass(shortClass).animate({ height : 120 }); + } + } else if ( lastHeight ) { + content.removeClass(shortClass).animate({ height : lastHeight }); + } + } + function switchFormat($this) { var editor, body, parent = $this.parent(), @@ -38,6 +53,8 @@ window.wp = window.wp || {}; }); } + resizeContent( -1 < $.inArray( format, shortContentFormats ) ); + postTitle.focus(); if ( '' === postTitle.val() ) @@ -71,7 +88,7 @@ window.wp = window.wp || {}; }); // Post formats selection - $('.post-format-options').on( 'click', 'a', function(e){ + $('.post-format-options').on( 'click', 'a', function (e) { e.preventDefault(); switchFormat($(this)); });