Edit File by line
/home/barbar84/public_h.../wp-admin/js/widgets
File: media-widgets.js
/**
[0] Fix | Delete
* @output wp-admin/js/widgets/media-widgets.js
[1] Fix | Delete
*/
[2] Fix | Delete
[3] Fix | Delete
/* eslint consistent-this: [ "error", "control" ] */
[4] Fix | Delete
[5] Fix | Delete
/**
[6] Fix | Delete
* @namespace wp.mediaWidgets
[7] Fix | Delete
* @memberOf wp
[8] Fix | Delete
*/
[9] Fix | Delete
wp.mediaWidgets = ( function( $ ) {
[10] Fix | Delete
'use strict';
[11] Fix | Delete
[12] Fix | Delete
var component = {};
[13] Fix | Delete
[14] Fix | Delete
/**
[15] Fix | Delete
* Widget control (view) constructors, mapping widget id_base to subclass of MediaWidgetControl.
[16] Fix | Delete
*
[17] Fix | Delete
* Media widgets register themselves by assigning subclasses of MediaWidgetControl onto this object by widget ID base.
[18] Fix | Delete
*
[19] Fix | Delete
* @memberOf wp.mediaWidgets
[20] Fix | Delete
*
[21] Fix | Delete
* @type {Object.<string, wp.mediaWidgets.MediaWidgetModel>}
[22] Fix | Delete
*/
[23] Fix | Delete
component.controlConstructors = {};
[24] Fix | Delete
[25] Fix | Delete
/**
[26] Fix | Delete
* Widget model constructors, mapping widget id_base to subclass of MediaWidgetModel.
[27] Fix | Delete
*
[28] Fix | Delete
* Media widgets register themselves by assigning subclasses of MediaWidgetControl onto this object by widget ID base.
[29] Fix | Delete
*
[30] Fix | Delete
* @memberOf wp.mediaWidgets
[31] Fix | Delete
*
[32] Fix | Delete
* @type {Object.<string, wp.mediaWidgets.MediaWidgetModel>}
[33] Fix | Delete
*/
[34] Fix | Delete
component.modelConstructors = {};
[35] Fix | Delete
[36] Fix | Delete
component.PersistentDisplaySettingsLibrary = wp.media.controller.Library.extend(/** @lends wp.mediaWidgets.PersistentDisplaySettingsLibrary.prototype */{
[37] Fix | Delete
[38] Fix | Delete
/**
[39] Fix | Delete
* Library which persists the customized display settings across selections.
[40] Fix | Delete
*
[41] Fix | Delete
* @constructs wp.mediaWidgets.PersistentDisplaySettingsLibrary
[42] Fix | Delete
* @augments wp.media.controller.Library
[43] Fix | Delete
*
[44] Fix | Delete
* @param {Object} options - Options.
[45] Fix | Delete
*
[46] Fix | Delete
* @return {void}
[47] Fix | Delete
*/
[48] Fix | Delete
initialize: function initialize( options ) {
[49] Fix | Delete
_.bindAll( this, 'handleDisplaySettingChange' );
[50] Fix | Delete
wp.media.controller.Library.prototype.initialize.call( this, options );
[51] Fix | Delete
},
[52] Fix | Delete
[53] Fix | Delete
/**
[54] Fix | Delete
* Sync changes to the current display settings back into the current customized.
[55] Fix | Delete
*
[56] Fix | Delete
* @param {Backbone.Model} displaySettings - Modified display settings.
[57] Fix | Delete
* @return {void}
[58] Fix | Delete
*/
[59] Fix | Delete
handleDisplaySettingChange: function handleDisplaySettingChange( displaySettings ) {
[60] Fix | Delete
this.get( 'selectedDisplaySettings' ).set( displaySettings.attributes );
[61] Fix | Delete
},
[62] Fix | Delete
[63] Fix | Delete
/**
[64] Fix | Delete
* Get the display settings model.
[65] Fix | Delete
*
[66] Fix | Delete
* Model returned is updated with the current customized display settings,
[67] Fix | Delete
* and an event listener is added so that changes made to the settings
[68] Fix | Delete
* will sync back into the model storing the session's customized display
[69] Fix | Delete
* settings.
[70] Fix | Delete
*
[71] Fix | Delete
* @param {Backbone.Model} model - Display settings model.
[72] Fix | Delete
* @return {Backbone.Model} Display settings model.
[73] Fix | Delete
*/
[74] Fix | Delete
display: function getDisplaySettingsModel( model ) {
[75] Fix | Delete
var display, selectedDisplaySettings = this.get( 'selectedDisplaySettings' );
[76] Fix | Delete
display = wp.media.controller.Library.prototype.display.call( this, model );
[77] Fix | Delete
[78] Fix | Delete
display.off( 'change', this.handleDisplaySettingChange ); // Prevent duplicated event handlers.
[79] Fix | Delete
display.set( selectedDisplaySettings.attributes );
[80] Fix | Delete
if ( 'custom' === selectedDisplaySettings.get( 'link_type' ) ) {
[81] Fix | Delete
display.linkUrl = selectedDisplaySettings.get( 'link_url' );
[82] Fix | Delete
}
[83] Fix | Delete
display.on( 'change', this.handleDisplaySettingChange );
[84] Fix | Delete
return display;
[85] Fix | Delete
}
[86] Fix | Delete
});
[87] Fix | Delete
[88] Fix | Delete
/**
[89] Fix | Delete
* Extended view for managing the embed UI.
[90] Fix | Delete
*
[91] Fix | Delete
* @class wp.mediaWidgets.MediaEmbedView
[92] Fix | Delete
* @augments wp.media.view.Embed
[93] Fix | Delete
*/
[94] Fix | Delete
component.MediaEmbedView = wp.media.view.Embed.extend(/** @lends wp.mediaWidgets.MediaEmbedView.prototype */{
[95] Fix | Delete
[96] Fix | Delete
/**
[97] Fix | Delete
* Initialize.
[98] Fix | Delete
*
[99] Fix | Delete
* @since 4.9.0
[100] Fix | Delete
*
[101] Fix | Delete
* @param {Object} options - Options.
[102] Fix | Delete
* @return {void}
[103] Fix | Delete
*/
[104] Fix | Delete
initialize: function( options ) {
[105] Fix | Delete
var view = this, embedController; // eslint-disable-line consistent-this
[106] Fix | Delete
wp.media.view.Embed.prototype.initialize.call( view, options );
[107] Fix | Delete
if ( 'image' !== view.controller.options.mimeType ) {
[108] Fix | Delete
embedController = view.controller.states.get( 'embed' );
[109] Fix | Delete
embedController.off( 'scan', embedController.scanImage, embedController );
[110] Fix | Delete
}
[111] Fix | Delete
},
[112] Fix | Delete
[113] Fix | Delete
/**
[114] Fix | Delete
* Refresh embed view.
[115] Fix | Delete
*
[116] Fix | Delete
* Forked override of {wp.media.view.Embed#refresh()} to suppress irrelevant "link text" field.
[117] Fix | Delete
*
[118] Fix | Delete
* @return {void}
[119] Fix | Delete
*/
[120] Fix | Delete
refresh: function refresh() {
[121] Fix | Delete
/**
[122] Fix | Delete
* @class wp.mediaWidgets~Constructor
[123] Fix | Delete
*/
[124] Fix | Delete
var Constructor;
[125] Fix | Delete
[126] Fix | Delete
if ( 'image' === this.controller.options.mimeType ) {
[127] Fix | Delete
Constructor = wp.media.view.EmbedImage;
[128] Fix | Delete
} else {
[129] Fix | Delete
[130] Fix | Delete
// This should be eliminated once #40450 lands of when this is merged into core.
[131] Fix | Delete
Constructor = wp.media.view.EmbedLink.extend(/** @lends wp.mediaWidgets~Constructor.prototype */{
[132] Fix | Delete
[133] Fix | Delete
/**
[134] Fix | Delete
* Set the disabled state on the Add to Widget button.
[135] Fix | Delete
*
[136] Fix | Delete
* @param {boolean} disabled - Disabled.
[137] Fix | Delete
* @return {void}
[138] Fix | Delete
*/
[139] Fix | Delete
setAddToWidgetButtonDisabled: function setAddToWidgetButtonDisabled( disabled ) {
[140] Fix | Delete
this.views.parent.views.parent.views.get( '.media-frame-toolbar' )[0].$el.find( '.media-button-select' ).prop( 'disabled', disabled );
[141] Fix | Delete
},
[142] Fix | Delete
[143] Fix | Delete
/**
[144] Fix | Delete
* Set or clear an error notice.
[145] Fix | Delete
*
[146] Fix | Delete
* @param {string} notice - Notice.
[147] Fix | Delete
* @return {void}
[148] Fix | Delete
*/
[149] Fix | Delete
setErrorNotice: function setErrorNotice( notice ) {
[150] Fix | Delete
var embedLinkView = this, noticeContainer; // eslint-disable-line consistent-this
[151] Fix | Delete
[152] Fix | Delete
noticeContainer = embedLinkView.views.parent.$el.find( '> .notice:first-child' );
[153] Fix | Delete
if ( ! notice ) {
[154] Fix | Delete
if ( noticeContainer.length ) {
[155] Fix | Delete
noticeContainer.slideUp( 'fast' );
[156] Fix | Delete
}
[157] Fix | Delete
} else {
[158] Fix | Delete
if ( ! noticeContainer.length ) {
[159] Fix | Delete
noticeContainer = $( '<div class="media-widget-embed-notice notice notice-error notice-alt"></div>' );
[160] Fix | Delete
noticeContainer.hide();
[161] Fix | Delete
embedLinkView.views.parent.$el.prepend( noticeContainer );
[162] Fix | Delete
}
[163] Fix | Delete
noticeContainer.empty();
[164] Fix | Delete
noticeContainer.append( $( '<p>', {
[165] Fix | Delete
html: notice
[166] Fix | Delete
}));
[167] Fix | Delete
noticeContainer.slideDown( 'fast' );
[168] Fix | Delete
}
[169] Fix | Delete
},
[170] Fix | Delete
[171] Fix | Delete
/**
[172] Fix | Delete
* Update oEmbed.
[173] Fix | Delete
*
[174] Fix | Delete
* @since 4.9.0
[175] Fix | Delete
*
[176] Fix | Delete
* @return {void}
[177] Fix | Delete
*/
[178] Fix | Delete
updateoEmbed: function() {
[179] Fix | Delete
var embedLinkView = this, url; // eslint-disable-line consistent-this
[180] Fix | Delete
[181] Fix | Delete
url = embedLinkView.model.get( 'url' );
[182] Fix | Delete
[183] Fix | Delete
// Abort if the URL field was emptied out.
[184] Fix | Delete
if ( ! url ) {
[185] Fix | Delete
embedLinkView.setErrorNotice( '' );
[186] Fix | Delete
embedLinkView.setAddToWidgetButtonDisabled( true );
[187] Fix | Delete
return;
[188] Fix | Delete
}
[189] Fix | Delete
[190] Fix | Delete
if ( ! url.match( /^(http|https):\/\/.+\// ) ) {
[191] Fix | Delete
embedLinkView.controller.$el.find( '#embed-url-field' ).addClass( 'invalid' );
[192] Fix | Delete
embedLinkView.setAddToWidgetButtonDisabled( true );
[193] Fix | Delete
}
[194] Fix | Delete
[195] Fix | Delete
wp.media.view.EmbedLink.prototype.updateoEmbed.call( embedLinkView );
[196] Fix | Delete
},
[197] Fix | Delete
[198] Fix | Delete
/**
[199] Fix | Delete
* Fetch media.
[200] Fix | Delete
*
[201] Fix | Delete
* @return {void}
[202] Fix | Delete
*/
[203] Fix | Delete
fetch: function() {
[204] Fix | Delete
var embedLinkView = this, fetchSuccess, matches, fileExt, urlParser, url, re, youTubeEmbedMatch; // eslint-disable-line consistent-this
[205] Fix | Delete
url = embedLinkView.model.get( 'url' );
[206] Fix | Delete
[207] Fix | Delete
if ( embedLinkView.dfd && 'pending' === embedLinkView.dfd.state() ) {
[208] Fix | Delete
embedLinkView.dfd.abort();
[209] Fix | Delete
}
[210] Fix | Delete
[211] Fix | Delete
fetchSuccess = function( response ) {
[212] Fix | Delete
embedLinkView.renderoEmbed({
[213] Fix | Delete
data: {
[214] Fix | Delete
body: response
[215] Fix | Delete
}
[216] Fix | Delete
});
[217] Fix | Delete
[218] Fix | Delete
embedLinkView.controller.$el.find( '#embed-url-field' ).removeClass( 'invalid' );
[219] Fix | Delete
embedLinkView.setErrorNotice( '' );
[220] Fix | Delete
embedLinkView.setAddToWidgetButtonDisabled( false );
[221] Fix | Delete
};
[222] Fix | Delete
[223] Fix | Delete
urlParser = document.createElement( 'a' );
[224] Fix | Delete
urlParser.href = url;
[225] Fix | Delete
matches = urlParser.pathname.toLowerCase().match( /\.(\w+)$/ );
[226] Fix | Delete
if ( matches ) {
[227] Fix | Delete
fileExt = matches[1];
[228] Fix | Delete
if ( ! wp.media.view.settings.embedMimes[ fileExt ] ) {
[229] Fix | Delete
embedLinkView.renderFail();
[230] Fix | Delete
} else if ( 0 !== wp.media.view.settings.embedMimes[ fileExt ].indexOf( embedLinkView.controller.options.mimeType ) ) {
[231] Fix | Delete
embedLinkView.renderFail();
[232] Fix | Delete
} else {
[233] Fix | Delete
fetchSuccess( '<!--success-->' );
[234] Fix | Delete
}
[235] Fix | Delete
return;
[236] Fix | Delete
}
[237] Fix | Delete
[238] Fix | Delete
// Support YouTube embed links.
[239] Fix | Delete
re = /https?:\/\/www\.youtube\.com\/embed\/([^/]+)/;
[240] Fix | Delete
youTubeEmbedMatch = re.exec( url );
[241] Fix | Delete
if ( youTubeEmbedMatch ) {
[242] Fix | Delete
url = 'https://www.youtube.com/watch?v=' + youTubeEmbedMatch[ 1 ];
[243] Fix | Delete
// silently change url to proper oembed-able version.
[244] Fix | Delete
embedLinkView.model.attributes.url = url;
[245] Fix | Delete
}
[246] Fix | Delete
[247] Fix | Delete
embedLinkView.dfd = wp.apiRequest({
[248] Fix | Delete
url: wp.media.view.settings.oEmbedProxyUrl,
[249] Fix | Delete
data: {
[250] Fix | Delete
url: url,
[251] Fix | Delete
maxwidth: embedLinkView.model.get( 'width' ),
[252] Fix | Delete
maxheight: embedLinkView.model.get( 'height' ),
[253] Fix | Delete
discover: false
[254] Fix | Delete
},
[255] Fix | Delete
type: 'GET',
[256] Fix | Delete
dataType: 'json',
[257] Fix | Delete
context: embedLinkView
[258] Fix | Delete
});
[259] Fix | Delete
[260] Fix | Delete
embedLinkView.dfd.done( function( response ) {
[261] Fix | Delete
if ( embedLinkView.controller.options.mimeType !== response.type ) {
[262] Fix | Delete
embedLinkView.renderFail();
[263] Fix | Delete
return;
[264] Fix | Delete
}
[265] Fix | Delete
fetchSuccess( response.html );
[266] Fix | Delete
});
[267] Fix | Delete
embedLinkView.dfd.fail( _.bind( embedLinkView.renderFail, embedLinkView ) );
[268] Fix | Delete
},
[269] Fix | Delete
[270] Fix | Delete
/**
[271] Fix | Delete
* Handle render failure.
[272] Fix | Delete
*
[273] Fix | Delete
* Overrides the {EmbedLink#renderFail()} method to prevent showing the "Link Text" field.
[274] Fix | Delete
* The element is getting display:none in the stylesheet, but the underlying method uses
[275] Fix | Delete
* uses {jQuery.fn.show()} which adds an inline style. This avoids the need for !important.
[276] Fix | Delete
*
[277] Fix | Delete
* @return {void}
[278] Fix | Delete
*/
[279] Fix | Delete
renderFail: function renderFail() {
[280] Fix | Delete
var embedLinkView = this; // eslint-disable-line consistent-this
[281] Fix | Delete
embedLinkView.controller.$el.find( '#embed-url-field' ).addClass( 'invalid' );
[282] Fix | Delete
embedLinkView.setErrorNotice( embedLinkView.controller.options.invalidEmbedTypeError || 'ERROR' );
[283] Fix | Delete
embedLinkView.setAddToWidgetButtonDisabled( true );
[284] Fix | Delete
}
[285] Fix | Delete
});
[286] Fix | Delete
}
[287] Fix | Delete
[288] Fix | Delete
this.settings( new Constructor({
[289] Fix | Delete
controller: this.controller,
[290] Fix | Delete
model: this.model.props,
[291] Fix | Delete
priority: 40
[292] Fix | Delete
}));
[293] Fix | Delete
}
[294] Fix | Delete
});
[295] Fix | Delete
[296] Fix | Delete
/**
[297] Fix | Delete
* Custom media frame for selecting uploaded media or providing media by URL.
[298] Fix | Delete
*
[299] Fix | Delete
* @class wp.mediaWidgets.MediaFrameSelect
[300] Fix | Delete
* @augments wp.media.view.MediaFrame.Post
[301] Fix | Delete
*/
[302] Fix | Delete
component.MediaFrameSelect = wp.media.view.MediaFrame.Post.extend(/** @lends wp.mediaWidgets.MediaFrameSelect.prototype */{
[303] Fix | Delete
[304] Fix | Delete
/**
[305] Fix | Delete
* Create the default states.
[306] Fix | Delete
*
[307] Fix | Delete
* @return {void}
[308] Fix | Delete
*/
[309] Fix | Delete
createStates: function createStates() {
[310] Fix | Delete
var mime = this.options.mimeType, specificMimes = [];
[311] Fix | Delete
_.each( wp.media.view.settings.embedMimes, function( embedMime ) {
[312] Fix | Delete
if ( 0 === embedMime.indexOf( mime ) ) {
[313] Fix | Delete
specificMimes.push( embedMime );
[314] Fix | Delete
}
[315] Fix | Delete
});
[316] Fix | Delete
if ( specificMimes.length > 0 ) {
[317] Fix | Delete
mime = specificMimes;
[318] Fix | Delete
}
[319] Fix | Delete
[320] Fix | Delete
this.states.add([
[321] Fix | Delete
[322] Fix | Delete
// Main states.
[323] Fix | Delete
new component.PersistentDisplaySettingsLibrary({
[324] Fix | Delete
id: 'insert',
[325] Fix | Delete
title: this.options.title,
[326] Fix | Delete
selection: this.options.selection,
[327] Fix | Delete
priority: 20,
[328] Fix | Delete
toolbar: 'main-insert',
[329] Fix | Delete
filterable: 'dates',
[330] Fix | Delete
library: wp.media.query({
[331] Fix | Delete
type: mime
[332] Fix | Delete
}),
[333] Fix | Delete
multiple: false,
[334] Fix | Delete
editable: true,
[335] Fix | Delete
[336] Fix | Delete
selectedDisplaySettings: this.options.selectedDisplaySettings,
[337] Fix | Delete
displaySettings: _.isUndefined( this.options.showDisplaySettings ) ? true : this.options.showDisplaySettings,
[338] Fix | Delete
displayUserSettings: false // We use the display settings from the current/default widget instance props.
[339] Fix | Delete
}),
[340] Fix | Delete
[341] Fix | Delete
new wp.media.controller.EditImage({ model: this.options.editImage }),
[342] Fix | Delete
[343] Fix | Delete
// Embed states.
[344] Fix | Delete
new wp.media.controller.Embed({
[345] Fix | Delete
metadata: this.options.metadata,
[346] Fix | Delete
type: 'image' === this.options.mimeType ? 'image' : 'link',
[347] Fix | Delete
invalidEmbedTypeError: this.options.invalidEmbedTypeError
[348] Fix | Delete
})
[349] Fix | Delete
]);
[350] Fix | Delete
},
[351] Fix | Delete
[352] Fix | Delete
/**
[353] Fix | Delete
* Main insert toolbar.
[354] Fix | Delete
*
[355] Fix | Delete
* Forked override of {wp.media.view.MediaFrame.Post#mainInsertToolbar()} to override text.
[356] Fix | Delete
*
[357] Fix | Delete
* @param {wp.Backbone.View} view - Toolbar view.
[358] Fix | Delete
* @this {wp.media.controller.Library}
[359] Fix | Delete
* @return {void}
[360] Fix | Delete
*/
[361] Fix | Delete
mainInsertToolbar: function mainInsertToolbar( view ) {
[362] Fix | Delete
var controller = this; // eslint-disable-line consistent-this
[363] Fix | Delete
view.set( 'insert', {
[364] Fix | Delete
style: 'primary',
[365] Fix | Delete
priority: 80,
[366] Fix | Delete
text: controller.options.text, // The whole reason for the fork.
[367] Fix | Delete
requires: { selection: true },
[368] Fix | Delete
[369] Fix | Delete
/**
[370] Fix | Delete
* Handle click.
[371] Fix | Delete
*
[372] Fix | Delete
* @ignore
[373] Fix | Delete
*
[374] Fix | Delete
* @fires wp.media.controller.State#insert()
[375] Fix | Delete
* @return {void}
[376] Fix | Delete
*/
[377] Fix | Delete
click: function onClick() {
[378] Fix | Delete
var state = controller.state(),
[379] Fix | Delete
selection = state.get( 'selection' );
[380] Fix | Delete
[381] Fix | Delete
controller.close();
[382] Fix | Delete
state.trigger( 'insert', selection ).reset();
[383] Fix | Delete
}
[384] Fix | Delete
});
[385] Fix | Delete
},
[386] Fix | Delete
[387] Fix | Delete
/**
[388] Fix | Delete
* Main embed toolbar.
[389] Fix | Delete
*
[390] Fix | Delete
* Forked override of {wp.media.view.MediaFrame.Post#mainEmbedToolbar()} to override text.
[391] Fix | Delete
*
[392] Fix | Delete
* @param {wp.Backbone.View} toolbar - Toolbar view.
[393] Fix | Delete
* @this {wp.media.controller.Library}
[394] Fix | Delete
* @return {void}
[395] Fix | Delete
*/
[396] Fix | Delete
mainEmbedToolbar: function mainEmbedToolbar( toolbar ) {
[397] Fix | Delete
toolbar.view = new wp.media.view.Toolbar.Embed({
[398] Fix | Delete
controller: this,
[399] Fix | Delete
text: this.options.text,
[400] Fix | Delete
event: 'insert'
[401] Fix | Delete
});
[402] Fix | Delete
},
[403] Fix | Delete
[404] Fix | Delete
/**
[405] Fix | Delete
* Embed content.
[406] Fix | Delete
*
[407] Fix | Delete
* Forked override of {wp.media.view.MediaFrame.Post#embedContent()} to suppress irrelevant "link text" field.
[408] Fix | Delete
*
[409] Fix | Delete
* @return {void}
[410] Fix | Delete
*/
[411] Fix | Delete
embedContent: function embedContent() {
[412] Fix | Delete
var view = new component.MediaEmbedView({
[413] Fix | Delete
controller: this,
[414] Fix | Delete
model: this.state()
[415] Fix | Delete
}).render();
[416] Fix | Delete
[417] Fix | Delete
this.content.set( view );
[418] Fix | Delete
}
[419] Fix | Delete
});
[420] Fix | Delete
[421] Fix | Delete
component.MediaWidgetControl = Backbone.View.extend(/** @lends wp.mediaWidgets.MediaWidgetControl.prototype */{
[422] Fix | Delete
[423] Fix | Delete
/**
[424] Fix | Delete
* Translation strings.
[425] Fix | Delete
*
[426] Fix | Delete
* The mapping of translation strings is handled by media widget subclasses,
[427] Fix | Delete
* exported from PHP to JS such as is done in WP_Widget_Media_Image::enqueue_admin_scripts().
[428] Fix | Delete
*
[429] Fix | Delete
* @type {Object}
[430] Fix | Delete
*/
[431] Fix | Delete
l10n: {
[432] Fix | Delete
add_to_widget: '{{add_to_widget}}',
[433] Fix | Delete
add_media: '{{add_media}}'
[434] Fix | Delete
},
[435] Fix | Delete
[436] Fix | Delete
/**
[437] Fix | Delete
* Widget ID base.
[438] Fix | Delete
*
[439] Fix | Delete
* This may be defined by the subclass. It may be exported from PHP to JS
[440] Fix | Delete
* such as is done in WP_Widget_Media_Image::enqueue_admin_scripts(). If not,
[441] Fix | Delete
* it will attempt to be discovered by looking to see if this control
[442] Fix | Delete
* instance extends each member of component.controlConstructors, and if
[443] Fix | Delete
* it does extend one, will use the key as the id_base.
[444] Fix | Delete
*
[445] Fix | Delete
* @type {string}
[446] Fix | Delete
*/
[447] Fix | Delete
id_base: '',
[448] Fix | Delete
[449] Fix | Delete
/**
[450] Fix | Delete
* Mime type.
[451] Fix | Delete
*
[452] Fix | Delete
* This must be defined by the subclass. It may be exported from PHP to JS
[453] Fix | Delete
* such as is done in WP_Widget_Media_Image::enqueue_admin_scripts().
[454] Fix | Delete
*
[455] Fix | Delete
* @type {string}
[456] Fix | Delete
*/
[457] Fix | Delete
mime_type: '',
[458] Fix | Delete
[459] Fix | Delete
/**
[460] Fix | Delete
* View events.
[461] Fix | Delete
*
[462] Fix | Delete
* @type {Object}
[463] Fix | Delete
*/
[464] Fix | Delete
events: {
[465] Fix | Delete
'click .notice-missing-attachment a': 'handleMediaLibraryLinkClick',
[466] Fix | Delete
'click .select-media': 'selectMedia',
[467] Fix | Delete
'click .placeholder': 'selectMedia',
[468] Fix | Delete
'click .edit-media': 'editMedia'
[469] Fix | Delete
},
[470] Fix | Delete
[471] Fix | Delete
/**
[472] Fix | Delete
* Show display settings.
[473] Fix | Delete
*
[474] Fix | Delete
* @type {boolean}
[475] Fix | Delete
*/
[476] Fix | Delete
showDisplaySettings: true,
[477] Fix | Delete
[478] Fix | Delete
/**
[479] Fix | Delete
* Media Widget Control.
[480] Fix | Delete
*
[481] Fix | Delete
* @constructs wp.mediaWidgets.MediaWidgetControl
[482] Fix | Delete
* @augments Backbone.View
[483] Fix | Delete
* @abstract
[484] Fix | Delete
*
[485] Fix | Delete
* @param {Object} options - Options.
[486] Fix | Delete
* @param {Backbone.Model} options.model - Model.
[487] Fix | Delete
* @param {jQuery} options.el - Control field container element.
[488] Fix | Delete
* @param {jQuery} options.syncContainer - Container element where fields are synced for the server.
[489] Fix | Delete
*
[490] Fix | Delete
* @return {void}
[491] Fix | Delete
*/
[492] Fix | Delete
initialize: function initialize( options ) {
[493] Fix | Delete
var control = this;
[494] Fix | Delete
[495] Fix | Delete
Backbone.View.prototype.initialize.call( control, options );
[496] Fix | Delete
[497] Fix | Delete
if ( ! ( control.model instanceof component.MediaWidgetModel ) ) {
[498] Fix | Delete
throw new Error( 'Missing options.model' );
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function