Force gallery state for gallery post format.
props lessbloat, wonderboymusic. fixes #24062. git-svn-id: http://core.svn.wordpress.org/trunk@24087 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
8f3fc94073
commit
1f6d2f796a
|
@ -1,7 +1,7 @@
|
||||||
window.wp = window.wp || {};
|
window.wp = window.wp || {};
|
||||||
|
|
||||||
(function($) {
|
(function($) {
|
||||||
var container, $container, mediaFrame, lastMimeType, mediaPreview, lastHeight = 360, content,
|
var container, $container, mediaFrame, lastMimeType, mediaPreview, lastHeight = 360, content, insertMediaButton,
|
||||||
initialFormat = 'standard',
|
initialFormat = 'standard',
|
||||||
shortClass = 'short-format',
|
shortClass = 'short-format',
|
||||||
shortContentFormats = ['status', 'aside'],
|
shortContentFormats = ['status', 'aside'],
|
||||||
|
@ -92,10 +92,19 @@ window.wp = window.wp || {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If gallery, force it to open to gallery state
|
||||||
|
if ( 'gallery' === format )
|
||||||
|
insertMediaButton.addClass( 'gallery' );
|
||||||
|
else
|
||||||
|
insertMediaButton.removeClass( 'gallery' );
|
||||||
|
|
||||||
postFormats.currentPostFormat = format;
|
postFormats.currentPostFormat = format;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
|
insertMediaButton = $( '#insert-media-button' );
|
||||||
$container = $( '.post-formats-fields' );
|
$container = $( '.post-formats-fields' );
|
||||||
|
|
||||||
initialFormat = $( '.post-format-options .active' ).data( 'wp-format' );
|
initialFormat = $( '.post-format-options .active' ).data( 'wp-format' );
|
||||||
|
|
|
@ -538,9 +538,6 @@
|
||||||
add: function( id, options ) {
|
add: function( id, options ) {
|
||||||
var workflow = this.get( id );
|
var workflow = this.get( id );
|
||||||
|
|
||||||
if ( workflow )
|
|
||||||
return workflow;
|
|
||||||
|
|
||||||
workflow = workflows[ id ] = wp.media( _.defaults( options || {}, {
|
workflow = workflows[ id ] = wp.media( _.defaults( options || {}, {
|
||||||
frame: 'post',
|
frame: 'post',
|
||||||
state: 'insert',
|
state: 'insert',
|
||||||
|
@ -692,9 +689,11 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
open: function( id ) {
|
open: function( id, options ) {
|
||||||
var workflow, editor;
|
var workflow, editor;
|
||||||
|
|
||||||
|
options = options || {};
|
||||||
|
|
||||||
id = this.id( id );
|
id = this.id( id );
|
||||||
|
|
||||||
// Save a bookmark of the caret position in IE.
|
// Save a bookmark of the caret position in IE.
|
||||||
|
@ -709,9 +708,9 @@
|
||||||
|
|
||||||
workflow = this.get( id );
|
workflow = this.get( id );
|
||||||
|
|
||||||
// Initialize the editor's workflow if we haven't yet.
|
// Redo workflow if state has changed
|
||||||
if ( ! workflow )
|
if ( ! workflow || ( workflow.options && options.state !== workflow.options.state ) )
|
||||||
workflow = this.add( id );
|
workflow = this.add( id, options );
|
||||||
|
|
||||||
return workflow.open();
|
return workflow.open();
|
||||||
},
|
},
|
||||||
|
@ -719,7 +718,13 @@
|
||||||
init: function() {
|
init: function() {
|
||||||
$(document.body).on( 'click', '.insert-media', function( event ) {
|
$(document.body).on( 'click', '.insert-media', function( event ) {
|
||||||
var $this = $(this),
|
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();
|
event.preventDefault();
|
||||||
|
|
||||||
|
@ -730,7 +735,12 @@
|
||||||
// See: http://core.trac.wordpress.org/ticket/22445
|
// See: http://core.trac.wordpress.org/ticket/22445
|
||||||
$this.blur();
|
$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 );
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue