mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Strip webpack and iframe support from Jua.js (only use xmlhttprequest)
This commit is contained in:
parent
1b331aca32
commit
c9d444250f
3 changed files with 872 additions and 1201 deletions
|
|
@ -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 | |
|
||||
|app.js |4.184.455 |3.127.807 | |
|
||||
|boot.js | 671.522 | 120.319 | |
|
||||
|libs.js | 647.614 | 511.296 | |
|
||||
|libs.js | 647.614 | 508.324 | |
|
||||
|polyfills.js | 325.834 | 0 | |
|
||||
|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 | |
|
||||
|app.js | 511.202 | 409.778 | |
|
||||
|boot.js | 66.007 | 14.697 | |
|
||||
|libs.js | 572.545 | 468.224 | |
|
||||
|libs.js | 572.545 | 465.247 | |
|
||||
|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
|
||||
|
||||
|
|
|
|||
405
vendors/jua/jua.js
vendored
405
vendors/jua/jua.js
vendored
|
|
@ -1,102 +1,13 @@
|
|||
/* 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';
|
||||
|
||||
var
|
||||
Globals = {},
|
||||
Utils = {},
|
||||
$ = jQuery;
|
||||
|
||||
window = __webpack_require__(1),
|
||||
$ = __webpack_require__(3),
|
||||
|
||||
Globals = __webpack_require__(2)
|
||||
;
|
||||
Globals.iDefLimit = 20;
|
||||
|
||||
/**
|
||||
* @param {*} mValue
|
||||
|
|
@ -464,25 +375,6 @@
|
|||
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
|
||||
|
|
@ -520,10 +412,7 @@
|
|||
/**
|
||||
* @return {boolean}
|
||||
*/
|
||||
AjaxDriver.prototype.isDragAndDropSupported = function ()
|
||||
{
|
||||
return true;
|
||||
};
|
||||
AjaxDriver.prototype.isDragAndDropSupported = () => true;
|
||||
|
||||
/**
|
||||
* @param {string} sUid
|
||||
|
|
@ -696,236 +585,38 @@
|
|||
}
|
||||
};
|
||||
|
||||
module.exports = AjaxDriver;
|
||||
|
||||
}());
|
||||
|
||||
|
||||
/***/ },
|
||||
/* 6 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
|
||||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
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;
|
||||
function queue(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)
|
||||
}
|
||||
|
||||
/**
|
||||
* @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
|
||||
oForm = this.oForms[sUid],
|
||||
aHidden = Utils.getValue(this.oOptions, 'hidden', {}),
|
||||
fStartFunction = this.oJua.getEvent('onStart'),
|
||||
fCompleteFunction = this.oJua.getEvent('onComplete')
|
||||
;
|
||||
|
||||
if (oForm)
|
||||
{
|
||||
oForm.append($('<input type="hidden" />').attr('name', 'jua-post-type').val('iframe'));
|
||||
$.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);
|
||||
var c = {},
|
||||
d = 0,
|
||||
e = 0,
|
||||
f = -1,
|
||||
g, h, i = null,
|
||||
j = [],
|
||||
k = ()=>{};
|
||||
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()
|
||||
}
|
||||
|
||||
oForm.find('iframe').on('load', function () {
|
||||
|
||||
var
|
||||
bResult = false,
|
||||
oIframeDoc = null,
|
||||
oResult = {}
|
||||
;
|
||||
|
||||
if (fCompleteFunction)
|
||||
{
|
||||
try
|
||||
{
|
||||
oIframeDoc = this.contentDocument ? this.contentDocument: this.contentWindow.document;
|
||||
oResult = $.parseJSON(oIframeDoc.body.innerHTML);
|
||||
bResult = true;
|
||||
return c
|
||||
}, c.await = function (a) {
|
||||
return k = a, e || k(i, j), c
|
||||
}, c
|
||||
}
|
||||
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
|
||||
|
|
@ -938,12 +629,7 @@
|
|||
var
|
||||
self = this,
|
||||
|
||||
Driver = null,
|
||||
|
||||
window = __webpack_require__(1),
|
||||
$ = __webpack_require__(3),
|
||||
|
||||
queue = __webpack_require__(8)
|
||||
$ = jQuery
|
||||
;
|
||||
|
||||
self.bEnableDnD = true;
|
||||
|
|
@ -971,7 +657,6 @@
|
|||
'clickElement': false,
|
||||
'dragAndDropElement': false,
|
||||
'dragAndDropBodyElement': false,
|
||||
'disableAjaxUpload': false,
|
||||
'disableDragAndDrop': false,
|
||||
'disableMultiple': false,
|
||||
'disableDocumentDropPrevent': false,
|
||||
|
|
@ -986,10 +671,7 @@
|
|||
});
|
||||
}
|
||||
|
||||
Driver = (!Utils.getValue(self.oOptions, 'disableAjaxUpload', false) ?
|
||||
__webpack_require__(5) : __webpack_require__(6));
|
||||
|
||||
self.oDriver = new Driver(self, self.oOptions);
|
||||
self.oDriver = new AjaxDriver(self, self.oOptions);
|
||||
|
||||
self.oClickElement = Utils.getValue(self.oOptions, 'clickElement', null);
|
||||
|
||||
|
|
@ -1008,8 +690,7 @@
|
|||
this.oDriver.generateNewInput(this.oClickElement);
|
||||
}
|
||||
|
||||
if (this.oDriver.isDragAndDropSupported() && Utils.getValue(this.oOptions, 'dragAndDropElement', false) &&
|
||||
!Utils.getValue(this.oOptions, 'disableAjaxUpload', false))
|
||||
if (this.oDriver.isDragAndDropSupported() && Utils.getValue(this.oOptions, 'dragAndDropElement', false))
|
||||
{
|
||||
(function (self) {
|
||||
var
|
||||
|
|
@ -1307,16 +988,6 @@
|
|||
}
|
||||
};
|
||||
|
||||
module.exports = Jua;
|
||||
window.Jua = Jua;
|
||||
|
||||
}());
|
||||
|
||||
|
||||
/***/ },
|
||||
/* 8 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
|
||||
module.exports = queue;
|
||||
|
||||
/***/ }
|
||||
/******/ ]);
|
||||
})();
|
||||
|
|
|
|||
2
vendors/jua/jua.min.js
vendored
2
vendors/jua/jua.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue