Edit File by line
/home/barbar84/public_h.../wp-inclu.../js
File: media-models.js
/******/ (function(modules) { // webpackBootstrap
[0] Fix | Delete
/******/ // The module cache
[1] Fix | Delete
/******/ var installedModules = {};
[2] Fix | Delete
/******/
[3] Fix | Delete
/******/ // The require function
[4] Fix | Delete
/******/ function __webpack_require__(moduleId) {
[5] Fix | Delete
/******/
[6] Fix | Delete
/******/ // Check if module is in cache
[7] Fix | Delete
/******/ if(installedModules[moduleId]) {
[8] Fix | Delete
/******/ return installedModules[moduleId].exports;
[9] Fix | Delete
/******/ }
[10] Fix | Delete
/******/ // Create a new module (and put it into the cache)
[11] Fix | Delete
/******/ var module = installedModules[moduleId] = {
[12] Fix | Delete
/******/ i: moduleId,
[13] Fix | Delete
/******/ l: false,
[14] Fix | Delete
/******/ exports: {}
[15] Fix | Delete
/******/ };
[16] Fix | Delete
/******/
[17] Fix | Delete
/******/ // Execute the module function
[18] Fix | Delete
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
[19] Fix | Delete
/******/
[20] Fix | Delete
/******/ // Flag the module as loaded
[21] Fix | Delete
/******/ module.l = true;
[22] Fix | Delete
/******/
[23] Fix | Delete
/******/ // Return the exports of the module
[24] Fix | Delete
/******/ return module.exports;
[25] Fix | Delete
/******/ }
[26] Fix | Delete
/******/
[27] Fix | Delete
/******/
[28] Fix | Delete
/******/ // expose the modules object (__webpack_modules__)
[29] Fix | Delete
/******/ __webpack_require__.m = modules;
[30] Fix | Delete
/******/
[31] Fix | Delete
/******/ // expose the module cache
[32] Fix | Delete
/******/ __webpack_require__.c = installedModules;
[33] Fix | Delete
/******/
[34] Fix | Delete
/******/ // define getter function for harmony exports
[35] Fix | Delete
/******/ __webpack_require__.d = function(exports, name, getter) {
[36] Fix | Delete
/******/ if(!__webpack_require__.o(exports, name)) {
[37] Fix | Delete
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
[38] Fix | Delete
/******/ }
[39] Fix | Delete
/******/ };
[40] Fix | Delete
/******/
[41] Fix | Delete
/******/ // define __esModule on exports
[42] Fix | Delete
/******/ __webpack_require__.r = function(exports) {
[43] Fix | Delete
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
[44] Fix | Delete
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
[45] Fix | Delete
/******/ }
[46] Fix | Delete
/******/ Object.defineProperty(exports, '__esModule', { value: true });
[47] Fix | Delete
/******/ };
[48] Fix | Delete
/******/
[49] Fix | Delete
/******/ // create a fake namespace object
[50] Fix | Delete
/******/ // mode & 1: value is a module id, require it
[51] Fix | Delete
/******/ // mode & 2: merge all properties of value into the ns
[52] Fix | Delete
/******/ // mode & 4: return value when already ns object
[53] Fix | Delete
/******/ // mode & 8|1: behave like require
[54] Fix | Delete
/******/ __webpack_require__.t = function(value, mode) {
[55] Fix | Delete
/******/ if(mode & 1) value = __webpack_require__(value);
[56] Fix | Delete
/******/ if(mode & 8) return value;
[57] Fix | Delete
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
[58] Fix | Delete
/******/ var ns = Object.create(null);
[59] Fix | Delete
/******/ __webpack_require__.r(ns);
[60] Fix | Delete
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
[61] Fix | Delete
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
[62] Fix | Delete
/******/ return ns;
[63] Fix | Delete
/******/ };
[64] Fix | Delete
/******/
[65] Fix | Delete
/******/ // getDefaultExport function for compatibility with non-harmony modules
[66] Fix | Delete
/******/ __webpack_require__.n = function(module) {
[67] Fix | Delete
/******/ var getter = module && module.__esModule ?
[68] Fix | Delete
/******/ function getDefault() { return module['default']; } :
[69] Fix | Delete
/******/ function getModuleExports() { return module; };
[70] Fix | Delete
/******/ __webpack_require__.d(getter, 'a', getter);
[71] Fix | Delete
/******/ return getter;
[72] Fix | Delete
/******/ };
[73] Fix | Delete
/******/
[74] Fix | Delete
/******/ // Object.prototype.hasOwnProperty.call
[75] Fix | Delete
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
[76] Fix | Delete
/******/
[77] Fix | Delete
/******/ // __webpack_public_path__
[78] Fix | Delete
/******/ __webpack_require__.p = "";
[79] Fix | Delete
/******/
[80] Fix | Delete
/******/
[81] Fix | Delete
/******/ // Load entry module and return exports
[82] Fix | Delete
/******/ return __webpack_require__(__webpack_require__.s = 22);
[83] Fix | Delete
/******/ })
[84] Fix | Delete
/************************************************************************/
[85] Fix | Delete
/******/ ({
[86] Fix | Delete
[87] Fix | Delete
/***/ 22:
[88] Fix | Delete
/***/ (function(module, exports, __webpack_require__) {
[89] Fix | Delete
[90] Fix | Delete
module.exports = __webpack_require__(23);
[91] Fix | Delete
[92] Fix | Delete
[93] Fix | Delete
/***/ }),
[94] Fix | Delete
[95] Fix | Delete
/***/ 23:
[96] Fix | Delete
/***/ (function(module, exports, __webpack_require__) {
[97] Fix | Delete
[98] Fix | Delete
/**
[99] Fix | Delete
* @output wp-includes/js/media-models.js
[100] Fix | Delete
*/
[101] Fix | Delete
[102] Fix | Delete
var $ = jQuery,
[103] Fix | Delete
Attachment, Attachments, l10n, media;
[104] Fix | Delete
[105] Fix | Delete
/** @namespace wp */
[106] Fix | Delete
window.wp = window.wp || {};
[107] Fix | Delete
[108] Fix | Delete
/**
[109] Fix | Delete
* Create and return a media frame.
[110] Fix | Delete
*
[111] Fix | Delete
* Handles the default media experience.
[112] Fix | Delete
*
[113] Fix | Delete
* @alias wp.media
[114] Fix | Delete
* @memberOf wp
[115] Fix | Delete
* @namespace
[116] Fix | Delete
*
[117] Fix | Delete
* @param {Object} attributes The properties passed to the main media controller.
[118] Fix | Delete
* @return {wp.media.view.MediaFrame} A media workflow.
[119] Fix | Delete
*/
[120] Fix | Delete
media = wp.media = function( attributes ) {
[121] Fix | Delete
var MediaFrame = media.view.MediaFrame,
[122] Fix | Delete
frame;
[123] Fix | Delete
[124] Fix | Delete
if ( ! MediaFrame ) {
[125] Fix | Delete
return;
[126] Fix | Delete
}
[127] Fix | Delete
[128] Fix | Delete
attributes = _.defaults( attributes || {}, {
[129] Fix | Delete
frame: 'select'
[130] Fix | Delete
});
[131] Fix | Delete
[132] Fix | Delete
if ( 'select' === attributes.frame && MediaFrame.Select ) {
[133] Fix | Delete
frame = new MediaFrame.Select( attributes );
[134] Fix | Delete
} else if ( 'post' === attributes.frame && MediaFrame.Post ) {
[135] Fix | Delete
frame = new MediaFrame.Post( attributes );
[136] Fix | Delete
} else if ( 'manage' === attributes.frame && MediaFrame.Manage ) {
[137] Fix | Delete
frame = new MediaFrame.Manage( attributes );
[138] Fix | Delete
} else if ( 'image' === attributes.frame && MediaFrame.ImageDetails ) {
[139] Fix | Delete
frame = new MediaFrame.ImageDetails( attributes );
[140] Fix | Delete
} else if ( 'audio' === attributes.frame && MediaFrame.AudioDetails ) {
[141] Fix | Delete
frame = new MediaFrame.AudioDetails( attributes );
[142] Fix | Delete
} else if ( 'video' === attributes.frame && MediaFrame.VideoDetails ) {
[143] Fix | Delete
frame = new MediaFrame.VideoDetails( attributes );
[144] Fix | Delete
} else if ( 'edit-attachments' === attributes.frame && MediaFrame.EditAttachments ) {
[145] Fix | Delete
frame = new MediaFrame.EditAttachments( attributes );
[146] Fix | Delete
}
[147] Fix | Delete
[148] Fix | Delete
delete attributes.frame;
[149] Fix | Delete
[150] Fix | Delete
media.frame = frame;
[151] Fix | Delete
[152] Fix | Delete
return frame;
[153] Fix | Delete
};
[154] Fix | Delete
[155] Fix | Delete
/** @namespace wp.media.model */
[156] Fix | Delete
/** @namespace wp.media.view */
[157] Fix | Delete
/** @namespace wp.media.controller */
[158] Fix | Delete
/** @namespace wp.media.frames */
[159] Fix | Delete
_.extend( media, { model: {}, view: {}, controller: {}, frames: {} });
[160] Fix | Delete
[161] Fix | Delete
// Link any localized strings.
[162] Fix | Delete
l10n = media.model.l10n = window._wpMediaModelsL10n || {};
[163] Fix | Delete
[164] Fix | Delete
// Link any settings.
[165] Fix | Delete
media.model.settings = l10n.settings || {};
[166] Fix | Delete
delete l10n.settings;
[167] Fix | Delete
[168] Fix | Delete
Attachment = media.model.Attachment = __webpack_require__( 24 );
[169] Fix | Delete
Attachments = media.model.Attachments = __webpack_require__( 25 );
[170] Fix | Delete
[171] Fix | Delete
media.model.Query = __webpack_require__( 26 );
[172] Fix | Delete
media.model.PostImage = __webpack_require__( 27 );
[173] Fix | Delete
media.model.Selection = __webpack_require__( 28 );
[174] Fix | Delete
[175] Fix | Delete
/**
[176] Fix | Delete
* ========================================================================
[177] Fix | Delete
* UTILITIES
[178] Fix | Delete
* ========================================================================
[179] Fix | Delete
*/
[180] Fix | Delete
[181] Fix | Delete
/**
[182] Fix | Delete
* A basic equality comparator for Backbone models.
[183] Fix | Delete
*
[184] Fix | Delete
* Used to order models within a collection - @see wp.media.model.Attachments.comparator().
[185] Fix | Delete
*
[186] Fix | Delete
* @param {mixed} a The primary parameter to compare.
[187] Fix | Delete
* @param {mixed} b The primary parameter to compare.
[188] Fix | Delete
* @param {string} ac The fallback parameter to compare, a's cid.
[189] Fix | Delete
* @param {string} bc The fallback parameter to compare, b's cid.
[190] Fix | Delete
* @return {number} -1: a should come before b.
[191] Fix | Delete
* 0: a and b are of the same rank.
[192] Fix | Delete
* 1: b should come before a.
[193] Fix | Delete
*/
[194] Fix | Delete
media.compare = function( a, b, ac, bc ) {
[195] Fix | Delete
if ( _.isEqual( a, b ) ) {
[196] Fix | Delete
return ac === bc ? 0 : (ac > bc ? -1 : 1);
[197] Fix | Delete
} else {
[198] Fix | Delete
return a > b ? -1 : 1;
[199] Fix | Delete
}
[200] Fix | Delete
};
[201] Fix | Delete
[202] Fix | Delete
_.extend( media, /** @lends wp.media */{
[203] Fix | Delete
/**
[204] Fix | Delete
* media.template( id )
[205] Fix | Delete
*
[206] Fix | Delete
* Fetch a JavaScript template for an id, and return a templating function for it.
[207] Fix | Delete
*
[208] Fix | Delete
* See wp.template() in `wp-includes/js/wp-util.js`.
[209] Fix | Delete
*
[210] Fix | Delete
* @borrows wp.template as template
[211] Fix | Delete
*/
[212] Fix | Delete
template: wp.template,
[213] Fix | Delete
[214] Fix | Delete
/**
[215] Fix | Delete
* media.post( [action], [data] )
[216] Fix | Delete
*
[217] Fix | Delete
* Sends a POST request to WordPress.
[218] Fix | Delete
* See wp.ajax.post() in `wp-includes/js/wp-util.js`.
[219] Fix | Delete
*
[220] Fix | Delete
* @borrows wp.ajax.post as post
[221] Fix | Delete
*/
[222] Fix | Delete
post: wp.ajax.post,
[223] Fix | Delete
[224] Fix | Delete
/**
[225] Fix | Delete
* media.ajax( [action], [options] )
[226] Fix | Delete
*
[227] Fix | Delete
* Sends an XHR request to WordPress.
[228] Fix | Delete
* See wp.ajax.send() in `wp-includes/js/wp-util.js`.
[229] Fix | Delete
*
[230] Fix | Delete
* @borrows wp.ajax.send as ajax
[231] Fix | Delete
*/
[232] Fix | Delete
ajax: wp.ajax.send,
[233] Fix | Delete
[234] Fix | Delete
/**
[235] Fix | Delete
* Scales a set of dimensions to fit within bounding dimensions.
[236] Fix | Delete
*
[237] Fix | Delete
* @param {Object} dimensions
[238] Fix | Delete
* @return {Object}
[239] Fix | Delete
*/
[240] Fix | Delete
fit: function( dimensions ) {
[241] Fix | Delete
var width = dimensions.width,
[242] Fix | Delete
height = dimensions.height,
[243] Fix | Delete
maxWidth = dimensions.maxWidth,
[244] Fix | Delete
maxHeight = dimensions.maxHeight,
[245] Fix | Delete
constraint;
[246] Fix | Delete
[247] Fix | Delete
/*
[248] Fix | Delete
* Compare ratios between the two values to determine
[249] Fix | Delete
* which max to constrain by. If a max value doesn't exist,
[250] Fix | Delete
* then the opposite side is the constraint.
[251] Fix | Delete
*/
[252] Fix | Delete
if ( ! _.isUndefined( maxWidth ) && ! _.isUndefined( maxHeight ) ) {
[253] Fix | Delete
constraint = ( width / height > maxWidth / maxHeight ) ? 'width' : 'height';
[254] Fix | Delete
} else if ( _.isUndefined( maxHeight ) ) {
[255] Fix | Delete
constraint = 'width';
[256] Fix | Delete
} else if ( _.isUndefined( maxWidth ) && height > maxHeight ) {
[257] Fix | Delete
constraint = 'height';
[258] Fix | Delete
}
[259] Fix | Delete
[260] Fix | Delete
// If the value of the constrained side is larger than the max,
[261] Fix | Delete
// then scale the values. Otherwise return the originals; they fit.
[262] Fix | Delete
if ( 'width' === constraint && width > maxWidth ) {
[263] Fix | Delete
return {
[264] Fix | Delete
width : maxWidth,
[265] Fix | Delete
height: Math.round( maxWidth * height / width )
[266] Fix | Delete
};
[267] Fix | Delete
} else if ( 'height' === constraint && height > maxHeight ) {
[268] Fix | Delete
return {
[269] Fix | Delete
width : Math.round( maxHeight * width / height ),
[270] Fix | Delete
height: maxHeight
[271] Fix | Delete
};
[272] Fix | Delete
} else {
[273] Fix | Delete
return {
[274] Fix | Delete
width : width,
[275] Fix | Delete
height: height
[276] Fix | Delete
};
[277] Fix | Delete
}
[278] Fix | Delete
},
[279] Fix | Delete
/**
[280] Fix | Delete
* Truncates a string by injecting an ellipsis into the middle.
[281] Fix | Delete
* Useful for filenames.
[282] Fix | Delete
*
[283] Fix | Delete
* @param {string} string
[284] Fix | Delete
* @param {number} [length=30]
[285] Fix | Delete
* @param {string} [replacement=…]
[286] Fix | Delete
* @return {string} The string, unless length is greater than string.length.
[287] Fix | Delete
*/
[288] Fix | Delete
truncate: function( string, length, replacement ) {
[289] Fix | Delete
length = length || 30;
[290] Fix | Delete
replacement = replacement || '…';
[291] Fix | Delete
[292] Fix | Delete
if ( string.length <= length ) {
[293] Fix | Delete
return string;
[294] Fix | Delete
}
[295] Fix | Delete
[296] Fix | Delete
return string.substr( 0, length / 2 ) + replacement + string.substr( -1 * length / 2 );
[297] Fix | Delete
}
[298] Fix | Delete
});
[299] Fix | Delete
[300] Fix | Delete
/**
[301] Fix | Delete
* ========================================================================
[302] Fix | Delete
* MODELS
[303] Fix | Delete
* ========================================================================
[304] Fix | Delete
*/
[305] Fix | Delete
/**
[306] Fix | Delete
* wp.media.attachment
[307] Fix | Delete
*
[308] Fix | Delete
* @static
[309] Fix | Delete
* @param {string} id A string used to identify a model.
[310] Fix | Delete
* @return {wp.media.model.Attachment}
[311] Fix | Delete
*/
[312] Fix | Delete
media.attachment = function( id ) {
[313] Fix | Delete
return Attachment.get( id );
[314] Fix | Delete
};
[315] Fix | Delete
[316] Fix | Delete
/**
[317] Fix | Delete
* A collection of all attachments that have been fetched from the server.
[318] Fix | Delete
*
[319] Fix | Delete
* @static
[320] Fix | Delete
* @member {wp.media.model.Attachments}
[321] Fix | Delete
*/
[322] Fix | Delete
Attachments.all = new Attachments();
[323] Fix | Delete
[324] Fix | Delete
/**
[325] Fix | Delete
* wp.media.query
[326] Fix | Delete
*
[327] Fix | Delete
* Shorthand for creating a new Attachments Query.
[328] Fix | Delete
*
[329] Fix | Delete
* @param {Object} [props]
[330] Fix | Delete
* @return {wp.media.model.Attachments}
[331] Fix | Delete
*/
[332] Fix | Delete
media.query = function( props ) {
[333] Fix | Delete
return new Attachments( null, {
[334] Fix | Delete
props: _.extend( _.defaults( props || {}, { orderby: 'date' } ), { query: true } )
[335] Fix | Delete
});
[336] Fix | Delete
};
[337] Fix | Delete
[338] Fix | Delete
// Clean up. Prevents mobile browsers caching.
[339] Fix | Delete
$(window).on('unload', function(){
[340] Fix | Delete
window.wp = null;
[341] Fix | Delete
});
[342] Fix | Delete
[343] Fix | Delete
[344] Fix | Delete
/***/ }),
[345] Fix | Delete
[346] Fix | Delete
/***/ 24:
[347] Fix | Delete
/***/ (function(module, exports) {
[348] Fix | Delete
[349] Fix | Delete
var $ = Backbone.$,
[350] Fix | Delete
Attachment;
[351] Fix | Delete
[352] Fix | Delete
/**
[353] Fix | Delete
* wp.media.model.Attachment
[354] Fix | Delete
*
[355] Fix | Delete
* @memberOf wp.media.model
[356] Fix | Delete
*
[357] Fix | Delete
* @class
[358] Fix | Delete
* @augments Backbone.Model
[359] Fix | Delete
*/
[360] Fix | Delete
Attachment = Backbone.Model.extend(/** @lends wp.media.model.Attachment.prototype */{
[361] Fix | Delete
/**
[362] Fix | Delete
* Triggered when attachment details change
[363] Fix | Delete
* Overrides Backbone.Model.sync
[364] Fix | Delete
*
[365] Fix | Delete
* @param {string} method
[366] Fix | Delete
* @param {wp.media.model.Attachment} model
[367] Fix | Delete
* @param {Object} [options={}]
[368] Fix | Delete
*
[369] Fix | Delete
* @return {Promise}
[370] Fix | Delete
*/
[371] Fix | Delete
sync: function( method, model, options ) {
[372] Fix | Delete
// If the attachment does not yet have an `id`, return an instantly
[373] Fix | Delete
// rejected promise. Otherwise, all of our requests will fail.
[374] Fix | Delete
if ( _.isUndefined( this.id ) ) {
[375] Fix | Delete
return $.Deferred().rejectWith( this ).promise();
[376] Fix | Delete
}
[377] Fix | Delete
[378] Fix | Delete
// Overload the `read` request so Attachment.fetch() functions correctly.
[379] Fix | Delete
if ( 'read' === method ) {
[380] Fix | Delete
options = options || {};
[381] Fix | Delete
options.context = this;
[382] Fix | Delete
options.data = _.extend( options.data || {}, {
[383] Fix | Delete
action: 'get-attachment',
[384] Fix | Delete
id: this.id
[385] Fix | Delete
});
[386] Fix | Delete
return wp.media.ajax( options );
[387] Fix | Delete
[388] Fix | Delete
// Overload the `update` request so properties can be saved.
[389] Fix | Delete
} else if ( 'update' === method ) {
[390] Fix | Delete
// If we do not have the necessary nonce, fail immediately.
[391] Fix | Delete
if ( ! this.get('nonces') || ! this.get('nonces').update ) {
[392] Fix | Delete
return $.Deferred().rejectWith( this ).promise();
[393] Fix | Delete
}
[394] Fix | Delete
[395] Fix | Delete
options = options || {};
[396] Fix | Delete
options.context = this;
[397] Fix | Delete
[398] Fix | Delete
// Set the action and ID.
[399] Fix | Delete
options.data = _.extend( options.data || {}, {
[400] Fix | Delete
action: 'save-attachment',
[401] Fix | Delete
id: this.id,
[402] Fix | Delete
nonce: this.get('nonces').update,
[403] Fix | Delete
post_id: wp.media.model.settings.post.id
[404] Fix | Delete
});
[405] Fix | Delete
[406] Fix | Delete
// Record the values of the changed attributes.
[407] Fix | Delete
if ( model.hasChanged() ) {
[408] Fix | Delete
options.data.changes = {};
[409] Fix | Delete
[410] Fix | Delete
_.each( model.changed, function( value, key ) {
[411] Fix | Delete
options.data.changes[ key ] = this.get( key );
[412] Fix | Delete
}, this );
[413] Fix | Delete
}
[414] Fix | Delete
[415] Fix | Delete
return wp.media.ajax( options );
[416] Fix | Delete
[417] Fix | Delete
// Overload the `delete` request so attachments can be removed.
[418] Fix | Delete
// This will permanently delete an attachment.
[419] Fix | Delete
} else if ( 'delete' === method ) {
[420] Fix | Delete
options = options || {};
[421] Fix | Delete
[422] Fix | Delete
if ( ! options.wait ) {
[423] Fix | Delete
this.destroyed = true;
[424] Fix | Delete
}
[425] Fix | Delete
[426] Fix | Delete
options.context = this;
[427] Fix | Delete
options.data = _.extend( options.data || {}, {
[428] Fix | Delete
action: 'delete-post',
[429] Fix | Delete
id: this.id,
[430] Fix | Delete
_wpnonce: this.get('nonces')['delete']
[431] Fix | Delete
});
[432] Fix | Delete
[433] Fix | Delete
return wp.media.ajax( options ).done( function() {
[434] Fix | Delete
this.destroyed = true;
[435] Fix | Delete
}).fail( function() {
[436] Fix | Delete
this.destroyed = false;
[437] Fix | Delete
});
[438] Fix | Delete
[439] Fix | Delete
// Otherwise, fall back to `Backbone.sync()`.
[440] Fix | Delete
} else {
[441] Fix | Delete
/**
[442] Fix | Delete
* Call `sync` directly on Backbone.Model
[443] Fix | Delete
*/
[444] Fix | Delete
return Backbone.Model.prototype.sync.apply( this, arguments );
[445] Fix | Delete
}
[446] Fix | Delete
},
[447] Fix | Delete
/**
[448] Fix | Delete
* Convert date strings into Date objects.
[449] Fix | Delete
*
[450] Fix | Delete
* @param {Object} resp The raw response object, typically returned by fetch()
[451] Fix | Delete
* @return {Object} The modified response object, which is the attributes hash
[452] Fix | Delete
* to be set on the model.
[453] Fix | Delete
*/
[454] Fix | Delete
parse: function( resp ) {
[455] Fix | Delete
if ( ! resp ) {
[456] Fix | Delete
return resp;
[457] Fix | Delete
}
[458] Fix | Delete
[459] Fix | Delete
resp.date = new Date( resp.date );
[460] Fix | Delete
resp.modified = new Date( resp.modified );
[461] Fix | Delete
return resp;
[462] Fix | Delete
},
[463] Fix | Delete
/**
[464] Fix | Delete
* @param {Object} data The properties to be saved.
[465] Fix | Delete
* @param {Object} options Sync options. e.g. patch, wait, success, error.
[466] Fix | Delete
*
[467] Fix | Delete
* @this Backbone.Model
[468] Fix | Delete
*
[469] Fix | Delete
* @return {Promise}
[470] Fix | Delete
*/
[471] Fix | Delete
saveCompat: function( data, options ) {
[472] Fix | Delete
var model = this;
[473] Fix | Delete
[474] Fix | Delete
// If we do not have the necessary nonce, fail immediately.
[475] Fix | Delete
if ( ! this.get('nonces') || ! this.get('nonces').update ) {
[476] Fix | Delete
return $.Deferred().rejectWith( this ).promise();
[477] Fix | Delete
}
[478] Fix | Delete
[479] Fix | Delete
return wp.media.post( 'save-attachment-compat', _.defaults({
[480] Fix | Delete
id: this.id,
[481] Fix | Delete
nonce: this.get('nonces').update,
[482] Fix | Delete
post_id: wp.media.model.settings.post.id
[483] Fix | Delete
}, data ) ).done( function( resp, status, xhr ) {
[484] Fix | Delete
model.set( model.parse( resp, xhr ), options );
[485] Fix | Delete
});
[486] Fix | Delete
}
[487] Fix | Delete
},/** @lends wp.media.model.Attachment */{
[488] Fix | Delete
/**
[489] Fix | Delete
* Create a new model on the static 'all' attachments collection and return it.
[490] Fix | Delete
*
[491] Fix | Delete
* @static
[492] Fix | Delete
*
[493] Fix | Delete
* @param {Object} attrs
[494] Fix | Delete
* @return {wp.media.model.Attachment}
[495] Fix | Delete
*/
[496] Fix | Delete
create: function( attrs ) {
[497] Fix | Delete
var Attachments = wp.media.model.Attachments;
[498] Fix | Delete
return Attachments.all.push( attrs );
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function