From c10958235f3572ce7349b10e490ba7fd04549478 Mon Sep 17 00:00:00 2001 From: Mark Jaquith Date: Thu, 25 Apr 2013 02:07:05 +0000 Subject: [PATCH] Make the content area smaller for Aside/Status posts. props wonderboymusic. fixes #23992. git-svn-id: https://develop.svn.wordpress.org/trunk@24077 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/js/post-formats.js | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) 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)); });