|
1 | 1 | ;var MXI_DEBUG = true;
|
2 | 2 | /**
|
3 | 3 | * mOxie - multi-runtime File API & XMLHttpRequest L2 Polyfill
|
4 |
| - * v1.5.6 |
| 4 | + * v1.5.7 |
5 | 5 | *
|
6 | 6 | * Copyright 2013, Moxiecode Systems AB
|
7 | 7 | * Released under GPL License.
|
8 | 8 | *
|
9 | 9 | * License: http://www.plupload.com/license
|
10 | 10 | * Contributing: http://www.plupload.com/contributing
|
11 | 11 | *
|
12 |
| - * Date: 2017-10-02 |
| 12 | + * Date: 2017-11-03 |
13 | 13 | */
|
14 | 14 | ;(function (global, factory) {
|
15 | 15 | var extract = function() {
|
@@ -280,7 +280,7 @@ define('moxie/core/utils/Basic', [], function() {
|
280 | 280 | child.prototype = new ctor();
|
281 | 281 |
|
282 | 282 | // keep a way to reference parent methods
|
283 |
| - child.super = parent.prototype; |
| 283 | + child.parent = parent.prototype; |
284 | 284 | return child;
|
285 | 285 | }
|
286 | 286 |
|
@@ -1553,7 +1553,8 @@ define("moxie/core/utils/Env", [
|
1553 | 1553 | console.appendChild(document.createTextNode(data + "\n"));
|
1554 | 1554 | }
|
1555 | 1555 |
|
1556 |
| - if (window && window.console && window.console.log) { |
| 1556 | + // if debugger present, IE8 might have window.console.log method, but not be able to apply on it (why...) |
| 1557 | + if (window && window.console && window.console.log && window.console.log.apply) { |
1557 | 1558 | window.console.log.apply(window.console, arguments);
|
1558 | 1559 | } else if (document) {
|
1559 | 1560 | var console = document.getElementById('moxie-console');
|
@@ -3365,7 +3366,7 @@ define("moxie/core/utils/Mime", [
|
3365 | 3366 | "moxie/core/utils/Basic",
|
3366 | 3367 | "moxie/core/I18n"
|
3367 | 3368 | ], function(Basic, I18n) {
|
3368 |
| - |
| 3369 | + |
3369 | 3370 | var mimeData = "" +
|
3370 | 3371 | "application/msword,doc dot," +
|
3371 | 3372 | "application/pdf,pdf," +
|
@@ -3416,169 +3417,178 @@ define("moxie/core/utils/Mime", [
|
3416 | 3417 | "video/3gpp,3gpp 3gp," +
|
3417 | 3418 | "video/3gpp2,3g2," +
|
3418 | 3419 | "video/vnd.rn-realvideo,rv," +
|
3419 |
| - "video/ogg,ogv," + |
| 3420 | + "video/ogg,ogv," + |
3420 | 3421 | "video/x-matroska,mkv," +
|
3421 | 3422 | "application/vnd.oasis.opendocument.formula-template,otf," +
|
3422 | 3423 | "application/octet-stream,exe";
|
3423 |
| - |
3424 |
| - |
3425 |
| - var Mime = { |
3426 | 3424 |
|
3427 |
| - /** |
3428 |
| - * Map of mimes to extensions |
3429 |
| - * |
3430 |
| - * @property mimes |
3431 |
| - * @type {Object} |
3432 |
| - */ |
3433 |
| - mimes: {}, |
3434 | 3425 |
|
3435 |
| - /** |
3436 |
| - * Map of extensions to mimes |
3437 |
| - * |
3438 |
| - * @property extensions |
3439 |
| - * @type {Object} |
3440 |
| - */ |
3441 |
| - extensions: {}, |
| 3426 | + /** |
| 3427 | + * Map of mimes to extensions |
| 3428 | + * |
| 3429 | + * @property mimes |
| 3430 | + * @type {Object} |
| 3431 | + */ |
| 3432 | + var mimes = {}; |
3442 | 3433 |
|
3443 |
| - /** |
3444 |
| - * Parses mimeData string into a mimes and extensions lookup maps. String should have the |
3445 |
| - * following format: |
3446 |
| - * |
3447 |
| - * application/msword,doc dot,application/pdf,pdf, ... |
3448 |
| - * |
3449 |
| - * so mime-type followed by comma and followed by space-separated list of associated extensions, |
3450 |
| - * then comma again and then another mime-type, etc. |
3451 |
| - * |
3452 |
| - * If invoked externally will replace override internal lookup maps with user-provided data. |
3453 |
| - * |
3454 |
| - * @method addMimeType |
3455 |
| - * @param {String} mimeData |
3456 |
| - */ |
3457 |
| - addMimeType: function (mimeData) { |
3458 |
| - var items = mimeData.split(/,/), i, ii, ext; |
3459 |
| - |
3460 |
| - for (i = 0; i < items.length; i += 2) { |
3461 |
| - ext = items[i + 1].split(/ /); |
| 3434 | + /** |
| 3435 | + * Map of extensions to mimes |
| 3436 | + * |
| 3437 | + * @property extensions |
| 3438 | + * @type {Object} |
| 3439 | + */ |
| 3440 | + var extensions = {}; |
3462 | 3441 |
|
3463 |
| - // extension to mime lookup |
3464 |
| - for (ii = 0; ii < ext.length; ii++) { |
3465 |
| - this.mimes[ext[ii]] = items[i]; |
3466 |
| - } |
3467 |
| - // mime to extension lookup |
3468 |
| - this.extensions[items[i]] = ext; |
| 3442 | + |
| 3443 | + /** |
| 3444 | + * Parses mimeData string into a mimes and extensions lookup maps. String should have the |
| 3445 | + * following format: |
| 3446 | + * |
| 3447 | + * application/msword,doc dot,application/pdf,pdf, ... |
| 3448 | + * |
| 3449 | + * so mime-type followed by comma and followed by space-separated list of associated extensions, |
| 3450 | + * then comma again and then another mime-type, etc. |
| 3451 | + * |
| 3452 | + * If invoked externally will replace override internal lookup maps with user-provided data. |
| 3453 | + * |
| 3454 | + * @method addMimeType |
| 3455 | + * @param {String} mimeData |
| 3456 | + */ |
| 3457 | + var addMimeType = function (mimeData) { |
| 3458 | + var items = mimeData.split(/,/), i, ii, ext; |
| 3459 | + |
| 3460 | + for (i = 0; i < items.length; i += 2) { |
| 3461 | + ext = items[i + 1].split(/ /); |
| 3462 | + |
| 3463 | + // extension to mime lookup |
| 3464 | + for (ii = 0; ii < ext.length; ii++) { |
| 3465 | + mimes[ext[ii]] = items[i]; |
3469 | 3466 | }
|
3470 |
| - }, |
| 3467 | + // mime to extension lookup |
| 3468 | + extensions[items[i]] = ext; |
| 3469 | + } |
| 3470 | + }; |
3471 | 3471 |
|
3472 | 3472 |
|
3473 |
| - extList2mimes: function (filters, addMissingExtensions) { |
3474 |
| - var self = this, ext, i, ii, type, mimes = []; |
3475 |
| - |
3476 |
| - // convert extensions to mime types list |
3477 |
| - for (i = 0; i < filters.length; i++) { |
3478 |
| - ext = filters[i].extensions.toLowerCase().split(/\s*,\s*/); |
| 3473 | + var extList2mimes = function (filters, addMissingExtensions) { |
| 3474 | + var ext, i, ii, type, mimes = []; |
3479 | 3475 |
|
3480 |
| - for (ii = 0; ii < ext.length; ii++) { |
3481 |
| - |
3482 |
| - // if there's an asterisk in the list, then accept attribute is not required |
3483 |
| - if (ext[ii] === '*') { |
3484 |
| - return []; |
3485 |
| - } |
| 3476 | + // convert extensions to mime types list |
| 3477 | + for (i = 0; i < filters.length; i++) { |
| 3478 | + ext = filters[i].extensions.toLowerCase().split(/\s*,\s*/); |
3486 | 3479 |
|
3487 |
| - type = self.mimes[ext[ii]]; |
| 3480 | + for (ii = 0; ii < ext.length; ii++) { |
3488 | 3481 |
|
3489 |
| - // future browsers should filter by extension, finally |
3490 |
| - if (addMissingExtensions && /^\w+$/.test(ext[ii])) { |
3491 |
| - mimes.push('.' + ext[ii]); |
3492 |
| - } else if (type && Basic.inArray(type, mimes) === -1) { |
3493 |
| - mimes.push(type); |
3494 |
| - } else if (!type) { |
3495 |
| - // if we have no type in our map, then accept all |
3496 |
| - return []; |
3497 |
| - } |
| 3482 | + // if there's an asterisk in the list, then accept attribute is not required |
| 3483 | + if (ext[ii] === '*') { |
| 3484 | + return []; |
| 3485 | + } |
| 3486 | + |
| 3487 | + type = mimes[ext[ii]]; |
| 3488 | + |
| 3489 | + // future browsers should filter by extension, finally |
| 3490 | + if (addMissingExtensions && /^\w+$/.test(ext[ii])) { |
| 3491 | + mimes.push('.' + ext[ii]); |
| 3492 | + } else if (type && Basic.inArray(type, mimes) === -1) { |
| 3493 | + mimes.push(type); |
| 3494 | + } else if (!type) { |
| 3495 | + // if we have no type in our map, then accept all |
| 3496 | + return []; |
3498 | 3497 | }
|
3499 | 3498 | }
|
3500 |
| - return mimes; |
3501 |
| - }, |
| 3499 | + } |
| 3500 | + return mimes; |
| 3501 | + }; |
3502 | 3502 |
|
3503 | 3503 |
|
3504 |
| - mimes2exts: function(mimes) { |
3505 |
| - var self = this, exts = []; |
3506 |
| - |
3507 |
| - Basic.each(mimes, function(mime) { |
3508 |
| - mime = mime.toLowerCase(); |
| 3504 | + var mimes2exts = function(mimes) { |
| 3505 | + var exts = []; |
3509 | 3506 |
|
3510 |
| - if (mime === '*') { |
3511 |
| - exts = []; |
3512 |
| - return false; |
3513 |
| - } |
| 3507 | + Basic.each(mimes, function(mime) { |
| 3508 | + mime = mime.toLowerCase(); |
3514 | 3509 |
|
3515 |
| - // check if this thing looks like mime type |
3516 |
| - var m = mime.match(/^(\w+)\/(\*|\w+)$/); |
3517 |
| - if (m) { |
3518 |
| - if (m[2] === '*') { |
3519 |
| - // wildcard mime type detected |
3520 |
| - Basic.each(self.extensions, function(arr, mime) { |
3521 |
| - if ((new RegExp('^' + m[1] + '/')).test(mime)) { |
3522 |
| - [].push.apply(exts, self.extensions[mime]); |
3523 |
| - } |
3524 |
| - }); |
3525 |
| - } else if (self.extensions[mime]) { |
3526 |
| - [].push.apply(exts, self.extensions[mime]); |
3527 |
| - } |
| 3510 | + if (mime === '*') { |
| 3511 | + exts = []; |
| 3512 | + return false; |
| 3513 | + } |
| 3514 | + |
| 3515 | + // check if this thing looks like mime type |
| 3516 | + var m = mime.match(/^(\w+)\/(\*|\w+)$/); |
| 3517 | + if (m) { |
| 3518 | + if (m[2] === '*') { |
| 3519 | + // wildcard mime type detected |
| 3520 | + Basic.each(extensions, function(arr, mime) { |
| 3521 | + if ((new RegExp('^' + m[1] + '/')).test(mime)) { |
| 3522 | + [].push.apply(exts, extensions[mime]); |
| 3523 | + } |
| 3524 | + }); |
| 3525 | + } else if (extensions[mime]) { |
| 3526 | + [].push.apply(exts, extensions[mime]); |
3528 | 3527 | }
|
3529 |
| - }); |
3530 |
| - return exts; |
3531 |
| - }, |
| 3528 | + } |
| 3529 | + }); |
| 3530 | + return exts; |
| 3531 | + }; |
3532 | 3532 |
|
3533 | 3533 |
|
3534 |
| - mimes2extList: function(mimes) { |
3535 |
| - var accept = [], exts = []; |
| 3534 | + var mimes2extList = function(mimes) { |
| 3535 | + var accept = [], exts = []; |
3536 | 3536 |
|
3537 |
| - if (Basic.typeOf(mimes) === 'string') { |
3538 |
| - mimes = Basic.trim(mimes).split(/\s*,\s*/); |
3539 |
| - } |
| 3537 | + if (Basic.typeOf(mimes) === 'string') { |
| 3538 | + mimes = Basic.trim(mimes).split(/\s*,\s*/); |
| 3539 | + } |
3540 | 3540 |
|
3541 |
| - exts = this.mimes2exts(mimes); |
3542 |
| - |
3543 |
| - accept.push({ |
3544 |
| - title: I18n.translate('Files'), |
3545 |
| - extensions: exts.length ? exts.join(',') : '*' |
3546 |
| - }); |
| 3541 | + exts = mimes2exts(mimes); |
3547 | 3542 |
|
3548 |
| - return accept; |
3549 |
| - }, |
| 3543 | + accept.push({ |
| 3544 | + title: I18n.translate('Files'), |
| 3545 | + extensions: exts.length ? exts.join(',') : '*' |
| 3546 | + }); |
3550 | 3547 |
|
3551 |
| - /** |
3552 |
| - * Extract extension from the given filename |
3553 |
| - * |
3554 |
| - * @method getFileExtension |
3555 |
| - * @param {String} fileName |
3556 |
| - * @return {String} File extension |
3557 |
| - */ |
3558 |
| - getFileExtension: function(fileName) { |
3559 |
| - var matches = fileName && fileName.match(/\.([^.]+)$/); |
3560 |
| - if (matches) { |
3561 |
| - return matches[1].toLowerCase(); |
3562 |
| - } |
3563 |
| - return ''; |
3564 |
| - }, |
| 3548 | + return accept; |
| 3549 | + }; |
3565 | 3550 |
|
3566 |
| - /** |
3567 |
| - * Get file mime-type from it's filename - will try to match the extension |
3568 |
| - * against internal mime-type lookup map |
3569 |
| - * |
3570 |
| - * @method getFileMime |
3571 |
| - * @param {String} fileName |
3572 |
| - * @return File mime-type if found or an empty string if not |
3573 |
| - */ |
3574 |
| - getFileMime: function(fileName) { |
3575 |
| - return this.mimes[this.getFileExtension(fileName)] || ''; |
| 3551 | + /** |
| 3552 | + * Extract extension from the given filename |
| 3553 | + * |
| 3554 | + * @method getFileExtension |
| 3555 | + * @param {String} fileName |
| 3556 | + * @return {String} File extension |
| 3557 | + */ |
| 3558 | + var getFileExtension = function(fileName) { |
| 3559 | + var matches = fileName && fileName.match(/\.([^.]+)$/); |
| 3560 | + if (matches) { |
| 3561 | + return matches[1].toLowerCase(); |
3576 | 3562 | }
|
| 3563 | + return ''; |
| 3564 | + }; |
| 3565 | + |
| 3566 | + |
| 3567 | + /** |
| 3568 | + * Get file mime-type from it's filename - will try to match the extension |
| 3569 | + * against internal mime-type lookup map |
| 3570 | + * |
| 3571 | + * @method getFileMime |
| 3572 | + * @param {String} fileName |
| 3573 | + * @return File mime-type if found or an empty string if not |
| 3574 | + */ |
| 3575 | + var getFileMime = function(fileName) { |
| 3576 | + return mimes[getFileExtension(fileName)] || ''; |
3577 | 3577 | };
|
3578 | 3578 |
|
3579 |
| - Mime.addMimeType(mimeData); |
3580 | 3579 |
|
3581 |
| - return Mime; |
| 3580 | + addMimeType(mimeData); |
| 3581 | + |
| 3582 | + return { |
| 3583 | + mimes: mimes, |
| 3584 | + extensions: extensions, |
| 3585 | + addMimeType: addMimeType, |
| 3586 | + extList2mimes: extList2mimes, |
| 3587 | + mimes2exts: mimes2exts, |
| 3588 | + mimes2extList: mimes2extList, |
| 3589 | + getFileExtension: getFileExtension, |
| 3590 | + getFileMime: getFileMime |
| 3591 | + } |
3582 | 3592 | });
|
3583 | 3593 |
|
3584 | 3594 | // Included from: src/javascript/file/FileInput.js
|
|
0 commit comments