Bugfix: somehow Jua minified was broken. Cleaned it up and it works again

This commit is contained in:
djmaze 2020-09-19 13:32:50 +02:00
parent a104287aa5
commit 1ec45a9f8e
2 changed files with 35 additions and 91 deletions

124
vendors/jua/jua.js vendored
View file

@ -79,15 +79,11 @@
eventContainsFiles = oEvent => eventContainsFiles = oEvent =>
{ {
if (oEvent.dataTransfer && oEvent.dataTransfer.types && oEvent.dataTransfer.types.length) { try {
let index = oEvent.dataTransfer.types.length; return oEvent.dataTransfer.types.includes('Files');
while (index--) { } catch (e) {
if (oEvent.dataTransfer.types[index].toLowerCase() === 'files') { return false;
return true;
}
}
} }
return false;
}; };
@ -122,13 +118,11 @@
/** /**
* @param {string} sUid * @param {string} sUid
* @param {?} oFileInfo * @param {?} oFileInfo
* @param {Function} fCallback
*/ */
uploadTask(sUid, oFileInfo, fCallback) uploadTask(sUid, oFileInfo)
{ {
if (false === this.oUids[sUid] || !oFileInfo || !oFileInfo['File']) if (false === this.oUids[sUid] || !oFileInfo || !oFileInfo['File'])
{ {
fCallback(null, sUid);
return false; return false;
} }
@ -184,23 +178,17 @@
{ {
self.oXhrs[sUid] = null; self.oXhrs[sUid] = null;
} }
fCallback(null, sUid);
} }
else else
{ {
if (4 === oXhr.readyState) if (4 === oXhr.readyState)
{ {
fCompleteFunction(sUid, false, null); fCompleteFunction(sUid, false, null);
fCallback(null, sUid);
} }
} }
}; };
if (fStartFunction) fStartFunction && fStartFunction(sUid);
{
fStartFunction(sUid);
}
oFormData.append('jua-post-type', 'ajax'); oFormData.append('jua-post-type', 'ajax');
oFormData.append(this.oOptions.name, oFileInfo['File']); oFormData.append(this.oOptions.name, oFileInfo['File']);
@ -215,9 +203,9 @@
} }
catch (oError) catch (oError)
{ {
console.error(oError)
} }
fCallback(null, sUid);
return false; return false;
} }
@ -277,6 +265,7 @@
} }
catch (oError) catch (oError)
{ {
console.error(oError);
} }
this.oXhrs[sUid] = null; this.oXhrs[sUid] = null;
@ -284,58 +273,26 @@
} }
} }
/** class Queue extends Array
* @type {Object} {
*/ constructor(limit) {
AjaxDriver.prototype.oXhrs = {}; super();
this.limit = parseInt(limit || 0, 10);
/** }
* @type {Object} push(fn, ...args) {
*/ if (this.limit > this.length) {
AjaxDriver.prototype.oUids = {}; super.push([fn, args]);
this.call();
/**
* @type {?Jua}
*/
AjaxDriver.prototype.oJua = null;
/**
* @type {Object}
*/
AjaxDriver.prototype.oOptions = {};
function queue(a) {
function l() {
if (g && d < a) {
let 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)
} }
} }
let c = {}, call() {
d = 0, if (!this.running) {
e = 0, this.running = true;
f = -1, let f;
g, h, i = null, while ((f = this.shift())) f[0](...f[1]);
j = [], this.running = false;
k = ()=>{};
return arguments.length < 1 && (a = Infinity), c.defer = function () {
if (!i) {
let 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
} }
/** /**
@ -369,7 +326,7 @@
multipleSizeLimit: iDefLimit multipleSizeLimit: iDefLimit
}, oOptions || {}); }, oOptions || {});
self.oQueue = queue(parseInt(oOptions.queueSize || 0, 10)); self.oQueue = new Queue(oOptions.queueSize);
self.oDriver = new AjaxDriver(self, oOptions); self.oDriver = new AjaxDriver(self, oOptions);
@ -381,7 +338,7 @@
el.style.display = 'inline-block'; el.style.display = 'inline-block';
} }
this.oDriver.generateNewInput(el); self.oDriver.generateNewInput(el);
} }
el = oOptions.dragAndDropElement; el = oOptions.dragAndDropElement;
@ -399,7 +356,9 @@
oEvent.dataTransfer.dropEffect = 'none'; oEvent.dataTransfer.dropEffect = 'none';
oEvent.preventDefault(); oEvent.preventDefault();
} }
catch (oExc) {} catch (oExc) {
console.error(oExc);
}
} }
}); });
} }
@ -455,10 +414,10 @@
oEvent.stopPropagation(); oEvent.stopPropagation();
oEvent.preventDefault(); oEvent.preventDefault();
oBigDropZone && oBigDropZone.dispatchEvent(oEvent);
} }
catch (oExc) {} catch (oExc) {
console.error(oExc);
}
} }
}, },
dragleave: oEvent => { dragleave: oEvent => {
@ -556,7 +515,7 @@
if (oFileInfo && (!fOnSelect || (false !== fOnSelect(sUid, oFileInfo)))) if (oFileInfo && (!fOnSelect || (false !== fOnSelect(sUid, oFileInfo))))
{ {
this.oDriver.regTaskUid(sUid); this.oDriver.regTaskUid(sUid);
this.oQueue.defer((...args) => this.oDriver.uploadTask(...args), sUid, oFileInfo); this.oQueue.push((...args) => this.oDriver.uploadTask(...args), sUid, oFileInfo);
} }
else else
{ {
@ -579,21 +538,6 @@
} }
}; };
/**
* @type {Object}
*/
Jua.prototype.oEvents = {};
/**
* @type {?Object}
*/
Jua.prototype.oQueue = null;
/**
* @type {?Object}
*/
Jua.prototype.oDriver = null;
window.Jua = Jua; window.Jua = Jua;
})(); })();

File diff suppressed because one or more lines are too long