2020-07-27 22:58:04 +08:00
|
|
|
(()=>{"use strict";var e={},n={},t=jQuery;function o(e,n){this.oXhrs={},this.oUids={},this.oJua=e,this.oOptions=n}function i(t){t=n.isUndefined(t)?{}:t;var i=this,r=jQuery;i.bEnableDnD=!0,i.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},i.oOptions=n.extend({action:"",name:"",hidden:{},queueSize:10,clickElement:!1,dragAndDropElement:!1,dragAndDropBodyElement:!1,disableDragAndDrop:!1,disableMultiple:!1,disableDocumentDropPrevent:!1,multipleSizeLimit:50},t),i.oQueue=function(e){function n(){if(t&&r<e){var i=t,l=i[0],d=Array.prototype.slice.call(i,1),c=i.index;t=t===o?o=null:t.next,++r,d.push(function(e,i){--r,u||(e?a&&p(u=e,a=s=t=o=null):(s[c]=i,--a?n():p(null,s)))}),l.apply(null,d)}}var t,o,i={},r=0,a=0,l=-1,u=null,s=[],p=()=>{};return arguments.length<1&&(e=1/0),i.defer=function(){if(!u){var e=arguments;e.index=++l,o?(o.next=e,o=o.next):t=o=e,++a,n()}return i},i.await=function(e){return p=e,a||p(u,s),i},i}(n.pInt(n.getValue(i.oOptions,"queueSize",10))),i.runEvent("onCompleteAll")&&i.oQueue.await(function(){i.runEvent("onCompleteAll")}),i.oDriver=new o(i,i.oOptions),i.oClickElement=n.getValue(i.oOptions,"clickElement",null),i.oClickElement&&(r(i.oClickElement).css({position:"relative",overflow:"hidden"}),"inline"===r(this.oClickElement).css("display")&&r(this.oClickElement).css("display","inline-block"),this.oDriver.generateNewInput(this.oClickElement)),this.oDriver.isDragAndDropSupported()&&n.getValue(this.oOptions,"dragAndDropElement",!1)?function(t){var o=r(window.document),i=r(n.getValue(t.oOptions,"dragAndDropBodyElement",!1)||o),a=n.getValue(t.oOptions,"dragAndDropElement",!1);a&&(n.getValue(t.oOptions,"disableDocumentDropPrevent",!1)||o.on("dragover",function(e){if(t.bEnableDnD&&e&&(e=n.getEvent(e))&&e.dataTransfer&&n.eventContainsFiles(e))try{e.dataTransfer.dropEffect="none",e.preventDefault()}catch(e){}}),i&&i[0]&&i.on("dragover",function(e){t.bEnableDnD&&e&&n.mainClearTimeout(t.iDocTimer)}).on("dragenter",function(e){t.bEnableDnD&&e&&(e=n.getEvent(e))&&n.eventContainsFiles(e)&&(n.mainClearTimeout(t.iDocTimer),e.preventDefault(),t.runEvent("onBodyDragEnter",[e]))}).on("dragleave",function(e){t.bEnableDnD&&e&&(e=n.getEvent(e))&&(n.mainClearTimeout(t.iDocTimer),t.iDocTimer=setTimeout(function(){t.runEvent("onBodyDragLeave",[e])},200))}).on("drop",function(e){if(t.bEnableDnD&&e&&(e=n.getEvent(e))){var o=n.eventContainsFiles(e);return o&&e.preventDefault(),t.runEvent("onBodyDragLeave",[e]),!o}return!1}),r(a).bind("dragenter",function(e){t.bEnableDnD&&e&&(e=n.getEvent(e))&&n.eventContainsFiles(e)&&(n.mainClearTimeout(t.iDocTimer),e.preventDefault(),t.runEvent("onDragEnter",[a,e]))}).bind("dragover",function(e){if(t.bEnableDnD&&e&&(e=n.getEvent(e))&&e.dataTransfer&&n.eventContainsFiles(e))try{var o=e.dataTransfer.effectAllowed;n.mainClearTimeout(t.iDocTimer),e.dataTransfer.dropEffect="move"===o||"linkMove"===o?"move":"copy",e.stopPropagation(),e.preventDefault(),i.trigger("dragover",e)}catch(e){}}).bind("dragleave",function(e){if(t.bEnableDnD&&e&&(e=n.getEvent(e))){var o=window.document.elementFromPoint?window.document.elementFromPoint(e.clientX,e.clientY):null;if(o&&n.contains(this,o))return;n.mainClearTimeout(t.iDocTimer),t.runEvent("onDragLeave",[a,e])}}).bind("drop",function(o){t.bEnableDnD&&o&&(o=n.getEvent(o))&&n.eventContainsFiles(o)&&(o.preventDefault(),n.getDataFromDragEvent(o,function(e){e&&(t.runEvent("onDrop",[e,o]),t.addNewFile(e),n.mainClearTimeout(t.iDocTimer))},n.getValue(t.oOptions,"multipleSizeLimit",e.iDefLimit),t.getEvent("onLimitReached"))),t.runEvent("onDragLeave",[o])}))}(i):i.bEnableDnD=!1,n.setValue(i,"on",i.on),n.setValue(i,"cancel",i.cancel),n.setValue(i,"isDragAndDropSupported",i.isDragAndDropSupported),n.setValue(i,"setDragAndDropEnabledStatus",i.setDragAndDropEnabledStatus)}e.iDefLimit=20,n.isUndefined=function(e){return void 0===e},n.extend=function(e,n){if(n)for(var t in n)n.hasOwnProperty(t)&&(e[t]=n[t]);return e},n.contains=f
|