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
* shortcode markup matching the passed tag name,
*
* @this wp.media.gallery
*
* @returns {wp.media.view.MediaFrame.Select} A media workflow.
*/
edit: function( content ) {

View File

@ -342,11 +342,10 @@ window.wp = window.wp || {};
});
/**
* wp.media.model.Attachment
* wp.media.model.PostImage
*
* @constructor
* @augments Backbone.Model
*
**/
PostImage = media.model.PostImage = Backbone.Model.extend({
@ -354,7 +353,7 @@ window.wp = window.wp || {};
this.attachment = false;
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.bindAttachmentListeners();
}
@ -364,7 +363,6 @@ window.wp = window.wp || {};
this.on( 'change:size', this.updateSize, this );
this.setLinkTypeFromUrl();
},
bindAttachmentListeners: function() {
@ -411,10 +409,8 @@ window.wp = window.wp || {};
}
this.set( 'link', type );
},
updateLinkUrl: function() {
var link = this.get( 'link' ),
url;
@ -434,9 +430,7 @@ window.wp = window.wp || {};
case 'none':
this.set( 'linkUrl', '' );
break;
}
},
updateSize: function() {
@ -450,10 +444,7 @@ window.wp = window.wp || {};
this.set( 'url', size.url );
this.set( 'width', size.width );
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
*
@ -910,7 +936,6 @@
toolbar: 'featured-image',
title: l10n.setFeaturedImageTitle,
priority: 60,
syncSelection: false
}, 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
*
* 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({
defaults: _.defaults({
id: 'replace-image',
@ -1022,7 +1030,6 @@
var library, comparator;
this.image = options.image;
// If we haven't been provided a `library`, create a `Selection`.
if ( ! this.get('library') ) {
this.set( 'library', media.query({ type: 'image' }) );
@ -1075,10 +1082,7 @@
attachment = this.image.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
captionBlock = editor.dom.getParents( imageNode, '.wp-caption' );
@ -172,7 +171,6 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
}
return metadata;
}
function updateImage( imageNode, imageData ) {
@ -223,7 +221,6 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
editor.selection.select( editor.dom.select( 'img', node )[0] );
}
editor.nodeChanged();
}
function createImageAndLink( imageData, mode ) {
@ -232,7 +229,6 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
mode = mode ? mode : 'node';
if ( ! imageData.caption ) {
classes.push( 'align' + imageData.align );
}
@ -261,14 +257,11 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
} else if ( mode === 'html' ) {
return editor.dom.createHTML( 'a', { href: imageData.linkUrl }, editor.dom.createHTML( 'img', props ) );
}
} else {
if ( mode === 'node' ) {
} else if ( mode === 'node' ) {
return editor.dom.create( 'img', props );
} else if ( mode === 'html' ) {
return editor.dom.createHTML( 'img', props );
}
}
}
editor.on( 'init', function() {
@ -650,8 +643,6 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
frame.state('replace-image').on( 'replace', callback );
frame.open();
}
}
} );

View File

@ -547,29 +547,19 @@ function wp_print_media_templates() {
</div>
<div class="setting link-to">
<span><?php _e('Link To'); ?></span>
<# if ( data.attachment ) { #>
<div class="button-group button-large" data-setting="link">
<# if ( data.attachment ) { #>
<button class="button" value="file">
<?php esc_attr_e('Media File'); ?>
</button>
<button class="button" value="post">
<?php esc_attr_e('Attachment Page'); ?>
</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 { #>
<div class="button-group button-large" data-setting="link">
<button class="button" value="file">
<?php esc_attr_e('Image URL'); ?>
</button>
<# } #>
<button class="button" value="custom">
<?php esc_attr_e('Custom URL'); ?>
</button>
@ -578,8 +568,6 @@ function wp_print_media_templates() {
</button>
</div>
<input type="text" class="link-to-custom" data-setting="linkUrl" />
<# } #>
</div>
<# if ( data.attachment ) { #>
@ -596,8 +584,7 @@ function wp_print_media_templates() {
) );
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 ) { #>
<button class="button" value="<?php echo esc_attr( $value ); ?>">
<?php echo esc_html( $name ); ?>

View File

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