Make WordPress Core

Changeset 24087


Ignore:
Timestamp:
04/25/2013 05:43:14 AM (13 years ago)
Author:
markjaquith
Message:

Force gallery state for gallery post format.

props lessbloat, wonderboymusic. fixes #24062.

Location:
trunk
Files:
2 edited

Legend:

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

    r24084 r24087  
    22
    33(function($) {
    4         var container, $container, mediaFrame, lastMimeType, mediaPreview, lastHeight = 360, content,
     4        var container, $container, mediaFrame, lastMimeType, mediaPreview, lastHeight = 360, content, insertMediaButton,
    55                initialFormat = 'standard',
    66                shortClass = 'short-format',
    … …  
    9393                }
    9494
    95                 postFormats.currentPostFormat = format;
    96         }
     95                // If gallery, force it to open to gallery state
     96                if ( 'gallery' === format )
     97                        insertMediaButton.addClass( 'gallery' );
     98                else
     99                        insertMediaButton.removeClass( 'gallery' );
     100
     101                        postFormats.currentPostFormat = format;
     102                }
     103
     104
    97105
    98106        $(function() {
     107                insertMediaButton = $( '#insert-media-button' );
    99108                $container = $( '.post-formats-fields' );
    100109
  • trunk/wp-includes/js/media-editor.js

    r24017 r24087  
    538538                add: function( id, options ) {
    539539                        var workflow = this.get( id );
    540 
    541                         if ( workflow )
    542                                 return workflow;
    543540
    544541                        workflow = workflows[ id ] = wp.media( _.defaults( options || {}, {
    … …  
    693690                },
    694691
    695                 open: function( id ) {
     692                open: function( id, options ) {
    696693                        var workflow, editor;
     694
     695                        options = options || {};
    697696
    698697                        id = this.id( id );
    … …  
    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();
    … …  
    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();
    … …  
    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                }
Note: See TracChangeset for help on using the changeset viewer.