Disambiguate `this` and use the `@this` annotation in `media-editor.js`. This will become way more necessary in other places, but a few examples here show how confusing it can be.
See #26870. Built from https://develop.svn.wordpress.org/trunk@26989 git-svn-id: http://core.svn.wordpress.org/trunk@26866 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
86aec42f7c
commit
f473d5eef2
|
@ -503,6 +503,7 @@
|
||||||
* wp.media.featuredImage
|
* wp.media.featuredImage
|
||||||
*/
|
*/
|
||||||
wp.media.featuredImage = {
|
wp.media.featuredImage = {
|
||||||
|
scott: 'yes',
|
||||||
/**
|
/**
|
||||||
* Get the featured image post ID
|
* Get the featured image post ID
|
||||||
*
|
*
|
||||||
|
@ -543,6 +544,8 @@
|
||||||
* @global wp.media.controller.FeaturedImage
|
* @global wp.media.controller.FeaturedImage
|
||||||
* @global wp.media.view.l10n
|
* @global wp.media.view.l10n
|
||||||
*
|
*
|
||||||
|
* @this wp.media.featuredImage
|
||||||
|
*
|
||||||
* @returns {wp.media.view.MediaFrame.Select} A media workflow.
|
* @returns {wp.media.view.MediaFrame.Select} A media workflow.
|
||||||
*/
|
*/
|
||||||
frame: function() {
|
frame: function() {
|
||||||
|
@ -556,6 +559,9 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
this._frame.on( 'toolbar:create:featured-image', function( toolbar ) {
|
this._frame.on( 'toolbar:create:featured-image', function( toolbar ) {
|
||||||
|
/**
|
||||||
|
* @this wp.media.view.MediaFrame.Select
|
||||||
|
*/
|
||||||
this.createSelectToolbar( toolbar, {
|
this.createSelectToolbar( toolbar, {
|
||||||
text: wp.media.view.l10n.setFeaturedImage
|
text: wp.media.view.l10n.setFeaturedImage
|
||||||
});
|
});
|
||||||
|
@ -566,6 +572,8 @@
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* @global wp.media.view.settings
|
* @global wp.media.view.settings
|
||||||
|
*
|
||||||
|
* @this wp.media.controller.FeaturedImage
|
||||||
*/
|
*/
|
||||||
select: function() {
|
select: function() {
|
||||||
var settings = wp.media.view.settings,
|
var settings = wp.media.view.settings,
|
||||||
|
@ -657,6 +665,8 @@
|
||||||
* @param {string} id A slug used to identify the workflow.
|
* @param {string} id A slug used to identify the workflow.
|
||||||
* @param {Object} [options={}]
|
* @param {Object} [options={}]
|
||||||
*
|
*
|
||||||
|
* @this wp.media.editor
|
||||||
|
*
|
||||||
* @returns {wp.media.view.MediaFrame.Select} A media workflow.
|
* @returns {wp.media.view.MediaFrame.Select} A media workflow.
|
||||||
*/
|
*/
|
||||||
add: function( id, options ) {
|
add: function( id, options ) {
|
||||||
|
@ -684,6 +694,9 @@
|
||||||
|
|
||||||
$.when.apply( $, selection.map( function( attachment ) {
|
$.when.apply( $, selection.map( function( attachment ) {
|
||||||
var display = state.display( attachment ).toJSON();
|
var display = state.display( attachment ).toJSON();
|
||||||
|
/**
|
||||||
|
* @this wp.media.editor
|
||||||
|
*/
|
||||||
return this.send.attachment( display, attachment.toJSON() );
|
return this.send.attachment( display, attachment.toJSON() );
|
||||||
}, this ) ).done( function() {
|
}, this ) ).done( function() {
|
||||||
wp.media.editor.insert( _.toArray( arguments ).join('\n\n') );
|
wp.media.editor.insert( _.toArray( arguments ).join('\n\n') );
|
||||||
|
@ -691,10 +704,16 @@
|
||||||
}, this );
|
}, this );
|
||||||
|
|
||||||
workflow.state('gallery-edit').on( 'update', function( selection ) {
|
workflow.state('gallery-edit').on( 'update', function( selection ) {
|
||||||
|
/**
|
||||||
|
* @this wp.media.editor
|
||||||
|
*/
|
||||||
this.insert( wp.media.gallery.shortcode( selection ).string() );
|
this.insert( wp.media.gallery.shortcode( selection ).string() );
|
||||||
}, this );
|
}, this );
|
||||||
|
|
||||||
workflow.state('embed').on( 'select', function() {
|
workflow.state('embed').on( 'select', function() {
|
||||||
|
/**
|
||||||
|
* @this wp.media.editor
|
||||||
|
*/
|
||||||
var state = workflow.state(),
|
var state = workflow.state(),
|
||||||
type = state.get('type'),
|
type = state.get('type'),
|
||||||
embed = state.props.toJSON();
|
embed = state.props.toJSON();
|
||||||
|
@ -764,6 +783,9 @@
|
||||||
* Return the workflow specified by id
|
* Return the workflow specified by id
|
||||||
*
|
*
|
||||||
* @param {string} id
|
* @param {string} id
|
||||||
|
*
|
||||||
|
* @this wp.media.editor
|
||||||
|
*
|
||||||
* @returns {wp.media.view.MediaFrame} A media workflow.
|
* @returns {wp.media.view.MediaFrame} A media workflow.
|
||||||
*/
|
*/
|
||||||
get: function( id ) {
|
get: function( id ) {
|
||||||
|
@ -774,6 +796,8 @@
|
||||||
* Remove the workflow represented by id from the workflow cache
|
* Remove the workflow represented by id from the workflow cache
|
||||||
*
|
*
|
||||||
* @param {string} id
|
* @param {string} id
|
||||||
|
*
|
||||||
|
* @this wp.media.editor
|
||||||
*/
|
*/
|
||||||
remove: function( id ) {
|
remove: function( id ) {
|
||||||
id = this.id( id );
|
id = this.id( id );
|
||||||
|
@ -861,6 +885,9 @@
|
||||||
/**
|
/**
|
||||||
* @param {string} id
|
* @param {string} id
|
||||||
* @param {Object} options
|
* @param {Object} options
|
||||||
|
*
|
||||||
|
* @this wp.media.editor
|
||||||
|
*
|
||||||
* @returns {wp.media.view.MediaFrame}
|
* @returns {wp.media.view.MediaFrame}
|
||||||
*/
|
*/
|
||||||
open: function( id, options ) {
|
open: function( id, options ) {
|
||||||
|
@ -897,8 +924,8 @@
|
||||||
*/
|
*/
|
||||||
init: function() {
|
init: function() {
|
||||||
$(document.body).on( 'click', '.insert-media', function( event ) {
|
$(document.body).on( 'click', '.insert-media', function( event ) {
|
||||||
var $this = $(this),
|
var elem = $( event.currentTarget ),
|
||||||
editor = $this.data('editor'),
|
editor = elem.data('editor'),
|
||||||
options = {
|
options = {
|
||||||
frame: 'post',
|
frame: 'post',
|
||||||
state: 'insert',
|
state: 'insert',
|
||||||
|
@ -913,9 +940,9 @@
|
||||||
// above the modal.
|
// above the modal.
|
||||||
//
|
//
|
||||||
// See: http://core.trac.wordpress.org/ticket/22445
|
// See: http://core.trac.wordpress.org/ticket/22445
|
||||||
$this.blur();
|
elem.blur();
|
||||||
|
|
||||||
if ( $this.hasClass( 'gallery' ) ) {
|
if ( elem.hasClass( 'gallery' ) ) {
|
||||||
options.state = 'gallery';
|
options.state = 'gallery';
|
||||||
options.title = wp.media.view.l10n.createGalleryTitle;
|
options.title = wp.media.view.l10n.createGalleryTitle;
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue