For starters, [27050] is rad. This just cleans up some extra new lines that were littered about, updates *some* of the inline docs (needs more), moves wp.media.controller.ImageDetails closer to its parent class, and de-dupes some code in media-template.php.

See #24409.


Built from https://develop.svn.wordpress.org/trunk@27051


git-svn-id: http://core.svn.wordpress.org/trunk@26925 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2014-01-28 23:21:13 +00:00
parent 33eedc570b
commit e1759d668a
8 changed files with 47 additions and 72 deletions

View File

@ -447,6 +447,9 @@
* *
* @param {string} content Content that is searched for possible * @param {string} content Content that is searched for possible
* shortcode markup matching the passed tag name, * shortcode markup matching the passed tag name,
*
* @this wp.media.gallery
*
* @returns {wp.media.view.MediaFrame.Select} A media workflow. * @returns {wp.media.view.MediaFrame.Select} A media workflow.
*/ */
edit: function( content ) { edit: function( content ) {

View File

@ -342,11 +342,10 @@ window.wp = window.wp || {};
}); });
/** /**
* wp.media.model.Attachment * wp.media.model.PostImage
* *
* @constructor * @constructor
* @augments Backbone.Model * @augments Backbone.Model
*
**/ **/
PostImage = media.model.PostImage = Backbone.Model.extend({ PostImage = media.model.PostImage = Backbone.Model.extend({
@ -354,7 +353,7 @@ window.wp = window.wp || {};
this.attachment = false; this.attachment = false;
if ( attributes.attachment_id ) { if ( attributes.attachment_id ) {
this.attachment = media.model.Attachment.get( attributes.attachment_id ); this.attachment = Attachment.get( attributes.attachment_id );
this.dfd = this.attachment.fetch(); this.dfd = this.attachment.fetch();
this.bindAttachmentListeners(); this.bindAttachmentListeners();
} }
@ -364,7 +363,6 @@ window.wp = window.wp || {};
this.on( 'change:size', this.updateSize, this ); this.on( 'change:size', this.updateSize, this );
this.setLinkTypeFromUrl(); this.setLinkTypeFromUrl();
}, },
bindAttachmentListeners: function() { bindAttachmentListeners: function() {
@ -411,10 +409,8 @@ window.wp = window.wp || {};
} }
this.set( 'link', type ); this.set( 'link', type );
}, },
updateLinkUrl: function() { updateLinkUrl: function() {
var link = this.get( 'link' ), var link = this.get( 'link' ),
url; url;
@ -434,9 +430,7 @@ window.wp = window.wp || {};
case 'none': case 'none':
this.set( 'linkUrl', '' ); this.set( 'linkUrl', '' );
break; break;
} }
}, },
updateSize: function() { updateSize: function() {
@ -450,10 +444,7 @@ window.wp = window.wp || {};
this.set( 'url', size.url ); this.set( 'url', size.url );
this.set( 'width', size.width ); this.set( 'width', size.width );
this.set( 'height', size.height ); this.set( 'height', size.height );
} }
}); });
/** /**

File diff suppressed because one or more lines are too long

View File

@ -725,6 +725,32 @@
} }
}); });
/**
* wp.media.controller.ImageDetails
*
* @constructor
* @augments wp.media.controller.State
* @augments Backbone.Model
*/
media.controller.ImageDetails = media.controller.State.extend({
defaults: _.defaults({
id: 'image-details',
toolbar: 'image-details',
title: l10n.imageDetailsTitle,
content: 'image-details',
menu: 'image-details',
router: false,
attachment: false,
priority: 60,
editing: false
}, media.controller.Library.prototype.defaults ),
initialize: function( options ) {
this.image = options.image;
media.controller.State.prototype.initialize.apply( this, arguments );
}
});
/** /**
* wp.media.controller.GalleryEdit * wp.media.controller.GalleryEdit
* *
@ -910,7 +936,6 @@
toolbar: 'featured-image', toolbar: 'featured-image',
title: l10n.setFeaturedImageTitle, title: l10n.setFeaturedImageTitle,
priority: 60, priority: 60,
syncSelection: false syncSelection: false
}, media.controller.Library.prototype.defaults ), }, media.controller.Library.prototype.defaults ),
@ -980,33 +1005,16 @@
} }
}); });
media.controller.ImageDetails = media.controller.State.extend({
defaults: _.defaults({
id: 'image-details',
toolbar: 'image-details',
title: l10n.imageDetailsTitle,
content: 'image-details',
menu: 'image-details',
router: false,
attachment: false,
priority: 60,
editing: false
}, media.controller.Library.prototype.defaults ),
initialize: function( options ) {
this.image = options.image;
media.controller.State.prototype.initialize.apply( this, arguments );
}
});
/** /**
* wp.media.controller.ReplaceImage * wp.media.controller.ReplaceImage
* *
* Replace a selected single image * Replace a selected single image
* *
**/ * @constructor
* @augments wp.media.controller.Library
* @augments wp.media.controller.State
* @augments Backbone.Model
*/
media.controller.ReplaceImage = media.controller.Library.extend({ media.controller.ReplaceImage = media.controller.Library.extend({
defaults: _.defaults({ defaults: _.defaults({
id: 'replace-image', id: 'replace-image',
@ -1022,7 +1030,6 @@
var library, comparator; var library, comparator;
this.image = options.image; this.image = options.image;
// If we haven't been provided a `library`, create a `Selection`. // If we haven't been provided a `library`, create a `Selection`.
if ( ! this.get('library') ) { if ( ! this.get('library') ) {
this.set( 'library', media.query({ type: 'image' }) ); this.set( 'library', media.query({ type: 'image' }) );
@ -1075,10 +1082,7 @@
attachment = this.image.attachment; attachment = this.image.attachment;
selection.reset( attachment ? [ attachment ] : [] ); selection.reset( attachment ? [ attachment ] : [] );
} }
}); });
/** /**

File diff suppressed because one or more lines are too long

View File

@ -143,7 +143,6 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
} }
} ); } );
// extract caption // extract caption
captionBlock = editor.dom.getParents( imageNode, '.wp-caption' ); captionBlock = editor.dom.getParents( imageNode, '.wp-caption' );
@ -172,7 +171,6 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
} }
return metadata; return metadata;
} }
function updateImage( imageNode, imageData ) { function updateImage( imageNode, imageData ) {
@ -223,7 +221,6 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
editor.selection.select( editor.dom.select( 'img', node )[0] ); editor.selection.select( editor.dom.select( 'img', node )[0] );
} }
editor.nodeChanged(); editor.nodeChanged();
} }
function createImageAndLink( imageData, mode ) { function createImageAndLink( imageData, mode ) {
@ -232,7 +229,6 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
mode = mode ? mode : 'node'; mode = mode ? mode : 'node';
if ( ! imageData.caption ) { if ( ! imageData.caption ) {
classes.push( 'align' + imageData.align ); classes.push( 'align' + imageData.align );
} }
@ -261,14 +257,11 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
} else if ( mode === 'html' ) { } else if ( mode === 'html' ) {
return editor.dom.createHTML( 'a', { href: imageData.linkUrl }, editor.dom.createHTML( 'img', props ) ); return editor.dom.createHTML( 'a', { href: imageData.linkUrl }, editor.dom.createHTML( 'img', props ) );
} }
} else { } else if ( mode === 'node' ) {
if ( mode === 'node' ) {
return editor.dom.create( 'img', props ); return editor.dom.create( 'img', props );
} else if ( mode === 'html' ) { } else if ( mode === 'html' ) {
return editor.dom.createHTML( 'img', props ); return editor.dom.createHTML( 'img', props );
} }
}
} }
editor.on( 'init', function() { editor.on( 'init', function() {
@ -650,8 +643,6 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
frame.state('replace-image').on( 'replace', callback ); frame.state('replace-image').on( 'replace', callback );
frame.open(); frame.open();
} }
} }
} ); } );

View File

@ -547,29 +547,19 @@ function wp_print_media_templates() {
</div> </div>
<div class="setting link-to"> <div class="setting link-to">
<span><?php _e('Link To'); ?></span> <span><?php _e('Link To'); ?></span>
<# if ( data.attachment ) { #>
<div class="button-group button-large" data-setting="link"> <div class="button-group button-large" data-setting="link">
<# if ( data.attachment ) { #>
<button class="button" value="file"> <button class="button" value="file">
<?php esc_attr_e('Media File'); ?> <?php esc_attr_e('Media File'); ?>
</button> </button>
<button class="button" value="post"> <button class="button" value="post">
<?php esc_attr_e('Attachment Page'); ?> <?php esc_attr_e('Attachment Page'); ?>
</button> </button>
<button class="button" value="custom">
<?php esc_attr_e('Custom URL'); ?>
</button>
<button class="button active" value="none">
<?php esc_attr_e('None'); ?>
</button>
</div>
<input type="text" class="link-to-custom" data-setting="linkUrl" />
<# } else { #> <# } else { #>
<div class="button-group button-large" data-setting="link">
<button class="button" value="file"> <button class="button" value="file">
<?php esc_attr_e('Image URL'); ?> <?php esc_attr_e('Image URL'); ?>
</button> </button>
<# } #>
<button class="button" value="custom"> <button class="button" value="custom">
<?php esc_attr_e('Custom URL'); ?> <?php esc_attr_e('Custom URL'); ?>
</button> </button>
@ -578,8 +568,6 @@ function wp_print_media_templates() {
</button> </button>
</div> </div>
<input type="text" class="link-to-custom" data-setting="linkUrl" /> <input type="text" class="link-to-custom" data-setting="linkUrl" />
<# } #>
</div> </div>
<# if ( data.attachment ) { #> <# if ( data.attachment ) { #>
@ -596,8 +584,7 @@ function wp_print_media_templates() {
) ); ) );
foreach ( $sizes as $value => $name ) : ?> foreach ( $sizes as $value => $name ) : ?>
<# <# var size = data.attachment.sizes['<?php echo esc_js( $value ); ?>'];
var size = data.attachment.sizes['<?php echo esc_js( $value ); ?>'];
if ( size ) { #> if ( size ) { #>
<button class="button" value="<?php echo esc_attr( $value ); ?>"> <button class="button" value="<?php echo esc_attr( $value ); ?>">
<?php echo esc_html( $name ); ?> <?php echo esc_html( $name ); ?>

View File

@ -2008,7 +2008,6 @@ function wp_enqueue_media( $args = array() ) {
'addToGalleryTitle' => __( 'Add to Gallery' ), 'addToGalleryTitle' => __( 'Add to Gallery' ),
'reverseOrder' => __( 'Reverse order' ), 'reverseOrder' => __( 'Reverse order' ),
// Edit Image // Edit Image
'imageDetailsTitle' => __( 'Image Details' ), 'imageDetailsTitle' => __( 'Image Details' ),
'imageReplaceTitle' => __( 'Replace Image' ), 'imageReplaceTitle' => __( 'Replace Image' ),