Skip to content

Commit

Permalink
Update js.
Browse files Browse the repository at this point in the history
  • Loading branch information
Davit Barbakadze committed Nov 3, 2017
1 parent 31851fd commit 0f37b16
Show file tree
Hide file tree
Showing 5 changed files with 162 additions and 152 deletions.
284 changes: 147 additions & 137 deletions js/moxie.js
@@ -1,15 +1,15 @@
;var MXI_DEBUG = true;
/**
* mOxie - multi-runtime File API & XMLHttpRequest L2 Polyfill
* v1.5.6
* v1.5.7
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*
* Date: 2017-10-02
* Date: 2017-11-03
*/
;(function (global, factory) {
var extract = function() {
Expand Down Expand Up @@ -280,7 +280,7 @@ define('moxie/core/utils/Basic', [], function() {
child.prototype = new ctor();

// keep a way to reference parent methods
child.super = parent.prototype;
child.parent = parent.prototype;
return child;
}

Expand Down Expand Up @@ -1553,7 +1553,8 @@ define("moxie/core/utils/Env", [
console.appendChild(document.createTextNode(data + "\n"));
}

if (window && window.console && window.console.log) {
// if debugger present, IE8 might have window.console.log method, but not be able to apply on it (why...)
if (window && window.console && window.console.log && window.console.log.apply) {
window.console.log.apply(window.console, arguments);
} else if (document) {
var console = document.getElementById('moxie-console');
Expand Down Expand Up @@ -3365,7 +3366,7 @@ define("moxie/core/utils/Mime", [
"moxie/core/utils/Basic",
"moxie/core/I18n"
], function(Basic, I18n) {

var mimeData = "" +
"application/msword,doc dot," +
"application/pdf,pdf," +
Expand Down Expand Up @@ -3416,169 +3417,178 @@ define("moxie/core/utils/Mime", [
"video/3gpp,3gpp 3gp," +
"video/3gpp2,3g2," +
"video/vnd.rn-realvideo,rv," +
"video/ogg,ogv," +
"video/ogg,ogv," +
"video/x-matroska,mkv," +
"application/vnd.oasis.opendocument.formula-template,otf," +
"application/octet-stream,exe";


var Mime = {

/**
* Map of mimes to extensions
*
* @property mimes
* @type {Object}
*/
mimes: {},

/**
* Map of extensions to mimes
*
* @property extensions
* @type {Object}
*/
extensions: {},
/**
* Map of mimes to extensions
*
* @property mimes
* @type {Object}
*/
var mimes = {};

/**
* Parses mimeData string into a mimes and extensions lookup maps. String should have the
* following format:
*
* application/msword,doc dot,application/pdf,pdf, ...
*
* so mime-type followed by comma and followed by space-separated list of associated extensions,
* then comma again and then another mime-type, etc.
*
* If invoked externally will replace override internal lookup maps with user-provided data.
*
* @method addMimeType
* @param {String} mimeData
*/
addMimeType: function (mimeData) {
var items = mimeData.split(/,/), i, ii, ext;

for (i = 0; i < items.length; i += 2) {
ext = items[i + 1].split(/ /);
/**
* Map of extensions to mimes
*
* @property extensions
* @type {Object}
*/
var extensions = {};

// extension to mime lookup
for (ii = 0; ii < ext.length; ii++) {
this.mimes[ext[ii]] = items[i];
}
// mime to extension lookup
this.extensions[items[i]] = ext;

/**
* Parses mimeData string into a mimes and extensions lookup maps. String should have the
* following format:
*
* application/msword,doc dot,application/pdf,pdf, ...
*
* so mime-type followed by comma and followed by space-separated list of associated extensions,
* then comma again and then another mime-type, etc.
*
* If invoked externally will replace override internal lookup maps with user-provided data.
*
* @method addMimeType
* @param {String} mimeData
*/
var addMimeType = function (mimeData) {
var items = mimeData.split(/,/), i, ii, ext;

for (i = 0; i < items.length; i += 2) {
ext = items[i + 1].split(/ /);

// extension to mime lookup
for (ii = 0; ii < ext.length; ii++) {
mimes[ext[ii]] = items[i];
}
},
// mime to extension lookup
extensions[items[i]] = ext;
}
};


extList2mimes: function (filters, addMissingExtensions) {
var self = this, ext, i, ii, type, mimes = [];

// convert extensions to mime types list
for (i = 0; i < filters.length; i++) {
ext = filters[i].extensions.toLowerCase().split(/\s*,\s*/);
var extList2mimes = function (filters, addMissingExtensions) {
var ext, i, ii, type, mimes = [];

for (ii = 0; ii < ext.length; ii++) {

// if there's an asterisk in the list, then accept attribute is not required
if (ext[ii] === '*') {
return [];
}
// convert extensions to mime types list
for (i = 0; i < filters.length; i++) {
ext = filters[i].extensions.toLowerCase().split(/\s*,\s*/);

type = self.mimes[ext[ii]];
for (ii = 0; ii < ext.length; ii++) {

// future browsers should filter by extension, finally
if (addMissingExtensions && /^\w+$/.test(ext[ii])) {
mimes.push('.' + ext[ii]);
} else if (type && Basic.inArray(type, mimes) === -1) {
mimes.push(type);
} else if (!type) {
// if we have no type in our map, then accept all
return [];
}
// if there's an asterisk in the list, then accept attribute is not required
if (ext[ii] === '*') {
return [];
}

type = mimes[ext[ii]];

// future browsers should filter by extension, finally
if (addMissingExtensions && /^\w+$/.test(ext[ii])) {
mimes.push('.' + ext[ii]);
} else if (type && Basic.inArray(type, mimes) === -1) {
mimes.push(type);
} else if (!type) {
// if we have no type in our map, then accept all
return [];
}
}
return mimes;
},
}
return mimes;
};


mimes2exts: function(mimes) {
var self = this, exts = [];

Basic.each(mimes, function(mime) {
mime = mime.toLowerCase();
var mimes2exts = function(mimes) {
var exts = [];

if (mime === '*') {
exts = [];
return false;
}
Basic.each(mimes, function(mime) {
mime = mime.toLowerCase();

// check if this thing looks like mime type
var m = mime.match(/^(\w+)\/(\*|\w+)$/);
if (m) {
if (m[2] === '*') {
// wildcard mime type detected
Basic.each(self.extensions, function(arr, mime) {
if ((new RegExp('^' + m[1] + '/')).test(mime)) {
[].push.apply(exts, self.extensions[mime]);
}
});
} else if (self.extensions[mime]) {
[].push.apply(exts, self.extensions[mime]);
}
if (mime === '*') {
exts = [];
return false;
}

// check if this thing looks like mime type
var m = mime.match(/^(\w+)\/(\*|\w+)$/);
if (m) {
if (m[2] === '*') {
// wildcard mime type detected
Basic.each(extensions, function(arr, mime) {
if ((new RegExp('^' + m[1] + '/')).test(mime)) {
[].push.apply(exts, extensions[mime]);
}
});
} else if (extensions[mime]) {
[].push.apply(exts, extensions[mime]);
}
});
return exts;
},
}
});
return exts;
};


mimes2extList: function(mimes) {
var accept = [], exts = [];
var mimes2extList = function(mimes) {
var accept = [], exts = [];

if (Basic.typeOf(mimes) === 'string') {
mimes = Basic.trim(mimes).split(/\s*,\s*/);
}
if (Basic.typeOf(mimes) === 'string') {
mimes = Basic.trim(mimes).split(/\s*,\s*/);
}

exts = this.mimes2exts(mimes);

accept.push({
title: I18n.translate('Files'),
extensions: exts.length ? exts.join(',') : '*'
});
exts = mimes2exts(mimes);

return accept;
},
accept.push({
title: I18n.translate('Files'),
extensions: exts.length ? exts.join(',') : '*'
});

/**
* Extract extension from the given filename
*
* @method getFileExtension
* @param {String} fileName
* @return {String} File extension
*/
getFileExtension: function(fileName) {
var matches = fileName && fileName.match(/\.([^.]+)$/);
if (matches) {
return matches[1].toLowerCase();
}
return '';
},
return accept;
};

/**
* Get file mime-type from it's filename - will try to match the extension
* against internal mime-type lookup map
*
* @method getFileMime
* @param {String} fileName
* @return File mime-type if found or an empty string if not
*/
getFileMime: function(fileName) {
return this.mimes[this.getFileExtension(fileName)] || '';
/**
* Extract extension from the given filename
*
* @method getFileExtension
* @param {String} fileName
* @return {String} File extension
*/
var getFileExtension = function(fileName) {
var matches = fileName && fileName.match(/\.([^.]+)$/);
if (matches) {
return matches[1].toLowerCase();
}
return '';
};


/**
* Get file mime-type from it's filename - will try to match the extension
* against internal mime-type lookup map
*
* @method getFileMime
* @param {String} fileName
* @return File mime-type if found or an empty string if not
*/
var getFileMime = function(fileName) {
return mimes[getFileExtension(fileName)] || '';
};

Mime.addMimeType(mimeData);

return Mime;
addMimeType(mimeData);

return {
mimes: mimes,
extensions: extensions,
addMimeType: addMimeType,
extList2mimes: extList2mimes,
mimes2exts: mimes2exts,
mimes2extList: mimes2extList,
getFileExtension: getFileExtension,
getFileMime: getFileMime
}
});

// Included from: src/javascript/file/FileInput.js
Expand Down
6 changes: 3 additions & 3 deletions js/moxie.min.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions js/plupload.dev.js
@@ -1,14 +1,14 @@
/**
* Plupload - multi-runtime File Uploader
* v2.3.5
* v2.3.6
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*
* Date: 2017-11-02
* Date: 2017-11-03
*/
;(function (global, factory) {
var extract = function() {
Expand Down Expand Up @@ -112,7 +112,7 @@ var plupload = {
* @static
* @final
*/
VERSION : '2.3.5',
VERSION : '2.3.6',

/**
* The state of the queue before it has started and after it has finished
Expand Down
12 changes: 6 additions & 6 deletions js/plupload.full.min.js

Large diffs are not rendered by default.

0 comments on commit 0f37b16

Please sign in to comment.