From 9f73377a88319673512eea8e34e1bdb726e0eb66 Mon Sep 17 00:00:00 2001 From: djmaze Date: Sat, 15 Aug 2020 20:11:56 +0200 Subject: [PATCH] Bugfix: compose e-mail file upload failed to wrong conversion to ES2015 Must be a 39 degrees workplace failure --- vendors/jua/jua.js | 27 ++++++++++----------------- vendors/jua/jua.min.js | 2 +- 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/vendors/jua/jua.js b/vendors/jua/jua.js index 909b231af..e4127dc25 100644 --- a/vendors/jua/jua.js +++ b/vendors/jua/jua.js @@ -31,20 +31,15 @@ Array.from(aItems).forEach(oItem => { if (oItem) { - if (!bUseLimit) { - if (0 <= --iLimit) - { - oFile = Utils.getDataFromFile(oItem); - oFile && fFileCallback(oFile); - } - } - else if (!bCallLimit) + if (!bUseLimit || 0 <= --iLimit) { - if (0 > iLimit && fLimitCallback) - { - bCallLimit = true; - fLimitCallback(iInputLimit); - } + oFile = Utils.getDataFromFile(oItem); + oFile && fFileCallback(oFile); + } + else if (bUseLimit && !bCallLimit && 0 > iLimit && fLimitCallback) + { + bCallLimit = true; + fLimitCallback(iInputLimit); } } }); @@ -436,13 +431,11 @@ } }) .on('change', function () { - Utils.getDataFromInput(this, function (oFile) { + Utils.getDataFromInput(this, oFile => { self.oJua.addNewFile(oFile); self.generateNewInput(oClickElement); - setTimeout(function () { - oLabel.remove(); - }, 10); + setTimeout(() => oLabel.remove(), 10); }, Utils.getValue(self.oOptions, 'multipleSizeLimit', iDefLimit), self.oJua.getEvent('onLimitReached') diff --git a/vendors/jua/jua.min.js b/vendors/jua/jua.min.js index bb1f5fa99..45e1022fb 100644 --- a/vendors/jua/jua.min.js +++ b/vendors/jua/jua.min.js @@ -1,2 +1,2 @@ /* RainLoop Webmail (c) RainLoop Team | MIT */ -(()=>{"use strict";var e=20,t=jQuery;const n=e=>void 0!==e,o=(t,o,i,r)=>{if(t&&t.length){var l,u,s=null,p=!1;i=n(i)?parseInt(i||0,10):e,l=i,u=0{e&&(u?p||0>i&&r&&(p=!0,r(l)):0<=--i&&(s=a.getDataFromFile(e))&&o(s))})}};var a={contains:(e,t)=>!(!e||!t)&&(e===t||(e.contains?e.contains(t):!!t.compareDocumentPosition&&!!(8&t.compareDocumentPosition(e)))),mainClearTimeout:e=>{0(e=e&&(e.originalEvent?e.originalEvent:e)||window.event).dataTransfer?e:null,getValue:(e,t,o)=>e&&t&&n(e[t])?e[t]:o,scopeBind:(e,t)=>(...o)=>e.apply(n(t)?t:null,Array.prototype.slice.call(o)),getNewUid:()=>"jua-uid-"+(e=>{var t="";for(e=n(e)?parseInt(e||0,10):32;e--;)t+="0123456789abcdefghijklmnopqrstuvwxyz".substr(Math.round(36*Math.random()),1);return t})(16)+"-"+(new Date).getTime().toString(),getDataFromFile:e=>{var t=n(e.fileName)?e.fileName:n(e.name)?e.name:null,o=n(e.fileSize)?e.fileSize:n(e.size)?e.size:null,a=n(e.type)?e.type:null;return"/"===t.charAt(0)&&(t=t.substr(1)),a||0!==o?{FileName:t,Size:o,Type:a,Folder:"",File:e}:null},getDataFromInput:(e,t,n,a)=>{var i=e&&0{var t=!1;if(e&&e.dataTransfer&&e.dataTransfer.types&&e.dataTransfer.types.length)for(var n=0,o=e.dataTransfer.types.length;n{var r=null;(e=a.getEvent(e))&&a.eventContainsFiles(e)&&(r=a.getValue(e,"files",null)||(e.dataTransfer?a.getValue(e.dataTransfer,"files",null):null),o(r,t,n,i))},createNextLabel:()=>t('').css({opacity:0}),createNextInput:()=>t(''),getNewInput:(e,t)=>{e=n(e)?e.toString():"";var o=a.createNextInput();return 0t.isFunction(e)?e.apply(null,Array.isArray(n)?n:[]).toString():e.toString()};class i{constructor(e,t){this.oXhrs={},this.oUids={},this.oJua=e,this.oOptions=t}regTaskUid(e){this.oUids[e]=!0}uploadTask(e,o,i){if(!1===this.oUids[e]||!o||!o.File)return i(null,e),!1;try{var r=this,l=new XMLHttpRequest,u=new FormData,s=a.getValue(this.oOptions,"action",""),p=a.getValue(this.oOptions,"hidden",{}),c=this.oJua.getEvent("onStart"),d=this.oJua.getEvent("onComplete"),g=this.oJua.getEvent("onProgress");return l.open("POST",s,!0),g&&l.upload&&(l.upload.onprogress=function(t){t&&t.lengthComputable&&n(t.loaded)&&n(t.total)&&g(e,t.loaded,t.total)}),l.onreadystatechange=function(){if(4===l.readyState&&200===l.status){if(d){var t=!1,o=null;try{o=JSON.parse(l.responseText),t=!0}catch(e){o=null}d(e,t,o)}n(r.oXhrs[e])&&(r.oXhrs[e]=null),i(null,e)}else 4===l.readyState&&(d(e,!1,null),i(null,e))},c&&c(e),u.append("jua-post-type","ajax"),u.append(a.getValue(this.oOptions,"name","juaFile"),o.File),t.each(p,function(e,t){u.append(e,a.getStringOrCallFunction(t,[o]))}),l.send(u),this.oXhrs[e]=l,!0}catch(e){}return i(null,e),!1}generateNewInput(n){var o=this,i=null,r=null;n&&(r=a.getNewInput("",!a.getValue(this.oOptions,"disableMultiple",!1)),(i=a.createNextLabel()).append(r),t(n).append(i),r.on("click",function(){var e=o.oJua.getEvent("onDialog");e&&e()}).on("change",function(){a.getDataFromInput(this,function(e){o.oJua.addNewFile(e),o.generateNewInput(n),setTimeout(function(){i.remove()},10)},a.getValue(o.oOptions,"multipleSizeLimit",e),o.oJua.getEvent("onLimitReached"))}))}cancel(e){if(this.oUids[e]=!1,this.oXhrs[e]){try{this.oXhrs[e].abort&&this.oXhrs[e].abort()}catch(e){}this.oXhrs[e]=null}}}i.prototype.oXhrs={},i.prototype.oUids={},i.prototype.oJua=null,i.prototype.oOptions={};class r{constructor(t){t=n(t)?t:{};var o=this,r=jQuery;o.bEnableDnD=!0,o.oEvents={onDialog:null,onSelect:null,onStart:null,onComplete:null,onCompleteAll:null,onProgress:null,onDragEnter:null,onDragLeave:null,onDrop:null,onBodyDragEnter:null,onBodyDragLeave:null,onLimitReached:null},o.oOptions={action:"",name:"",hidden:{},queueSize:10,clickElement:!1,dragAndDropElement:!1,dragAndDropBodyElement:!1,disableDragAndDrop:!1,disableMultiple:!1,disableDocumentDropPrevent:!1,multipleSizeLimit:50},Object.entries(t).forEach(([e,t])=>o.oOptions[e]=t),o.oQueue=function(e){function t(){if(n&&i{};return arguments.length<1&&(e=1/0),a.defer=function(){if(!u){var e=arguments;e.index=++l,o?(o.next=e,o=o.next):n=o=e,++r,t()}return a},a.await=function(e){return p=e,r||p(u,s),a},a}(parseInt(a.getValue(o.oOptions,"queueSize",10)||0,10)),o.runEvent("onCompleteAll")&&o.oQueue.await(function(){o.runEvent("onCompleteAll")}),o.oDriver=new i(o,o.oOptions),o.oClickElement=a.getValue(o.oOptions,"clickElement",null),o.oClickElement&&(r(o.oClickElement).css({position:"relative",overflow:"hidden"}),"inline"===r(this.oClickElement).css("display")&&r(this.oClickElement).css("display","inline-block"),this.oDriver.generateNewInput(this.oClickElement)),a.getValue(this.oOptions,"dragAndDropElement",!1)?function(t){var n=r(document),o=r(a.getValue(t.oOptions,"dragAndDropBodyElement",!1)||n),i=a.getValue(t.oOptions,"dragAndDropElement",!1);i&&(a.getValue(t.oOptions,"disableDocumentDropPrevent",!1)||n.on("dragover",function(e){if(t.bEnableDnD&&e&&(e=a.getEvent(e))&&e.dataTransfer&&a.eventContainsFiles(e))try{e.dataTransfer.dropEffect="none",e.preventDefault()}catch(e){}}),o&&o[0]&&o.on("dragover",function(e){t.bEnableDnD&&e&&a.mainClearTimeout(t.iDocTimer)}).on("dragenter",function(e){t.bEnableDnD&&e&&(e=a.getEvent(e))&&a.eventContainsFiles(e)&&(a.mainClearTimeout(t.iDocTimer),e.preventDefault(),t.runEvent("onBodyDragEnter",[e]))}).on("dragleave",function(e){t.bEnableDnD&&e&&(e=a.getEvent(e))&&(a.mainClearTimeout(t.iDocTimer),t.iDocTimer=setTimeout(function(){t.runEvent("onBodyDragLeave",[e])},200))}).on("drop",function(e){if(t.bEnableDnD&&e&&(e=a.getEvent(e))){var n=a.eventContainsFiles(e);return n&&e.preventDefault(),t.runEvent("onBodyDragLeave",[e]),!n}return!1}),r(i).on("dragenter",function(e){t.bEnableDnD&&e&&(e=a.getEvent(e))&&a.eventContainsFiles(e)&&(a.mainClearTimeout(t.iDocTimer),e.preventDefault(),t.runEvent("onDragEnter",[i,e]))}).on("dragover",function(e){if(t.bEnableDnD&&e&&(e=a.getEvent(e))&&e.dataTransfer&&a.eventContainsFiles(e))try{var n=e.dataTransfer.effectAllowed;a.mainClearTimeout(t.iDocTimer),e.dataTransfer.dropEffect="move"===n||"linkMove"===n?"move":"copy",e.stopPropagation(),e.preventDefault(),o.trigger("dragover",e)}catch(e){}}).on("dragleave",function(e){if(t.bEnableDnD&&e&&(e=a.getEvent(e))){var n=document.elementFromPoint?document.elementFromPoint(e.clientX,e.clientY):null;if(n&&a.contains(this,n))return;a.mainClearTimeout(t.iDocTimer),t.runEvent("onDragLeave",[i,e])}}).on("drop",function(n){t.bEnableDnD&&n&&(n=a.getEvent(n))&&a.eventContainsFiles(n)&&(n.preventDefault(),a.getDataFromDragEvent(n,function(e){e&&(t.runEvent("onDrop",[e,n]),t.addNewFile(e),a.mainClearTimeout(t.iDocTimer))},a.getValue(t.oOptions,"multipleSizeLimit",e),t.getEvent("onLimitReached"))),t.runEvent("onDragLeave",[n])}))}(o):o.bEnableDnD=!1}on(e,t){return this.oEvents[e]=t,this}runEvent(e,t){this.oEvents[e]&&this.oEvents[e].apply(null,t||[])}getEvent(e){return this.oEvents[e]||null}cancel(e){this.oDriver.cancel(e)}setDragAndDropEnabledStatus(e){this.bEnableDnD=!!e}addNewFile(e){this.addFile(a.getNewUid(),e)}addFile(e,t){var n=this.getEvent("onSelect");!t||n&&!1===n(e,t)?this.oDriver.cancel(e):(this.oDriver.regTaskUid(e),this.oQueue.defer(a.scopeBind(this.oDriver.uploadTask,this.oDriver),e,t))}}r.prototype.bEnableDnD=!0,r.prototype.iDocTimer=0,r.prototype.oOptions={},r.prototype.oEvents={},r.prototype.oQueue=null,r.prototype.oDriver=null,window.Jua=r})(); +(()=>{"use strict";var e=20,t=jQuery;const n=e=>void 0!==e,o=(t,o,i,r)=>{if(t&&t.length){var l,u,s=null,p=!1;i=n(i)?parseInt(i||0,10):e,l=i,u=0{e&&(!u||0<=--i?(s=a.getDataFromFile(e))&&o(s):u&&!p&&0>i&&r&&(p=!0,r(l)))})}};var a={contains:(e,t)=>!(!e||!t)&&(e===t||(e.contains?e.contains(t):!!t.compareDocumentPosition&&!!(8&t.compareDocumentPosition(e)))),mainClearTimeout:e=>{0(e=e&&(e.originalEvent?e.originalEvent:e)||window.event).dataTransfer?e:null,getValue:(e,t,o)=>e&&t&&n(e[t])?e[t]:o,scopeBind:(e,t)=>(...o)=>e.apply(n(t)?t:null,Array.prototype.slice.call(o)),getNewUid:()=>"jua-uid-"+(e=>{var t="";for(e=n(e)?parseInt(e||0,10):32;e--;)t+="0123456789abcdefghijklmnopqrstuvwxyz".substr(Math.round(36*Math.random()),1);return t})(16)+"-"+(new Date).getTime().toString(),getDataFromFile:e=>{var t=n(e.fileName)?e.fileName:n(e.name)?e.name:null,o=n(e.fileSize)?e.fileSize:n(e.size)?e.size:null,a=n(e.type)?e.type:null;return"/"===t.charAt(0)&&(t=t.substr(1)),a||0!==o?{FileName:t,Size:o,Type:a,Folder:"",File:e}:null},getDataFromInput:(e,t,n,a)=>{var i=e&&0{var t=!1;if(e&&e.dataTransfer&&e.dataTransfer.types&&e.dataTransfer.types.length)for(var n=0,o=e.dataTransfer.types.length;n{var r=null;(e=a.getEvent(e))&&a.eventContainsFiles(e)&&(r=a.getValue(e,"files",null)||(e.dataTransfer?a.getValue(e.dataTransfer,"files",null):null),o(r,t,n,i))},createNextLabel:()=>t('').css({opacity:0}),createNextInput:()=>t(''),getNewInput:(e,t)=>{e=n(e)?e.toString():"";var o=a.createNextInput();return 0t.isFunction(e)?e.apply(null,Array.isArray(n)?n:[]).toString():e.toString()};class i{constructor(e,t){this.oXhrs={},this.oUids={},this.oJua=e,this.oOptions=t}regTaskUid(e){this.oUids[e]=!0}uploadTask(e,o,i){if(!1===this.oUids[e]||!o||!o.File)return i(null,e),!1;try{var r=this,l=new XMLHttpRequest,u=new FormData,s=a.getValue(this.oOptions,"action",""),p=a.getValue(this.oOptions,"hidden",{}),c=this.oJua.getEvent("onStart"),d=this.oJua.getEvent("onComplete"),g=this.oJua.getEvent("onProgress");return l.open("POST",s,!0),g&&l.upload&&(l.upload.onprogress=function(t){t&&t.lengthComputable&&n(t.loaded)&&n(t.total)&&g(e,t.loaded,t.total)}),l.onreadystatechange=function(){if(4===l.readyState&&200===l.status){if(d){var t=!1,o=null;try{o=JSON.parse(l.responseText),t=!0}catch(e){o=null}d(e,t,o)}n(r.oXhrs[e])&&(r.oXhrs[e]=null),i(null,e)}else 4===l.readyState&&(d(e,!1,null),i(null,e))},c&&c(e),u.append("jua-post-type","ajax"),u.append(a.getValue(this.oOptions,"name","juaFile"),o.File),t.each(p,function(e,t){u.append(e,a.getStringOrCallFunction(t,[o]))}),l.send(u),this.oXhrs[e]=l,!0}catch(e){}return i(null,e),!1}generateNewInput(n){var o=this,i=null,r=null;n&&(r=a.getNewInput("",!a.getValue(this.oOptions,"disableMultiple",!1)),(i=a.createNextLabel()).append(r),t(n).append(i),r.on("click",function(){var e=o.oJua.getEvent("onDialog");e&&e()}).on("change",function(){a.getDataFromInput(this,e=>{o.oJua.addNewFile(e),o.generateNewInput(n),setTimeout(()=>i.remove(),10)},a.getValue(o.oOptions,"multipleSizeLimit",e),o.oJua.getEvent("onLimitReached"))}))}cancel(e){if(this.oUids[e]=!1,this.oXhrs[e]){try{this.oXhrs[e].abort&&this.oXhrs[e].abort()}catch(e){}this.oXhrs[e]=null}}}i.prototype.oXhrs={},i.prototype.oUids={},i.prototype.oJua=null,i.prototype.oOptions={};class r{constructor(t){t=n(t)?t:{};var o=this,r=jQuery;o.bEnableDnD=!0,o.oEvents={onDialog:null,onSelect:null,onStart:null,onComplete:null,onCompleteAll:null,onProgress:null,onDragEnter:null,onDragLeave:null,onDrop:null,onBodyDragEnter:null,onBodyDragLeave:null,onLimitReached:null},o.oOptions={action:"",name:"",hidden:{},queueSize:10,clickElement:!1,dragAndDropElement:!1,dragAndDropBodyElement:!1,disableDragAndDrop:!1,disableMultiple:!1,disableDocumentDropPrevent:!1,multipleSizeLimit:50},Object.entries(t).forEach(([e,t])=>o.oOptions[e]=t),o.oQueue=function(e){function t(){if(n&&i{};return arguments.length<1&&(e=1/0),a.defer=function(){if(!u){var e=arguments;e.index=++l,o?(o.next=e,o=o.next):n=o=e,++r,t()}return a},a.await=function(e){return p=e,r||p(u,s),a},a}(parseInt(a.getValue(o.oOptions,"queueSize",10)||0,10)),o.runEvent("onCompleteAll")&&o.oQueue.await(function(){o.runEvent("onCompleteAll")}),o.oDriver=new i(o,o.oOptions),o.oClickElement=a.getValue(o.oOptions,"clickElement",null),o.oClickElement&&(r(o.oClickElement).css({position:"relative",overflow:"hidden"}),"inline"===r(this.oClickElement).css("display")&&r(this.oClickElement).css("display","inline-block"),this.oDriver.generateNewInput(this.oClickElement)),a.getValue(this.oOptions,"dragAndDropElement",!1)?function(t){var n=r(document),o=r(a.getValue(t.oOptions,"dragAndDropBodyElement",!1)||n),i=a.getValue(t.oOptions,"dragAndDropElement",!1);i&&(a.getValue(t.oOptions,"disableDocumentDropPrevent",!1)||n.on("dragover",function(e){if(t.bEnableDnD&&e&&(e=a.getEvent(e))&&e.dataTransfer&&a.eventContainsFiles(e))try{e.dataTransfer.dropEffect="none",e.preventDefault()}catch(e){}}),o&&o[0]&&o.on("dragover",function(e){t.bEnableDnD&&e&&a.mainClearTimeout(t.iDocTimer)}).on("dragenter",function(e){t.bEnableDnD&&e&&(e=a.getEvent(e))&&a.eventContainsFiles(e)&&(a.mainClearTimeout(t.iDocTimer),e.preventDefault(),t.runEvent("onBodyDragEnter",[e]))}).on("dragleave",function(e){t.bEnableDnD&&e&&(e=a.getEvent(e))&&(a.mainClearTimeout(t.iDocTimer),t.iDocTimer=setTimeout(function(){t.runEvent("onBodyDragLeave",[e])},200))}).on("drop",function(e){if(t.bEnableDnD&&e&&(e=a.getEvent(e))){var n=a.eventContainsFiles(e);return n&&e.preventDefault(),t.runEvent("onBodyDragLeave",[e]),!n}return!1}),r(i).on("dragenter",function(e){t.bEnableDnD&&e&&(e=a.getEvent(e))&&a.eventContainsFiles(e)&&(a.mainClearTimeout(t.iDocTimer),e.preventDefault(),t.runEvent("onDragEnter",[i,e]))}).on("dragover",function(e){if(t.bEnableDnD&&e&&(e=a.getEvent(e))&&e.dataTransfer&&a.eventContainsFiles(e))try{var n=e.dataTransfer.effectAllowed;a.mainClearTimeout(t.iDocTimer),e.dataTransfer.dropEffect="move"===n||"linkMove"===n?"move":"copy",e.stopPropagation(),e.preventDefault(),o.trigger("dragover",e)}catch(e){}}).on("dragleave",function(e){if(t.bEnableDnD&&e&&(e=a.getEvent(e))){var n=document.elementFromPoint?document.elementFromPoint(e.clientX,e.clientY):null;if(n&&a.contains(this,n))return;a.mainClearTimeout(t.iDocTimer),t.runEvent("onDragLeave",[i,e])}}).on("drop",function(n){t.bEnableDnD&&n&&(n=a.getEvent(n))&&a.eventContainsFiles(n)&&(n.preventDefault(),a.getDataFromDragEvent(n,function(e){e&&(t.runEvent("onDrop",[e,n]),t.addNewFile(e),a.mainClearTimeout(t.iDocTimer))},a.getValue(t.oOptions,"multipleSizeLimit",e),t.getEvent("onLimitReached"))),t.runEvent("onDragLeave",[n])}))}(o):o.bEnableDnD=!1}on(e,t){return this.oEvents[e]=t,this}runEvent(e,t){this.oEvents[e]&&this.oEvents[e].apply(null,t||[])}getEvent(e){return this.oEvents[e]||null}cancel(e){this.oDriver.cancel(e)}setDragAndDropEnabledStatus(e){this.bEnableDnD=!!e}addNewFile(e){this.addFile(a.getNewUid(),e)}addFile(e,t){var n=this.getEvent("onSelect");!t||n&&!1===n(e,t)?this.oDriver.cancel(e):(this.oDriver.regTaskUid(e),this.oQueue.defer(a.scopeBind(this.oDriver.uploadTask,this.oDriver),e,t))}}r.prototype.bEnableDnD=!0,r.prototype.iDocTimer=0,r.prototype.oOptions={},r.prototype.oEvents={},r.prototype.oQueue=null,r.prototype.oDriver=null,window.Jua=r})();