mirror of
https://github.com/the-djmaze/snappymail.git
synced 2024-11-11 09:45:54 +08:00
3 lines
No EOL
14 KiB
JavaScript
3 lines
No EOL
14 KiB
JavaScript
/* 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(e){function t(o){if(n[o])return n[o].exports;var i=n[o]={exports:{},id:o,loaded:!1};return e[o].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){!function(){"use strict";n(1).Jua=n(7)}()},function(e){e.exports=window},function(e,t,n){!function(){"use strict";var t={};t.iDefLimit=20,t.bIsAjaxUploaderSupported=function(){var e=n(1),t=e.document.createElement("input");return t.type="file",!!("XMLHttpRequest"in e&&"multiple"in t&&"FormData"in e&&(new e.XMLHttpRequest).upload)}(),e.exports=t}()},function(e){e.exports=jQuery},function(e,t,n){!function(){"use strict";var t={},o=n(1),i=n(3),r=n(2);t.isUndefined=function(e){return"undefined"==typeof e},t.extend=function(e,t){if(t)for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);return e},t.contains=function(e,t){var n=!1;return e&&t&&(n=e===t?!0:e.contains?e.contains(t):t.compareDocumentPosition?!!(8&t.compareDocumentPosition(e)):!1),n},t.mainClearTimeout=function(e){e>0&&clearTimeout(e),e=0},t.getEvent=function(e){return e=e&&(e.originalEvent?e.originalEvent:e)||o.event,e.dataTransfer?e:null},t.getValue=function(e,n,o){return e&&n&&!t.isUndefined(e[n])?e[n]:o},t.setValue=function(e,t,n){e[t]=n},t.isNonEmptyArray=function(e){return e&&e.length&&0<e.length?!0:!1},t.pInt=function(e){return parseInt(e||0,10)},t.scopeBind=function(e,n){return function(){return e.apply(t.isUndefined(n)?null:n,Array.prototype.slice.call(arguments))}},t.fakeMd5=function(e){var n="",i="0123456789abcdefghijklmnopqrstuvwxyz";for(e=t.isUndefined(e)?32:t.pInt(e);n.length<e;)n+=i.substr(o.Math.round(o.Math.random()*i.length),1);return n},t.getNewUid=function(){return"jua-uid-"+t.fakeMd5(16)+"-"+(new o.Date).getTime().toString()},t.getDataFromFile=function(e,n){var o=t.isUndefined(e.fileName)?t.isUndefined(e.name)?null:e.name:e.fileName,i=t.isUndefined(e.fileSize)?t.isUndefined(e.size)?null:e.size:e.fileSize,r=t.isUndefined(e.type)?null:e.type;return{FileName:o,Size:i,Type:r,Folder:t.isUndefined(n)?"":n,File:e}},t.getDataFromFiles=function(e,n,o,i,a,l){var u=0,s=0,p=0,d=null,c=null,f=!1,g=!1,m=function(e,n,o,r){if(e&&!t.isUndefined(e.name))if(n=n||"",e.isFile)e.file(function(e){!f||0<=--a?o(t.getDataFromFile(e,n)):f&&!g&&0>a&&l&&(g=!0,l(u))});else if(i&&e.isDirectory&&e.createReader){var s=e.createReader(),p=0,d=0;s&&s.readEntries&&s.readEntries(function(i){if(i&&t.isNonEmptyArray(i))for(p=0,d=i.length;d>p;p++)m(i[p],n+e.name+"/",o,r)})}};if(i=t.isUndefined(i)?!0:!!i,o=t.isUndefined(o)?!1:!!o,a=t.isUndefined(a)?r.iDefLimit:t.pInt(a),u=a,f=a>0,e=e&&0<e.length?e:null)for(p=0,s=e.length;s>p;p++)d=e[p],d&&(o?"file"===d.kind&&d.webkitGetAsEntry&&(c=d.webkitGetAsEntry(),c&&m(c,"",n,l)):!f||0<=--a?n(t.getDataFromFile(d)):f&&!g&&0>a&&l&&(g=!0,l(u)))},t.getDataFromInput=function(e,n,o,i){var r=e&&e.files&&0<e.files.length?e.files:null;r?t.getDataFromFiles(r,n,!1,!1,o,i):n({FileName:e.value.split("\\").pop().split("/").pop(),Size:null,Type:null,Folder:"",File:null})},t.eventContainsFiles=function(e){var t=!1;if(e&&e.dataTransfer&&e.dataTransfer.types&&e.dataTransfer.types.length)for(var n=0,o=e.dataTransfer.types.length;o>n;n++)if("files"===e.dataTransfer.types[n].toLowerCase()){t=!0;break}return t},t.getDataFromDragEvent=function(e,n,o,i,r){var a=null,l=null;e=t.getEvent(e),e&&(a=(e.dataTransfer?t.getValue(e.dataTransfer,"items",null):null)||t.getValue(e,"items",null),a&&0<a.length&&a[0]&&a[0].webkitGetAsEntry?t.getDataFromFiles(a,n,!0,r,o,i):t.eventContainsFiles(e)&&(l=t.getValue(e,"files",null)||(e.dataTransfer?t.getValue(e.dataTransfer,"files",null):null),l&&0<l.length&&t.getDataFromFiles(l,n,!1,!1,o,i)))},t.createNextLabel=function(){return i('<label style="position: absolute; background-color:#fff; right: 0px; top: 0px; left: 0px; bottom: 0px; margin: 0px; padding: 0px; cursor: pointer;"></label>').css({opacity:0})},t.createNextInput=function(){return i('<input type="file" tabindex="-1" hidefocus="hidefocus" style="position: absolute; left: -9999px;" />')},t.getNewInput=function(e,n){e=t.isUndefined(e)?"":e.toString();var o=t.createNextInput();return 0<e.length&&o.attr("name",e),(t.isUndefined(n)?!0:n)&&o.prop("multiple",!0),o},t.getStringOrCallFunction=function(e,t){return i.isFunction(e)?e.apply(null,i.isArray(t)?t:[]).toString():e.toString()},e.exports=t}()},function(e,t,n){!function(){"use strict";function t(e,t){this.oXhrs={},this.oUids={},this.oJua=e,this.oOptions=t}var o=n(3),i=n(2),r=n(4);t.prototype.oXhrs={},t.prototype.oUids={},t.prototype.oJua=null,t.prototype.oOptions={},t.prototype.isDragAndDropSupported=function(){return!0},t.prototype.regTaskUid=function(e){this.oUids[e]=!0},t.prototype.uploadTask=function(e,t,n){if(!1===this.oUids[e]||!t||!t.File)return n(null,e),!1;try{var i=this,a=new XMLHttpRequest,l=new FormData,u=r.getValue(this.oOptions,"action",""),s=r.getValue(this.oOptions,"hidden",{}),p=this.oJua.getEvent("onStart"),d=this.oJua.getEvent("onComplete"),c=this.oJua.getEvent("onProgress");return a.open("POST",u,!0),c&&a.upload&&(a.upload.onprogress=function(t){t&&t.lengthComputable&&!r.isUndefined(t.loaded)&&!r.isUndefined(t.total)&&c(e,t.loaded,t.total)}),a.onreadystatechange=function(){if(4===a.readyState&&200===a.status){if(d){var t=!1,l=null;try{l=o.parseJSON(a.responseText),t=!0}catch(u){l=null}d(e,t,l)}r.isUndefined(i.oXhrs[e])||(i.oXhrs[e]=null),n(null,e)}else 4===a.readyState&&(d(e,!1,null),n(null,e))},p&&p(e),l.append("jua-post-type","ajax"),l.append(r.getValue(this.oOptions,"name","juaFile"),t.File),o.each(s,function(e,n){l.append(e,r.getStringOrCallFunction(n,[t]))}),a.send(l),this.oXhrs[e]=a,!0}catch(f){}return n(null,e),!1},t.prototype.generateNewInput=function(e){var t=this,n=null,a=null;e&&(a=r.getNewInput("",!r.getValue(this.oOptions,"disableMultiple",!1)),n=r.createNextLabel(),n.append(a),o(e).append(n),a.on("click",function(){var e=t.oJua.getEvent("onDialog");e&&e()}).on("change",function(){r.getDataFromInput(this,function(o){t.oJua.addNewFile(o),t.generateNewInput(e),setTimeout(function(){n.remove()},10)},r.getValue(t.oOptions,"multipleSizeLimit",i.iDefLimit),t.oJua.getEvent("onLimitReached"))}))},t.prototype.cancel=function(e){if(this.oUids[e]=!1,this.oXhrs[e]){try{this.oXhrs[e].abort&&this.oXhrs[e].abort()}catch(t){}this.oXhrs[e]=null}},e.exports=t}()},function(e,t,n){!function(){"use strict";function t(e,t){this.oUids={},this.oForms={},this.oJua=e,this.oOptions=t}var o=n(1),i=n(3),r=n(2),a=n(4);t.prototype.oUids={},t.prototype.oForms={},t.prototype.oJua=null,t.prototype.oOptions={},t.prototype.isDragAndDropSupported=function(){return!1},t.prototype.regTaskUid=function(e){this.oUids[e]=!0},t.prototype.uploadTask=function(e,t,n){if(!1===this.oUids[e])return n(null,e),!1;var r=this.oForms[e],l=a.getValue(this.oOptions,"hidden",{}),u=this.oJua.getEvent("onStart"),s=this.oJua.getEvent("onComplete");return r?(r.append(i('<input type="hidden" />').attr("name","jua-post-type").val("iframe")),i.each(l,function(e,n){r.append(i('<input type="hidden" />').attr("name",e).val(a.getStringOrCallFunction(n,[t])))}),r.trigger("submit"),u&&u(e),r.find("iframe").on("load",function(){var t=!1,a=null,l={};if(s){try{a=this.contentDocument?this.contentDocument:this.contentWindow.document,l=i.parseJSON(a.body.innerHTML),t=!0}catch(u){l={}}s(e,t,l)}n(null,e),o.setTimeout(function(){r.remove()},100)})):n(null,e),!0},t.prototype.generateNewInput=function(e){var t=this,n="",o=null,l=null,u=a.getValue(this.oOptions,"action",""),s=null;e&&(n=a.getNewUid(),o=a.getNewInput(a.getValue(this.oOptions,"name","juaFile"),!a.getValue(this.oOptions,"disableMultiple",!1)),s=i('<form action="'+u+'" target="iframe-'+n+'" method="POST" enctype="multipart/form-data" style="display: block; cursor: pointer;"></form>'),l=i('<iframe name="iframe-'+n+'" tabindex="-1" src="javascript:void(0);" style="position: absolute; top: -1000px; left: -1000px; cursor: pointer;" />').css({opacity:0}),s.append(a.createNextLabel().append(o)).append(l),i(e).append(s),this.oForms[n]=s,o.on("click",function(){var e=t.oJua.getEvent("onDialog");e&&e()}).on("change",function(){a.getDataFromInput(this,function(o){o&&(s.css({position:"absolute",top:-1e3,left:-1e3}),t.oJua.addFile(n,o),t.generateNewInput(e))},a.getValue(t.oOptions,"multipleSizeLimit",r.iDefLimit),t.oJua.getEvent("onLimitReached"))}))},t.prototype.cancel=function(e){this.oUids[e]=!1,this.oForms[e]&&(this.oForms[e].remove(),this.oForms[e]=!1)},e.exports=t}()},function(e,t,n){!function(){"use strict";function t(e){e=o.isUndefined(e)?{}:e;var t=this,r=n(1),a=n(3),l=n(8);t.bEnableDnD=!0,t.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},t.oOptions=o.extend({action:"",name:"",hidden:{},queueSize:10,clickElement:!1,dragAndDropElement:!1,dragAndDropBodyElement:!1,disableAjaxUpload:!1,disableFolderDragAndDrop:!0,disableDragAndDrop:!1,disableMultiple:!1,disableDocumentDropPrevent:!1,multipleSizeLimit:50},e),t.oQueue=l(o.pInt(o.getValue(t.oOptions,"queueSize",10))),t.runEvent("onCompleteAll")&&t.oQueue.await(function(){t.runEvent("onCompleteAll")}),t.oDriver=t.isAjaxUploaderSupported()&&!o.getValue(t.oOptions,"disableAjaxUpload",!1)?new(n(5))(t,t.oOptions):new(n(6))(t,t.oOptions),t.oClickElement=o.getValue(t.oOptions,"clickElement",null),t.oClickElement&&(a(t.oClickElement).css({position:"relative",overflow:"hidden"}),"inline"===a(this.oClickElement).css("display")&&a(this.oClickElement).css("display","inline-block"),this.oDriver.generateNewInput(this.oClickElement)),this.oDriver.isDragAndDropSupported()&&o.getValue(this.oOptions,"dragAndDropElement",!1)&&!o.getValue(this.oOptions,"disableAjaxUpload",!1)?!function(e){var t=a(r.document),n=a(o.getValue(e.oOptions,"dragAndDropBodyElement",!1)||t),l=o.getValue(e.oOptions,"dragAndDropElement",!1),u=function(t){if(e.bEnableDnD&&t&&(t=o.getEvent(t),t&&t.dataTransfer&&o.eventContainsFiles(t)))try{var i=t.dataTransfer.effectAllowed;o.mainClearTimeout(e.iDocTimer),t.dataTransfer.dropEffect="move"===i||"linkMove"===i?"move":"copy",t.stopPropagation(),t.preventDefault(),n.trigger("dragover",t)}catch(r){}},s=function(t){e.bEnableDnD&&t&&(t=o.getEvent(t),t&&o.eventContainsFiles(t)&&(t.preventDefault(),o.getDataFromDragEvent(t,function(n){n&&(e.runEvent("onDrop",[n,t]),e.addNewFile(n),o.mainClearTimeout(e.iDocTimer))},o.getValue(e.oOptions,"multipleSizeLimit",i.iDefLimit),e.getEvent("onLimitReached"),!o.getValue(e.oOptions,"disableFolderDragAndDrop",!0)))),e.runEvent("onDragLeave",[t])},p=function(t){e.bEnableDnD&&t&&(t=o.getEvent(t),t&&o.eventContainsFiles(t)&&(o.mainClearTimeout(e.iDocTimer),t.preventDefault(),e.runEvent("onDragEnter",[l,t])))},d=function(t){if(e.bEnableDnD&&t){if(t=o.getEvent(t)){var n=r.document.elementFromPoint?r.document.elementFromPoint(t.clientX,t.clientY):null;if(n&&o.contains(this,n))return;o.mainClearTimeout(e.iDocTimer),e.runEvent("onDragLeave",[l,t])}}else;};l&&(o.getValue(e.oOptions,"disableDocumentDropPrevent",!1)||t.on("dragover",function(t){if(e.bEnableDnD&&t&&(t=o.getEvent(t),t&&t.dataTransfer&&o.eventContainsFiles(t)))try{t.dataTransfer.dropEffect="none",t.preventDefault()}catch(n){}}),n&&n[0]&&n.on("dragover",function(t){e.bEnableDnD&&t&&o.mainClearTimeout(e.iDocTimer)}).on("dragenter",function(t){e.bEnableDnD&&t&&(t=o.getEvent(t),t&&o.eventContainsFiles(t)&&(o.mainClearTimeout(e.iDocTimer),t.preventDefault(),e.runEvent("onBodyDragEnter",[t])))}).on("dragleave",function(t){e.bEnableDnD&&t&&(t=o.getEvent(t),t&&(o.mainClearTimeout(e.iDocTimer),e.iDocTimer=setTimeout(function(){e.runEvent("onBodyDragLeave",[t])},200)))}).on("drop",function(t){if(e.bEnableDnD&&t&&(t=o.getEvent(t))){var n=o.eventContainsFiles(t);return n&&t.preventDefault(),e.runEvent("onBodyDragLeave",[t]),!n}return!1}),a(l).bind("dragenter",p).bind("dragover",u).bind("dragleave",d).bind("drop",s))}(t):t.bEnableDnD=!1,o.setValue(t,"on",t.on),o.setValue(t,"cancel",t.cancel),o.setValue(t,"isDragAndDropSupported",t.isDragAndDropSupported),o.setValue(t,"isAjaxUploaderSupported",t.isAjaxUploaderSupported),o.setValue(t,"setDragAndDropEnabledStatus",t.setDragAndDropEnabledStatus)}var o=n(4),i=n(2);t.prototype.bEnableDnD=!0,t.prototype.iDocTimer=0,t.prototype.oOptions={},t.prototype.oEvents={},t.prototype.oQueue=null,t.prototype.oDriver=null,t.prototype.on=function(e,t){return this.oEvents[e]=t,this},t.prototype.runEvent=function(e,t){this.oEvents[e]&&this.oEvents[e].apply(null,t||[])},t.prototype.getEvent=function(e){return this.oEvents[e]||null},t.prototype.cancel=function(e){this.oDriver.cancel(e)},t.prototype.isAjaxUploaderSupported=function(){return i.bIsAjaxUploaderSupported},t.prototype.setDragAndDropEnabledStatus=function(e){this.bEnableDnD=!!e},t.prototype.isDragAndDropSupported=function(){return this.oDriver.isDragAndDropSupported()},t.prototype.addNewFile=function(e){this.addFile(o.getNewUid(),e)},t.prototype.addFile=function(e,t){var n=this.getEvent("onSelect");!t||n&&!1===n(e,t)?this.oDriver.cancel(e):(this.oDriver.regTaskUid(e),this.oQueue.defer(o.scopeBind(this.oDriver.uploadTask,this.oDriver),e,t))},e.exports=t}()},function(e){e.exports=queue}]); |