Strip webpack and iframe support from Jua.js (only use xmlhttprequest)

This commit is contained in:
djmaze 2020-07-27 16:58:04 +02:00
parent 1b331aca32
commit c9d444250f
3 changed files with 872 additions and 1201 deletions

View file

@ -61,7 +61,7 @@ Things might work in Edge 15-18, Firefox 47-62 and Chrome 54-68 due to one polyf
|admin.js |2.130.942 |1.359.501 | | |admin.js |2.130.942 |1.359.501 | |
|app.js |4.184.455 |3.127.807 | | |app.js |4.184.455 |3.127.807 | |
|boot.js | 671.522 | 120.319 | | |boot.js | 671.522 | 120.319 | |
|libs.js | 647.614 | 511.296 | | |libs.js | 647.614 | 508.324 | |
|polyfills.js | 325.834 | 0 | | |polyfills.js | 325.834 | 0 | |
|TOTAL js |7.960.367 |5.119.409 | | |TOTAL js |7.960.367 |5.119.409 | |
@ -70,11 +70,11 @@ Things might work in Edge 15-18, Firefox 47-62 and Chrome 54-68 due to one polyf
|admin.js | 252.147 | 177.094 | | |admin.js | 252.147 | 177.094 | |
|app.js | 511.202 | 409.778 | | |app.js | 511.202 | 409.778 | |
|boot.js | 66.007 | 14.697 | | |boot.js | 66.007 | 14.697 | |
|libs.js | 572.545 | 468.224 | | |libs.js | 572.545 | 465.247 | |
|polyfills.js | 32.452 | 0 | | |polyfills.js | 32.452 | 0 | |
|TOTAL js/min |1.434.353 |1.069.793 |364.560 | |TOTAL js/min |1.434.353 |1.066.816 |367.537 |
364.560 bytes is not much, but it feels faster. 367.537 bytes is not much, but it feels faster.
### PHP73 branch ### PHP73 branch

405
vendors/jua/jua.js vendored
View file

