From 031414171e03091d74894f7cdc29758fb7a8746a Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Tue, 28 Jan 2014 23:20:04 +0000 Subject: [PATCH] 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. git-svn-id: https://develop.svn.wordpress.org/trunk@27051 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/js/media-editor.js | 3 + src/wp-includes/js/media-models.js | 13 +---- src/wp-includes/js/media-views.js | 58 ++++++++++--------- .../js/tinymce/plugins/wpeditimage/plugin.js | 17 ++---- src/wp-includes/media-template.php | 23 ++------ src/wp-includes/media.php | 1 - 6 files changed, 45 insertions(+), 70 deletions(-) diff --git a/src/wp-includes/js/media-editor.js b/src/wp-includes/js/media-editor.js index 913e34c6d5..5ce7ae73a7 100644 --- a/src/wp-includes/js/media-editor.js +++ b/src/wp-includes/js/media-editor.js @@ -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 ) { diff --git a/src/wp-includes/js/media-models.js b/src/wp-includes/js/media-models.js index 6ea947fa41..5363ffe737 100644 --- a/src/wp-includes/js/media-models.js +++ b/src/wp-includes/js/media-models.js @@ -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 ); - } - - }); /** diff --git a/src/wp-includes/js/media-views.js b/src/wp-includes/js/media-views.js index 3fa9ecd09b..4c4aee2def 100644 --- a/src/wp-includes/js/media-views.js +++ b/src/wp-includes/js/media-views.js @@ -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 ] : [] ); - } - - }); /** diff --git a/src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js b/src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js index 91392396ff..f3e66e6e4c 100644 --- a/src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js +++ b/src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js @@ -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,13 +257,10 @@ 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' ) { - return editor.dom.create( 'img', props ); - } else if ( mode === 'html' ) { - return editor.dom.createHTML( 'img', props ); - } - + } else if ( mode === 'node' ) { + return editor.dom.create( 'img', props ); + } else if ( mode === 'html' ) { + return editor.dom.createHTML( 'img', props ); } } @@ -650,8 +643,6 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) { frame.state('replace-image').on( 'replace', callback ); frame.open(); - - } } } ); diff --git a/src/wp-includes/media-template.php b/src/wp-includes/media-template.php index 71e9c8282d..93bf672643 100644 --- a/src/wp-includes/media-template.php +++ b/src/wp-includes/media-template.php @@ -546,30 +546,20 @@ function wp_print_media_templates() { <# if ( data.attachment ) { #> @@ -596,8 +584,7 @@ function wp_print_media_templates() { ) ); foreach ( $sizes as $value => $name ) : ?> - <# - var size = data.attachment.sizes['']; + <# var size = data.attachment.sizes['']; if ( size ) { #>