Media: Integrate the gallery workflow with the media menu.

`wp.media.model.Query.more()`
* If a request has already been sent out for more attachments, return that request object instead of creating another.

`wp.media.controller.Region`
* A region allows views to be swapped in and out of a section of the page without either view having to know about the other.
* Application components can use the same callbacks and resources by leveraging `Region.mode()`, which triggers a set of callbacks to create or transform the current view, but only if necessary.

`wp.media.view.Frame`
* Leverage `Region` controllers instead of forcing states to swap view objects, which causes states to fit more comfortably in the controller-camp.
* Add `previous()`, a method to fetch the previous state `id`.
* Separate out the default settings over several objects (so blank frames can be instantiated).

`wp.media.view.MediaFrame`
* The base `Frame` used for media management: handles integration with the `Modal` and `UploaderWindow` views.

`wp.media.view.MediaFrame.Post`
* Includes all default media states and callbacks necessary for inserting media into a post.

see #21390.


git-svn-id: http://core.svn.wordpress.org/trunk@22437 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Daryl Koopersmith 2012-11-07 20:14:41 +00:00
parent e1f25c2c0e
commit 90781c9e83
7 changed files with 648 additions and 407 deletions

View File

@ -116,7 +116,7 @@ var tb_position;
}).join('') );
}, this );
workflow.get('gallery').on( 'update', function( selection ) {
workflow.get('gallery-edit').on( 'update', function( selection ) {
var view = wp.mce.view.get('gallery'),
shortcode;
@ -125,9 +125,6 @@ var tb_position;
shortcode = view.gallery.shortcode( selection );
this.insert( shortcode.string() );
// Reset the workflow view to the library.
workflow.render('library');
}, this );
return workflow;

View File

@ -132,7 +132,7 @@
top: 0;
right: 0;
bottom: 61px;
width: 247px;
width: 267px;
padding: 0 16px;
z-index: 75;
background: #f5f5f5;
@ -140,7 +140,7 @@
}
.hide-sidebar .media-sidebar {
right: -280px;
right: -300px;
}
.hide-toolbar .media-sidebar {
@ -218,6 +218,10 @@
border-bottom: 1px solid #fff;
}
.media-menu > a.button {
margin: 0 20px;
}
/**
* Frame
*/
@ -225,11 +229,11 @@
overflow: hidden;
}
.media-frame .media-content {
.media-frame .region-content {
position: absolute;
top: 0;
left: 200px;
right: 280px;
right: 300px;
bottom: 61px;
height: auto;
width: auto;
@ -237,11 +241,11 @@
overflow: auto;
}
.media-frame.hide-sidebar .media-content {
.media-frame.hide-sidebar .region-content {
right: 0;
}
.media-frame.hide-toolbar .media-content {
.media-frame.hide-toolbar .region-content {
bottom: 0;
}
@ -578,7 +582,7 @@
display: block;
}
.media-content.uploader-inline {
.region-content.uploader-inline {
margin: 20px;
padding: 20px;
border: 1px dashed #aaa;
@ -799,16 +803,6 @@
* Attachment Display Settings
*/
.attachment-display-settings,
.button div.attachment-display-settings {
padding: 0 1em 1em;
}
.attachment-display-settings h3 {
font-weight: 200;
margin: 1.4em 0 0.4em;
}
.attachment-display-settings h4 {
margin: 1.4em 0 0.4em;
}

View File

@ -694,7 +694,7 @@ window.wp = window.wp || {};
return;
this.frame = wp.media({
state: 'gallery',
state: 'gallery-edit',
title: mceview.l10n.editGallery,
editing: true,
multiple: true,
@ -712,7 +712,7 @@ window.wp = window.wp || {};
}, this );
// Update the `shortcode` and `attachments`.
this.frame.get('gallery').on( 'update', function( selection ) {
this.frame.get('gallery-edit').on( 'update', function( selection ) {
var view = mceview.get('gallery');
this.options.shortcode = view.gallery.shortcode( selection );

View File

@ -14,8 +14,8 @@ window.wp = window.wp || {};
* @return {object} A media workflow.
*/
media = wp.media = function( attributes ) {
if ( media.view.Frame )
return new media.view.Frame( attributes ).render().attach().open();
if ( media.view.MediaFrame.Post )
return new media.view.MediaFrame.Post( attributes ).render().attach().open();
};
_.extend( media, { model: {}, view: {}, controller: {} });
@ -497,13 +497,16 @@ window.wp = window.wp || {};
more: function( options ) {
var query = this;
if ( this._more && 'pending' === this._more.state() )
return this._more;
if ( ! this.hasMore )
return $.Deferred().resolve().promise();
options = options || {};
options.add = true;
return this.fetch( options ).done( function( resp ) {
return this._more = this.fetch( options ).done( function( resp ) {
if ( _.isEmpty( resp ) || -1 === this.args.posts_per_page || resp.length < this.args.posts_per_page )
query.hasMore = false;
});

File diff suppressed because it is too large Load Diff

View File

@ -1414,6 +1414,8 @@ function wp_print_media_templates( $attachment ) {
</script>
<script type="text/html" id="tmpl-attachment-display-settings">
<h3><?php _e('Attachment Display Settings'); ?></h3>
<h4><?php _e('Alignment'); ?></h4>
<div class="alignment button-group button-large" data-setting="align">
<button class="button" value="left">
@ -1445,6 +1447,8 @@ function wp_print_media_templates( $attachment ) {
</script>
<script type="text/html" id="tmpl-gallery-settings">
<h3><?php _e('Gallery Settings'); ?></h3>
<h4><?php _e('Link To'); ?></h4>
<div class="link-to button-group" data-setting="link">
<button class="button" value="post">
@ -1458,7 +1462,7 @@ function wp_print_media_templates( $attachment ) {
<h4><?php _e('Gallery Columns'); ?></h4>
<select class="columns" name="columns" data-setting="columns">
<?php for( $i = 1; $i <= 9; $i++ ) : ?>
<?php for ( $i = 1; $i <= 9; $i++ ) : ?>
<option value="<?php echo esc_attr( $i ); ?>">
<?php echo esc_html( $i ); ?>
</option>

View File

@ -330,8 +330,9 @@ function wp_default_scripts( &$scripts ) {
'selected' => __( 'selected' ),
// Upload
'uploadFilesTitle' => __( 'Upload Files' ),
'selectFiles' => __( 'Select files' ),
'uploadFilesTitle' => __( 'Upload Files' ),
'selectFiles' => __( 'Select files' ),
'uploadImagesTitle' => __( 'Upload Images' ),
// Library
'mediaLibraryTitle' => __( 'Media Library' ),
@ -342,8 +343,14 @@ function wp_default_scripts( &$scripts ) {
// Embed
'embedFromUrlTitle' => __( 'Embed From URL' ),
// Batch
'batchInsert' => __( 'Batch insert' ),
'cancelBatchTitle' => __( '&#8592; Cancel Batch' ),
// Gallery
'createGalleryTitle' => __( 'Create Gallery' ),
'editGalleryTitle' => __( 'Edit Gallery' ),
'cancelGalleryTitle' => __( '&#8592; Cancel Gallery' ),
'insertGallery' => __( 'Insert gallery' ),
'updateGallery' => __( 'Update gallery' ),
'continueEditing' => __( 'Continue editing' ),