2 lines
70 KiB
JavaScript
2 lines
70 KiB
JavaScript
(function(I,k){var se,f={},p=function(i,e){var n,s,a;if(typeof i=="string")return o(i);for(n=[],s=i.length,a=0;s>a;a++)n.push(o(i[a]));return e.apply(null,n)},d=function(i,e,n){arguments.length===2&&(n=e,e=null),p(e||[],function(){u(i,n,arguments)})},u=function(i,e,n){var s,a={exports:e};typeof e=="function"&&(n.length||(n=[p,a.exports,a]),s=e.apply(null,n),s!==void 0&&(a.exports=s)),f[i]=a.exports},o=function(i){var e=f[i]||I[i];if(!e)throw new Error("`"+i+"` is undefined");return e},t=function(i){var e,n,s,a,l,y;y=function(w){return w&&w.charAt(0).toUpperCase()+w.substr(1)};for(e in f)if(n=i,f.hasOwnProperty(e)){for(s=e.split("/"),l=y(s.pop());a=y(s.shift());)n[a]=n[a]||{},n=n[a];n[l]=f[e]}return i},r=function(i){return I.__dollar=i,t(k(I,d,p))};typeof module=="object"&&typeof module.exports=="object"?module.exports=r():typeof define=="function"&&define.amd?define(["jquery"],r):(se=I.WebUploader,I.WebUploader=r(),I.WebUploader.noConflict=function(){I.WebUploader=se})})(window,function(I,k,se){return k("dollar-third",[],function(){var f=I.__dollar||I.jQuery||I.Zepto;if(!f)throw new Error("jQuery or Zepto not found!");return f}),k("dollar",["dollar-third"],function(f){return f}),k("promise-third",["dollar"],function(f){return{Deferred:f.Deferred,when:f.when,isPromise:function(p){return p&&typeof p.then=="function"}}}),k("promise",["promise-third"],function(f){return f}),k("base",["dollar","promise"],function(f,p){function d(i){return function(){return r.apply(i,arguments)}}function u(i,e){return function(){return i.apply(e,arguments)}}function o(i){var e;return Object.create?Object.create(i):(e=function(){},e.prototype=i,new e)}var t=function(){},r=Function.call;return{version:"0.1.5",$:f,Deferred:p.Deferred,isPromise:p.isPromise,when:p.when,browser:function(i){var e={},n=i.match(/WebKit\/([\d.]+)/),s=i.match(/Chrome\/([\d.]+)/)||i.match(/CriOS\/([\d.]+)/),a=i.match(/MSIE\s([\d\.]+)/)||i.match(/(?:trident)(?:.*rv:([\w.]+))?/i),l=i.match(/Firefox\/([\d.]+)/),y=i.match(/Safari\/([\d.]+)/),w=i.match(/OPR\/([\d.]+)/);return n&&(e.webkit=parseFloat(n[1])),s&&(e.chrome=parseFloat(s[1])),a&&(e.ie=parseFloat(a[1])),l&&(e.firefox=parseFloat(l[1])),y&&(e.safari=parseFloat(y[1])),w&&(e.opera=parseFloat(w[1])),e}(navigator.userAgent),os:function(i){var e={},n=i.match(/(?:Android);?[\s\/]+([\d.]+)?/),s=i.match(/(?:iPad|iPod|iPhone).*OS\s([\d_]+)/);return n&&(e.android=parseFloat(n[1])),s&&(e.ios=parseFloat(s[1].replace(/_/g,"."))),e}(navigator.userAgent),inherits:function(i,e,n){var s;return typeof e=="function"?(s=e,e=null):s=e&&e.hasOwnProperty("constructor")?e.constructor:function(){return i.apply(this,arguments)},f.extend(!0,s,i,n||{}),s.__super__=i.prototype,s.prototype=o(i.prototype),e&&f.extend(!0,s.prototype,e),s},noop:t,bindFn:u,log:function(){return I.console?u(console.log,console):t}(),nextTick:function(){return function(i){setTimeout(i,1)}}(),slice:d([].slice),guid:function(){var i=0;return function(e){for(var n=(+new Date).toString(32),s=0;5>s;s++)n+=Math.floor(65535*Math.random()).toString(32);return(e||"wu_")+n+(i++).toString(32)}}(),formatSize:function(i,e,n){var s;for(n=n||["B","K","M","G","TB"];(s=n.shift())&&i>1024;)i/=1024;return(s==="B"?i:i.toFixed(e||2))+s}}}),k("mediator",["base"],function(f){function p(e,n,s,a){return t.grep(e,function(l){return!(!l||n&&l.e!==n||s&&l.cb!==s&&l.cb._cb!==s||a&&l.ctx!==a)})}function d(e,n,s){t.each((e||"").split(i),function(a,l){s(l,n)})}function u(e,n){for(var s,a=!1,l=-1,y=e.length;++l<y;)if(s=e[l],s.cb.apply(s.ctx2,n)===!1){a=!0;break}return!a}var o,t=f.$,r=[].slice,i=/\s+/;return o={on:function(e,n,s){var a,l=this;return n?(a=this._events||(this._events=[]),d(e,n,function(y,w){var R={e:y};R.cb=w,R.ctx=s,R.ctx2=s||l,R.id=a.length,a.push(R)}),this):this},once:function(e,n,s){var a=this;return n&&d(e,n,function(l,y){var w=function(){return a.off(l,w),y.apply(s||a,arguments)};w._cb=y,a.on(l,w,s)}),a},off:function(e,n,s){var a=this._events;return a?e||n||s?(d(e,n,function(l,y){t.each(p(a,l,y,s),function(){delete a[this.id]})}),this):(this._events=[],this):this},trigger:function(e){var n,s,a;return this._events&&e?(n=r.call(arguments,1),s=p(this._events,e),a=p(this._events,"all"),u(s,n)&&u(a,arguments)):this}},t.extend({installTo:function(e){return t.extend(e,o)}},o)}),k("uploader",["base","mediator"],function(f,p){function d(o){this.options=u.extend(!0,{},d.options,o),this._init(this.options)}var u=f.$;return d.options={},p.installTo(d.prototype),u.each({upload:"start-upload",stop:"stop-upload",getFile:"get-file",getFiles:"get-files",addFile:"add-file",addFiles:"add-file",sort:"sort-files",removeFile:"remove-file",cancelFile:"cancel-file",skipFile:"skip-file",retry:"retry",isInProgress:"is-in-progress",makeThumb:"make-thumb",md5File:"md5-file",getDimension:"get-dimension",addButton:"add-btn",predictRuntimeType:"predict-runtime-type",refresh:"refresh",disable:"disable",enable:"enable",reset:"reset"},function(o,t){d.prototype[o]=function(){return this.request(t,arguments)}}),u.extend(d.prototype,{state:"pending",_init:function(o){var t=this;t.request("init",o,function(){t.state="ready",t.trigger("ready")})},option:function(o,t){var r=this.options;return arguments.length>1?void(u.isPlainObject(t)&&u.isPlainObject(r[o])?u.extend(r[o],t):r[o]=t):o?r[o]:r},getStats:function(){var o=this.request("get-stats");return o?{successNum:o.numOfSuccess,progressNum:o.numOfProgress,cancelNum:o.numOfCancel,invalidNum:o.numOfInvalid,uploadFailNum:o.numOfUploadFailed,queueNum:o.numOfQueue,interruptNum:o.numofInterrupt}:{}},trigger:function(o){var t=[].slice.call(arguments,1),r=this.options,i="on"+o.substring(0,1).toUpperCase()+o.substring(1);return!(p.trigger.apply(this,arguments)===!1||u.isFunction(r[i])&&r[i].apply(this,t)===!1||u.isFunction(this[i])&&this[i].apply(this,t)===!1||p.trigger.apply(p,[this,o].concat(t))===!1)},destroy:function(){this.request("destroy",arguments),this.off()},request:f.noop}),f.create=d.create=function(o){return new d(o)},f.Uploader=d,d}),k("runtime/runtime",["base","mediator"],function(f,p){function d(r){this.options=u.extend({container:document.body},r),this.uid=f.guid("rt_")}var u=f.$,o={},t=function(r){for(var i in r)if(r.hasOwnProperty(i))return i;return null};return u.extend(d.prototype,{getContainer:function(){var r,i,e=this.options;return this._container?this._container:(r=u(e.container||document.body),i=u(document.createElement("div")),i.attr("id","rt_"+this.uid),i.css({position:"absolute",top:"0px",left:"0px",width:"1px",height:"1px",overflow:"hidden"}),r.append(i),r.addClass("webuploader-container"),this._container=i,this._parent=r,i)},init:f.noop,exec:f.noop,destroy:function(){this._container&&this._container.remove(),this._parent&&this._parent.removeClass("webuploader-container"),this.off()}}),d.orders="html5,flash",d.addRuntime=function(r,i){o[r]=i},d.hasRuntime=function(r){return!!(r?o[r]:t(o))},d.create=function(r,i){var e,n;if(i=i||d.orders,u.each(i.split(/\s*,\s*/g),function(){return o[this]?(e=this,!1):void 0}),e=e||t(o),!e)throw new Error("Runtime Error");return n=new o[e](r)},p.installTo(d.prototype),d}),k("runtime/client",["base","mediator","runtime/runtime"],function(f,p,d){function u(t,r){var i,e=f.Deferred();this.uid=f.guid("client_"),this.runtimeReady=function(n){return e.done(n)},this.connectRuntime=function(n,s){if(i)throw new Error("already connected!");return e.done(s),typeof n=="string"&&o.get(n)&&(i=o.get(n)),i=i||o.get(null,r),i?(f.$.extend(i.options,n),i.__promise.then(e.resolve),i.__client++):(i=d.create(n,n.runtimeOrder),i.__promise=e.promise(),i.once("ready",e.resolve),i.init(),o.add(i),i.__client=1),r&&(i.__standalone=r),i},this.getRuntime=function(){return i},this.disconnectRuntime=function(){i&&(i.__client--,i.__client<=0&&(o.remove(i),delete i.__promise,i.destroy()),i=null)},this.exec=function(){if(i){var n=f.slice(arguments);return t&&n.unshift(t),i.exec.apply(this,n)}},this.getRuid=function(){return i&&i.uid},this.destroy=function(n){return function(){n&&n.apply(this,arguments),this.trigger("destroy"),this.off(),this.exec("destroy"),this.disconnectRuntime()}}(this.destroy)}var o;return o=function(){var t={};return{add:function(r){t[r.uid]=r},get:function(r,i){var e;if(r)return t[r];for(e in t)if(!i||!t[e].__standalone)return t[e];return null},remove:function(r){delete t[r.uid]}}}(),p.installTo(u.prototype),u}),k("lib/dnd",["base","mediator","runtime/client"],function(f,p,d){function u(t){t=this.options=o.extend({},u.options,t),t.container=o(t.container),t.container.length&&d.call(this,"DragAndDrop")}var o=f.$;return u.options={accept:null,disableGlobalDnd:!1},f.inherits(d,{constructor:u,init:function(){var t=this;t.connectRuntime(t.options,function(){t.exec("init"),t.trigger("ready")})}}),p.installTo(u.prototype),u}),k("widgets/widget",["base","uploader"],function(f,p){function d(n){if(!n)return!1;var s=n.length,a=o.type(n);return n.nodeType===1&&s?!0:a==="array"||a!=="function"&&a!=="string"&&(s===0||typeof s=="number"&&s>0&&s-1 in n)}function u(n){this.owner=n,this.options=n.options}var o=f.$,t=p.prototype._init,r=p.prototype.destroy,i={},e=[];return o.extend(u.prototype,{init:f.noop,invoke:function(n,s){var a=this.responseMap;return a&&n in a&&a[n]in this&&o.isFunction(this[a[n]])?this[a[n]].apply(this,s):i},request:function(){return this.owner.request.apply(this.owner,arguments)}}),o.extend(p.prototype,{_init:function(){var n=this,s=n._widgets=[],a=n.options.disableWidgets||"";return o.each(e,function(l,y){(!a||!~a.indexOf(y._name))&&s.push(new y(n))}),t.apply(n,arguments)},request:function(n,s,a){var l,y,w,R,b=0,m=this._widgets,c=m&&m.length,h=[],g=[];for(s=d(s)?s:[s];c>b;b++)l=m[b],y=l.invoke(n,s),y!==i&&(f.isPromise(y)?g.push(y):h.push(y));return a||g.length?(w=f.when.apply(f,g),R=w.pipe?"pipe":"then",w[R](function(){var v=f.Deferred(),_=arguments;return _.length===1&&(_=_[0]),setTimeout(function(){v.resolve(_)},1),v.promise()})[a?R:"done"](a||f.noop)):h[0]},destroy:function(){r.apply(this,arguments),this._widgets=null}}),p.register=u.register=function(n,s){var a,l={init:"init",destroy:"destroy",name:"anonymous"};return arguments.length===1?(s=n,o.each(s,function(y){return y[0]==="_"||y==="name"?void(y==="name"&&(l.name=s.name)):void(l[y.replace(/[A-Z]/g,"-$&").toLowerCase()]=y)})):l=o.extend(l,n),s.responseMap=l,a=f.inherits(u,s),a._name=l.name,e.push(a),a},p.unRegister=u.unRegister=function(n){if(n&&n!=="anonymous")for(var s=e.length;s--;)e[s]._name===n&&e.splice(s,1)},u}),k("widgets/filednd",["base","uploader","lib/dnd","widgets/widget"],function(f,p,d){var u=f.$;return p.options.dnd="",p.register({name:"dnd",init:function(o){if(o.dnd&&this.request("predict-runtime-type")==="html5"){var t,r=this,i=f.Deferred(),e=u.extend({},{disableGlobalDnd:o.disableGlobalDnd,container:o.dnd,accept:o.accept});return this.dnd=t=new d(e),t.once("ready",i.resolve),t.on("drop",function(n){r.request("add-file",[n])}),t.on("accept",function(n){return r.owner.trigger("dndAccept",n)}),t.init(),i.promise()}},destroy:function(){this.dnd&&this.dnd.destroy()}})}),k("lib/filepaste",["base","mediator","runtime/client"],function(f,p,d){function u(t){t=this.options=o.extend({},t),t.container=o(t.container||document.body),d.call(this,"FilePaste")}var o=f.$;return f.inherits(d,{constructor:u,init:function(){var t=this;t.connectRuntime(t.options,function(){t.exec("init"),t.trigger("ready")})}}),p.installTo(u.prototype),u}),k("widgets/filepaste",["base","uploader","lib/filepaste","widgets/widget"],function(f,p,d){var u=f.$;return p.register({name:"paste",init:function(o){if(o.paste&&this.request("predict-runtime-type")==="html5"){var t,r=this,i=f.Deferred(),e=u.extend({},{container:o.paste,accept:o.accept});return this.paste=t=new d(e),t.once("ready",i.resolve),t.on("paste",function(n){r.owner.request("add-file",[n])}),t.init(),i.promise()}},destroy:function(){this.paste&&this.paste.destroy()}})}),k("lib/blob",["base","runtime/client"],function(f,p){function d(u,o){var t=this;t.source=o,t.ruid=u,this.size=o.size||0,this.type=!o.type&&this.ext&&~"jpg,jpeg,png,gif,bmp".indexOf(this.ext)?"image/"+(this.ext==="jpg"?"jpeg":this.ext):o.type||"application/octet-stream",p.call(t,"Blob"),this.uid=o.uid||this.uid,u&&t.connectRuntime(u)}return f.inherits(p,{constructor:d,slice:function(u,o){return this.exec("slice",u,o)},getSource:function(){return this.source}}),d}),k("lib/file",["base","lib/blob"],function(f,p){function d(t,r){var i;this.name=r.name||"untitled"+u++,i=o.exec(r.name)?RegExp.$1.toLowerCase():"",!i&&r.type&&(i=/\/(jpg|jpeg|png|gif|bmp)$/i.exec(r.type)?RegExp.$1.toLowerCase():"",this.name+="."+i),this.ext=i,this.lastModifiedDate=r.lastModifiedDate||new Date().toLocaleString(),p.apply(this,arguments)}var u=1,o=/\.([^.]+)$/;return f.inherits(p,d)}),k("lib/filepicker",["base","runtime/client","lib/file"],function(f,p,d){function u(t){if(t=this.options=o.extend({},u.options,t),t.container=o(t.id),!t.container.length)throw new Error("\u6309\u94AE\u6307\u5B9A\u9519\u8BEF");t.innerHTML=t.innerHTML||t.label||t.container.html()||"",t.button=o(t.button||document.createElement("div")),t.button.html(t.innerHTML),t.container.html(t.button),p.call(this,"FilePicker",!0)}var o=f.$;return u.options={button:null,container:null,label:null,innerHTML:null,multiple:!0,accept:null,name:"file"},f.inherits(p,{constructor:u,init:function(){var t=this,r=t.options,i=r.button;i.addClass("webuploader-pick"),t.on("all",function(e){var n;switch(e){case"mouseenter":i.addClass("webuploader-pick-hover");break;case"mouseleave":i.removeClass("webuploader-pick-hover");break;case"change":n=t.exec("getFiles"),t.trigger("select",o.map(n,function(s){return s=new d(t.getRuid(),s),s._refer=r.container,s}),r.container)}}),t.connectRuntime(r,function(){t.refresh(),t.exec("init",r),t.trigger("ready")}),this._resizeHandler=f.bindFn(this.refresh,this),o(I).on("resize",this._resizeHandler)},refresh:function(){var t=this.getRuntime().getContainer(),r=this.options.button,i=r.outerWidth?r.outerWidth():r.width(),e=r.outerHeight?r.outerHeight():r.height(),n=r.offset();i&&e&&t.css({bottom:"auto",right:"auto",width:i+"px",height:e+"px"}).offset(n)},enable:function(){var t=this.options.button;t.removeClass("webuploader-pick-disable"),this.refresh()},disable:function(){var t=this.options.button;this.getRuntime().getContainer().css({top:"-99999px"}),t.addClass("webuploader-pick-disable")},destroy:function(){var t=this.options.button;o(I).off("resize",this._resizeHandler),t.removeClass("webuploader-pick-disable webuploader-pick-hover webuploader-pick")}}),u}),k("widgets/filepicker",["base","uploader","lib/filepicker","widgets/widget"],function(f,p,d){var u=f.$;return u.extend(p.options,{pick:null,accept:null}),p.register({name:"picker",init:function(o){return this.pickers=[],o.pick&&this.addBtn(o.pick)},refresh:function(){u.each(this.pickers,function(){this.refresh()})},addBtn:function(o){var t=this,r=t.options,i=r.accept,e=[];if(o)return u.isPlainObject(o)||(o={id:o}),u(o.id).each(function(){var n,s,a;a=f.Deferred(),n=u.extend({},o,{accept:u.isPlainObject(i)?[i]:i,swf:r.swf,runtimeOrder:r.runtimeOrder,id:this}),s=new d(n),s.once("ready",a.resolve),s.on("select",function(l){t.owner.request("add-file",[l])}),s.init(),t.pickers.push(s),e.push(a.promise())}),f.when.apply(f,e)},disable:function(){u.each(this.pickers,function(){this.disable()})},enable:function(){u.each(this.pickers,function(){this.enable()})},destroy:function(){u.each(this.pickers,function(){this.destroy()}),this.pickers=null}})}),k("lib/image",["base","runtime/client","lib/blob"],function(f,p,d){function u(t){this.options=o.extend({},u.options,t),p.call(this,"Image"),this.on("load",function(){this._info=this.exec("info"),this._meta=this.exec("meta")})}var o=f.$;return u.options={quality:90,crop:!1,preserveHeaders:!1,allowMagnify:!1},f.inherits(p,{constructor:u,info:function(t){return t?(this._info=t,this):this._info},meta:function(t){return t?(this._meta=t,this):this._meta},loadFromBlob:function(t){var r=this,i=t.getRuid();this.connectRuntime(i,function(){r.exec("init",r.options),r.exec("loadFromBlob",t)})},resize:function(){var t=f.slice(arguments);return this.exec.apply(this,["resize"].concat(t))},crop:function(){var t=f.slice(arguments);return this.exec.apply(this,["crop"].concat(t))},getAsDataUrl:function(t){return this.exec("getAsDataUrl",t)},getAsBlob:function(t){var r=this.exec("getAsBlob",t);return new d(this.getRuid(),r)}}),u}),k("widgets/image",["base","uploader","lib/image","widgets/widget"],function(f,p,d){var u,o=f.$;return u=function(t){var r=0,i=[],e=function(){for(var n;i.length&&t>r;)n=i.shift(),r+=n[0],n[1]()};return function(n,s,a){i.push([s,a]),n.once("destroy",function(){r-=s,setTimeout(e,1)}),setTimeout(e,1)}}(5242880),o.extend(p.options,{thumb:{width:110,height:110,quality:70,allowMagnify:!0,crop:!0,preserveHeaders:!1,type:"image/jpeg"},compress:{width:1600,height:1600,quality:90,allowMagnify:!1,crop:!1,preserveHeaders:!0}}),p.register({name:"image",makeThumb:function(t,r,i,e){var n,s;return t=this.request("get-file",t),t.type.match(/^image/)?(n=o.extend({},this.options.thumb),o.isPlainObject(i)&&(n=o.extend(n,i),i=null),i=i||n.width,e=e||n.height,s=new d(n),s.once("load",function(){t._info=t._info||s.info(),t._meta=t._meta||s.meta(),1>=i&&i>0&&(i=t._info.width*i),1>=e&&e>0&&(e=t._info.height*e),s.resize(i,e)}),s.once("complete",function(){r(!1,s.getAsDataUrl(n.type)),s.destroy()}),s.once("error",function(a){r(a||!0),s.destroy()}),void u(s,t.source.size,function(){t._info&&s.info(t._info),t._meta&&s.meta(t._meta),s.loadFromBlob(t.source)})):void r(!0)},beforeSendFile:function(t){var r,i,e=this.options.compress||this.options.resize,n=e&&e.compressSize||0,s=e&&e.noCompressIfLarger||!1;return t=this.request("get-file",t),!e||!~"image/jpeg,image/jpg".indexOf(t.type)||t.size<n||t._compressed?void 0:(e=o.extend({},e),i=f.Deferred(),r=new d(e),i.always(function(){r.destroy(),r=null}),r.once("error",i.reject),r.once("load",function(){var a=e.width,l=e.height;t._info=t._info||r.info(),t._meta=t._meta||r.meta(),1>=a&&a>0&&(a=t._info.width*a),1>=l&&l>0&&(l=t._info.height*l),r.resize(a,l)}),r.once("complete",function(){var a,l;try{a=r.getAsBlob(e.type),l=t.size,(!s||a.size<l)&&(t.source=a,t.size=a.size,t.trigger("resize",a.size,l)),t._compressed=!0,i.resolve()}catch(y){i.resolve()}}),t._info&&r.info(t._info),t._meta&&r.meta(t._meta),r.loadFromBlob(t.source),i.promise())}})}),k("file",["base","mediator"],function(f,p){function d(){return t+r++}function u(n){this.name=n.name||"Untitled",this.size=n.size||0,this.type=n.type||"application/octet-stream",this.lastModifiedDate=n.lastModifiedDate||1*new Date,this.id=d(),this.ext=i.exec(this.name)?RegExp.$1:"",this.statusText="",e[this.id]=u.Status.INITED,this.source=n,this.loaded=0,this.on("error",function(s){this.setStatus(u.Status.ERROR,s)})}var o=f.$,t="WU_FILE_",r=0,i=/\.([^.]+)$/,e={};return o.extend(u.prototype,{setStatus:function(n,s){var a=e[this.id];typeof s!="undefined"&&(this.statusText=s),n!==a&&(e[this.id]=n,this.trigger("statuschange",n,a))},getStatus:function(){return e[this.id]},getSource:function(){return this.source},destroy:function(){this.off(),delete e[this.id]}}),p.installTo(u.prototype),u.Status={INITED:"inited",QUEUED:"queued",PROGRESS:"progress",ERROR:"error",COMPLETE:"complete",CANCELLED:"cancelled",INTERRUPT:"interrupt",INVALID:"invalid"},u}),k("queue",["base","mediator","file"],function(f,p,d){function u(){this.stats={numOfQueue:0,numOfSuccess:0,numOfCancel:0,numOfProgress:0,numOfUploadFailed:0,numOfInvalid:0,numofDeleted:0,numofInterrupt:0},this._queue=[],this._map={}}var o=f.$,t=d.Status;return o.extend(u.prototype,{append:function(r){return this._queue.push(r),this._fileAdded(r),this},prepend:function(r){return this._queue.unshift(r),this._fileAdded(r),this},getFile:function(r){return typeof r!="string"?r:this._map[r]},fetch:function(r){var i,e,n=this._queue.length;for(r=r||t.QUEUED,i=0;n>i;i++)if(e=this._queue[i],r===e.getStatus())return e;return null},sort:function(r){typeof r=="function"&&this._queue.sort(r)},getFiles:function(){for(var r,i=[].slice.call(arguments,0),e=[],n=0,s=this._queue.length;s>n;n++)r=this._queue[n],(!i.length||~o.inArray(r.getStatus(),i))&&e.push(r);return e},removeFile:function(r){var i=this._map[r.id];i&&(delete this._map[r.id],r.destroy(),this.stats.numofDeleted++)},_fileAdded:function(r){var i=this,e=this._map[r.id];e||(this._map[r.id]=r,r.on("statuschange",function(n,s){i._onFileStatusChange(n,s)}))},_onFileStatusChange:function(r,i){var e=this.stats;switch(i){case t.PROGRESS:e.numOfProgress--;break;case t.QUEUED:e.numOfQueue--;break;case t.ERROR:e.numOfUploadFailed--;break;case t.INVALID:e.numOfInvalid--;break;case t.INTERRUPT:e.numofInterrupt--}switch(r){case t.QUEUED:e.numOfQueue++;break;case t.PROGRESS:e.numOfProgress++;break;case t.ERROR:e.numOfUploadFailed++;break;case t.COMPLETE:e.numOfSuccess++;break;case t.CANCELLED:e.numOfCancel++;break;case t.INVALID:e.numOfInvalid++;break;case t.INTERRUPT:e.numofInterrupt++}}}),p.installTo(u.prototype),u}),k("widgets/queue",["base","uploader","queue","file","lib/file","runtime/client","widgets/widget"],function(f,p,d,u,o,t){var r=f.$,i=/\.\w+$/,e=u.Status;return p.register({name:"queue",init:function(n){var s,a,l,y,w,R,b,m=this;if(r.isPlainObject(n.accept)&&(n.accept=[n.accept]),n.accept){for(w=[],l=0,a=n.accept.length;a>l;l++)y=n.accept[l].extensions,y&&w.push(y);w.length&&(R="\\."+w.join(",").replace(/,/g,"$|\\.").replace(/\*/g,".*")+"$"),m.accept=new RegExp(R,"i")}return m.queue=new d,m.stats=m.queue.stats,this.request("predict-runtime-type")==="html5"?(s=f.Deferred(),this.placeholder=b=new t("Placeholder"),b.connectRuntime({runtimeOrder:"html5"},function(){m._ruid=b.getRuid(),s.resolve()}),s.promise()):void 0},_wrapFile:function(n){if(!(n instanceof u)){if(!(n instanceof o)){if(!this._ruid)throw new Error("Can't add external files.");n=new o(this._ruid,n)}n=new u(n)}return n},acceptFile:function(n){var s=!n||!n.size||this.accept&&i.exec(n.name)&&!this.accept.test(n.name);return!s},_addFile:function(n){var s=this;return n=s._wrapFile(n),s.owner.trigger("beforeFileQueued",n)?s.acceptFile(n)?(s.queue.append(n),s.owner.trigger("fileQueued",n),n):void s.owner.trigger("error","Q_TYPE_DENIED",n):void 0},getFile:function(n){return this.queue.getFile(n)},addFile:function(n){var s=this;n.length||(n=[n]),n=r.map(n,function(a){return s._addFile(a)}),s.owner.trigger("filesQueued",n),s.options.auto&&setTimeout(function(){s.request("start-upload")},20)},getStats:function(){return this.stats},removeFile:function(n,s){var a=this;n=n.id?n:a.queue.getFile(n),this.request("cancel-file",n),s&&this.queue.removeFile(n)},getFiles:function(){return this.queue.getFiles.apply(this.queue,arguments)},fetchFile:function(){return this.queue.fetch.apply(this.queue,arguments)},retry:function(n,s){var a,l,y,w=this;if(n)return n=n.id?n:w.queue.getFile(n),n.setStatus(e.QUEUED),void(s||w.request("start-upload"));for(a=w.queue.getFiles(e.ERROR),l=0,y=a.length;y>l;l++)n=a[l],n.setStatus(e.QUEUED);w.request("start-upload")},sortFiles:function(){return this.queue.sort.apply(this.queue,arguments)},reset:function(){this.owner.trigger("reset"),this.queue=new d,this.stats=this.queue.stats},destroy:function(){this.reset(),this.placeholder&&this.placeholder.destroy()}})}),k("widgets/runtime",["uploader","runtime/runtime","widgets/widget"],function(f,p){return f.support=function(){return p.hasRuntime.apply(p,arguments)},f.register({name:"runtime",init:function(){if(!this.predictRuntimeType())throw Error("Runtime Error")},predictRuntimeType:function(){var d,u,o=this.options.runtimeOrder||p.orders,t=this.type;if(!t){for(o=o.split(/\s*,\s*/g),d=0,u=o.length;u>d;d++)if(p.hasRuntime(o[d])){this.type=t=o[d];break}}return t}})}),k("lib/transport",["base","runtime/client","mediator"],function(f,p,d){function u(t){var r=this;t=r.options=o.extend(!0,{},u.options,t||{}),p.call(this,"Transport"),this._blob=null,this._formData=t.formData||{},this._headers=t.headers||{},this.on("progress",this._timeout),this.on("load error",function(){r.trigger("progress",1),clearTimeout(r._timer)})}var o=f.$;return u.options={server:"",method:"POST",withCredentials:!1,fileVal:"file",timeout:12e4,formData:{},headers:{},sendAsBinary:!1},o.extend(u.prototype,{appendBlob:function(t,r,i){var e=this,n=e.options;e.getRuid()&&e.disconnectRuntime(),e.connectRuntime(r.ruid,function(){e.exec("init")}),e._blob=r,n.fileVal=t||n.fileVal,n.filename=i||n.filename},append:function(t,r){typeof t=="object"?o.extend(this._formData,t):this._formData[t]=r},setRequestHeader:function(t,r){typeof t=="object"?o.extend(this._headers,t):this._headers[t]=r},send:function(t){this.exec("send",t),this._timeout()},abort:function(){return clearTimeout(this._timer),this.exec("abort")},destroy:function(){this.trigger("destroy"),this.off(),this.exec("destroy"),this.disconnectRuntime()},getResponse:function(){return this.exec("getResponse")},getResponseAsJson:function(){return this.exec("getResponseAsJson")},getStatus:function(){return this.exec("getStatus")},_timeout:function(){var t=this,r=t.options.timeout;r&&(clearTimeout(t._timer),t._timer=setTimeout(function(){t.abort(),t.trigger("error","timeout")},r))}}),d.installTo(u.prototype),u}),k("widgets/upload",["base","uploader","file","lib/transport","widgets/widget"],function(f,p,d,u){function o(e,n){var s,a,l=[],y=e.source,w=y.size,R=n?Math.ceil(w/n):1,b=0,m=0;for(a={file:e,has:function(){return!!l.length},shift:function(){return l.shift()},unshift:function(c){l.unshift(c)}};R>m;)s=Math.min(n,w-b),l.push({file:e,start:b,end:n?b+s:w,total:w,chunks:R,chunk:m++,cuted:a}),b+=s;return e.blocks=l.concat(),e.remaning=l.length,a}var t=f.$,r=f.isPromise,i=d.Status;t.extend(p.options,{prepareNextFile:!1,chunked:!1,chunkSize:5242880,chunkRetry:2,threads:3,formData:{}}),p.register({name:"upload",init:function(){var e=this.owner,n=this;this.runing=!1,this.progress=!1,e.on("startUpload",function(){n.progress=!0}).on("uploadFinished",function(){n.progress=!1}),this.pool=[],this.stack=[],this.pending=[],this.remaning=0,this.__tick=f.bindFn(this._tick,this),e.on("uploadComplete",function(s){s.blocks&&t.each(s.blocks,function(a,l){l.transport&&(l.transport.abort(),l.transport.destroy()),delete l.transport}),delete s.blocks,delete s.remaning})},reset:function(){this.request("stop-upload",!0),this.runing=!1,this.pool=[],this.stack=[],this.pending=[],this.remaning=0,this._trigged=!1,this._promise=null},startUpload:function(e){var n=this;if(t.each(n.request("get-files",i.INVALID),function(){n.request("remove-file",this)}),e)if(e=e.id?e:n.request("get-file",e),e.getStatus()===i.INTERRUPT)t.each(n.pool,function(a,l){l.file===e&&l.transport&&l.transport.send()}),e.setStatus(i.QUEUED);else{if(e.getStatus()===i.PROGRESS)return;e.setStatus(i.QUEUED)}else t.each(n.request("get-files",[i.INITED]),function(){this.setStatus(i.QUEUED)});if(!n.runing){n.runing=!0;var s=[];t.each(n.pool,function(a,l){var y=l.file;y.getStatus()===i.INTERRUPT&&(s.push(y),n._trigged=!1,l.transport&&l.transport.send())});for(var e;e=s.shift();)e.setStatus(i.PROGRESS);e||t.each(n.request("get-files",i.INTERRUPT),function(){this.setStatus(i.PROGRESS)}),n._trigged=!1,f.nextTick(n.__tick),n.owner.trigger("startUpload")}},stopUpload:function(e,n){var s=this;if(e===!0&&(n=e,e=null),s.runing!==!1){if(e)return e=e.id?e:s.request("get-file",e),e.getStatus()!==i.PROGRESS&&e.getStatus()!==i.QUEUED?void 0:(e.setStatus(i.INTERRUPT),t.each(s.pool,function(a,l){l.file===e&&(l.transport&&l.transport.abort(),s._putback(l),s._popBlock(l))}),f.nextTick(s.__tick));s.runing=!1,this._promise&&this._promise.file&&this._promise.file.setStatus(i.INTERRUPT),n&&t.each(s.pool,function(a,l){l.transport&&l.transport.abort(),l.file.setStatus(i.INTERRUPT)}),s.owner.trigger("stopUpload")}},cancelFile:function(e){e=e.id?e:this.request("get-file",e),e.blocks&&t.each(e.blocks,function(n,s){var a=s.transport;a&&(a.abort(),a.destroy(),delete s.transport)}),e.setStatus(i.CANCELLED),this.owner.trigger("fileDequeued",e)},isInProgress:function(){return!!this.progress},_getStats:function(){return this.request("get-stats")},skipFile:function(e,n){e=e.id?e:this.request("get-file",e),e.setStatus(n||i.COMPLETE),e.skipped=!0,e.blocks&&t.each(e.blocks,function(s,a){var l=a.transport;l&&(l.abort(),l.destroy(),delete a.transport)}),this.owner.trigger("uploadSkip",e)},_tick:function(){var e,n,s=this,a=s.options;return s._promise?s._promise.always(s.__tick):void(s.pool.length<a.threads&&(n=s._nextBlock())?(s._trigged=!1,e=function(l){s._promise=null,l&&l.file&&s._startSend(l),f.nextTick(s.__tick)},s._promise=r(n)?n.always(e):e(n)):s.remaning||s._getStats().numOfQueue||s._getStats().numofInterrupt||(s.runing=!1,s._trigged||f.nextTick(function(){s.owner.trigger("uploadFinished")}),s._trigged=!0))},_putback:function(e){var n;e.cuted.unshift(e),n=this.stack.indexOf(e.cuted),~n||this.stack.unshift(e.cuted)},_getStack:function(){for(var e,n=0;e=this.stack[n++];){if(e.has()&&e.file.getStatus()===i.PROGRESS)return e;(!e.has()||e.file.getStatus()!==i.PROGRESS&&e.file.getStatus()!==i.INTERRUPT)&&this.stack.splice(--n,1)}return null},_nextBlock:function(){var e,n,s,a,l=this,y=l.options;return(e=this._getStack())?(y.prepareNextFile&&!l.pending.length&&l._prepareNextFile(),e.shift()):l.runing?(!l.pending.length&&l._getStats().numOfQueue&&l._prepareNextFile(),n=l.pending.shift(),s=function(w){return w?(e=o(w,y.chunked?y.chunkSize:0),l.stack.push(e),e.shift()):null},r(n)?(a=n.file,n=n[n.pipe?"pipe":"then"](s),n.file=a,n):s(n)):void 0},_prepareNextFile:function(){var e,n=this,s=n.request("fetch-file"),a=n.pending;s&&(e=n.request("before-send-file",s,function(){return s.getStatus()===i.PROGRESS||s.getStatus()===i.INTERRUPT?s:n._finishFile(s)}),n.owner.trigger("uploadStart",s),s.setStatus(i.PROGRESS),e.file=s,e.done(function(){var l=t.inArray(e,a);~l&&a.splice(l,1,s)}),e.fail(function(l){s.setStatus(i.ERROR,l),n.owner.trigger("uploadError",s,l),n.owner.trigger("uploadComplete",s)}),a.push(e))},_popBlock:function(e){var n=t.inArray(e,this.pool);this.pool.splice(n,1),e.file.remaning--,this.remaning--},_startSend:function(e){var n,s=this,a=e.file;return a.getStatus()!==i.PROGRESS?void(a.getStatus()===i.INTERRUPT&&s._putback(e)):(s.pool.push(e),s.remaning++,e.blob=e.chunks===1?a.source:a.source.slice(e.start,e.end),n=s.request("before-send",e,function(){a.getStatus()===i.PROGRESS?s._doSend(e):(s._popBlock(e),f.nextTick(s.__tick))}),void n.fail(function(){a.remaning===1?s._finishFile(a).always(function(){e.percentage=1,s._popBlock(e),s.owner.trigger("uploadComplete",a),f.nextTick(s.__tick)}):(e.percentage=1,s.updateFileProgress(a),s._popBlock(e),f.nextTick(s.__tick))}))},_doSend:function(e){var n,s,a=this,l=a.owner,y=a.options,w=e.file,R=new u(y),b=t.extend({},y.formData),m=t.extend({},y.headers);e.transport=R,R.on("destroy",function(){delete e.transport,a._popBlock(e),f.nextTick(a.__tick)}),R.on("progress",function(c){e.percentage=c,a.updateFileProgress(w)}),n=function(c){var h;return s=R.getResponseAsJson()||{},s._raw=R.getResponse(),h=function(g){c=g},l.trigger("uploadAccept",e,s,h)||(c=c||"server"),c},R.on("error",function(c,h){e.retried=e.retried||0,e.chunks>1&&~"http,abort".indexOf(c)&&e.retried<y.chunkRetry?(e.retried++,R.send()):(h||c!=="server"||(c=n(c)),w.setStatus(i.ERROR,c),l.trigger("uploadError",w,c),l.trigger("uploadComplete",w))}),R.on("load",function(){var c;return(c=n())?void R.trigger("error",c,!0):void(w.remaning===1?a._finishFile(w,s):R.destroy())}),b=t.extend(b,{id:w.id,name:w.name,type:w.type,lastModifiedDate:w.lastModifiedDate,size:w.size}),e.chunks>1&&t.extend(b,{chunks:e.chunks,chunk:e.chunk}),l.trigger("uploadBeforeSend",e,b,m),R.appendBlob(y.fileVal,e.blob,w.name),R.append(b),R.setRequestHeader(m),R.send()},_finishFile:function(e,n,s){var a=this.owner;return a.request("after-send-file",arguments,function(){e.setStatus(i.COMPLETE),a.trigger("uploadSuccess",e,n,s)}).fail(function(l){e.getStatus()===i.PROGRESS&&e.setStatus(i.ERROR,l),a.trigger("uploadError",e,l)}).always(function(){a.trigger("uploadComplete",e)})},updateFileProgress:function(e){var n=0,s=0;e.blocks&&(t.each(e.blocks,function(a,l){s+=(l.percentage||0)*(l.end-l.start)}),n=s/e.size,this.owner.trigger("uploadProgress",e,n||0))}})}),k("widgets/validator",["base","uploader","file","widgets/widget"],function(f,p,d){var u,o=f.$,t={};return u={addValidator:function(r,i){t[r]=i},removeValidator:function(r){delete t[r]}},p.register({name:"validator",init:function(){var r=this;f.nextTick(function(){o.each(t,function(){this.call(r.owner)})})}}),u.addValidator("fileNumLimit",function(){var r=this,i=r.options,e=0,n=parseInt(i.fileNumLimit,10),s=!0;n&&(r.on("beforeFileQueued",function(a){return e>=n&&s&&(s=!1,this.trigger("error","Q_EXCEED_NUM_LIMIT",n,a),setTimeout(function(){s=!0},1)),!(e>=n)}),r.on("fileQueued",function(){e++}),r.on("fileDequeued",function(){e--}),r.on("reset",function(){e=0}))}),u.addValidator("fileSizeLimit",function(){var r=this,i=r.options,e=0,n=parseInt(i.fileSizeLimit,10),s=!0;n&&(r.on("beforeFileQueued",function(a){var l=e+a.size>n;return l&&s&&(s=!1,this.trigger("error","Q_EXCEED_SIZE_LIMIT",n,a),setTimeout(function(){s=!0},1)),!l}),r.on("fileQueued",function(a){e+=a.size}),r.on("fileDequeued",function(a){e-=a.size}),r.on("reset",function(){e=0}))}),u.addValidator("fileSingleSizeLimit",function(){var r=this,i=r.options,e=i.fileSingleSizeLimit;e&&r.on("beforeFileQueued",function(n){return n.size>e?(n.setStatus(d.Status.INVALID,"exceed_size"),this.trigger("error","F_EXCEED_SIZE",e,n),!1):void 0})}),u.addValidator("duplicate",function(){function r(s){for(var a,l=0,y=0,w=s.length;w>y;y++)a=s.charCodeAt(y),l=a+(l<<6)+(l<<16)-l;return l}var i=this,e=i.options,n={};e.duplicate||(i.on("beforeFileQueued",function(s){var a=s.__hash||(s.__hash=r(s.name+s.size+s.lastModifiedDate));return n[a]?(this.trigger("error","F_DUPLICATE",s),!1):void 0}),i.on("fileQueued",function(s){var a=s.__hash;a&&(n[a]=!0)}),i.on("fileDequeued",function(s){var a=s.__hash;a&&delete n[a]}),i.on("reset",function(){n={}}))}),u}),k("lib/md5",["runtime/client","mediator"],function(f,p){function d(){f.call(this,"Md5")}return p.installTo(d.prototype),d.prototype.loadFromBlob=function(u){var o=this;o.getRuid()&&o.disconnectRuntime(),o.connectRuntime(u.ruid,function(){o.exec("init"),o.exec("loadFromBlob",u)})},d.prototype.getResult=function(){return this.exec("getResult")},d}),k("widgets/md5",["base","uploader","lib/md5","lib/blob","widgets/widget"],function(f,p,d,u){return p.register({name:"md5",md5File:function(o,t,r){var i=new d,e=f.Deferred(),n=o instanceof u?o:this.request("get-file",o).source;return i.on("progress load",function(s){s=s||{},e.notify(s.total?s.loaded/s.total:1)}),i.on("complete",function(){e.resolve(i.getResult())}),i.on("error",function(s){e.reject(s)}),arguments.length>1&&(t=t||0,r=r||0,0>t&&(t=n.size+t),0>r&&(r=n.size+r),r=Math.min(r,n.size),n=n.slice(t,r)),i.loadFromBlob(n),e.promise()}})}),k("runtime/compbase",[],function(){function f(p,d){this.owner=p,this.options=p.options,this.getRuntime=function(){return d},this.getRuid=function(){return d.uid},this.trigger=function(){return p.trigger.apply(p,arguments)}}return f}),k("runtime/html5/runtime",["base","runtime/runtime","runtime/compbase"],function(f,p,d){function u(){var r={},i=this,e=this.destroy;p.apply(i,arguments),i.type=o,i.exec=function(n,s){var a,l=this,y=l.uid,w=f.slice(arguments,2);return t[n]&&(a=r[y]=r[y]||new t[n](l,i),a[s])?a[s].apply(a,w):void 0},i.destroy=function(){return e&&e.apply(this,arguments)}}var o="html5",t={};return f.inherits(p,{constructor:u,init:function(){var r=this;setTimeout(function(){r.trigger("ready")},1)}}),u.register=function(r,i){var e=t[r]=f.inherits(d,i);return e},I.Blob&&I.FileReader&&I.DataView&&p.addRuntime(o,u),u}),k("runtime/html5/blob",["runtime/html5/runtime","lib/blob"],function(f,p){return f.register("Blob",{slice:function(d,u){var o=this.owner.source,t=o.slice||o.webkitSlice||o.mozSlice;return o=t.call(o,d,u),new p(this.getRuid(),o)}})}),k("runtime/html5/dnd",["base","runtime/html5/runtime","lib/file"],function(f,p,d){var u=f.$,o="webuploader-dnd-";return p.register("DragAndDrop",{init:function(){var t=this.elem=this.options.container;this.dragEnterHandler=f.bindFn(this._dragEnterHandler,this),this.dragOverHandler=f.bindFn(this._dragOverHandler,this),this.dragLeaveHandler=f.bindFn(this._dragLeaveHandler,this),this.dropHandler=f.bindFn(this._dropHandler,this),this.dndOver=!1,t.on("dragenter",this.dragEnterHandler),t.on("dragover",this.dragOverHandler),t.on("dragleave",this.dragLeaveHandler),t.on("drop",this.dropHandler),this.options.disableGlobalDnd&&(u(document).on("dragover",this.dragOverHandler),u(document).on("drop",this.dropHandler))},_dragEnterHandler:function(t){var r,i=this,e=i._denied||!1;return t=t.originalEvent||t,i.dndOver||(i.dndOver=!0,r=t.dataTransfer.items,r&&r.length&&(i._denied=e=!i.trigger("accept",r)),i.elem.addClass(o+"over"),i.elem[e?"addClass":"removeClass"](o+"denied")),t.dataTransfer.dropEffect=e?"none":"copy",!1},_dragOverHandler:function(t){var r=this.elem.parent().get(0);return r&&!u.contains(r,t.currentTarget)||(clearTimeout(this._leaveTimer),this._dragEnterHandler.call(this,t)),!1},_dragLeaveHandler:function(){var t,r=this;return t=function(){r.dndOver=!1,r.elem.removeClass(o+"over "+o+"denied")},clearTimeout(r._leaveTimer),r._leaveTimer=setTimeout(t,100),!1},_dropHandler:function(t){var r,i,e=this,n=e.getRuid(),s=e.elem.parent().get(0);if(s&&!u.contains(s,t.currentTarget))return!1;t=t.originalEvent||t,r=t.dataTransfer;try{i=r.getData("text/html")}catch(a){}return i?void 0:(e._getTansferFiles(r,function(a){e.trigger("drop",u.map(a,function(l){return new d(n,l)}))}),e.dndOver=!1,e.elem.removeClass(o+"over"),!1)},_getTansferFiles:function(t,r){var i,e,n,s,a,l,y,w=[],R=[];for(i=t.items,e=t.files,y=!(!i||!i[0].webkitGetAsEntry),a=0,l=e.length;l>a;a++)n=e[a],s=i&&i[a],y&&s.webkitGetAsEntry().isDirectory?R.push(this._traverseDirectoryTree(s.webkitGetAsEntry(),w)):w.push(n);f.when.apply(f,R).done(function(){w.length&&r(w)})},_traverseDirectoryTree:function(t,r){var i=f.Deferred(),e=this;return t.isFile?t.file(function(n){r.push(n),i.resolve()}):t.isDirectory&&t.createReader().readEntries(function(n){var s,a=n.length,l=[],y=[];for(s=0;a>s;s++)l.push(e._traverseDirectoryTree(n[s],y));f.when.apply(f,l).then(function(){r.push.apply(r,y),i.resolve()},i.reject)}),i.promise()},destroy:function(){var t=this.elem;t&&(t.off("dragenter",this.dragEnterHandler),t.off("dragover",this.dragOverHandler),t.off("dragleave",this.dragLeaveHandler),t.off("drop",this.dropHandler),this.options.disableGlobalDnd&&(u(document).off("dragover",this.dragOverHandler),u(document).off("drop",this.dropHandler)))}})}),k("runtime/html5/filepaste",["base","runtime/html5/runtime","lib/file"],function(f,p,d){return p.register("FilePaste",{init:function(){var u,o,t,r,i=this.options,e=this.elem=i.container,n=".*";if(i.accept){for(u=[],o=0,t=i.accept.length;t>o;o++)r=i.accept[o].mimeTypes,r&&u.push(r);u.length&&(n=u.join(","),n=n.replace(/,/g,"|").replace(/\*/g,".*"))}this.accept=n=new RegExp(n,"i"),this.hander=f.bindFn(this._pasteHander,this),e.on("paste",this.hander)},_pasteHander:function(u){var o,t,r,i,e,n=[],s=this.getRuid();for(u=u.originalEvent||u,o=u.clipboardData.items,i=0,e=o.length;e>i;i++)t=o[i],t.kind==="file"&&(r=t.getAsFile())&&n.push(new d(s,r));n.length&&(u.preventDefault(),u.stopPropagation(),this.trigger("paste",n))},destroy:function(){this.elem.off("paste",this.hander)}})}),k("runtime/html5/filepicker",["base","runtime/html5/runtime"],function(f,p){var d=f.$;return p.register("FilePicker",{init:function(){var u,o,t,r,i=this.getRuntime().getContainer(),e=this,n=e.owner,s=e.options,a=this.label=d(document.createElement("label")),l=this.input=d(document.createElement("input"));if(l.attr("type","file"),l.attr("name",s.name),l.addClass("webuploader-element-invisible"),l.attr("webkitdirectory",""),a.on("click",function(){l.trigger("click")}),a.css({opacity:0,width:"100%",height:"100%",display:"block",cursor:"pointer",background:"#ffffff"}),s.multiple&&l.attr("multiple","multiple"),s.accept&&s.accept.length>0){for(u=[],o=0,t=s.accept.length;t>o;o++)u.push(s.accept[o].mimeTypes);l.attr("accept",u.join(","))}i.append(l),i.append(a),r=function(y){n.trigger(y.type)},l.on("change",function(y){var w,R=arguments.callee;e.files=y.target.files,w=this.cloneNode(!0),w.value=null,this.parentNode.replaceChild(w,this),l.off(),l=d(w).on("change",R).on("mouseenter mouseleave",r),n.trigger("change")}),a.on("mouseenter mouseleave",r)},getFiles:function(){return this.files},destroy:function(){this.input.off(),this.label.off()}})}),k("runtime/html5/util",["base"],function(f){var p=I.createObjectURL&&I||I.URL&&URL.revokeObjectURL&&URL||I.webkitURL,d=f.noop,u=d;return p&&(d=function(){return p.createObjectURL.apply(p,arguments)},u=function(){return p.revokeObjectURL.apply(p,arguments)}),{createObjectURL:d,revokeObjectURL:u,dataURL2Blob:function(o){var t,r,i,e,n,s;for(s=o.split(","),t=~s[0].indexOf("base64")?atob(s[1]):decodeURIComponent(s[1]),i=new ArrayBuffer(t.length),r=new Uint8Array(i),e=0;e<t.length;e++)r[e]=t.charCodeAt(e);return n=s[0].split(":")[1].split(";")[0],this.arrayBufferToBlob(i,n)},dataURL2ArrayBuffer:function(o){var t,r,i,e;for(e=o.split(","),t=~e[0].indexOf("base64")?atob(e[1]):decodeURIComponent(e[1]),r=new Uint8Array(t.length),i=0;i<t.length;i++)r[i]=t.charCodeAt(i);return r.buffer},arrayBufferToBlob:function(o,t){var r,i=I.BlobBuilder||I.WebKitBlobBuilder;return i?(r=new i,r.append(o),r.getBlob(t)):new Blob([o],t?{type:t}:{})},canvasToDataUrl:function(o,t,r){return o.toDataURL(t,r/100)},parseMeta:function(o,t){t(!1,{})},updateImageHead:function(o){return o}}}),k("runtime/html5/imagemeta",["runtime/html5/util"],function(f){var p;return p={parsers:{65505:[]},maxMetaDataSize:262144,parse:function(d,u){var o=this,t=new FileReader;t.onload=function(){u(!1,o._parse(this.result)),t=t.onload=t.onerror=null},t.onerror=function(r){u(r.message),t=t.onload=t.onerror=null},d=d.slice(0,o.maxMetaDataSize),t.readAsArrayBuffer(d.getSource())},_parse:function(d,u){if(!(d.byteLength<6)){var o,t,r,i,e=new DataView(d),n=2,s=e.byteLength-4,a=n,l={};if(e.getUint16(0)===65496){for(;s>n&&(o=e.getUint16(n),o>=65504&&65519>=o||o===65534)&&(t=e.getUint16(n+2)+2,!(n+t>e.byteLength));){if(r=p.parsers[o],!u&&r)for(i=0;i<r.length;i+=1)r[i].call(p,e,n,t,l);n+=t,a=n}a>6&&(l.imageHead=d.slice?d.slice(2,a):new Uint8Array(d).subarray(2,a))}return l}},updateImageHead:function(d,u){var o,t,r,i=this._parse(d,!0);return r=2,i.imageHead&&(r=2+i.imageHead.byteLength),t=d.slice?d.slice(r):new Uint8Array(d).subarray(r),o=new Uint8Array(u.byteLength+2+t.byteLength),o[0]=255,o[1]=216,o.set(new Uint8Array(u),2),o.set(new Uint8Array(t),u.byteLength+2),o.buffer}},f.parseMeta=function(){return p.parse.apply(p,arguments)},f.updateImageHead=function(){return p.updateImageHead.apply(p,arguments)},p}),k("runtime/html5/imagemeta/exif",["base","runtime/html5/imagemeta"],function(f,p){var d={};return d.ExifMap=function(){return this},d.ExifMap.prototype.map={Orientation:274},d.ExifMap.prototype.get=function(u){return this[u]||this[this.map[u]]},d.exifTagTypes={1:{getValue:function(u,o){return u.getUint8(o)},size:1},2:{getValue:function(u,o){return String.fromCharCode(u.getUint8(o))},size:1,ascii:!0},3:{getValue:function(u,o,t){return u.getUint16(o,t)},size:2},4:{getValue:function(u,o,t){return u.getUint32(o,t)},size:4},5:{getValue:function(u,o,t){return u.getUint32(o,t)/u.getUint32(o+4,t)},size:8},9:{getValue:function(u,o,t){return u.getInt32(o,t)},size:4},10:{getValue:function(u,o,t){return u.getInt32(o,t)/u.getInt32(o+4,t)},size:8}},d.exifTagTypes[7]=d.exifTagTypes[1],d.getExifValue=function(u,o,t,r,i,e){var n,s,a,l,y,w,R=d.exifTagTypes[r];if(!R)return void f.log("Invalid Exif data: Invalid tag type.");if(n=R.size*i,s=n>4?o+u.getUint32(t+8,e):t+8,s+n>u.byteLength)return void f.log("Invalid Exif data: Invalid data offset.");if(i===1)return R.getValue(u,s,e);for(a=[],l=0;i>l;l+=1)a[l]=R.getValue(u,s+l*R.size,e);if(R.ascii){for(y="",l=0;l<a.length&&(w=a[l],w!=="\0");l+=1)y+=w;return y}return a},d.parseExifTag=function(u,o,t,r,i){var e=u.getUint16(t,r);i.exif[e]=d.getExifValue(u,o,t,u.getUint16(t+2,r),u.getUint32(t+4,r),r)},d.parseExifTags=function(u,o,t,r,i){var e,n,s;if(t+6>u.byteLength)return void f.log("Invalid Exif data: Invalid directory offset.");if(e=u.getUint16(t,r),n=t+2+12*e,n+4>u.byteLength)return void f.log("Invalid Exif data: Invalid directory size.");for(s=0;e>s;s+=1)this.parseExifTag(u,o,t+2+12*s,r,i);return u.getUint32(n,r)},d.parseExifData=function(u,o,t,r){var i,e,n=o+10;if(u.getUint32(o+4)===1165519206){if(n+8>u.byteLength)return void f.log("Invalid Exif data: Invalid segment size.");if(u.getUint16(o+8)!==0)return void f.log("Invalid Exif data: Missing byte alignment offset.");switch(u.getUint16(n)){case 18761:i=!0;break;case 19789:i=!1;break;default:return void f.log("Invalid Exif data: Invalid byte alignment marker.")}if(u.getUint16(n+2,i)!==42)return void f.log("Invalid Exif data: Missing TIFF marker.");e=u.getUint32(n+4,i),r.exif=new d.ExifMap,e=d.parseExifTags(u,n,n+e,i,r)}},p.parsers[65505].push(d.parseExifData),d}),k("runtime/html5/jpegencoder",[],function(){function f(p){function d(x){for(var F=[16,11,10,16,24,40,51,61,12,12,14,19,26,58,60,55,14,13,16,24,40,57,69,56,14,17,22,29,51,87,80,62,18,22,37,56,68,109,103,77,24,35,55,64,81,104,113,92,49,64,78,87,103,121,120,101,72,92,95,98,112,100,103,99],S=0;64>S;S++){var T=L((F[S]*x+50)/100);1>T?T=1:T>255&&(T=255),X[ie[S]]=T}for(var A=[17,18,24,47,99,99,99,99,18,21,26,66,99,99,99,99,24,26,56,99,99,99,99,99,47,66,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99],U=0;64>U;U++){var D=L((A[U]*x+50)/100);1>D?D=1:D>255&&(D=255),ne[ie[U]]=D}for(var B=[1,1.387039845,1.306562965,1.175875602,1,.785694958,.5411961,.275899379],j=0,H=0;8>H;H++)for(var O=0;8>O;O++)Y[j]=1/(X[ie[j]]*B[H]*B[O]*8),K[j]=1/(ne[ie[j]]*B[H]*B[O]*8),j++}function u(x,F){for(var S=0,T=0,A=new Array,U=1;16>=U;U++){for(var D=1;D<=x[U];D++)A[F[T]]=[],A[F[T]][0]=S,A[F[T]][1]=U,T++,S++;S*=2}return A}function o(){g=u(Re,ke),v=u(Fe,Te),_=u(Ee,Se),q=u(Ue,Ae)}function t(){for(var x=1,F=2,S=1;15>=S;S++){for(var T=x;F>T;T++)ue[32767+T]=S,G[32767+T]=[],G[32767+T][1]=S,G[32767+T][0]=T;for(var A=-(F-1);-x>=A;A++)ue[32767+A]=S,G[32767+A]=[],G[32767+A][1]=S,G[32767+A][0]=F-1+A;x<<=1,F<<=1}}function r(){for(var x=0;256>x;x++)P[x]=19595*x,P[x+256>>0]=38470*x,P[x+512>>0]=7471*x+32768,P[x+768>>0]=-11059*x,P[x+1024>>0]=-21709*x,P[x+1280>>0]=32768*x+8421375,P[x+1536>>0]=-27439*x,P[x+1792>>0]=-5329*x}function i(x){for(var F=x[0],S=x[1]-1;S>=0;)F&1<<S&&(te|=1<<W),S--,W--,0>W&&(te==255?(e(255),e(0)):e(te),W=7,te=0)}function e(x){ae.push(be[x])}function n(x){e(x>>8&255),e(255&x)}function s(x,F){var S,T,A,U,D,B,j,H,O,E=0,$=8,Q=64;for(O=0;$>O;++O){S=x[E],T=x[E+1],A=x[E+2],U=x[E+3],D=x[E+4],B=x[E+5],j=x[E+6],H=x[E+7];var z=S+H,Z=S-H,M=T+j,V=T-j,N=A+B,J=A-B,ce=U+D,Ze=U-D,re=z+ce,ge=z-ce,le=M+N,fe=M-N;x[E]=re+le,x[E+4]=re-le;var De=.707106781*(fe+ge);x[E+2]=ge+De,x[E+6]=ge-De,re=Ze+J,le=J+V,fe=V+Z;var Oe=.382683433*(re-fe),Ie=.5411961*re+Oe,Ce=1.306562965*fe+Oe,qe=.707106781*le,Be=Z+qe,Le=Z-qe;x[E+5]=Le+Ie,x[E+3]=Le-Ie,x[E+1]=Be+Ce,x[E+7]=Be-Ce,E+=8}for(E=0,O=0;$>O;++O){S=x[E],T=x[E+8],A=x[E+16],U=x[E+24],D=x[E+32],B=x[E+40],j=x[E+48],H=x[E+56];var je=S+H,me=S-H,Pe=T+j,He=T-j,Me=A+B,ze=A-B,Ne=U+D,Ke=U-D,oe=je+Ne,ve=je-Ne,de=Pe+Me,he=Pe-Me;x[E]=oe+de,x[E+32]=oe-de;var $e=.707106781*(he+ve);x[E+16]=ve+$e,x[E+48]=ve-$e,oe=Ke+ze,de=ze+He,he=He+me;var Qe=.382683433*(oe-he),Ve=.5411961*oe+Qe,Ge=1.306562965*he+Qe,We=.707106781*de,Je=me+We,Xe=me-We;x[E+40]=Xe+Ve,x[E+24]=Xe-Ve,x[E+8]=Je+Ge,x[E+56]=Je-Ge,E++}var pe;for(O=0;Q>O;++O)pe=x[O]*F[O],_e[O]=pe>0?pe+.5|0:pe-.5|0;return _e}function a(){n(65504),n(16),e(74),e(70),e(73),e(70),e(0),e(1),e(1),e(0),n(1),n(1),e(0),e(0)}function l(x,F){n(65472),n(17),e(8),n(F),n(x),e(3),e(1),e(17),e(0),e(2),e(17),e(1),e(3),e(17),e(1)}function y(){n(65499),n(132),e(0);for(var x=0;64>x;x++)e(X[x]);e(1);for(var F=0;64>F;F++)e(ne[F])}function w(){n(65476),n(418),e(0);for(var x=0;16>x;x++)e(Re[x+1]);for(var F=0;11>=F;F++)e(ke[F]);e(16);for(var S=0;16>S;S++)e(Ee[S+1]);for(var T=0;161>=T;T++)e(Se[T]);e(1);for(var A=0;16>A;A++)e(Fe[A+1]);for(var U=0;11>=U;U++)e(Te[U]);e(17);for(var D=0;16>D;D++)e(Ue[D+1]);for(var B=0;161>=B;B++)e(Ae[B])}function R(){n(65498),n(12),e(3),e(1),e(0),e(2),e(17),e(3),e(17),e(0),e(63),e(0)}function b(x,F,S,T,A){for(var U,D=A[0],B=A[240],j=16,H=63,O=64,E=s(x,F),$=0;O>$;++$)ee[ie[$]]=E[$];var Q=ee[0]-S;S=ee[0],Q==0?i(T[0]):(U=32767+Q,i(T[ue[U]]),i(G[U]));for(var z=63;z>0&&ee[z]==0;z--);if(z==0)return i(D),S;for(var Z,M=1;z>=M;){for(var V=M;ee[M]==0&&z>=M;++M);var N=M-V;if(N>=j){Z=N>>4;for(var J=1;Z>=J;++J)i(B);N=15&N}U=32767+ee[M],i(A[(N<<4)+ue[U]]),i(G[U]),M++}return z!=H&&i(D),S}function m(){for(var x=String.fromCharCode,F=0;256>F;F++)be[F]=x(F)}function c(x){if(0>=x&&(x=1),x>100&&(x=100),C!=x){var F=0;F=Math.floor(50>x?5e3/x:200-2*x),d(F),C=x}}function h(){p||(p=50),m(),o(),t(),r(),c(p)}var g,v,_,q,C,L=Math.floor,X=new Array(64),ne=new Array(64),Y=new Array(64),K=new Array(64),G=new Array(65535),ue=new Array(65535),_e=new Array(64),ee=new Array(64),ae=[],te=0,W=7,ye=new Array(64),we=new Array(64),xe=new Array(64),be=new Array(256),P=new Array(2048),ie=[0,1,5,6,14,15,27,28,2,4,7,13,16,26,29,42,3,8,12,17,25,30,41,43,9,11,18,24,31,40,44,53,10,19,23,32,39,45,52,54,20,22,33,38,46,51,55,60,21,34,37,47,50,56,59,61,35,36,48,49,57,58,62,63],Re=[0,0,1,5,1,1,1,1,1,1,0,0,0,0,0,0,0],ke=[0,1,2,3,4,5,6,7,8,9,10,11],Ee=[0,0,2,1,3,3,2,4,3,5,5,4,4,0,0,1,125],Se=[1,2,3,0,4,17,5,18,33,49,65,6,19,81,97,7,34,113,20,50,129,145,161,8,35,66,177,193,21,82,209,240,36,51,98,114,130,9,10,22,23,24,25,26,37,38,39,40,41,42,52,53,54,55,56,57,58,67,68,69,70,71,72,73,74,83,84,85,86,87,88,89,90,99,100,101,102,103,104,105,106,115,116,117,118,119,120,121,122,131,132,133,134,135,136,137,138,146,147,148,149,150,151,152,153,154,162,163,164,165,166,167,168,169,170,178,179,180,181,182,183,184,185,186,194,195,196,197,198,199,200,201,202,210,211,212,213,214,215,216,217,218,225,226,227,228,229,230,231,232,233,234,241,242,243,244,245,246,247,248,249,250],Fe=[0,0,3,1,1,1,1,1,1,1,1,1,0,0,0,0,0],Te=[0,1,2,3,4,5,6,7,8,9,10,11],Ue=[0,0,2,1,2,4,4,3,4,7,5,4,4,0,1,2,119],Ae=[0,1,2,3,17,4,5,33,49,6,18,65,81,7,97,113,19,34,50,129,8,20,66,145,161,177,193,9,35,51,82,240,21,98,114,209,10,22,36,52,225,37,241,23,24,25,26,38,39,40,41,42,53,54,55,56,57,58,67,68,69,70,71,72,73,74,83,84,85,86,87,88,89,90,99,100,101,102,103,104,105,106,115,116,117,118,119,120,121,122,130,131,132,133,134,135,136,137,138,146,147,148,149,150,151,152,153,154,162,163,164,165,166,167,168,169,170,178,179,180,181,182,183,184,185,186,194,195,196,197,198,199,200,201,202,210,211,212,213,214,215,216,217,218,226,227,228,229,230,231,232,233,234,242,243,244,245,246,247,248,249,250];this.encode=function(x,F){F&&c(F),ae=new Array,te=0,W=7,n(65496),a(),y(),l(x.width,x.height),w(),R();var S=0,T=0,A=0;te=0,W=7,this.encode.displayName="_encode_";for(var U,D,B,j,H,O,E,$,Q,z=x.data,Z=x.width,M=x.height,V=4*Z,N=0;M>N;){for(U=0;V>U;){for(H=V*N+U,O=H,E=-1,$=0,Q=0;64>Q;Q++)$=Q>>3,E=4*(7&Q),O=H+$*V+E,N+$>=M&&(O-=V*(N+1+$-M)),U+E>=V&&(O-=U+E-V+4),D=z[O++],B=z[O++],j=z[O++],ye[Q]=(P[D]+P[B+256>>0]+P[j+512>>0]>>16)-128,we[Q]=(P[D+768>>0]+P[B+1024>>0]+P[j+1280>>0]>>16)-128,xe[Q]=(P[D+1280>>0]+P[B+1536>>0]+P[j+1792>>0]>>16)-128;S=b(ye,Y,S,g,_),T=b(we,K,T,v,q),A=b(xe,K,A,v,q),U+=32}N+=8}if(W>=0){var J=[];J[1]=W+1,J[0]=(1<<W+1)-1,i(J)}n(65497);var ce="data:image/jpeg;base64,"+btoa(ae.join(""));return ae=[],ce},h()}return f.encode=function(p,d){var u=new f(d);return u.encode(p)},f}),k("runtime/html5/androidpatch",["runtime/html5/util","runtime/html5/jpegencoder","base"],function(f,p,d){var u,o=f.canvasToDataUrl;f.canvasToDataUrl=function(t,r,i){var e,n,s,a,l;return d.os.android?(r==="image/jpeg"&&typeof u=="undefined"&&(a=o.apply(null,arguments),l=a.split(","),a=~l[0].indexOf("base64")?atob(l[1]):decodeURIComponent(l[1]),a=a.substring(0,2),u=a.charCodeAt(0)===255&&a.charCodeAt(1)===216),r!=="image/jpeg"||u?o.apply(null,arguments):(n=t.width,s=t.height,e=t.getContext("2d"),p.encode(e.getImageData(0,0,n,s),i))):o.apply(null,arguments)}}),k("runtime/html5/image",["base","runtime/html5/runtime","runtime/html5/util"],function(f,p,d){var u="data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs%3D";return p.register("Image",{modified:!1,init:function(){var o=this,t=new Image;t.onload=function(){o._info={type:o.type,width:this.width,height:this.height},o._metas||o.type!=="image/jpeg"?o.owner.trigger("load"):d.parseMeta(o._blob,function(r,i){o._metas=i,o.owner.trigger("load")})},t.onerror=function(){o.owner.trigger("error")},o._img=t},loadFromBlob:function(o){var t=this,r=t._img;t._blob=o,t.type=o.type,r.src=d.createObjectURL(o.getSource()),t.owner.once("load",function(){d.revokeObjectURL(r.src)})},resize:function(o,t){var r=this._canvas||(this._canvas=document.createElement("canvas"));this._resize(this._img,r,o,t),this._blob=null,this.modified=!0,this.owner.trigger("complete","resize")},crop:function(o,t,r,i,e){var n=this._canvas||(this._canvas=document.createElement("canvas")),s=this.options,a=this._img,l=a.naturalWidth,y=a.naturalHeight,w=this.getOrientation();e=e||1,n.width=r,n.height=i,s.preserveHeaders||this._rotate2Orientaion(n,w),this._renderImageToCanvas(n,a,-o,-t,l*e,y*e),this._blob=null,this.modified=!0,this.owner.trigger("complete","crop")},getAsBlob:function(o){var t,r=this._blob,i=this.options;if(o=o||this.type,this.modified||this.type!==o){if(t=this._canvas,o==="image/jpeg"){if(r=d.canvasToDataUrl(t,o,i.quality),i.preserveHeaders&&this._metas&&this._metas.imageHead)return r=d.dataURL2ArrayBuffer(r),r=d.updateImageHead(r,this._metas.imageHead),r=d.arrayBufferToBlob(r,o)}else r=d.canvasToDataUrl(t,o);r=d.dataURL2Blob(r)}return r},getAsDataUrl:function(o){var t=this.options;return o=o||this.type,o==="image/jpeg"?d.canvasToDataUrl(this._canvas,o,t.quality):this._canvas.toDataURL(o)},getOrientation:function(){return this._metas&&this._metas.exif&&this._metas.exif.get("Orientation")||1},info:function(o){return o?(this._info=o,this):this._info},meta:function(o){return o?(this._meta=o,this):this._meta},destroy:function(){var o=this._canvas;this._img.onload=null,o&&(o.getContext("2d").clearRect(0,0,o.width,o.height),o.width=o.height=0,this._canvas=null),this._img.src=u,this._img=this._blob=null},_resize:function(o,t,r,i){var e,n,s,a,l,y=this.options,w=o.width,R=o.height,b=this.getOrientation();~[5,6,7,8].indexOf(b)&&(r^=i,i^=r,r^=i),e=Math[y.crop?"max":"min"](r/w,i/R),y.allowMagnify||(e=Math.min(1,e)),n=w*e,s=R*e,y.crop?(t.width=r,t.height=i):(t.width=n,t.height=s),a=(t.width-n)/2,l=(t.height-s)/2,y.preserveHeaders||this._rotate2Orientaion(t,b),this._renderImageToCanvas(t,o,a,l,n,s)},_rotate2Orientaion:function(o,t){var r=o.width,i=o.height,e=o.getContext("2d");switch(t){case 5:case 6:case 7:case 8:o.width=i,o.height=r}switch(t){case 2:e.translate(r,0),e.scale(-1,1);break;case 3:e.translate(r,i),e.rotate(Math.PI);break;case 4:e.translate(0,i),e.scale(1,-1);break;case 5:e.rotate(.5*Math.PI),e.scale(1,-1);break;case 6:e.rotate(.5*Math.PI),e.translate(0,-i);break;case 7:e.rotate(.5*Math.PI),e.translate(r,-i),e.scale(-1,1);break;case 8:e.rotate(-.5*Math.PI),e.translate(-r,0)}},_renderImageToCanvas:function(){function o(r,i,e){var n,s,a,l=document.createElement("canvas"),y=l.getContext("2d"),w=0,R=e,b=e;for(l.width=1,l.height=e,y.drawImage(r,0,0),n=y.getImageData(0,0,1,e).data;b>w;)s=n[4*(b-1)+3],s===0?R=b:w=b,b=R+w>>1;return a=b/e,a===0?1:a}function t(r){var i,e,n=r.naturalWidth,s=r.naturalHeight;return n*s>1048576?(i=document.createElement("canvas"),i.width=i.height=1,e=i.getContext("2d"),e.drawImage(r,-n+1,0),e.getImageData(0,0,1,1).data[3]===0):!1}return f.os.ios?f.os.ios>=7?function(r,i,e,n,s,a){var l=i.naturalWidth,y=i.naturalHeight,w=o(i,l,y);return r.getContext("2d").drawImage(i,0,0,l*w,y*w,e,n,s,a)}:function(r,i,e,n,s,a){var l,y,w,R,b,m,c,h=i.naturalWidth,g=i.naturalHeight,v=r.getContext("2d"),_=t(i),q=this.type==="image/jpeg",C=1024,L=0,X=0;for(_&&(h/=2,g/=2),v.save(),l=document.createElement("canvas"),l.width=l.height=C,y=l.getContext("2d"),w=q?o(i,h,g):1,R=Math.ceil(C*s/h),b=Math.ceil(C*a/g/w);g>L;){for(m=0,c=0;h>m;)y.clearRect(0,0,C,C),y.drawImage(i,-m,-L),v.drawImage(l,0,0,C,C,e+c,n+X,R,b),m+=C,c+=R;L+=C,X+=b}v.restore(),l=y=null}:function(r){var i=f.slice(arguments,1),e=r.getContext("2d");e.drawImage.apply(e,i)}}()})}),k("runtime/html5/transport",["base","runtime/html5/runtime"],function(f,p){var d=f.noop,u=f.$;return p.register("Transport",{init:function(){this._status=0,this._response=null},send:function(){var o,t,r,i=this.owner,e=this.options,n=this._initAjax(),s=i._blob,a=e.server;e.sendAsBinary?(a+=(/\?/.test(a)?"&":"?")+u.param(i._formData),t=s.getSource()):(o=new FormData,u.each(i._formData,function(l,y){o.append(l,y)}),o.append(e.fileVal,s.getSource(),e.filename||i._formData.name||"")),e.withCredentials&&"withCredentials"in n?(n.open(e.method,a,!0),n.withCredentials=!0):n.open(e.method,a),this._setRequestHeader(n,e.headers),t?(n.overrideMimeType&&n.overrideMimeType("application/octet-stream"),f.os.android?(r=new FileReader,r.onload=function(){n.send(this.result),r=r.onload=null},r.readAsArrayBuffer(t)):n.send(t)):n.send(o)},getResponse:function(){return this._response},getResponseAsJson:function(){return this._parseJson(this._response)},getStatus:function(){return this._status},abort:function(){var o=this._xhr;o&&(o.upload.onprogress=d,o.onreadystatechange=d,o.abort(),this._xhr=o=null)},destroy:function(){this.abort()},_initAjax:function(){var o=this,t=new XMLHttpRequest,r=this.options;return!r.withCredentials||"withCredentials"in t||typeof XDomainRequest=="undefined"||(t=new XDomainRequest),t.upload.onprogress=function(i){var e=0;return i.lengthComputable&&(e=i.loaded/i.total),o.trigger("progress",e)},t.onreadystatechange=function(){return t.readyState===4?(t.upload.onprogress=d,t.onreadystatechange=d,o._xhr=null,o._status=t.status,t.status>=200&&t.status<300?(o._response=t.responseText,o.trigger("load")):t.status>=500&&t.status<600?(o._response=t.responseText,o.trigger("error","server")):o.trigger("error",o._status?"http":"abort")):void 0},o._xhr=t,t},_setRequestHeader:function(o,t){u.each(t,function(r,i){o.setRequestHeader(r,i)})},_parseJson:function(o){var t;try{t=JSON.parse(o)}catch(r){t={}}return t}})}),k("runtime/html5/md5",["runtime/html5/runtime"],function(f){var p=function(m,c){return m+c&4294967295},d=function(m,c,h,g,v,_){return c=p(p(c,m),p(g,_)),p(c<<v|c>>>32-v,h)},u=function(m,c,h,g,v,_,q){return d(c&h|~c&g,m,c,v,_,q)},o=function(m,c,h,g,v,_,q){return d(c&g|h&~g,m,c,v,_,q)},t=function(m,c,h,g,v,_,q){return d(c^h^g,m,c,v,_,q)},r=function(m,c,h,g,v,_,q){return d(h^(c|~g),m,c,v,_,q)},i=function(m,c){var h=m[0],g=m[1],v=m[2],_=m[3];h=u(h,g,v,_,c[0],7,-680876936),_=u(_,h,g,v,c[1],12,-389564586),v=u(v,_,h,g,c[2],17,606105819),g=u(g,v,_,h,c[3],22,-1044525330),h=u(h,g,v,_,c[4],7,-176418897),_=u(_,h,g,v,c[5],12,1200080426),v=u(v,_,h,g,c[6],17,-1473231341),g=u(g,v,_,h,c[7],22,-45705983),h=u(h,g,v,_,c[8],7,1770035416),_=u(_,h,g,v,c[9],12,-1958414417),v=u(v,_,h,g,c[10],17,-42063),g=u(g,v,_,h,c[11],22,-1990404162),h=u(h,g,v,_,c[12],7,1804603682),_=u(_,h,g,v,c[13],12,-40341101),v=u(v,_,h,g,c[14],17,-1502002290),g=u(g,v,_,h,c[15],22,1236535329),h=o(h,g,v,_,c[1],5,-165796510),_=o(_,h,g,v,c[6],9,-1069501632),v=o(v,_,h,g,c[11],14,643717713),g=o(g,v,_,h,c[0],20,-373897302),h=o(h,g,v,_,c[5],5,-701558691),_=o(_,h,g,v,c[10],9,38016083),v=o(v,_,h,g,c[15],14,-660478335),g=o(g,v,_,h,c[4],20,-405537848),h=o(h,g,v,_,c[9],5,568446438),_=o(_,h,g,v,c[14],9,-1019803690),v=o(v,_,h,g,c[3],14,-187363961),g=o(g,v,_,h,c[8],20,1163531501),h=o(h,g,v,_,c[13],5,-1444681467),_=o(_,h,g,v,c[2],9,-51403784),v=o(v,_,h,g,c[7],14,1735328473),g=o(g,v,_,h,c[12],20,-1926607734),h=t(h,g,v,_,c[5],4,-378558),_=t(_,h,g,v,c[8],11,-2022574463),v=t(v,_,h,g,c[11],16,1839030562),g=t(g,v,_,h,c[14],23,-35309556),h=t(h,g,v,_,c[1],4,-1530992060),_=t(_,h,g,v,c[4],11,1272893353),v=t(v,_,h,g,c[7],16,-155497632),g=t(g,v,_,h,c[10],23,-1094730640),h=t(h,g,v,_,c[13],4,681279174),_=t(_,h,g,v,c[0],11,-358537222),v=t(v,_,h,g,c[3],16,-722521979),g=t(g,v,_,h,c[6],23,76029189),h=t(h,g,v,_,c[9],4,-640364487),_=t(_,h,g,v,c[12],11,-421815835),v=t(v,_,h,g,c[15],16,530742520),g=t(g,v,_,h,c[2],23,-995338651),h=r(h,g,v,_,c[0],6,-198630844),_=r(_,h,g,v,c[7],10,1126891415),v=r(v,_,h,g,c[14],15,-1416354905),g=r(g,v,_,h,c[5],21,-57434055),h=r(h,g,v,_,c[12],6,1700485571),_=r(_,h,g,v,c[3],10,-1894986606),v=r(v,_,h,g,c[10],15,-1051523),g=r(g,v,_,h,c[1],21,-2054922799),h=r(h,g,v,_,c[8],6,1873313359),_=r(_,h,g,v,c[15],10,-30611744),v=r(v,_,h,g,c[6],15,-1560198380),g=r(g,v,_,h,c[13],21,1309151649),h=r(h,g,v,_,c[4],6,-145523070),_=r(_,h,g,v,c[11],10,-1120210379),v=r(v,_,h,g,c[2],15,718787259),g=r(g,v,_,h,c[9],21,-343485551),m[0]=p(h,m[0]),m[1]=p(g,m[1]),m[2]=p(v,m[2]),m[3]=p(_,m[3])},e=function(m){var c,h=[];for(c=0;64>c;c+=4)h[c>>2]=m.charCodeAt(c)+(m.charCodeAt(c+1)<<8)+(m.charCodeAt(c+2)<<16)+(m.charCodeAt(c+3)<<24);return h},n=function(m){var c,h=[];for(c=0;64>c;c+=4)h[c>>2]=m[c]+(m[c+1]<<8)+(m[c+2]<<16)+(m[c+3]<<24);return h},s=function(m){var c,h,g,v,_,q,C=m.length,L=[1732584193,-271733879,-1732584194,271733878];for(c=64;C>=c;c+=64)i(L,e(m.substring(c-64,c)));for(m=m.substring(c-64),h=m.length,g=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],c=0;h>c;c+=1)g[c>>2]|=m.charCodeAt(c)<<(c%4<<3);if(g[c>>2]|=128<<(c%4<<3),c>55)for(i(L,g),c=0;16>c;c+=1)g[c]=0;return v=8*C,v=v.toString(16).match(/(.*?)(.{0,8})$/),_=parseInt(v[2],16),q=parseInt(v[1],16)||0,g[14]=_,g[15]=q,i(L,g),L},a=function(m){var c,h,g,v,_,q,C=m.length,L=[1732584193,-271733879,-1732584194,271733878];for(c=64;C>=c;c+=64)i(L,n(m.subarray(c-64,c)));for(m=C>c-64?m.subarray(c-64):new Uint8Array(0),h=m.length,g=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],c=0;h>c;c+=1)g[c>>2]|=m[c]<<(c%4<<3);if(g[c>>2]|=128<<(c%4<<3),c>55)for(i(L,g),c=0;16>c;c+=1)g[c]=0;return v=8*C,v=v.toString(16).match(/(.*?)(.{0,8})$/),_=parseInt(v[2],16),q=parseInt(v[1],16)||0,g[14]=_,g[15]=q,i(L,g),L},l=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"],y=function(m){var c,h="";for(c=0;4>c;c+=1)h+=l[m>>8*c+4&15]+l[m>>8*c&15];return h},w=function(m){var c;for(c=0;c<m.length;c+=1)m[c]=y(m[c]);return m.join("")},R=function(m){return w(s(m))},b=function(){this.reset()};return R("hello")!=="5d41402abc4b2a76b9719d911017c592"&&(p=function(m,c){var h=(65535&m)+(65535&c),g=(m>>16)+(c>>16)+(h>>16);return g<<16|65535&h}),b.prototype.append=function(m){return/[\u0080-\uFFFF]/.test(m)&&(m=unescape(encodeURIComponent(m))),this.appendBinary(m),this},b.prototype.appendBinary=function(m){this._buff+=m,this._length+=m.length;var c,h=this._buff.length;for(c=64;h>=c;c+=64)i(this._state,e(this._buff.substring(c-64,c)));return this._buff=this._buff.substr(c-64),this},b.prototype.end=function(m){var c,h,g=this._buff,v=g.length,_=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(c=0;v>c;c+=1)_[c>>2]|=g.charCodeAt(c)<<(c%4<<3);return this._finish(_,v),h=m?this._state:w(this._state),this.reset(),h},b.prototype._finish=function(m,c){var h,g,v,_=c;if(m[_>>2]|=128<<(_%4<<3),_>55)for(i(this._state,m),_=0;16>_;_+=1)m[_]=0;h=8*this._length,h=h.toString(16).match(/(.*?)(.{0,8})$/),g=parseInt(h[2],16),v=parseInt(h[1],16)||0,m[14]=g,m[15]=v,i(this._state,m)},b.prototype.reset=function(){return this._buff="",this._length=0,this._state=[1732584193,-271733879,-1732584194,271733878],this},b.prototype.destroy=function(){delete this._state,delete this._buff,delete this._length},b.hash=function(m,c){/[\u0080-\uFFFF]/.test(m)&&(m=unescape(encodeURIComponent(m)));var h=s(m);return c?h:w(h)},b.hashBinary=function(m,c){var h=s(m);return c?h:w(h)},b.ArrayBuffer=function(){this.reset()},b.ArrayBuffer.prototype.append=function(m){var c,h=this._concatArrayBuffer(this._buff,m),g=h.length;for(this._length+=m.byteLength,c=64;g>=c;c+=64)i(this._state,n(h.subarray(c-64,c)));return this._buff=g>c-64?h.subarray(c-64):new Uint8Array(0),this},b.ArrayBuffer.prototype.end=function(m){var c,h,g=this._buff,v=g.length,_=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(c=0;v>c;c+=1)_[c>>2]|=g[c]<<(c%4<<3);return this._finish(_,v),h=m?this._state:w(this._state),this.reset(),h},b.ArrayBuffer.prototype._finish=b.prototype._finish,b.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._state=[1732584193,-271733879,-1732584194,271733878],this},b.ArrayBuffer.prototype.destroy=b.prototype.destroy,b.ArrayBuffer.prototype._concatArrayBuffer=function(m,c){var h=m.length,g=new Uint8Array(h+c.byteLength);return g.set(m),g.set(new Uint8Array(c),h),g},b.ArrayBuffer.hash=function(m,c){var h=a(new Uint8Array(m));return c?h:w(h)},f.register("Md5",{init:function(){},loadFromBlob:function(m){var c,h,g=m.getSource(),v=2097152,_=Math.ceil(g.size/v),q=0,C=this.owner,L=new b.ArrayBuffer,X=this,ne=g.mozSlice||g.webkitSlice||g.slice;h=new FileReader,(c=function(){var Y,K;Y=q*v,K=Math.min(Y+v,g.size),h.onload=function(G){L.append(G.target.result),C.trigger("progress",{total:m.size,loaded:K})},h.onloadend=function(){h.onloadend=h.onload=null,++q<_?setTimeout(c,1):setTimeout(function(){C.trigger("load"),X.result=L.end(),c=m=g=L=null,C.trigger("complete")},50)},h.readAsArrayBuffer(ne.call(g,Y,K))})()},getResult:function(){return this.result}})}),k("runtime/flash/runtime",["base","runtime/runtime","runtime/compbase"],function(f,p,d){function u(){var e;try{e=navigator.plugins["Shockwave Flash"],e=e.description}catch(n){try{e=new ActiveXObject("ShockwaveFlash.ShockwaveFlash").GetVariable("$version")}catch(s){e="0.0"}}return e=e.match(/\d+/g),parseFloat(e[0]+"."+e[1],10)}function o(){function e(w,R){var b,m,c=w.type||w;b=c.split("::"),m=b[0],c=b[1],c==="Ready"&&m===l.uid?l.trigger("ready"):s[m]&&s[m].trigger(c.toLowerCase(),w,R)}var n={},s={},a=this.destroy,l=this,y=f.guid("webuploader_");p.apply(l,arguments),l.type=r,l.exec=function(w,R){var b,m=this,c=m.uid,h=f.slice(arguments,2);return s[c]=m,i[w]&&(n[c]||(n[c]=new i[w](m,l)),b=n[c],b[R])?b[R].apply(b,h):l.flashExec.apply(m,arguments)},I[y]=function(){var w=arguments;setTimeout(function(){e.apply(null,w)},1)},this.jsreciver=y,this.destroy=function(){return a&&a.apply(this,arguments)},this.flashExec=function(w,R){var b=l.getFlash(),m=f.slice(arguments,2);return b.exec(this.uid,w,R,m)}}var t=f.$,r="flash",i={};return f.inherits(p,{constructor:o,init:function(){var e,n=this.getContainer(),s=this.options;n.css({position:"absolute",top:"-8px",left:"-8px",width:"9px",height:"9px",overflow:"hidden"}),e='<object id="'+this.uid+'" type="application/x-shockwave-flash" data="'+s.swf+'" ',f.browser.ie&&(e+='classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" '),e+='width="100%" height="100%" style="outline:0"><param name="movie" value="'+s.swf+'" /><param name="flashvars" value="uid='+this.uid+"&jsreciver="+this.jsreciver+'" /><param name="wmode" value="transparent" /><param name="allowscriptaccess" value="always" /></object>',n.html(e)},getFlash:function(){return this._flash?this._flash:(this._flash=t("#"+this.uid).get(0),this._flash)}}),o.register=function(e,n){return n=i[e]=f.inherits(d,t.extend({flashExec:function(){var s=this.owner,a=this.getRuntime();return a.flashExec.apply(s,arguments)}},n))},u()>=11.4&&p.addRuntime(r,o),o}),k("runtime/flash/filepicker",["base","runtime/flash/runtime"],function(f,p){var d=f.$;return p.register("FilePicker",{init:function(u){var o,t,r=d.extend({},u);for(o=r.accept&&r.accept.length,t=0;o>t;t++)r.accept[t].title||(r.accept[t].title="Files");delete r.button,delete r.id,delete r.container,this.flashExec("FilePicker","init",r)},destroy:function(){this.flashExec("FilePicker","destroy")}})}),k("runtime/flash/image",["runtime/flash/runtime"],function(f){return f.register("Image",{loadFromBlob:function(p){var d=this.owner;d.info()&&this.flashExec("Image","info",d.info()),d.meta()&&this.flashExec("Image","meta",d.meta()),this.flashExec("Image","loadFromBlob",p.uid)}})}),k("runtime/flash/transport",["base","runtime/flash/runtime","runtime/client"],function(f,p,d){var u=f.$;return p.register("Transport",{init:function(){this._status=0,this._response=null,this._responseJson=null},send:function(){var o,t=this.owner,r=this.options,i=this._initAjax(),e=t._blob,n=r.server;i.connectRuntime(e.ruid),r.sendAsBinary?(n+=(/\?/.test(n)?"&":"?")+u.param(t._formData),o=e.uid):(u.each(t._formData,function(s,a){i.exec("append",s,a)}),i.exec("appendBlob",r.fileVal,e.uid,r.filename||t._formData.name||"")),this._setRequestHeader(i,r.headers),i.exec("send",{method:r.method,url:n,forceURLStream:r.forceURLStream,mimeType:"application/octet-stream"},o)},getStatus:function(){return this._status},getResponse:function(){return this._response||""},getResponseAsJson:function(){return this._responseJson},abort:function(){var o=this._xhr;o&&(o.exec("abort"),o.destroy(),this._xhr=o=null)},destroy:function(){this.abort()},_initAjax:function(){var o=this,t=new d("XMLHttpRequest");return t.on("uploadprogress progress",function(r){var i=r.loaded/r.total;return i=Math.min(1,Math.max(0,i)),o.trigger("progress",i)}),t.on("load",function(){var r,i=t.exec("getStatus"),e=!1,n="";return t.off(),o._xhr=null,i>=200&&300>i?e=!0:i>=500&&600>i?(e=!0,n="server"):n="http",e&&(o._response=t.exec("getResponse"),o._response=decodeURIComponent(o._response),r=I.JSON&&I.JSON.parse||function(s){try{return new Function("return "+s).call()}catch(a){return{}}},o._responseJson=o._response?r(o._response):{}),t.destroy(),t=null,n?o.trigger("error",n):o.trigger("load")}),t.on("error",function(){t.off(),o._xhr=null,o.trigger("error","http")}),o._xhr=t,t},_setRequestHeader:function(o,t){u.each(t,function(r,i){o.exec("setRequestHeader",r,i)})}})}),k("runtime/flash/blob",["runtime/flash/runtime","lib/blob"],function(f,p){return f.register("Blob",{slice:function(d,u){var o=this.flashExec("Blob","slice",d,u);return new p(o.uid,o)}})}),k("runtime/flash/md5",["runtime/flash/runtime"],function(f){return f.register("Md5",{init:function(){},loadFromBlob:function(p){return this.flashExec("Md5","loadFromBlob",p.uid)}})}),k("preset/all",["base","widgets/filednd","widgets/filepaste","widgets/filepicker","widgets/image","widgets/queue","widgets/runtime","widgets/upload","widgets/validator","widgets/md5","runtime/html5/blob","runtime/html5/dnd","runtime/html5/filepaste","runtime/html5/filepicker","runtime/html5/imagemeta/exif","runtime/html5/androidpatch","runtime/html5/image","runtime/html5/transport","runtime/html5/md5","runtime/flash/filepicker","runtime/flash/image","runtime/flash/transport","runtime/flash/blob","runtime/flash/md5"],function(f){return f}),k("widgets/log",["base","uploader","widgets/widget"],function(f,p){function d(e){var n=o.extend({},u,e),s=t.replace(/^(.*)\?/,"$1"+o.param(n)),a=new Image;a.src=s}var u,o=f.$,t=" http://static.tieba.baidu.com/tb/pms/img/st.gif??",r=(location.hostname||location.host||"protected").toLowerCase(),i=r&&/baidu/i.exec(r);if(i)return u={dv:3,master:"webuploader",online:/test/.exec(r)?0:1,module:"",product:r,type:0},p.register({name:"log",init:function(){var e=this.owner,n=0,s=0;e.on("error",function(a){d({type:2,c_error_code:a})}).on("uploadError",function(a,l){d({type:2,c_error_code:"UPLOAD_ERROR",c_reason:""+l})}).on("uploadComplete",function(a){n++,s+=a.size}).on("uploadFinished",function(){d({c_count:n,c_size:s}),n=s=0}),d({c_usage:1})}})}),k("webuploader",["preset/all","widgets/log"],function(f){return f}),se("webuploader")});
|