Make WordPress Core

Ticket #24062: 24062.diff

File 24062.diff, 2.7 KB (added by lessbloat, 12 years ago)
  • wp-includes/js/media-editor.js

     
    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
    698695                        id = this.id( id );
     696                       
     697                        if ( ! options )
     698                                var options = {};
    699699
    700700                        // Save a bookmark of the caret position in IE.
    701701                        if ( typeof tinymce !== 'undefined' ) {
     
    710710                        workflow = this.get( id );
    711711
    712712                        // Initialize the editor's workflow if we haven't yet.
    713                         if ( ! workflow )
    714                                 workflow = this.add( id );
     713                        // Redo workflow if state has changed
     714                        if ( ! workflow || workflow.options && options.state !== workflow.options.state )
     715                                workflow = this.add( id, options );
    715716
    716717                        return workflow.open();
    717718                },
     
    719720                init: function() {
    720721                        $(document.body).on( 'click', '.insert-media', function( event ) {
    721722                                var $this = $(this),
    722                                         editor = $this.data('editor');
     723                                        editor = $this.data('editor'),
     724                                        options = {
     725                                                frame:    'post',
     726                                                state:    'insert',
     727                                                title:    wp.media.view.l10n.addMedia,
     728                                                multiple: true
     729                                        };
    723730
    724731                                event.preventDefault();
    725732
     
    729736                                //
    730737                                // See: http://core.trac.wordpress.org/ticket/22445
    731738                                $this.blur();
     739                               
     740                                if ( $this.hasClass( 'gallery' ) ) {
     741                                        options = {
     742                                                title:          wp.media.view.l10n.createGalleryTitle,
     743                                                state:          'gallery',
     744                                                frame:          'post',
     745                                                multiple:       true
     746                                        }
     747                                }
    732748
    733                                 wp.media.editor.open( editor );
     749                                wp.media.editor.open( editor, options );
    734750                        });
    735751                }
    736752        };
  • wp-admin/js/post-formats.js

     
    1717                        var $this = $(this), editor, body,
    1818                                parent = $this.parent(),
    1919                                format = $this.data('wp-format'),
     20                                insertMediaButton = $( '#insert-media-button' ),
    2021                                description = $('.post-format-description');
    2122
    2223                if ( typeof container === 'undefined' )
     
    5758                                        editor.dom.addClass( body, 'post-format-' + format );
    5859                                }
    5960                        }
     61                       
     62                        // If gallery, force it to open to gallery state
     63                        if ( 'gallery' === format )
     64                                insertMediaButton.addClass( 'gallery' );
     65                        else
     66                                insertMediaButton.removeClass( 'gallery' );
    6067
    6168                        postFormats.currentPostFormat = format;
    6269                }).on('mouseenter focusin', 'a', function () {