Make WordPress Core

Changeset 23854


Ignore:
Timestamp:
03/29/2013 07:46:24 AM (14 years ago)
Author:
markjaquith
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/js/post-formats.js

    r23853 r23854  
    22
    33(function($) {
    4         var mediaFrame, lastMimeType, lastMenu, mediaPreview;
     4        var container, mediaFrame, lastMimeType, lastMenu, mediaPreview, noUIFormats = ['standard', 'chat', 'status', 'aside'];
     5
     6        function switchFormatClass( format ) {
     7                container.get(0).className = container.get(0).className.replace( /\bwp-format-[^ ]+/, '' );
     8                container.addClass('wp-format-' + format);
     9        }
     10
    511        $(function(){
    612                var $container = $( '.post-formats-fields' );
    … …  
    814                // Post formats selection
    915                $('.post-format-options').on( 'click', 'a', function(e){
     16                        e.preventDefault();
    1017                        var $this = $(this), editor, body,
    1118                                parent = $this.parent(),
    1219                                format = $this.data('wp-format'),
    13                                 container = $('#post-body-content'),
    1420                                description = $('.post-format-description');
     21
     22                if ( typeof container === 'undefined' )
     23                        container = $('#post-body-content');
     24
     25                        // Already on this post format. Bail.
     26                        if ( format === postFormats.currentPostFormat )
     27                                return;
    1528
    1629                        parent.find('a.active').removeClass('active');
    … …  
    1932                        $('#post_format').val(format);
    2033
    21                         $container.slideUp( 200, function(){
    22                                 container.get(0).className = container.get(0).className.replace( /\bwp-format-[^ ]+/, '' );
    23                                 container.addClass('wp-format-' + format);
    24                                 $container.slideDown( 400 );
    25                         });
     34                        if ( -1 < $.inArray( format, noUIFormats ) && -1 < $.inArray( postFormats.currentPostFormat, noUIFormats ) ) {
     35                                switchFormatClass( format ); // No slide
     36                        } else {
     37                                $container.slideUp( 200, function(){
     38                                        switchFormatClass( format );
     39                                        $container.slideDown( 400 );
     40                                });
     41                        }
    2642
    2743                        $('#title').focus();
    … …  
    4460
    4561                        postFormats.currentPostFormat = format;
    46 
    47                         e.preventDefault();
    4862                }).on('mouseenter focusin', 'a', function () {
    4963                        $('.post-format-tip').html( $(this).prop('title') );
Note: See TracChangeset for help on using the changeset viewer.