Force gallery state for gallery post format.

props lessbloat, wonderboymusic. fixes #24062.

git-svn-id: https://develop.svn.wordpress.org/trunk@24087 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Mark Jaquith 2013-04-25 05:43:14 +00:00
parent 89872e2a71
commit bab5ddd458
2 changed files with 31 additions and 12 deletions

View File

@ -1,7 +1,7 @@
window.wp = window.wp || {};
(function($) {
var container, $container, mediaFrame, lastMimeType, mediaPreview, lastHeight = 360, content,
var container, $container, mediaFrame, lastMimeType, mediaPreview, lastHeight = 360, content, insertMediaButton,
initialFormat = 'standard',
shortClass = 'short-format',
shortContentFormats = ['status', 'aside'],
@ -92,10 +92,19 @@ window.wp = window.wp || {};
}
}
postFormats.currentPostFormat = format;
}
// If gallery, force it to open to gallery state
if ( 'gallery' === format )
insertMediaButton.addClass( 'gallery' );
else
insertMediaButton.removeClass( 'gallery' );
postFormats.currentPostFormat = format;
}
$(function() {
insertMediaButton = $( '#insert-media-button' );
$container = $( '.post-formats-fields' );
initialFormat = $( '.post-format-options .active' ).data( 'wp-format' );

View File

@ -538,9 +538,6 @@
add: function( id, options ) {
var workflow = this.get( id );
if ( workflow )
return workflow;
workflow = workflows[ id ] = wp.media( _.defaults( options || {}, {
frame: 'post',
state: 'insert',
@ -692,9 +689,11 @@
}
},
open: function( id ) {
open: function( id, options ) {
var workflow, editor;
options = options || {};
id = this.id( id );
// Save a bookmark of the caret position in IE.
@ -709,9 +708,9 @@
workflow = this.get( id );
// Initialize the editor's workflow if we haven't yet.
if ( ! workflow )
workflow = this.add( id );
// Redo workflow if state has changed
if ( ! workflow || ( workflow.options && options.state !== workflow.options.state ) )
workflow = this.add( id, options );
return workflow.open();
},
@ -719,7 +718,13 @@
init: function() {
$(document.body).on( 'click', '.insert-media', function( event ) {
var $this = $(this),
editor = $this.data('editor');
editor = $this.data('editor'),
options = {
frame: 'post',
state: 'insert',
title: wp.media.view.l10n.addMedia,
multiple: true
};
event.preventDefault();
@ -730,7 +735,12 @@
// See: http://core.trac.wordpress.org/ticket/22445
$this.blur();
wp.media.editor.open( editor );
if ( $this.hasClass( 'gallery' ) ) {
options.state = 'gallery';
options.title = wp.media.view.l10n.createGalleryTitle;
}
wp.media.editor.open( editor, options );
});
}
};