From fb78aa819ec19187110e2fd521dbb99fe5bb10d6 Mon Sep 17 00:00:00 2001 From: Mark Jaquith Date: Fri, 29 Mar 2013 07:06:21 +0000 Subject: [PATCH] Use jQuery.on() properly. Add some slideUp()/slideDown() transitions to ease post format switches. see #19570 git-svn-id: http://core.svn.wordpress.org/trunk@23853 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/post-formats.php | 2 +- wp-admin/js/post-formats.js | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/wp-admin/includes/post-formats.php b/wp-admin/includes/post-formats.php index a1bf209597..be0d4580ad 100644 --- a/wp-admin/includes/post-formats.php +++ b/wp-admin/includes/post-formats.php @@ -4,7 +4,7 @@ $format_meta = get_post_format_meta( $post_ID ); ?>
-
+
diff --git a/wp-admin/js/post-formats.js b/wp-admin/js/post-formats.js index d7b799c268..8f582616dc 100644 --- a/wp-admin/js/post-formats.js +++ b/wp-admin/js/post-formats.js @@ -3,8 +3,10 @@ window.wp = window.wp || {}; (function($) { var mediaFrame, lastMimeType, lastMenu, mediaPreview; $(function(){ + var $container = $( '.post-formats-fields' ); + // Post formats selection - $('.post-format-options a').on( 'click', function(e){ + $('.post-format-options').on( 'click', 'a', function(e){ var $this = $(this), editor, body, parent = $this.parent(), format = $this.data('wp-format'), @@ -16,8 +18,12 @@ window.wp = window.wp || {}; $('#icon-edit').removeClass(postFormats.currentPostFormat).addClass(format); $('#post_format').val(format); - container.get(0).className = container.get(0).className.replace( /\bwp-format-[^ ]+/, '' ); - container.addClass('wp-format-' + format); + $container.slideUp( 200, function(){ + container.get(0).className = container.get(0).className.replace( /\bwp-format-[^ ]+/, '' ); + container.addClass('wp-format-' + format); + $container.slideDown( 400 ); + }); + $('#title').focus(); // Update description line @@ -39,9 +45,9 @@ window.wp = window.wp || {}; postFormats.currentPostFormat = format; e.preventDefault(); - }).on('mouseenter focusin', function () { + }).on('mouseenter focusin', 'a', function () { $('.post-format-tip').html( $(this).prop('title') ); - }).on('mouseleave focusout', function () { + }).on('mouseleave focusout', 'a', function () { $('.post-format-tip').html( $('.post-format-options a.active').prop('title') ); });