Make WordPress Core

Ticket #24062: 24062.2.diff

File 24062.2.diff, 2.7 KB (added by wonderboymusic, 12 years ago)
  • wp-admin/js/post-formats.js

    diff --git wp-admin/js/post-formats.js wp-admin/js/post-formats.js
    index 69729ad..54e8a75 100644
     
    11window.wp = window.wp || {};
    22
    33(function($) {
    4         var container, mediaFrame, lastMimeType, mediaPreview,
     4        var container, mediaFrame, lastMimeType, mediaPreview, insertMediaButton,
    55                noUIFormats = ['standard', 'chat', 'status', 'aside', 'gallery'],
    66                $container = $( '.post-formats-fields' ),
    77                $screenIcon = $( '.icon32' );
    window.wp = window.wp || {}; 
    5959                        }
    6060                }
    6161
     62                // If gallery, force it to open to gallery state
     63                if ( 'gallery' === format )
     64                        insertMediaButton.addClass( 'gallery' );
     65                else
     66                        insertMediaButton.removeClass( 'gallery' );
     67
    6268                postFormats.currentPostFormat = format;
    6369        }
    6470
    65         $(function(){
     71        $(function() {
     72                insertMediaButton = $( '#insert-media-button' );
    6673
    6774                $('.post-format-change a').click(function() {
    6875                        $('.post-formats-fields, .post-format-change').slideUp();
  • wp-includes/js/media-editor.js

    diff --git wp-includes/js/media-editor.js wp-includes/js/media-editor.js
    index 96a6f1c..3e2a651 100644
     
    538538                add: function( id, options ) {
    539539                        var workflow = this.get( id );
    540540
    541                         if ( workflow )
    542                                 return workflow;
    543 
    544541                        workflow = workflows[ id ] = wp.media( _.defaults( options || {}, {
    545542                                frame:    'post',
    546543                                state:    'insert',
     
    692689                        }
    693690                },
    694691
    695                 open: function( id ) {
     692                open: function( id, options ) {
    696693                        var workflow, editor;
    697694
     695                        options = options || {};
     696
    698697                        id = this.id( id );
    699698
    700699                        // Save a bookmark of the caret position in IE.
     
    709708
    710709                        workflow = this.get( id );
    711710
    712                         // Initialize the editor's workflow if we haven't yet.
    713                         if ( ! workflow )
    714                                 workflow = this.add( id );
     711                        // Redo workflow if state has changed
     712                        if ( ! workflow || ( workflow.options && options.state !== workflow.options.state ) )
     713                                workflow = this.add( id, options );
    715714
    716715                        return workflow.open();
    717716                },
     
    719718                init: function() {
    720719                        $(document.body).on( 'click', '.insert-media', function( event ) {
    721720                                var $this = $(this),
    722                                         editor = $this.data('editor');
     721                                        editor = $this.data('editor'),
     722                                        options = {
     723                                                frame:    'post',
     724                                                state:    'insert',
     725                                                title:    wp.media.view.l10n.addMedia,
     726                                                multiple: true
     727                                        };
    723728
    724729                                event.preventDefault();
    725730
     
    730735                                // See: http://core.trac.wordpress.org/ticket/22445
    731736                                $this.blur();
    732737
    733                                 wp.media.editor.open( editor );
     738                                if ( $this.hasClass( 'gallery' ) ) {
     739                                        options.state = 'gallery';
     740                                        options.title = wp.media.view.l10n.createGalleryTitle;
     741                                }
     742
     743                                wp.media.editor.open( editor, options );
    734744                        });
    735745                }
    736746        };