@ -1,102 +1,13 @@
/* RainLoop Webmail (c) RainLoop Team | MIT */ /* RainLoop Webmail (c) RainLoop Team | MIT */
(function(){function a(a){function l(){if(g&&d<a){var b=g,c=b[0],f=Array.prototype.slice.call(b,1),m=b.index;g===h?g=h=null:g=g.next,++d,f.push(function(a,b){--d;if(i)return;a?e&&k(i=a,e=j=g=h=null):(j[m]=b,--e?l():k(null,j))}),c.apply(null,f)}}var c={},d=0,e=0,f=-1,g,h,i=null,j=[],k=b;return arguments.length<1&&(a=Infinity),c.defer=function(){if(!i){var a=arguments;a.index=++f,h?(h.next=a,h=h.next):g=h=a,++e,l()}return c},c.await=function(a){return k=a,e||k(i,j),c},c}function b(){}typeof module=="undefined"?self.queue=a:module.exports=a,a.version="0.0.2"})(); (()=>{
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ exports: {},
/******/ id: moduleId,
/******/ loaded: false
/******/ };
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ // Flag the module as loaded
/******/ module.loaded = true;
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/ // Load entry module and return exports
/******/ return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ function(module, exports, __webpack_require__) {
(function () {
'use strict';
__webpack_require__(1).Jua = __webpack_require__(7);
}());
/***/ },
/* 1 */
/***/ function(module, exports, __webpack_require__) {
module.exports = window;
/***/ },
/* 2 */
/***/ function(module, exports, __webpack_require__) {
(function () {
'use strict';
var Globals = {};
Globals.iDefLimit = 20;
module.exports = Globals;
}());
/***/ },
/* 3 */
/***/ function(module, exports, __webpack_require__) {
module.exports = jQuery;
/***/ },
/* 4 */
/***/ function(module, exports, __webpack_require__) {
(function () {
'use strict'; 'use strict';
var var
Globals = {},
Utils = {}, Utils = {},
$ = jQuery;
window = __webpack_require__(1), Globals.iDefLimit = 20;
$ = __webpack_require__(3),
Globals = __webpack_require__(2)
;
/** /**
* @param {*} mValue * @param {*} mValue
@ -464,25 +375,6 @@
mStringOrFunction.toString(); mStringOrFunction.toString();
}; };
module.exports = Utils;
}());
/***/ },
/* 5 */
/***/ function(module, exports, __webpack_require__) {
(function () {
'use strict';
var
$ = __webpack_require__(3),
Globals = __webpack_require__(2),
Utils = __webpack_require__(4)
;
/** /**
* @constructor * @constructor
@ -520,10 +412,7 @@
/** /**
* @return {boolean} * @return {boolean}
*/ */
AjaxDriver.prototype.isDragAndDropSupported = function () AjaxDriver.prototype.isDragAndDropSupported = () => true;
{
return true;
};
/** /**
* @param {string} sUid * @param {string} sUid
@ -696,236 +585,38 @@
} }
}; };
module.exports = AjaxDriver; function queue(a) {
function l() {
}()); if (g && d < a) {
var b = g,
c = b[0],
/***/ }, f = Array.prototype.slice.call(b, 1),
/* 6 */ m = b.index;
/***/ function(module, exports, __webpack_require__) { g === h ? g = h = null : g = g.next, ++d, f.push(function (a, b) {
--d;
if (i) return;
(function () { a ? e && k(i = a, e = j = g = h = null) : (j[m] = b, --e ? l() : k(null, j))
}),
'use strict'; c.apply(null, f)
var
window = __webpack_require__(1),
$ = __webpack_require__(3),
Globals = __webpack_require__(2),
Utils = __webpack_require__(4)
;
/**
* @constructor
* @param {Jua} oJua
* @param {Object} oOptions
*/
function IframeDriver(oJua, oOptions)
{
this.oUids = {};
this.oForms = {};
this.oJua = oJua;
this.oOptions = oOptions;
} }
/**
* @type {Object}
*/
IframeDriver.prototype.oUids = {};
/**
* @type {Object}
*/
IframeDriver.prototype.oForms = {};
/**
* @type {?Jua}
*/
IframeDriver.prototype.oJua = null;
/**
* @type {Object}
*/
IframeDriver.prototype.oOptions = {};
/**
* @return {boolean}
*/
IframeDriver.prototype.isDragAndDropSupported = function ()
{
return false;
};
/**
* @param {string} sUid
*/
IframeDriver.prototype.regTaskUid = function (sUid)
{
this.oUids[sUid] = true;
};
/**
* @param {string} sUid
* @param {?} oFileInfo
* @param {Function} fCallback
*/
IframeDriver.prototype.uploadTask = function (sUid, oFileInfo, fCallback)
{
if (false === this.oUids[sUid])
{
fCallback(null, sUid);
return false;
} }
var c = {},
var d = 0,
oForm = this.oForms[sUid], e = 0,
aHidden = Utils.getValue(this.oOptions, 'hidden', {}), f = -1,
fStartFunction = this.oJua.getEvent('onStart'), g, h, i = null,
fCompleteFunction = this.oJua.getEvent('onComplete') j = [],
; k = ()=>{};
return arguments.length < 1 && (a = Infinity), c.defer = function () {
if (oForm) if (!i) {
{ var a = arguments;
oForm.append($('<input type="hidden" />').attr('name', 'jua-post-type').val('iframe')); a.index = ++f, h ? (h.next = a, h = h.next) : g = h = a, ++e, l()
$.each(aHidden, function (sKey, sValue) {
oForm.append($('<input type="hidden" />').attr('name', sKey).val(Utils.getStringOrCallFunction(sValue, [oFileInfo])));
});
oForm.trigger('submit');
if (fStartFunction)
{
fStartFunction(sUid);
} }
return c
oForm.find('iframe').on('load', function () { }, c.await = function (a) {
return k = a, e || k(i, j), c
var }, c
bResult = false,
oIframeDoc = null,
oResult = {}
;
if (fCompleteFunction)
{
try
{
oIframeDoc = this.contentDocument ? this.contentDocument: this.contentWindow.document;
oResult = $.parseJSON(oIframeDoc.body.innerHTML);
bResult = true;
} }
catch (oErr)
{
oResult = {};
}
fCompleteFunction(sUid, bResult, oResult);
}
fCallback(null, sUid);
window.setTimeout(function () {
oForm.remove();
}, 100);
});
}
else
{
fCallback(null, sUid);
}
return true;
};
IframeDriver.prototype.generateNewInput = function (oClickElement)
{
var
self = this,
sUid = '',
oInput = null,
oIframe = null,
sAction = Utils.getValue(this.oOptions, 'action', ''),
oForm = null
;
if (oClickElement)
{
sUid = Utils.getNewUid();
oInput = Utils.getNewInput(Utils.getValue(this.oOptions, 'name', 'juaFile'), !Utils.getValue(this.oOptions, 'disableMultiple', false));
oForm = $('<form action="' + sAction + '" target="iframe-' + sUid + '" ' +
' method="POST" enctype="multipart/form-data" style="display: block; cursor: pointer;"></form>');
oIframe = $('<iframe name="iframe-' + sUid + '" tabindex="-1" src="javascript:void(0);" ' +
' style="position: absolute; top: -1000px; left: -1000px; cursor: pointer;" />').css({'opacity': 0});
oForm.append(Utils.createNextLabel().append(oInput)).append(oIframe);
$(oClickElement).append(oForm);
this.oForms[sUid] = oForm;
oInput
.on('click', function () {
var fOn = self.oJua.getEvent('onDialog');
if (fOn)
{
fOn();
}
})
.on('change', function () {
Utils.getDataFromInput(this, function (oFile) {
if (oFile)
{
oForm.css({
'position': 'absolute',
'top': -1000,
'left': -1000
});
self.oJua.addFile(sUid, oFile);
self.generateNewInput(oClickElement);
}
},
Utils.getValue(self.oOptions, 'multipleSizeLimit', Globals.iDefLimit),
self.oJua.getEvent('onLimitReached')
);
})
;
}
};
IframeDriver.prototype.cancel = function (sUid)
{
this.oUids[sUid] = false;
if (this.oForms[sUid])
{
this.oForms[sUid].remove();
this.oForms[sUid] = false;
}
};
module.exports = IframeDriver;
}());
/***/ },
/* 7 */
/***/ function(module, exports, __webpack_require__) {
(function () {
'use strict';
var
Utils = __webpack_require__(4),
Globals = __webpack_require__(2)
;
/** /**
* @constructor * @constructor
@ -938,12 +629,7 @@
var var
self = this, self = this,
Driver = null, $ = jQuery
window = __webpack_require__(1),
$ = __webpack_require__(3),
queue = __webpack_require__(8)
; ;
self.bEnableDnD = true; self.bEnableDnD = true;
@ -971,7 +657,6 @@
'clickElement': false, 'clickElement': false,
'dragAndDropElement': false, 'dragAndDropElement': false,
'dragAndDropBodyElement': false, 'dragAndDropBodyElement': false,
'disableAjaxUpload': false,
'disableDragAndDrop': false, 'disableDragAndDrop': false,
'disableMultiple': false, 'disableMultiple': false,
'disableDocumentDropPrevent': false, 'disableDocumentDropPrevent': false,
@ -986,10 +671,7 @@
}); });
} }
Driver = (!Utils.getValue(self.oOptions, 'disableAjaxUpload', false) ? self.oDriver = new AjaxDriver(self, self.oOptions);
__webpack_require__(5) : __webpack_require__(6));
self.oDriver = new Driver(self, self.oOptions);
self.oClickElement = Utils.getValue(self.oOptions, 'clickElement', null); self.oClickElement = Utils.getValue(self.oOptions, 'clickElement', null);
@ -1008,8 +690,7 @@
this.oDriver.generateNewInput(this.oClickElement); this.oDriver.generateNewInput(this.oClickElement);
} }
if (this.oDriver.isDragAndDropSupported() && Utils.getValue(this.oOptions, 'dragAndDropElement', false) && if (this.oDriver.isDragAndDropSupported() && Utils.getValue(this.oOptions, 'dragAndDropElement', false))
!Utils.getValue(this.oOptions, 'disableAjaxUpload', false))
{ {
(function (self) { (function (self) {
var var
@ -1307,16 +988,6 @@
} }
}; };
module.exports = Jua; window.Jua = Jua;
}()); })();
/***/ },
/* 8 */
/***/ function(module, exports, __webpack_require__) {
module.exports = queue;
/***/ }
/******/ ]);

File diff suppressed because one or more lines are too long