Edit File by line
/home/barbar84/public_h.../wp-inclu.../js/plupload
File: plupload.js
/**
[0] Fix | Delete
* Plupload - multi-runtime File Uploader
[1] Fix | Delete
* v2.1.9
[2] Fix | Delete
*
[3] Fix | Delete
* Copyright 2013, Moxiecode Systems AB
[4] Fix | Delete
* Released under GPL License.
[5] Fix | Delete
*
[6] Fix | Delete
* License: http://www.plupload.com/license
[7] Fix | Delete
* Contributing: http://www.plupload.com/contributing
[8] Fix | Delete
*
[9] Fix | Delete
* Date: 2016-05-15
[10] Fix | Delete
*/
[11] Fix | Delete
/**
[12] Fix | Delete
* Plupload.js
[13] Fix | Delete
*
[14] Fix | Delete
* Copyright 2013, Moxiecode Systems AB
[15] Fix | Delete
* Released under GPL License.
[16] Fix | Delete
*
[17] Fix | Delete
* License: http://www.plupload.com/license
[18] Fix | Delete
* Contributing: http://www.plupload.com/contributing
[19] Fix | Delete
*/
[20] Fix | Delete
[21] Fix | Delete
/**
[22] Fix | Delete
* Modified for WordPress, Silverlight and Flash runtimes support was removed.
[23] Fix | Delete
* See https://core.trac.wordpress.org/ticket/41755.
[24] Fix | Delete
*/
[25] Fix | Delete
[26] Fix | Delete
/*global mOxie:true */
[27] Fix | Delete
[28] Fix | Delete
;(function(window, o, undef) {
[29] Fix | Delete
[30] Fix | Delete
var delay = window.setTimeout
[31] Fix | Delete
, fileFilters = {}
[32] Fix | Delete
;
[33] Fix | Delete
[34] Fix | Delete
// convert plupload features to caps acceptable by mOxie
[35] Fix | Delete
function normalizeCaps(settings) {
[36] Fix | Delete
var features = settings.required_features, caps = {};
[37] Fix | Delete
[38] Fix | Delete
function resolve(feature, value, strict) {
[39] Fix | Delete
// Feature notation is deprecated, use caps (this thing here is required for backward compatibility)
[40] Fix | Delete
var map = {
[41] Fix | Delete
chunks: 'slice_blob',
[42] Fix | Delete
jpgresize: 'send_binary_string',
[43] Fix | Delete
pngresize: 'send_binary_string',
[44] Fix | Delete
progress: 'report_upload_progress',
[45] Fix | Delete
multi_selection: 'select_multiple',
[46] Fix | Delete
dragdrop: 'drag_and_drop',
[47] Fix | Delete
drop_element: 'drag_and_drop',
[48] Fix | Delete
headers: 'send_custom_headers',
[49] Fix | Delete
urlstream_upload: 'send_binary_string',
[50] Fix | Delete
canSendBinary: 'send_binary',
[51] Fix | Delete
triggerDialog: 'summon_file_dialog'
[52] Fix | Delete
};
[53] Fix | Delete
[54] Fix | Delete
if (map[feature]) {
[55] Fix | Delete
caps[map[feature]] = value;
[56] Fix | Delete
} else if (!strict) {
[57] Fix | Delete
caps[feature] = value;
[58] Fix | Delete
}
[59] Fix | Delete
}
[60] Fix | Delete
[61] Fix | Delete
if (typeof(features) === 'string') {
[62] Fix | Delete
plupload.each(features.split(/\s*,\s*/), function(feature) {
[63] Fix | Delete
resolve(feature, true);
[64] Fix | Delete
});
[65] Fix | Delete
} else if (typeof(features) === 'object') {
[66] Fix | Delete
plupload.each(features, function(value, feature) {
[67] Fix | Delete
resolve(feature, value);
[68] Fix | Delete
});
[69] Fix | Delete
} else if (features === true) {
[70] Fix | Delete
// check settings for required features
[71] Fix | Delete
if (settings.chunk_size > 0) {
[72] Fix | Delete
caps.slice_blob = true;
[73] Fix | Delete
}
[74] Fix | Delete
[75] Fix | Delete
if (settings.resize.enabled || !settings.multipart) {
[76] Fix | Delete
caps.send_binary_string = true;
[77] Fix | Delete
}
[78] Fix | Delete
[79] Fix | Delete
plupload.each(settings, function(value, feature) {
[80] Fix | Delete
resolve(feature, !!value, true); // strict check
[81] Fix | Delete
});
[82] Fix | Delete
}
[83] Fix | Delete
[84] Fix | Delete
// WP: only html runtimes.
[85] Fix | Delete
settings.runtimes = 'html5,html4';
[86] Fix | Delete
[87] Fix | Delete
return caps;
[88] Fix | Delete
}
[89] Fix | Delete
[90] Fix | Delete
/**
[91] Fix | Delete
* @module plupload
[92] Fix | Delete
* @static
[93] Fix | Delete
*/
[94] Fix | Delete
var plupload = {
[95] Fix | Delete
/**
[96] Fix | Delete
* Plupload version will be replaced on build.
[97] Fix | Delete
*
[98] Fix | Delete
* @property VERSION
[99] Fix | Delete
* @for Plupload
[100] Fix | Delete
* @static
[101] Fix | Delete
* @final
[102] Fix | Delete
*/
[103] Fix | Delete
VERSION : '2.1.9',
[104] Fix | Delete
[105] Fix | Delete
/**
[106] Fix | Delete
* The state of the queue before it has started and after it has finished
[107] Fix | Delete
*
[108] Fix | Delete
* @property STOPPED
[109] Fix | Delete
* @static
[110] Fix | Delete
* @final
[111] Fix | Delete
*/
[112] Fix | Delete
STOPPED : 1,
[113] Fix | Delete
[114] Fix | Delete
/**
[115] Fix | Delete
* Upload process is running
[116] Fix | Delete
*
[117] Fix | Delete
* @property STARTED
[118] Fix | Delete
* @static
[119] Fix | Delete
* @final
[120] Fix | Delete
*/
[121] Fix | Delete
STARTED : 2,
[122] Fix | Delete
[123] Fix | Delete
/**
[124] Fix | Delete
* File is queued for upload
[125] Fix | Delete
*
[126] Fix | Delete
* @property QUEUED
[127] Fix | Delete
* @static
[128] Fix | Delete
* @final
[129] Fix | Delete
*/
[130] Fix | Delete
QUEUED : 1,
[131] Fix | Delete
[132] Fix | Delete
/**
[133] Fix | Delete
* File is being uploaded
[134] Fix | Delete
*
[135] Fix | Delete
* @property UPLOADING
[136] Fix | Delete
* @static
[137] Fix | Delete
* @final
[138] Fix | Delete
*/
[139] Fix | Delete
UPLOADING : 2,
[140] Fix | Delete
[141] Fix | Delete
/**
[142] Fix | Delete
* File has failed to be uploaded
[143] Fix | Delete
*
[144] Fix | Delete
* @property FAILED
[145] Fix | Delete
* @static
[146] Fix | Delete
* @final
[147] Fix | Delete
*/
[148] Fix | Delete
FAILED : 4,
[149] Fix | Delete
[150] Fix | Delete
/**
[151] Fix | Delete
* File has been uploaded successfully
[152] Fix | Delete
*
[153] Fix | Delete
* @property DONE
[154] Fix | Delete
* @static
[155] Fix | Delete
* @final
[156] Fix | Delete
*/
[157] Fix | Delete
DONE : 5,
[158] Fix | Delete
[159] Fix | Delete
// Error constants used by the Error event
[160] Fix | Delete
[161] Fix | Delete
/**
[162] Fix | Delete
* Generic error for example if an exception is thrown inside Silverlight.
[163] Fix | Delete
*
[164] Fix | Delete
* @property GENERIC_ERROR
[165] Fix | Delete
* @static
[166] Fix | Delete
* @final
[167] Fix | Delete
*/
[168] Fix | Delete
GENERIC_ERROR : -100,
[169] Fix | Delete
[170] Fix | Delete
/**
[171] Fix | Delete
* HTTP transport error. For example if the server produces a HTTP status other than 200.
[172] Fix | Delete
*
[173] Fix | Delete
* @property HTTP_ERROR
[174] Fix | Delete
* @static
[175] Fix | Delete
* @final
[176] Fix | Delete
*/
[177] Fix | Delete
HTTP_ERROR : -200,
[178] Fix | Delete
[179] Fix | Delete
/**
[180] Fix | Delete
* Generic I/O error. For example if it wasn't possible to open the file stream on local machine.
[181] Fix | Delete
*
[182] Fix | Delete
* @property IO_ERROR
[183] Fix | Delete
* @static
[184] Fix | Delete
* @final
[185] Fix | Delete
*/
[186] Fix | Delete
IO_ERROR : -300,
[187] Fix | Delete
[188] Fix | Delete
/**
[189] Fix | Delete
* @property SECURITY_ERROR
[190] Fix | Delete
* @static
[191] Fix | Delete
* @final
[192] Fix | Delete
*/
[193] Fix | Delete
SECURITY_ERROR : -400,
[194] Fix | Delete
[195] Fix | Delete
/**
[196] Fix | Delete
* Initialization error. Will be triggered if no runtime was initialized.
[197] Fix | Delete
*
[198] Fix | Delete
* @property INIT_ERROR
[199] Fix | Delete
* @static
[200] Fix | Delete
* @final
[201] Fix | Delete
*/
[202] Fix | Delete
INIT_ERROR : -500,
[203] Fix | Delete
[204] Fix | Delete
/**
[205] Fix | Delete
* File size error. If the user selects a file that is too large it will be blocked and an error of this type will be triggered.
[206] Fix | Delete
*
[207] Fix | Delete
* @property FILE_SIZE_ERROR
[208] Fix | Delete
* @static
[209] Fix | Delete
* @final
[210] Fix | Delete
*/
[211] Fix | Delete
FILE_SIZE_ERROR : -600,
[212] Fix | Delete
[213] Fix | Delete
/**
[214] Fix | Delete
* File extension error. If the user selects a file that isn't valid according to the filters setting.
[215] Fix | Delete
*
[216] Fix | Delete
* @property FILE_EXTENSION_ERROR
[217] Fix | Delete
* @static
[218] Fix | Delete
* @final
[219] Fix | Delete
*/
[220] Fix | Delete
FILE_EXTENSION_ERROR : -601,
[221] Fix | Delete
[222] Fix | Delete
/**
[223] Fix | Delete
* Duplicate file error. If prevent_duplicates is set to true and user selects the same file again.
[224] Fix | Delete
*
[225] Fix | Delete
* @property FILE_DUPLICATE_ERROR
[226] Fix | Delete
* @static
[227] Fix | Delete
* @final
[228] Fix | Delete
*/
[229] Fix | Delete
FILE_DUPLICATE_ERROR : -602,
[230] Fix | Delete
[231] Fix | Delete
/**
[232] Fix | Delete
* Runtime will try to detect if image is proper one. Otherwise will throw this error.
[233] Fix | Delete
*
[234] Fix | Delete
* @property IMAGE_FORMAT_ERROR
[235] Fix | Delete
* @static
[236] Fix | Delete
* @final
[237] Fix | Delete
*/
[238] Fix | Delete
IMAGE_FORMAT_ERROR : -700,
[239] Fix | Delete
[240] Fix | Delete
/**
[241] Fix | Delete
* While working on files runtime may run out of memory and will throw this error.
[242] Fix | Delete
*
[243] Fix | Delete
* @since 2.1.2
[244] Fix | Delete
* @property MEMORY_ERROR
[245] Fix | Delete
* @static
[246] Fix | Delete
* @final
[247] Fix | Delete
*/
[248] Fix | Delete
MEMORY_ERROR : -701,
[249] Fix | Delete
[250] Fix | Delete
/**
[251] Fix | Delete
* Each runtime has an upper limit on a dimension of the image it can handle. If bigger, will throw this error.
[252] Fix | Delete
*
[253] Fix | Delete
* @property IMAGE_DIMENSIONS_ERROR
[254] Fix | Delete
* @static
[255] Fix | Delete
* @final
[256] Fix | Delete
*/
[257] Fix | Delete
IMAGE_DIMENSIONS_ERROR : -702,
[258] Fix | Delete
[259] Fix | Delete
/**
[260] Fix | Delete
* Mime type lookup table.
[261] Fix | Delete
*
[262] Fix | Delete
* @property mimeTypes
[263] Fix | Delete
* @type Object
[264] Fix | Delete
* @final
[265] Fix | Delete
*/
[266] Fix | Delete
mimeTypes : o.mimes,
[267] Fix | Delete
[268] Fix | Delete
/**
[269] Fix | Delete
* In some cases sniffing is the only way around :(
[270] Fix | Delete
*/
[271] Fix | Delete
ua: o.ua,
[272] Fix | Delete
[273] Fix | Delete
/**
[274] Fix | Delete
* Gets the true type of the built-in object (better version of typeof).
[275] Fix | Delete
* @credits Angus Croll (http://javascriptweblog.wordpress.com/)
[276] Fix | Delete
*
[277] Fix | Delete
* @method typeOf
[278] Fix | Delete
* @static
[279] Fix | Delete
* @param {Object} o Object to check.
[280] Fix | Delete
* @return {String} Object [[Class]]
[281] Fix | Delete
*/
[282] Fix | Delete
typeOf: o.typeOf,
[283] Fix | Delete
[284] Fix | Delete
/**
[285] Fix | Delete
* Extends the specified object with another object.
[286] Fix | Delete
*
[287] Fix | Delete
* @method extend
[288] Fix | Delete
* @static
[289] Fix | Delete
* @param {Object} target Object to extend.
[290] Fix | Delete
* @param {Object..} obj Multiple objects to extend with.
[291] Fix | Delete
* @return {Object} Same as target, the extended object.
[292] Fix | Delete
*/
[293] Fix | Delete
extend : o.extend,
[294] Fix | Delete
[295] Fix | Delete
/**
[296] Fix | Delete
* Generates an unique ID. This is 99.99% unique since it takes the current time and 5 random numbers.
[297] Fix | Delete
* The only way a user would be able to get the same ID is if the two persons at the same exact millisecond manages
[298] Fix | Delete
* to get 5 the same random numbers between 0-65535 it also uses a counter so each call will be guaranteed to be page unique.
[299] Fix | Delete
* It's more probable for the earth to be hit with an asteriod. You can also if you want to be 100% sure set the plupload.guidPrefix property
[300] Fix | Delete
* to an user unique key.
[301] Fix | Delete
*
[302] Fix | Delete
* @method guid
[303] Fix | Delete
* @static
[304] Fix | Delete
* @return {String} Virtually unique id.
[305] Fix | Delete
*/
[306] Fix | Delete
guid : o.guid,
[307] Fix | Delete
[308] Fix | Delete
/**
[309] Fix | Delete
* Get array of DOM Elements by their ids.
[310] Fix | Delete
*
[311] Fix | Delete
* @method get
[312] Fix | Delete
* @param {String} id Identifier of the DOM Element
[313] Fix | Delete
* @return {Array}
[314] Fix | Delete
*/
[315] Fix | Delete
getAll : function get(ids) {
[316] Fix | Delete
var els = [], el;
[317] Fix | Delete
[318] Fix | Delete
if (plupload.typeOf(ids) !== 'array') {
[319] Fix | Delete
ids = [ids];
[320] Fix | Delete
}
[321] Fix | Delete
[322] Fix | Delete
var i = ids.length;
[323] Fix | Delete
while (i--) {
[324] Fix | Delete
el = plupload.get(ids[i]);
[325] Fix | Delete
if (el) {
[326] Fix | Delete
els.push(el);
[327] Fix | Delete
}
[328] Fix | Delete
}
[329] Fix | Delete
[330] Fix | Delete
return els.length ? els : null;
[331] Fix | Delete
},
[332] Fix | Delete
[333] Fix | Delete
/**
[334] Fix | Delete
Get DOM element by id
[335] Fix | Delete
[336] Fix | Delete
@method get
[337] Fix | Delete
@param {String} id Identifier of the DOM Element
[338] Fix | Delete
@return {Node}
[339] Fix | Delete
*/
[340] Fix | Delete
get: o.get,
[341] Fix | Delete
[342] Fix | Delete
/**
[343] Fix | Delete
* Executes the callback function for each item in array/object. If you return false in the
[344] Fix | Delete
* callback it will break the loop.
[345] Fix | Delete
*
[346] Fix | Delete
* @method each
[347] Fix | Delete
* @static
[348] Fix | Delete
* @param {Object} obj Object to iterate.
[349] Fix | Delete
* @param {function} callback Callback function to execute for each item.
[350] Fix | Delete
*/
[351] Fix | Delete
each : o.each,
[352] Fix | Delete
[353] Fix | Delete
/**
[354] Fix | Delete
* Returns the absolute x, y position of an Element. The position will be returned in a object with x, y fields.
[355] Fix | Delete
*
[356] Fix | Delete
* @method getPos
[357] Fix | Delete
* @static
[358] Fix | Delete
* @param {Element} node HTML element or element id to get x, y position from.
[359] Fix | Delete
* @param {Element} root Optional root element to stop calculations at.
[360] Fix | Delete
* @return {object} Absolute position of the specified element object with x, y fields.
[361] Fix | Delete
*/
[362] Fix | Delete
getPos : o.getPos,
[363] Fix | Delete
[364] Fix | Delete
/**
[365] Fix | Delete
* Returns the size of the specified node in pixels.
[366] Fix | Delete
*
[367] Fix | Delete
* @method getSize
[368] Fix | Delete
* @static
[369] Fix | Delete
* @param {Node} node Node to get the size of.
[370] Fix | Delete
* @return {Object} Object with a w and h property.
[371] Fix | Delete
*/
[372] Fix | Delete
getSize : o.getSize,
[373] Fix | Delete
[374] Fix | Delete
/**
[375] Fix | Delete
* Encodes the specified string.
[376] Fix | Delete
*
[377] Fix | Delete
* @method xmlEncode
[378] Fix | Delete
* @static
[379] Fix | Delete
* @param {String} s String to encode.
[380] Fix | Delete
* @return {String} Encoded string.
[381] Fix | Delete
*/
[382] Fix | Delete
xmlEncode : function(str) {
[383] Fix | Delete
var xmlEncodeChars = {'<' : 'lt', '>' : 'gt', '&' : 'amp', '"' : 'quot', '\'' : '#39'}, xmlEncodeRegExp = /[<>&\"\']/g;
[384] Fix | Delete
[385] Fix | Delete
return str ? ('' + str).replace(xmlEncodeRegExp, function(chr) {
[386] Fix | Delete
return xmlEncodeChars[chr] ? '&' + xmlEncodeChars[chr] + ';' : chr;
[387] Fix | Delete
}) : str;
[388] Fix | Delete
},
[389] Fix | Delete
[390] Fix | Delete
/**
[391] Fix | Delete
* Forces anything into an array.
[392] Fix | Delete
*
[393] Fix | Delete
* @method toArray
[394] Fix | Delete
* @static
[395] Fix | Delete
* @param {Object} obj Object with length field.
[396] Fix | Delete
* @return {Array} Array object containing all items.
[397] Fix | Delete
*/
[398] Fix | Delete
toArray : o.toArray,
[399] Fix | Delete
[400] Fix | Delete
/**
[401] Fix | Delete
* Find an element in array and return its index if present, otherwise return -1.
[402] Fix | Delete
*
[403] Fix | Delete
* @method inArray
[404] Fix | Delete
* @static
[405] Fix | Delete
* @param {mixed} needle Element to find
[406] Fix | Delete
* @param {Array} array
[407] Fix | Delete
* @return {Int} Index of the element, or -1 if not found
[408] Fix | Delete
*/
[409] Fix | Delete
inArray : o.inArray,
[410] Fix | Delete
[411] Fix | Delete
/**
[412] Fix | Delete
* Extends the language pack object with new items.
[413] Fix | Delete
*
[414] Fix | Delete
* @method addI18n
[415] Fix | Delete
* @static
[416] Fix | Delete
* @param {Object} pack Language pack items to add.
[417] Fix | Delete
* @return {Object} Extended language pack object.
[418] Fix | Delete
*/
[419] Fix | Delete
addI18n : o.addI18n,
[420] Fix | Delete
[421] Fix | Delete
/**
[422] Fix | Delete
* Translates the specified string by checking for the english string in the language pack lookup.
[423] Fix | Delete
*
[424] Fix | Delete
* @method translate
[425] Fix | Delete
* @static
[426] Fix | Delete
* @param {String} str String to look for.
[427] Fix | Delete
* @return {String} Translated string or the input string if it wasn't found.
[428] Fix | Delete
*/
[429] Fix | Delete
translate : o.translate,
[430] Fix | Delete
[431] Fix | Delete
/**
[432] Fix | Delete
* Checks if object is empty.
[433] Fix | Delete
*
[434] Fix | Delete
* @method isEmptyObj
[435] Fix | Delete
* @static
[436] Fix | Delete
* @param {Object} obj Object to check.
[437] Fix | Delete
* @return {Boolean}
[438] Fix | Delete
*/
[439] Fix | Delete
isEmptyObj : o.isEmptyObj,
[440] Fix | Delete
[441] Fix | Delete
/**
[442] Fix | Delete
* Checks if specified DOM element has specified class.
[443] Fix | Delete
*
[444] Fix | Delete
* @method hasClass
[445] Fix | Delete
* @static
[446] Fix | Delete
* @param {Object} obj DOM element like object to add handler to.
[447] Fix | Delete
* @param {String} name Class name
[448] Fix | Delete
*/
[449] Fix | Delete
hasClass : o.hasClass,
[450] Fix | Delete
[451] Fix | Delete
/**
[452] Fix | Delete
* Adds specified className to specified DOM element.
[453] Fix | Delete
*
[454] Fix | Delete
* @method addClass
[455] Fix | Delete
* @static
[456] Fix | Delete
* @param {Object} obj DOM element like object to add handler to.
[457] Fix | Delete
* @param {String} name Class name
[458] Fix | Delete
*/
[459] Fix | Delete
addClass : o.addClass,
[460] Fix | Delete
[461] Fix | Delete
/**
[462] Fix | Delete
* Removes specified className from specified DOM element.
[463] Fix | Delete
*
[464] Fix | Delete
* @method removeClass
[465] Fix | Delete
* @static
[466] Fix | Delete
* @param {Object} obj DOM element like object to add handler to.
[467] Fix | Delete
* @param {String} name Class name
[468] Fix | Delete
*/
[469] Fix | Delete
removeClass : o.removeClass,
[470] Fix | Delete
[471] Fix | Delete
/**
[472] Fix | Delete
* Returns a given computed style of a DOM element.
[473] Fix | Delete
*
[474] Fix | Delete
* @method getStyle
[475] Fix | Delete
* @static
[476] Fix | Delete
* @param {Object} obj DOM element like object.
[477] Fix | Delete
* @param {String} name Style you want to get from the DOM element
[478] Fix | Delete
*/
[479] Fix | Delete
getStyle : o.getStyle,
[480] Fix | Delete
[481] Fix | Delete
/**
[482] Fix | Delete
* Adds an event handler to the specified object and store reference to the handler
[483] Fix | Delete
* in objects internal Plupload registry (@see removeEvent).
[484] Fix | Delete
*
[485] Fix | Delete
* @method addEvent
[486] Fix | Delete
* @static
[487] Fix | Delete
* @param {Object} obj DOM element like object to add handler to.
[488] Fix | Delete
* @param {String} name Name to add event listener to.
[489] Fix | Delete
* @param {Function} callback Function to call when event occurs.
[490] Fix | Delete
* @param {String} (optional) key that might be used to add specifity to the event record.
[491] Fix | Delete
*/
[492] Fix | Delete
addEvent : o.addEvent,
[493] Fix | Delete
[494] Fix | Delete
/**
[495] Fix | Delete
* Remove event handler from the specified object. If third argument (callback)
[496] Fix | Delete
* is not specified remove all events with the specified name.
[497] Fix | Delete
*
[498] Fix | Delete
* @method removeEvent
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function