Media: Update the gallery "add images" state. see #21390.
git-svn-id: http://core.svn.wordpress.org/trunk@22356 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
0672d11502
commit
9670372812
|
@ -303,6 +303,32 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
media.controller.GalleryAddImages = media.controller.Library.extend({
|
||||||
|
defaults: {
|
||||||
|
id: 'gallery:add',
|
||||||
|
multiple: true,
|
||||||
|
title: l10n.createGalleryTitle
|
||||||
|
},
|
||||||
|
|
||||||
|
initialize: function() {
|
||||||
|
if ( ! this.get('library') )
|
||||||
|
this.set( 'library', media.query({ type: 'image' }) );
|
||||||
|
return media.controller.Library.prototype.initialize.apply( this, arguments );
|
||||||
|
},
|
||||||
|
|
||||||
|
toolbar: function() {
|
||||||
|
var frame = this.frame;
|
||||||
|
|
||||||
|
frame.toolbar( new media.view.Toolbar.GalleryAddImages({
|
||||||
|
controller: frame,
|
||||||
|
state: this
|
||||||
|
}) );
|
||||||
|
},
|
||||||
|
|
||||||
|
// Leave the sidebar.
|
||||||
|
sidebar: function() {}
|
||||||
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ========================================================================
|
* ========================================================================
|
||||||
* VIEWS
|
* VIEWS
|
||||||
|
@ -383,7 +409,8 @@
|
||||||
new media.controller.Gallery({
|
new media.controller.Gallery({
|
||||||
library: options.selection,
|
library: options.selection,
|
||||||
editing: options.editing
|
editing: options.editing
|
||||||
})
|
}),
|
||||||
|
new media.controller.GalleryAddImages()
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Set the default state.
|
// Set the default state.
|
||||||
|
@ -834,11 +861,24 @@
|
||||||
click: function() {
|
click: function() {
|
||||||
controller.close();
|
controller.close();
|
||||||
state.trigger( 'update', library );
|
state.trigger( 'update', library );
|
||||||
library.clear();
|
controller.get('library').get('selection').clear();
|
||||||
controller.state('library');
|
controller.state('library');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
addImages: {
|
||||||
|
text: l10n.addImages,
|
||||||
|
priority: -40,
|
||||||
|
|
||||||
|
click: function() {
|
||||||
|
controller.get('gallery:add').set( 'selection', new media.model.Selection( library.models, {
|
||||||
|
props: library.props.toJSON(),
|
||||||
|
multiple: true
|
||||||
|
}) );
|
||||||
|
controller.state('gallery:add');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
cancel: {
|
cancel: {
|
||||||
text: l10n.cancel,
|
text: l10n.cancel,
|
||||||
priority: -60,
|
priority: -60,
|
||||||
|
@ -856,6 +896,41 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// wp.media.view.Toolbar.GalleryAddImages
|
||||||
|
// -----------------------------
|
||||||
|
media.view.Toolbar.GalleryAddImages = media.view.Toolbar.extend({
|
||||||
|
initialize: function() {
|
||||||
|
var state = this.options.state,
|
||||||
|
editing = state.get('editing'),
|
||||||
|
library = state.get('library'),
|
||||||
|
controller = this.options.controller;
|
||||||
|
|
||||||
|
this.options.items = {
|
||||||
|
update: {
|
||||||
|
style: 'primary',
|
||||||
|
text: l10n.continueEditing,
|
||||||
|
priority: 40,
|
||||||
|
|
||||||
|
click: function() {
|
||||||
|
controller.get('gallery').set( 'library', state.get('selection') );
|
||||||
|
controller.state('gallery');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
cancel: {
|
||||||
|
text: l10n.cancel,
|
||||||
|
priority: -60,
|
||||||
|
|
||||||
|
click: function() {
|
||||||
|
controller.state('gallery');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
media.view.Toolbar.prototype.initialize.apply( this, arguments );
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* wp.media.view.Button
|
* wp.media.view.Button
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -338,6 +338,7 @@ function wp_default_scripts( &$scripts ) {
|
||||||
'createGalleryTitle' => __( 'Create Gallery' ),
|
'createGalleryTitle' => __( 'Create Gallery' ),
|
||||||
'insertGallery' => __( 'Insert gallery' ),
|
'insertGallery' => __( 'Insert gallery' ),
|
||||||
'updateGallery' => __( 'Update gallery' ),
|
'updateGallery' => __( 'Update gallery' ),
|
||||||
|
'continueEditing' => __( 'Continue editing' ),
|
||||||
) );
|
) );
|
||||||
|
|
||||||
$scripts->add( 'shortcode', "/wp-includes/js/shortcode$suffix.js", array( 'underscore' ), false, 1 );
|
$scripts->add( 'shortcode', "/wp-includes/js/shortcode$suffix.js", array( 'underscore' ), false, 1 );
|
||||||
|
|
Loading…
Reference in New Issue