Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fix transform with serial: false #216

Merged
merged 3 commits into from

3 participants

@jrdi

I am trying to use serial: false from dev branch and it only transform properly the first image. Here is the code I am using.

FileAPI.upload('./upload', files, {
  serial: false,
  imageTransform: {
    type: 'image/jpeg',
    quality: 0.86, // jpeg quality
    maxWidth: 100
  },
  progress: function (evt){ /* ... */ },
  complete: function (err, xhr){ /* ... */ }
});

After take a look to the code I found this block:

if( isOrignTrans ){
    // Convert to array for transform function
    trans = [trans];
}

It is inside of an each so we modify trans every iteration and finally we get something similar to [[[trans]]], it causes transformation errors. I hope I fix it properly.

@jrdi

Close #208

@markets

:+1: for this fix

@RubaXa do you think dev branch it's ready to push a new release? If no, is there to much to end?

@RubaXa RubaXa merged commit a390f9b into mailru:dev
@RubaXa
Owner

Wow i'm sorry, I forgot.
Thanks a lot.

@jrdi jrdi deleted the jrdi:fix-serial-transform branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 8, 2014
  1. @jrdi
  2. @jrdi

    assembling files properly

    jrdi authored
  3. @jrdi

    add uglify files

    jrdi authored
This page is out of date. Refresh to see the latest.
View
6 dist/FileAPI.html5.js
@@ -526,7 +526,7 @@
doneList =
failList = null;
-
+
progressList = [];
for( ; i < n; i++ ){
@@ -1611,7 +1611,7 @@
, type: api.getMimeType(name)
};
}
-
+
function _isRegularFile(file, callback){
// http://stackoverflow.com/questions/8856628/detecting-folders-directories-in-javascript-filelist-objects
@@ -1784,7 +1784,7 @@
if( isOrignTrans ){
// Convert to array for transform function
- trans = [trans];
+ trans = [].concat(trans);
}
api.Image.transform(file, trans, options.imageAutoOrientation, function (err, images){
View
2  dist/FileAPI.html5.min.js
@@ -1,3 +1,3 @@
/*! FileAPI 2.1.0 - BSD | git://github.com/mailru/FileAPI.git */
-!function(a){"use strict";var b=a.HTMLCanvasElement&&a.HTMLCanvasElement.prototype,c=a.Blob&&function(){try{return Boolean(new Blob)}catch(a){return!1}}(),d=c&&a.Uint8Array&&function(){try{return 100===new Blob([new Uint8Array(100)]).size}catch(a){return!1}}(),e=a.BlobBuilder||a.WebKitBlobBuilder||a.MozBlobBuilder||a.MSBlobBuilder,f=(c||e)&&a.atob&&a.ArrayBuffer&&a.Uint8Array&&function(a){var b,f,g,h,i,j;for(b=a.split(",")[0].indexOf("base64")>=0?atob(a.split(",")[1]):decodeURIComponent(a.split(",")[1]),f=new ArrayBuffer(b.length),g=new Uint8Array(f),h=0;h<b.length;h+=1)g[h]=b.charCodeAt(h);return i=a.split(",")[0].split(":")[1].split(";")[0],c?new Blob([d?g:f],{type:i}):(j=new e,j.append(f),j.getBlob(i))};a.HTMLCanvasElement&&!b.toBlob&&(b.mozGetAsFile?b.toBlob=function(a,c,d){d&&b.toDataURL&&f?a(f(this.toDataURL(c,d))):a(this.mozGetAsFile("blob",c))}:b.toDataURL&&f&&(b.toBlob=function(a,b,c){a(f(this.toDataURL(b,c)))})),a.dataURLtoBlob=f}(window),function(a,b){"use strict";function c(a,b,c,d,e){var f={type:c.type||c,target:a,result:d};_(f,e),b(f)}function d(a){return A&&!!A.prototype["readAs"+a]}function e(a,e,f,g){if(fb.isBlob(a)&&d(f)){var h=new A;ab(h,T,function j(b){var d=b.type;"progress"==d?c(a,e,b,b.target.result,{loaded:b.loaded,total:b.total}):"loadend"==d?(bb(h,T,j),h=null):c(a,e,b,b.target.result)});try{g?h["readAs"+f](a,g):h["readAs"+f](a)}catch(i){c(a,e,"error",b,{error:i.toString()})}}else c(a,e,"error",b,{error:"filreader_not_support_"+f})}function f(a){return a&&(z&&a instanceof z||a.blob||a.image&&a.file||a.flashId)}function g(a){return{name:(a+"").split(/\\|\//g).pop(),type:fb.getMimeType(a)}}function h(a,b){if(!a.type&&a.size%4096===0&&a.size<=102400)if(A)try{var c=new A;cb(c,T,function(a){var d="error"!=a.type;b(d),d&&c.abort()}),c.readAsDataURL(a)}catch(d){b(!1)}else b(null);else b(!0)}function i(a){var b;return a.getAsEntry?b=a.getAsEntry():a.webkitGetAsEntry&&(b=a.webkitGetAsEntry()),b}function j(a,b){if(a)if(a.isFile)a.file(function(c){c.fullPath=a.fullPath,b(!1,[c])},function(a){b("FileError.code: "+a.code)});else if(a.isDirectory){var c=a.createReader(),d=[];c.readEntries(function(a){fb.afor(a,function(a,c){j(c,function(c,e){c?fb.log(c):d=d.concat(e),a?a():b(!1,d)})})},function(a){b("directory_reader: "+a)})}else j(i(a),b);else b("invalid entry")}function k(a,b){var c=[],d={};if(n(a)){var e=fb.getFiles(a);d[a.name||b]=null!==a.getAttribute("multiple")?e:e[0]}else Y(a)?n(a[0])?Z(a,function(a){d[a.name||b]=fb.getFiles(a)}):f(a[0])&&(d[b]=a):f(a)?d[b]=a:d=a;return Z(d,function g(a,b){Y(a)?Z(a,function(a){g(a,b)}):f(a)&&c.push({name:b,file:a,size:a.size,total:a.size,loaded:0})}),c}function l(a,b,c){var d=new fb.Form,e=fb.queue(function(){c(d)}),f=fb.support.transform&&a.imageTransform,g=f&&p(f),h=fb.postNameConcat;Z(b,function(b,c){var i=b.file,j=h(b.name,a.serial||a.chunkSize?null:c),k=i.name,l=i.type;!function m(b){b.image?(e.inc(),b.toData(function(a,b){k=k||(new Date).getTime()+".png",m(b),e.next()})):fb.Image&&f&&(/^image/.test(b.type)||K.test(b.nodeName))?(e.inc(),g&&(f=[f]),fb.Image.transform(b,f,a.imageAutoOrientation,function(c,i){if(g&&!c)H||fb.flashEngine||(d.multipart=!0),d.append(j,i[0],k,f[0].type||l);else{var m=0;c||Z(i,function(a,b){H||fb.flashEngine||(d.multipart=!0),f[b].postName||(m=1),d.append(f[b].postName||h(j,b),a,k,f[b].type||l)}),(c||a.imageOriginal)&&d.append(h(j,m?"original":null),b,k,l)}e.next()})):k!==fb.expando&&d.append(j,b,k)}(i)}),Z(a.data,function i(a,b){"object"==typeof a?Z(a,function(a,c){i(a,h(b,c))}):d.append(b,a)}),e.check()}function m(a){var b={};return Z(a,function(a,c){a&&"object"==typeof a&&null==a.nodeType&&(a=_({},a)),b[c]=a}),b}function n(a){return L.test(a&&a.tagName)}function o(a){return(a.originalEvent||a||"").dataTransfer||{}}function p(a){var b;for(b in a)if(a.hasOwnProperty(b)&&!(a[b]instanceof Object||"overlay"===b||"filter"===b))return!0;return!1}function q(a,b){var c=!1;if(v.msSaveBlob)c=v.msSaveBlob(a,b);else if(fb.support.download){var d=fb.createURL(a),e=t.body,f=X("a");d&&(f.href=d,f.download=b||a.name,f.style.top="-10000px",f.style.position="absolute",e.appendChild(f),f.click(),e.removeChild(f),c=!0,O(function(){fb.revokeURL(d)},1))}return c}var r=1,s=function(){},t=a.document,u=t.doctype||{},v=a.navigator,w=a.navigator.userAgent,x=a.createObjectURL&&a||a.URL&&URL.revokeObjectURL&&URL||a.webkitURL&&webkitURL,y=a.Blob,z=a.File,A=a.FileReader,B=a.FormData,C=a.jQuery,D=a.XMLHttpRequest,E=!(!(z&&A&&(a.Uint8Array||B||D.prototype.sendAsBinary))||/safari\//i.test(w)&&!/chrome\//i.test(w)&&/windows/i.test(w)),F=E&&"withCredentials"in new D,G=E&&!!y&&!!(y.prototype.webkitSlice||y.prototype.mozSlice||y.prototype.slice),H=a.dataURLtoBlob,I=/img/i,J=/canvas/i,K=/img|canvas/i,L=/input/i,M=/^data:[^,]+,/,N=a.Math,O=a.setTimeout,P=a.clearTimeout,Q=function(b){return b=new a.Number(N.pow(1024,b)),b.from=function(a){return N.round(a*this)},b},R={},S=[],T="abort progress error load loadend",U="status statusText readyState response responseXML responseText responseBody".split(" "),V="currentTarget",W="preventDefault",X=function(a){return t.createElement(a)},Y=function(a){return a&&"length"in a},Z=function(a,b,c){if(a)if(Y(a))for(var d=0,e=a.length;e>d;d++)d in a&&b.call(c,a[d],d,a);else for(var f in a)a.hasOwnProperty(f)&&b.call(c,a[f],f,a)},$=function(a,b){for(var c=-1,d=a&&a.length;d--;)if(a[d]===b){c=d;break}return c},_=function(a){for(var b=arguments,c=1,d=function(b,c){a[c]=b};c<b.length;c++)Z(b[c],d);return a},ab=function(a,b,c){if(a){var d=fb.uid(a);R[d]||(R[d]={});var e=A&&a&&a instanceof A;Z(b.split(/\s+/),function(b){C&&!e?C.event.add(a,b,c):(R[d][b]||(R[d][b]=[]),R[d][b].push(c),a.addEventListener?a.addEventListener(b,c,!1):a.attachEvent?a.attachEvent("on"+b,c):a["on"+b]=c)})}},bb=function(a,b,c){if(a){var d=fb.uid(a),e=R[d]||{},f=A&&a&&a instanceof A;Z(b.split(/\s+/),function(b){if(C&&!f)C.event.remove(a,b,c);else{for(var d=e[b]||[],g=d.length;g--;)if(d[g]===c){d.splice(g,1);break}a.addEventListener?a.removeEventListener(b,c,!1):a.detachEvent?a.detachEvent("on"+b,c):a["on"+b]=null}})}},cb=function(a,b,c){ab(a,b,function d(e){bb(a,b,d),c(e)})},db=function(b){return b.target||(b.target=a.event&&a.event.srcElement||t),3===b.target.nodeType&&(b.target=b.target.parentNode),b},eb=function(a){var b=X("input");return b.setAttribute("type","file"),a in b},fb={version:"2.1.0",cors:!1,html5:!0,media:!1,formData:!0,multiPassResize:!0,debug:!1,pingUrl:!1,multiFlash:!1,flashAbortTimeout:0,withCredentials:!0,staticPath:"./dist/",flashUrl:0,flashImageUrl:0,postNameConcat:function(a,b){return a+(null!=b?"["+b+"]":"")},support:{dnd:F&&"ondrop"in X("div"),cors:F,html5:E,chunked:G,dataURI:!0,accept:eb("accept"),multiple:eb("multiple"),saveAs:!!v.msSaveBlob,download:"download"in X("a")},ext2mime:{jpg:"image/jpeg",tif:"image/tiff",txt:"text/plain"},accept:{"image/*":"art bm bmp dwg dxf cbr cbz fif fpx gif ico iefs jfif jpe jpeg jpg jps jut mcf nap nif pbm pcx pgm pict pm png pnm qif qtif ras rast rf rp svf tga tif tiff xbm xbm xpm xwd","audio/*":"m4a flac aac rm mpa wav wma ogg mp3 mp2 m3u mod amf dmf dsm far gdm imf it m15 med okt s3m stm sfx ult uni xm sid ac3 dts cue aif aiff wpl ape mac mpc mpp shn wv nsf spc gym adplug adx dsp adp ymf ast afc hps xs","video/*":"m4v 3gp nsv ts ty strm rm rmvb m3u ifo mov qt divx xvid bivx vob nrg img iso pva wmv asf asx ogm m2v avi bin dat dvr-ms mpg mpeg mp4 mkv avc vp3 svq3 nuv viv dv fli flv wpl"},uploadRetry:0,networkDownRetryTimeout:5e3,chunkSize:0,chunkUploadRetry:0,chunkNetworkDownRetryTimeout:2e3,KB:Q(1),MB:Q(2),GB:Q(3),TB:Q(4),EMPTY_PNG:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQIW2NkAAIAAAoAAggA9GkAAAAASUVORK5CYII=",expando:"fileapi"+(new Date).getTime(),uid:function(a){return a?a[fb.expando]=a[fb.expando]||fb.uid():(++r,fb.expando+r)},log:function(){fb.debug&&a.console&&console.log&&(console.log.apply?console.log.apply(console,arguments):console.log([].join.call(arguments," ")))},newImage:function(a,b){var c=X("img");return b&&fb.event.one(c,"error load",function(a){b("error"==a.type,c),c=null}),c.src=a,c},getXHR:function(){var b;if(D)b=new D;else if(a.ActiveXObject)try{b=new ActiveXObject("MSXML2.XMLHttp.3.0")}catch(c){b=new ActiveXObject("Microsoft.XMLHTTP")}return b},createURL:function(a){return x?x.createObjectURL(a):null},revokeURL:function(a){return x&&x.revokeObjectURL(a)},isArray:Y,event:{on:ab,off:bb,one:cb,fix:db},throttle:function(b,c){var d,e;return function(){e=arguments,d||(b.apply(a,e),d=O(function(){d=0,b.apply(a,e)},c))}},F:s,parseJSON:function(b){var c;try{c=a.JSON&&JSON.parse?JSON.parse(b):new Function("return ("+b.replace(/([\r\n])/g,"\\$1")+");")()}catch(d){fb.log("[err] FileAPI.parseJSON: "+d)}return c},trim:function(a){return a=String(a),a.trim?a.trim():a.replace(/^\s+|\s+$/g,"")},defer:function(){var a=[],b=[],c=[],d=function(c,d){return d&&(c?a:b).push(d),this},e=function(f,g){var h=f?a:b,i=0,j=h.length;for(d=function(a,b){a===f&&b.apply(this,g)},e=s,a=b=null,c=[];j>i;i++)h[i]&&h[i].apply(this,g)},f={done:function(a){return d(1,a),this},fail:function(a){return d(0,a),this},resolve:function(){return e(1,arguments),this},reject:function(){return e(0,arguments),this},notify:function(){for(var a=0,b=c.length;b>a;a++)c[a].apply(this,arguments)},progress:function(a){return a&&c.push(a),this},then:function(a,b){return this.done(a).fail(b)},always:function(a){return this.then(a,a)},promise:function(){return this}};return f},queue:function(a){var b=0,c=0,d=!1,e=!1,f={inc:function(){c++},next:function(){b++,O(f.check,0)},check:function(){b>=c&&!d&&f.end()},isFail:function(){return d},fail:function(){!d&&a(d=!0)},end:function(){e||(e=!0,a())}};return f},each:Z,indexOf:$,afor:function(a,b){var c=0,d=a.length;Y(a)&&d--?!function e(){b(d!=c&&e,a[c],c++)}():b(!1)},extend:_,isFile:function(a){return E&&a&&(a instanceof z||a instanceof y)},isBlob:function(a){return E&&a&&a instanceof y},isCanvas:function(a){return a&&J.test(a.nodeName)},getFilesFilter:function(a){return a="string"==typeof a?a:a.getAttribute&&a.getAttribute("accept")||"",a?new RegExp("("+a.replace(/\./g,"\\.").replace(/,/g,"|")+")$","i"):/./},readAsDataURL:function(a,b){fb.isCanvas(a)?c(a,b,"load",fb.toDataURL(a)):e(a,b,"DataURL")},readAsBinaryString:function(a,b){d("BinaryString")?e(a,b,"BinaryString"):fb.readAsDataURL(a,function(a){if("load"==a.type)try{a.result=fb.toBinaryString(a.result)}catch(c){a.type="error",a.message=c.toString()}b(a)})},readAsArrayBuffer:function(a,b){e(a,b,"ArrayBuffer")},readAsText:function(a,b,c){c||(c=b,b="utf-8"),e(a,c,"Text",b)},toDataURL:function(a,b){return"string"==typeof a?a:a.toDataURL?a.toDataURL(b||"image/png"):void 0},toBinaryString:function(b){return a.atob(fb.toDataURL(b).replace(M,""))},readAsImage:function(a,b,d){if(fb.isFile(a))if(x){var e=fb.createURL(a);e?fb.readAsImage(e,b,d):c(a,b,"error")}else fb.readAsDataURL(a,function(e){"load"==e.type?fb.readAsImage(e.result,b,d):(d||"error"==e.type)&&c(a,b,e,null,{loaded:e.loaded,total:e.total})});else if(fb.isCanvas(a))c(a,b,"load",a);else if(I.test(a.nodeName))if(a.complete)c(a,b,"load",a);else{var f="error abort load";cb(a,f,function h(d){"load"==d.type&&x&&fb.revokeURL(a.src),bb(a,f,h),c(a,b,d,a)})}else if(a.iframe)c(a,b,{type:"error",message:"is iframe"});else{var g=fb.newImage(a.dataURL||a);fb.readAsImage(g,b,d)}},getMimeType:function(a){var b,c,d=a&&(a.type||String(a.name||a).split(".").pop()),e=fb.accept;if(!/^[^/]+\/[^/]+$/.test(d))for(c in e)if(b=new RegExp(e[c].replace(/\s/g,"|"),"i"),b.test(d)||fb.ext2mime[d]){d=fb.ext2mime[d]||c.split("/")[0]+"/"+d;break}return d},getDropFiles:function(a,b){var c=[],d=o(a),e=Y(d.items)&&d.items[0]&&i(d.items[0]),f=fb.queue(function(){b(c)});Z((e?d.items:d.files)||[],function(a){f.inc();try{e?j(a,function(a,b){a?fb.log("[err] getDropFiles:",a):c.push.apply(c,b),f.next()}):h(a,function(b){b&&c.push(a),f.next()})}catch(b){f.next(),fb.log("[err] getDropFiles: ",b)}}),f.check()},getFiles:function(a,b,c){var d=[];return c?(fb.filterFiles(fb.getFiles(a),b,c),null):(a.jquery&&(a.each(function(){d=d.concat(fb.getFiles(this))}),a=d,d=[]),"string"==typeof b&&(b=fb.getFilesFilter(b)),a.originalEvent?a=db(a.originalEvent):a.srcElement&&(a=db(a)),a.dataTransfer?a=a.dataTransfer:a.target&&(a=a.target),a.files?(d=a.files,E||(d[0].blob=a,d[0].iframe=!0)):!E&&n(a)?fb.trim(a.value)&&(d=[g(a.value)],d[0].blob=a,d[0].iframe=!0):Y(a)&&(d=a),fb.filter(d,function(a){return!b||b.test(a.name)}))},getTotalSize:function(a){for(var b=0,c=a&&a.length;c--;)b+=a[c].size;return b},getInfo:function(a,b){var c={},d=S.concat();fb.isFile(a)?!function e(){var f=d.shift();f?f.test(fb.getMimeType(a))?f(a,function(a,d){a?b(a):(_(c,d),e())}):e():b(!1,c)}():b("not_support_info",c)},addInfoReader:function(a,b){b.test=function(b){return a.test(b)},S.push(b)},filter:function(a,b){for(var c,d=[],e=0,f=a.length;f>e;e++)e in a&&(c=a[e],b.call(c,c,e,a)&&d.push(c));return d},filterFiles:function(a,b,c){if(a.length){var d,e=a.concat(),f=[],g=[];!function h(){e.length?(d=e.shift(),fb.getInfo(d,function(a,c){(b(d,a?!1:c)?f:g).push(d),h()})):c(f,g)}()}else c([],a)},upload:function(a,b,c){function d(){for(var a,b=0,c=t.length;c--;)a=t[c],b+=a.size*(a.loaded/a.total);return b}function e(){var a=g.splice(0,p?1:1e5),b=p?a[0]&&a[0].file:f.files,i=fb.getTotalSize(a),k=!1,v=m(c);if(a.loaded=0,a.size=a.total=i,t.push(a),r&&(b=null,fb.log("[warn] FileAPI.upload() — called without files")),"abort"==f.statusText&&!f.current||!a.length&&!r){if(!o){var w=200==f.status||201==f.status||204==f.status?!1:f.statusText||"error";w?h.reject(w,f,c):h.resolve(f,c),c.complete(w,f,c)}}else{if(r=!1,o++,f.currentFile=b,b&&c.prepare(b,v)===!1)return e(),void 0;v.file=b,l(v,a,function(i){n||c.upload(f,c);var l=new fb.XHR(_({},v,{upload:b?function(){p&&(u.push(b),l.activeFiles=u,c.fileupload(b,l,v))}:s,progress:b?function(e){k||(k=e.loaded==e.total,a.total=e.total,a.loaded=N.min(e.loaded,e.total),(p||q)&&c.fileprogress({type:"progress",total:a.total,loaded:a.loaded},b,l,v),h.notify({type:"progress",total:j,loaded:f.loaded=d()},b,l,v))}:s,complete:function(g){Z(U,function(a){f[a]=l[a]}),b&&(a.total=a.total||a.size,a.loaded=a.total,this.progress(a),k=!0,f.loaded=n=d(),p&&(u.splice($(u,b),1),c.filecomplete(g,l,b,v))),o--,O(function(){e()},0)}}));f.abort=function(a){a||(g.length=0),this.current=a,l.abort()},l.send(i)})}}c=b||"string"==typeof a?_({},c,{url:a,files:[].concat(b)}):a,c=_({jsonp:"callback",prepare:s,beforeupload:s,upload:s,fileupload:s,fileprogress:s,filecomplete:s,progress:s,complete:s,pause:s,serial:!0,parallel:0,postName:"files",chunkSize:fb.chunkSize,imageOriginal:!0,chunkUploadRetry:fb.chunkUploadRetry,uploadRetry:fb.uploadRetry},c),c.serial||(c.chunkSize&&(c.chunkSize=0,fb.log("[warn] FileAPI.upload: `chunkSize > 0` is not supported, if serial == false")),fb.flashEngine&&fb.log("[warn] FileAPI.upload: `serial == false` is not supported in Flash.")),c.parallel>0&&(c.serial=!0,fb.flashEngine&&fb.log("[warn] FileAPI.upload: `parallel > 0` is not supported in Flash.")),c.imageAutoOrientation&&!c.imageTransform&&(c.imageTransform={rotate:"auto"});var f=new fb.XHR(c),g=k(c.files,c.postName),h=fb.defer(),i=this,j=0,n=0,o=0,p=E&&c.serial,q=p&&c.parallel,r=!g.length,t=[],u=f.activeFiles=[];return Z(g,function(a){j+=a.size}),f.files=[],Z(g,function(a){f.files.push(a.file)}),f.total=j,f.loaded=0,f.filesLeft=g.length,c.beforeupload(f,c),h.progress(c.progress),h.done(c.success),h.fail(c.error),O(function(){for(var a=0;a<N.max(q,1);a++)e()},0),f.append=function(a,b){a=fb._getFilesDataArray([].concat(a)),Z(a,function(a){j+=a.size,f.files.push(a.file),b?g.unshift(a):g.push(a)}),f.statusText="",o||e.call(i)},f.remove=function(a){for(var b,c=g.length;c--;)g[c].file==a&&(b=g.splice(c,1),j-=b.size);return b},f.error=h.fail,f.success=h.done,_(f,h)},reset:function(a,b){var c,d;return C?(d=C(a).clone(!0).insertBefore(a).val("")[0],b||C(a).remove()):(c=a.parentNode,d=c.insertBefore(a.cloneNode(!0),a),d.value="",b||c.removeChild(a),Z(R[fb.uid(a)],function(b,c){Z(b,function(b){bb(a,c,b),ab(d,c,b)})})),d},load:function(a,b){var c=new fb.XHR(b=_(b||{},{url:a,type:"GET",cache:!0,responseType:"blob"})),d=c.defer.resolve;return c.defer.resolve=function(a,b){var c=a.response;return c&&y&&c instanceof y?d(c,a,b):a.defer.reject("load_not_supported",a,b)},l(b,[],function(a){c.send(a)}),c},saveAs:function(a,c){var d=fb.defer();if("string"==typeof a)c===b&&(c=a.split("/").pop()),fb.load(a).progress(d.notify).done(function(a){fb.saveAs(a,c).then(d.resolve,d.reject)}).fail(d.reject);else try{q(a,c)?d.resolve():d.reject("saveAs_not_support")}catch(e){fb.log("[err] FileAPI.saveAs: "+e.toString()),d.reject(e)}return d}};fb.addInfoReader(/^image/,function(a,b){if(!a.__dimensions){var c=a.__dimensions=fb.defer();fb.readAsImage(a,function(a){var b=a.target;c.resolve("load"==a.type?!1:"error",{width:b.width,height:b.height}),b.src=fb.EMPTY_PNG,b=null})}a.__dimensions.then(b)}),fb.event.dnd=function(a,b,c){var d,e;c||(c=b,b=s),A?(ab(a,"dragenter dragleave dragover",function(a){for(var c=o(a).types,f=c&&c.length,g=!1;f--;)if(~c[f].indexOf("File")){a[W](),e!==a.type&&(e=a.type,"dragleave"!=e&&b.call(a[V],!0,a),g=!0);break}g&&(P(d),d=O(function(){b.call(a[V],"dragleave"!=e,a)},50))}),ab(a,"drop",function(a){a[W](),e=0,b.call(a[V],!1,a),fb.getDropFiles(a,function(b){c.call(a[V],b,a)})})):fb.log("Drag'n'Drop -- not supported")},fb.event.dnd.off=function(a,b,c){bb(a,"dragenter dragleave dragover",b),bb(a,"drop",c)},C&&!C.fn.dnd&&(C.fn.dnd=function(a,b){return this.each(function(){fb.event.dnd(this,a,b)})},C.fn.offdnd=function(a,b){return this.each(function(){fb.event.dnd.off(this,a,b)})}),a.FileAPI=_(fb,a.FileAPI),fb.log("FileAPI: "+fb.version),fb.log("protocol: "+a.location.protocol),fb.log("doctype: ["+u.name+"] "+u.publicId+" "+u.systemId),Z(t.getElementsByTagName("meta"),function(a){/x-ua-compatible/i.test(a.getAttribute("http-equiv"))&&fb.log("meta.http-equiv: "+a.getAttribute("content"))}),fb.flashUrl||(fb.flashUrl=fb.staticPath+"FileAPI.flash.swf"),fb.flashImageUrl||(fb.flashImageUrl=fb.staticPath+"FileAPI.flash.image.swf"),fb.flashWebcamUrl||(fb.flashWebcamUrl=fb.staticPath+"FileAPI.flash.camera.swf")}(window,void 0),function(a,b,c){"use strict";function d(b){if(b instanceof d){var c=new d(b.file);return a.extend(c.matrix,b.matrix),c}return this instanceof d?(this.file=b,this.size=b.size||100,this.matrix={sx:0,sy:0,sw:0,sh:0,dx:0,dy:0,dw:0,dh:0,resize:0,deg:0,quality:1,filter:0,multipass:a.multiPassResize},void 0):new d(b)}var e=Math.min,f=Math.round,g=function(){return b.createElement("canvas")},h=!1,i={8:270,3:180,6:90};try{h=g().toDataURL("image/png").indexOf("data:image/png")>-1}catch(j){}d.prototype={image:!0,constructor:d,set:function(b){return a.extend(this.matrix,b),this},crop:function(a,b,d,e){return d===c&&(d=a,e=b,a=b=0),this.set({sx:a,sy:b,sw:d,sh:e||d})},resize:function(a,b,c){return/min|max/.test(b)&&(c=b,b=a),this.set({dw:a,dh:b||a,resize:c})},preview:function(a,b){return this.resize(a,b||a,"preview")},rotate:function(a){return this.set({deg:a})},filter:function(a){return this.set({filter:a})},overlay:function(a){return this.set({overlay:a})},clone:function(){return new d(this)},_load:function(b,c){var d=this;/img|video/i.test(b.nodeName)?c.call(d,null,b):a.readAsImage(b,function(a){c.call(d,"load"!=a.type,a.result)})},_apply:function(b,c){var f,h=g(),i=this.getMatrix(b),j=h.getContext("2d"),k=b.videoWidth||b.width,l=b.videoHeight||b.height,m=i.deg,n=i.dw,o=i.dh,p=k,q=l,r=i.filter,s=b,t=i.overlay,u=a.queue(function(){b.src=a.EMPTY_PNG,c(!1,h)}),v=a.renderImageToCanvas;if(m-=360*Math.floor(m/360),b._type=this.file.type,i.multipass)for(;e(p/n,q/o)>2;)p=p/2+.5|0,q=q/2+.5|0,f=g(),f.width=p,f.height=q,s!==b?(v(f,s,0,0,s.width,s.height,0,0,p,q),s=f):(s=f,v(s,b,i.sx,i.sy,i.sw,i.sh,0,0,p,q),i.sx=i.sy=i.sw=i.sh=0);h.width=m%180?o:n,h.height=m%180?n:o,h.type=i.type,h.quality=i.quality,j.rotate(m*Math.PI/180),v(j.canvas,s,i.sx,i.sy,i.sw||s.width,i.sh||s.height,180==m||270==m?-n:0,90==m||180==m?-o:0,n,o),n=h.width,o=h.height,t&&a.each([].concat(t),function(b){u.inc();var c=new window.Image,d=function(){var e=0|b.x,f=0|b.y,g=b.w||c.width,h=b.h||c.height,i=b.rel;e=1==i||4==i||7==i?(n-g+e)/2:2==i||5==i||8==i?n-(g+e):e,f=3==i||4==i||5==i?(o-h+f)/2:i>=6?o-(h+f):f,a.event.off(c,"error load abort",d);try{j.globalAlpha=b.opacity||1,j.drawImage(c,e,f,g,h)}catch(k){}u.next()};a.event.on(c,"error load abort",d),c.src=b.src,c.complete&&d()}),r&&(u.inc(),d.applyFilter(h,r,u.next)),u.check()},getMatrix:function(b){var c=a.extend({},this.matrix),d=c.sw=c.sw||b.videoWidth||b.naturalWidth||b.width,g=c.sh=c.sh||b.videoHeight||b.naturalHeight||b.height,h=c.dw=c.dw||d,i=c.dh=c.dh||g,j=d/g,k=h/i,l=c.resize;if("preview"==l){if(h!=d||i!=g){var m,n;k>=j?(m=d,n=m/k):(n=g,m=n*k),(m!=d||n!=g)&&(c.sx=~~((d-m)/2),c.sy=~~((g-n)/2),d=m,g=n)}}else l&&(d>h||g>i?"min"==l?(h=f(k>j?e(d,h):i*j),i=f(k>j?h/j:e(g,i))):(h=f(j>=k?e(d,h):i*j),i=f(j>=k?h/j:e(g,i))):(h=d,i=g));return c.sw=d,c.sh=g,c.dw=h,c.dh=i,c.multipass=a.multiPassResize,c},_trans:function(b){this._load(this.file,function(c,d){if(c)b(c);else try{this._apply(d,b)}catch(c){a.log("[err] FileAPI.Image.fn._apply:",c),b(c)}})},get:function(b){if(a.support.transform){var c=this,d=c.matrix;"auto"==d.deg?a.getInfo(c.file,function(a,e){d.deg=i[e&&e.exif&&e.exif.Orientation]||0,c._trans(b)}):c._trans(b)}else b("not_support_transform");return this},toData:function(a){return this.get(a)}},d.exifOrientation=i,d.transform=function(b,e,f,g){function h(h,i){var j={},k=a.queue(function(a){g(a,j)});h?k.fail():a.each(e,function(a,e){if(!k.isFail()){var g=new d(i.nodeType?i:b);if("function"==typeof a?a(i,g):a.width?g[a.preview?"preview":"resize"](a.width,a.height,a.strategy):a.maxWidth&&(i.width>a.maxWidth||i.height>a.maxHeight)&&g.resize(a.maxWidth,a.maxHeight,"max"),a.crop){var h=a.crop;g.crop(0|h.x,0|h.y,h.w||h.width,h.h||h.height)}a.rotate===c&&f&&(a.rotate="auto"),g.set({deg:a.rotate,type:a.type||b.type||"image/png",quality:a.quality||1,overlay:a.overlay,filter:a.filter}),k.inc(),g.toData(function(a,b){a?k.fail():(j[e]=b,k.next())})}})}b.width?h(!1,b):a.getInfo(b,h)},a.each(["TOP","CENTER","BOTTOM"],function(b,c){a.each(["LEFT","CENTER","RIGHT"],function(a,e){d[b+"_"+a]=3*c+e,d[a+"_"+b]=3*c+e})}),d.toCanvas=function(a){var c=b.createElement("canvas");return c.width=a.videoWidth||a.width,c.height=a.videoHeight||a.height,c.getContext("2d").drawImage(a,0,0),c},d.fromDataURL=function(b,c,d){var e=a.newImage(b);a.extend(e,c),d(e)},d.applyFilter=function(b,c,e){"function"==typeof c?c(b,e):window.Caman&&window.Caman("IMG"==b.tagName?d.toCanvas(b):b,function(){"string"==typeof c?this[c]():a.each(c,function(a,b){this[b](a)},this),this.render(e)})},a.renderImageToCanvas=function(b,c,d,e,f,g,h,i,j,k){try{return b.getContext("2d").drawImage(c,d,e,f,g,h,i,j,k)}catch(l){throw a.log("renderImageToCanvas failed:",l),l}},a.support.canvas=a.support.transform=h,a.Image=d}(FileAPI,document),function(a){"use strict";a(FileAPI)}(function(a){"use strict";if(window.navigator&&window.navigator.platform&&/iP(hone|od|ad)/.test(window.navigator.platform)){var b=a.renderImageToCanvas;a.detectSubsampling=function(a){var b,c;return a.width*a.height>1048576?(b=document.createElement("canvas"),b.width=b.height=1,c=b.getContext("2d"),c.drawImage(a,-a.width+1,0),0===c.getImageData(0,0,1,1).data[3]):!1},a.detectVerticalSquash=function(a,b){var c,d,e,f,g,h=a.naturalHeight||a.height,i=document.createElement("canvas"),j=i.getContext("2d");for(b&&(h/=2),i.width=1,i.height=h,j.drawImage(a,0,0),c=j.getImageData(0,0,1,h).data,d=0,e=h,f=h;f>d;)g=c[4*(f-1)+3],0===g?e=f:d=f,f=e+d>>1;return f/h||1},a.renderImageToCanvas=function(c,d,e,f,g,h,i,j,k,l){if("image/jpeg"===d._type){var m,n,o,p,q=c.getContext("2d"),r=document.createElement("canvas"),s=1024,t=r.getContext("2d");if(r.width=s,r.height=s,q.save(),m=a.detectSubsampling(d),m&&(e/=2,f/=2,g/=2,h/=2),n=a.detectVerticalSquash(d,m),m||1!==n){for(f*=n,k=Math.ceil(s*k/g),l=Math.ceil(s*l/h/n),j=0,p=0;h>p;){for(i=0,o=0;g>o;)t.clearRect(0,0,s,s),t.drawImage(d,e,f,g,h,-o,-p,g,h),q.drawImage(r,0,0,s,s,i,j,k,l),o+=s,i+=k;p+=s,j+=l}return q.restore(),c}}return b(c,d,e,f,g,h,i,j,k,l)}}}),function(a,b){"use strict";function c(){this.items=[]}function d(b,c,d){var e=b.blob,f=b.file;if(f){if(!e.toDataURL)return a.readAsBinaryString(e,function(a){"load"==a.type&&c(b,a.result)}),void 0;var g={"image/jpeg":".jpe?g","image/png":".png"},h=g[b.type]?b.type:"image/png",i=g[h]||".png",j=e.quality||1;f.match(new RegExp(i+"$","i"))||(f+=i.replace("?","")),b.file=f,b.type=h,!d&&e.toBlob?e.toBlob(function(a){c(b,a)},h,j):c(b,a.toBinaryString(e.toDataURL(h,j)))}else c(b,e)}var e=b.FormData,f=b.document,g=b.unescape,h=b.encodeURIComponent;c.prototype={append:function(a,b,c,d){this.items.push({name:a,blob:b&&b.blob||(void 0==b?"":b),file:b&&(c||b.name),type:b&&(d||b.type)})},each:function(a){for(var b=0,c=this.items.length;c>b;b++)a.call(this,this.items[b])},toData:function(b,c){c._chunked=a.support.chunked&&c.chunkSize>0&&1==a.filter(this.items,function(a){return a.file}).length,a.support.html5?a.formData&&!this.multipart&&e?c._chunked?(a.log("FileAPI.Form.toPlainData"),this.toPlainData(b)):(a.log("FileAPI.Form.toFormData"),this.toFormData(b)):(a.log("FileAPI.Form.toMultipartData"),this.toMultipartData(b)):(a.log("FileAPI.Form.toHtmlData"),this.toHtmlData(b))},_to:function(b,c,d,e){var f=a.queue(function(){c(b)});this.each(function(a){d(a,b,f,e)}),f.check()},toHtmlData:function(b){this._to(f.createDocumentFragment(),b,function(b,c){var d,e=b.blob;b.file?(a.reset(e,!0),e.name=b.name,c.appendChild(e)):(d=f.createElement("input"),d.name=b.name,d.type="hidden",d.value=e,c.appendChild(d))})},toPlainData:function(a){this._to({},a,function(a,b,c){a.file&&(b.type=a.file),a.blob.toBlob?(c.inc(),d(a,function(a,d){b.name=a.name,b.file=d,b.size=d.length,b.type=a.type,c.next()})):a.file?(b.name=a.blob.name,b.file=a.blob,b.size=a.blob.size,b.type=a.type):(b.params||(b.params=[]),b.params.push(h(a.name)+"="+h(a.blob))),b.start=-1,b.end=b.file&&b.file.FileAPIReadPosition||-1,b.retry=0})},toFormData:function(a){this._to(new e,a,function(a,b,c){a.blob&&a.blob.toBlob?(c.inc(),d(a,function(a,d){b.append(a.name,d,a.file),c.next()})):a.file?b.append(a.name,a.blob,a.file):b.append(a.name,a.blob),a.file&&b.append("_"+a.name,a.file)})},toMultipartData:function(b){this._to([],b,function(a,b,c,e){c.inc(),d(a,function(a,d){b.push("--_"+e+'\r\nContent-Disposition: form-data; name="'+a.name+'"'+(a.file?'; filename="'+g(h(a.file))+'"':"")+(a.file?"\r\nContent-Type: "+(a.type||"application/octet-stream"):"")+"\r\n\r\n"+d+"\r\n"),c.next()},!0)},a.expando)}},a.Form=c}(FileAPI,window),function(a,b){"use strict";var c=b.F,d=a.document,e=function(a){var d=b.defer().progress(a.progress);this.uid=b.uid(),this.xhr={abort:c,getResponseHeader:c,getAllResponseHeaders:c},this.defer=d,this.options=b.extend({upload:c,complete:c,withCredentials:b.withCredentials},a),this.done=this.success=d.done,this.fail=this.error=d.fail,this.notify=d.notify,this.progress=d.progress},f={"":1,XML:1,Text:1,Body:1};e.prototype={status:0,statusText:"",constructor:e,getResponseHeader:function(a){return this.xhr.getResponseHeader(a)},getAllResponseHeaders:function(){return this.xhr.getAllResponseHeaders()||{}},end:function(d,e){var f=this,g=f.defer,h=f.options,i=200==d||201==d?!1:e||"unknown";f.end=f.abort=c,f.status=d,e&&(f.statusText=e),b.log("xhr.end:",d,e),i?g.reject(i,f,h):g.resolve(f,h),h.complete(i,f),f.xhr&&f.xhr.node&&setTimeout(function(){var b=f.xhr.node;try{b.parentNode.removeChild(b)}catch(c){}try{delete a[f.uid]}catch(c){}a[f.uid]=f.xhr.node=null},9)},abort:function(){this.end(0,"abort"),this.xhr&&(this.xhr.aborted=!0,this.xhr.abort())},send:function(a){var b=this,c=this.options;a.toData(function(a){c.upload(c,b),b._send.call(b,c,a)},c)},_send:function(c,e){var g,h=this,i=h.uid,j=c.url;if(b.log("XHR._send:",e),c.cache||(j+=(~j.indexOf("?")?"&":"?")+b.uid()),e.nodeName){var k=c.jsonp;j=j.replace(/([a-z]+)=(\?)/i,"$1="+i),c.upload(c,h),g=d.createElement("div"),g.innerHTML='<form target="'+i+'" action="'+j+'" method="POST" enctype="multipart/form-data" style="position: absolute; top: -1000px; overflow: hidden; width: 1px; height: 1px;"><iframe name="'+i+'" src="javascript:false;"></iframe>'+(k&&c.url.indexOf("=?")<0?'<input value="'+i+'" name="'+k+'" type="hidden"/>':"")+"</form>";var l=g.getElementsByTagName("form")[0],m=g.getElementsByTagName("iframe")[0];l.appendChild(e),b.log(l.parentNode.innerHTML),d.body.appendChild(g),h.xhr.node=g;var n=function(a){if(~j.indexOf(a.origin))try{var c=b.parseJSON(a.data);c.id==i&&o(c.status,c.statusText,c.response)}catch(d){o(0,d.message)}},o=a[i]=function(c,d,e){h.readyState=4,h.responseText=e,h.end(c,d),b.event.off(a,"message",n),a[i]=g=m=m.onload=null};h.xhr.abort=function(){try{m.stop?m.stop():m.contentWindow.stop?m.contentWindow.stop():m.contentWindow.document.execCommand("Stop")}catch(a){}o(0,"abort")},b.event.on(a,"message",n),m.onload=function(){try{var a=m.contentWindow,c=a.document,d=a.result||b.parseJSON(c.body.innerHTML);o(d.status,d.statusText,d.response)}catch(e){b.log("[transport.onload]",e)}},h.readyState=2,l.submit(),l=null}else{if(j=j.replace(/([a-z]+)=(\?)&?/i,""),this.xhr&&this.xhr.aborted)return b.log("Error: already aborted"),void 0;if(e.params&&(j+=(j.indexOf("?")<0?"?":"&")+e.params.join("&")),g=h.xhr=b.getXHR(),g.open(c.type||"POST",j,!0),c.responseType&&(g.responseType=c.responseType),c.withCredentials&&(g.withCredentials="true"),c.headers&&c.headers["X-Requested-With"]||g.setRequestHeader("X-Requested-With","XMLHttpRequest"),b.each(c.headers,function(a,b){g.setRequestHeader(b,a)}),c._chunked){g.upload&&g.upload.addEventListener("progress",b.throttle(function(a){e.retry||h.notify({type:a.type,total:e.size,loaded:e.start+a.loaded,totalSize:e.size},h,c)},100),!1),g.onreadystatechange=function(){var a=parseInt(g.getResponseHeader("X-Last-Known-Byte"),10);if(h.status=g.status,h.statusText=g.statusText,h.readyState=g.readyState,4==g.readyState){try{for(var d in f)h["response"+d]=g["response"+d]}catch(i){}if(g.onreadystatechange=null,!g.status||g.status-201>0)if(b.log("Error: "+g.status),(!g.status&&!g.aborted||500==g.status||416==g.status)&&++e.retry<=c.chunkUploadRetry){var j=g.status?0:b.chunkNetworkDownRetryTimeout;c.pause(e.file,c),b.log("X-Last-Known-Byte: "+a),a?e.end=a:(e.end=e.start-1,416==g.status&&(e.end=e.end-c.chunkSize)),setTimeout(function(){h._send(c,e)},j)}else h.end(g.status);else e.retry=0,e.end==e.size-1?h.end(g.status):(b.log("X-Last-Known-Byte: "+a),a&&(e.end=a),e.file.FileAPIReadPosition=e.end,setTimeout(function(){h._send(c,e)},0));g=null}},e.start=e.end+1,e.end=Math.max(Math.min(e.start+c.chunkSize,e.size)-1,e.start);var p=e.file,q=(p.slice||p.mozSlice||p.webkitSlice).call(p,e.start,e.end+1);e.size&&!q.size?setTimeout(function(){h.end(-1)}):(g.setRequestHeader("Content-Range","bytes "+e.start+"-"+e.end+"/"+e.size),g.setRequestHeader("Content-Disposition","attachment; filename="+encodeURIComponent(e.name)),g.setRequestHeader("Content-Type",e.type||"application/octet-stream"),g.send(q)),p=q=null}else if(g.upload&&(g.upload.addEventListener("progress",b.throttle(function(a){h.notify(a,h,c)},100),!1),b.event.on(g,"progress",function(a){h.notify(a,h,c)})),g.onreadystatechange=function(){if(h.status=g.status,h.statusText=g.statusText,h.readyState=g.readyState,4==g.readyState){try{for(var a in f)h["response"+a]=g["response"+a]}catch(d){}if(g.onreadystatechange=null,!g.status||g.status>201)if(b.log("Error: "+g.status),(!g.status&&!g.aborted||500==g.status)&&(c.retry||0)<c.uploadRetry){c.retry=(c.retry||0)+1;var i=b.networkDownRetryTimeout;c.pause(c.file,c),setTimeout(function(){h._send(c,e)},i)}else h.end(g.status);else h.end(g.status);g=null}},b.isArray(e)){g.setRequestHeader("Content-Type","multipart/form-data; boundary=_"+b.expando);var r=e.join("")+"--_"+b.expando+"--";if(g.sendAsBinary)g.sendAsBinary(r);else{var s=Array.prototype.map.call(r,function(a){return 255&a.charCodeAt(0)
+!function(a){"use strict";var b=a.HTMLCanvasElement&&a.HTMLCanvasElement.prototype,c=a.Blob&&function(){try{return Boolean(new Blob)}catch(a){return!1}}(),d=c&&a.Uint8Array&&function(){try{return 100===new Blob([new Uint8Array(100)]).size}catch(a){return!1}}(),e=a.BlobBuilder||a.WebKitBlobBuilder||a.MozBlobBuilder||a.MSBlobBuilder,f=(c||e)&&a.atob&&a.ArrayBuffer&&a.Uint8Array&&function(a){var b,f,g,h,i,j;for(b=a.split(",")[0].indexOf("base64")>=0?atob(a.split(",")[1]):decodeURIComponent(a.split(",")[1]),f=new ArrayBuffer(b.length),g=new Uint8Array(f),h=0;h<b.length;h+=1)g[h]=b.charCodeAt(h);return i=a.split(",")[0].split(":")[1].split(";")[0],c?new Blob([d?g:f],{type:i}):(j=new e,j.append(f),j.getBlob(i))};a.HTMLCanvasElement&&!b.toBlob&&(b.mozGetAsFile?b.toBlob=function(a,c,d){a(d&&b.toDataURL&&f?f(this.toDataURL(c,d)):this.mozGetAsFile("blob",c))}:b.toDataURL&&f&&(b.toBlob=function(a,b,c){a(f(this.toDataURL(b,c)))})),a.dataURLtoBlob=f}(window),function(a,b){"use strict";function c(a,b,c,d,e){var f={type:c.type||c,target:a,result:d};_(f,e),b(f)}function d(a){return A&&!!A.prototype["readAs"+a]}function e(a,e,f,g){if(fb.isBlob(a)&&d(f)){var h=new A;ab(h,T,function j(b){var d=b.type;"progress"==d?c(a,e,b,b.target.result,{loaded:b.loaded,total:b.total}):"loadend"==d?(bb(h,T,j),h=null):c(a,e,b,b.target.result)});try{g?h["readAs"+f](a,g):h["readAs"+f](a)}catch(i){c(a,e,"error",b,{error:i.toString()})}}else c(a,e,"error",b,{error:"filreader_not_support_"+f})}function f(a){return a&&(z&&a instanceof z||a.blob||a.image&&a.file||a.flashId)}function g(a){return{name:(a+"").split(/\\|\//g).pop(),type:fb.getMimeType(a)}}function h(a,b){if(!a.type&&a.size%4096===0&&a.size<=102400)if(A)try{var c=new A;cb(c,T,function(a){var d="error"!=a.type;b(d),d&&c.abort()}),c.readAsDataURL(a)}catch(d){b(!1)}else b(null);else b(!0)}function i(a){var b;return a.getAsEntry?b=a.getAsEntry():a.webkitGetAsEntry&&(b=a.webkitGetAsEntry()),b}function j(a,b){if(a)if(a.isFile)a.file(function(c){c.fullPath=a.fullPath,b(!1,[c])},function(a){b("FileError.code: "+a.code)});else if(a.isDirectory){var c=a.createReader(),d=[];c.readEntries(function(a){fb.afor(a,function(a,c){j(c,function(c,e){c?fb.log(c):d=d.concat(e),a?a():b(!1,d)})})},function(a){b("directory_reader: "+a)})}else j(i(a),b);else b("invalid entry")}function k(a,b){var c=[],d={};if(n(a)){var e=fb.getFiles(a);d[a.name||b]=null!==a.getAttribute("multiple")?e:e[0]}else Y(a)?n(a[0])?Z(a,function(a){d[a.name||b]=fb.getFiles(a)}):f(a[0])&&(d[b]=a):f(a)?d[b]=a:d=a;return Z(d,function g(a,b){Y(a)?Z(a,function(a){g(a,b)}):f(a)&&c.push({name:b,file:a,size:a.size,total:a.size,loaded:0})}),c}function l(a,b,c){var d=new fb.Form,e=fb.queue(function(){c(d)}),f=fb.support.transform&&a.imageTransform,g=f&&p(f),h=fb.postNameConcat;Z(b,function(b,c){var i=b.file,j=h(b.name,a.serial||a.chunkSize?null:c),k=i.name,l=i.type;!function m(b){b.image?(e.inc(),b.toData(function(a,b){k=k||(new Date).getTime()+".png",m(b),e.next()})):fb.Image&&f&&(/^image/.test(b.type)||K.test(b.nodeName))?(e.inc(),g&&(f=[].concat(f)),fb.Image.transform(b,f,a.imageAutoOrientation,function(c,i){if(g&&!c)H||fb.flashEngine||(d.multipart=!0),d.append(j,i[0],k,f[0].type||l);else{var m=0;c||Z(i,function(a,b){H||fb.flashEngine||(d.multipart=!0),f[b].postName||(m=1),d.append(f[b].postName||h(j,b),a,k,f[b].type||l)}),(c||a.imageOriginal)&&d.append(h(j,m?"original":null),b,k,l)}e.next()})):k!==fb.expando&&d.append(j,b,k)}(i)}),Z(a.data,function i(a,b){"object"==typeof a?Z(a,function(a,c){i(a,h(b,c))}):d.append(b,a)}),e.check()}function m(a){var b={};return Z(a,function(a,c){a&&"object"==typeof a&&null==a.nodeType&&(a=_({},a)),b[c]=a}),b}function n(a){return L.test(a&&a.tagName)}function o(a){return(a.originalEvent||a||"").dataTransfer||{}}function p(a){var b;for(b in a)if(a.hasOwnProperty(b)&&!(a[b]instanceof Object||"overlay"===b||"filter"===b))return!0;return!1}function q(a,b){var c=!1;if(v.msSaveBlob)c=v.msSaveBlob(a,b);else if(fb.support.download){var d=fb.createURL(a),e=t.body,f=X("a");d&&(f.href=d,f.download=b||a.name,f.style.top="-10000px",f.style.position="absolute",e.appendChild(f),f.click(),e.removeChild(f),c=!0,O(function(){fb.revokeURL(d)},1))}return c}var r=1,s=function(){},t=a.document,u=t.doctype||{},v=a.navigator,w=a.navigator.userAgent,x=a.createObjectURL&&a||a.URL&&URL.revokeObjectURL&&URL||a.webkitURL&&webkitURL,y=a.Blob,z=a.File,A=a.FileReader,B=a.FormData,C=a.jQuery,D=a.XMLHttpRequest,E=!(!(z&&A&&(a.Uint8Array||B||D.prototype.sendAsBinary))||/safari\//i.test(w)&&!/chrome\//i.test(w)&&/windows/i.test(w)),F=E&&"withCredentials"in new D,G=E&&!!y&&!!(y.prototype.webkitSlice||y.prototype.mozSlice||y.prototype.slice),H=a.dataURLtoBlob,I=/img/i,J=/canvas/i,K=/img|canvas/i,L=/input/i,M=/^data:[^,]+,/,N=a.Math,O=a.setTimeout,P=a.clearTimeout,Q=function(b){return b=new a.Number(N.pow(1024,b)),b.from=function(a){return N.round(a*this)},b},R={},S=[],T="abort progress error load loadend",U="status statusText readyState response responseXML responseText responseBody".split(" "),V="currentTarget",W="preventDefault",X=function(a){return t.createElement(a)},Y=function(a){return a&&"length"in a},Z=function(a,b,c){if(a)if(Y(a))for(var d=0,e=a.length;e>d;d++)d in a&&b.call(c,a[d],d,a);else for(var f in a)a.hasOwnProperty(f)&&b.call(c,a[f],f,a)},$=function(a,b){for(var c=-1,d=a&&a.length;d--;)if(a[d]===b){c=d;break}return c},_=function(a){for(var b=arguments,c=1,d=function(b,c){a[c]=b};c<b.length;c++)Z(b[c],d);return a},ab=function(a,b,c){if(a){var d=fb.uid(a);R[d]||(R[d]={});var e=A&&a&&a instanceof A;Z(b.split(/\s+/),function(b){C&&!e?C.event.add(a,b,c):(R[d][b]||(R[d][b]=[]),R[d][b].push(c),a.addEventListener?a.addEventListener(b,c,!1):a.attachEvent?a.attachEvent("on"+b,c):a["on"+b]=c)})}},bb=function(a,b,c){if(a){var d=fb.uid(a),e=R[d]||{},f=A&&a&&a instanceof A;Z(b.split(/\s+/),function(b){if(C&&!f)C.event.remove(a,b,c);else{for(var d=e[b]||[],g=d.length;g--;)if(d[g]===c){d.splice(g,1);break}a.addEventListener?a.removeEventListener(b,c,!1):a.detachEvent?a.detachEvent("on"+b,c):a["on"+b]=null}})}},cb=function(a,b,c){ab(a,b,function d(e){bb(a,b,d),c(e)})},db=function(b){return b.target||(b.target=a.event&&a.event.srcElement||t),3===b.target.nodeType&&(b.target=b.target.parentNode),b},eb=function(a){var b=X("input");return b.setAttribute("type","file"),a in b},fb={version:"2.1.0",cors:!1,html5:!0,media:!1,formData:!0,multiPassResize:!0,debug:!1,pingUrl:!1,multiFlash:!1,flashAbortTimeout:0,withCredentials:!0,staticPath:"./dist/",flashUrl:0,flashImageUrl:0,postNameConcat:function(a,b){return a+(null!=b?"["+b+"]":"")},support:{dnd:F&&"ondrop"in X("div"),cors:F,html5:E,chunked:G,dataURI:!0,accept:eb("accept"),multiple:eb("multiple"),saveAs:!!v.msSaveBlob,download:"download"in X("a")},ext2mime:{jpg:"image/jpeg",tif:"image/tiff",txt:"text/plain"},accept:{"image/*":"art bm bmp dwg dxf cbr cbz fif fpx gif ico iefs jfif jpe jpeg jpg jps jut mcf nap nif pbm pcx pgm pict pm png pnm qif qtif ras rast rf rp svf tga tif tiff xbm xbm xpm xwd","audio/*":"m4a flac aac rm mpa wav wma ogg mp3 mp2 m3u mod amf dmf dsm far gdm imf it m15 med okt s3m stm sfx ult uni xm sid ac3 dts cue aif aiff wpl ape mac mpc mpp shn wv nsf spc gym adplug adx dsp adp ymf ast afc hps xs","video/*":"m4v 3gp nsv ts ty strm rm rmvb m3u ifo mov qt divx xvid bivx vob nrg img iso pva wmv asf asx ogm m2v avi bin dat dvr-ms mpg mpeg mp4 mkv avc vp3 svq3 nuv viv dv fli flv wpl"},uploadRetry:0,networkDownRetryTimeout:5e3,chunkSize:0,chunkUploadRetry:0,chunkNetworkDownRetryTimeout:2e3,KB:Q(1),MB:Q(2),GB:Q(3),TB:Q(4),EMPTY_PNG:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQIW2NkAAIAAAoAAggA9GkAAAAASUVORK5CYII=",expando:"fileapi"+(new Date).getTime(),uid:function(a){return a?a[fb.expando]=a[fb.expando]||fb.uid():(++r,fb.expando+r)},log:function(){fb.debug&&a.console&&console.log&&(console.log.apply?console.log.apply(console,arguments):console.log([].join.call(arguments," ")))},newImage:function(a,b){var c=X("img");return b&&fb.event.one(c,"error load",function(a){b("error"==a.type,c),c=null}),c.src=a,c},getXHR:function(){var b;if(D)b=new D;else if(a.ActiveXObject)try{b=new ActiveXObject("MSXML2.XMLHttp.3.0")}catch(c){b=new ActiveXObject("Microsoft.XMLHTTP")}return b},createURL:function(a){return x?x.createObjectURL(a):null},revokeURL:function(a){return x&&x.revokeObjectURL(a)},isArray:Y,event:{on:ab,off:bb,one:cb,fix:db},throttle:function(b,c){var d,e;return function(){e=arguments,d||(b.apply(a,e),d=O(function(){d=0,b.apply(a,e)},c))}},F:s,parseJSON:function(b){var c;try{c=a.JSON&&JSON.parse?JSON.parse(b):new Function("return ("+b.replace(/([\r\n])/g,"\\$1")+");")()}catch(d){fb.log("[err] FileAPI.parseJSON: "+d)}return c},trim:function(a){return a=String(a),a.trim?a.trim():a.replace(/^\s+|\s+$/g,"")},defer:function(){var a=[],b=[],c=[],d=function(c,d){return d&&(c?a:b).push(d),this},e=function(f,g){var h=f?a:b,i=0,j=h.length;for(d=function(a,b){a===f&&b.apply(this,g)},e=s,a=b=null,c=[];j>i;i++)h[i]&&h[i].apply(this,g)},f={done:function(a){return d(1,a),this},fail:function(a){return d(0,a),this},resolve:function(){return e(1,arguments),this},reject:function(){return e(0,arguments),this},notify:function(){for(var a=0,b=c.length;b>a;a++)c[a].apply(this,arguments)},progress:function(a){return a&&c.push(a),this},then:function(a,b){return this.done(a).fail(b)},always:function(a){return this.then(a,a)},promise:function(){return this}};return f},queue:function(a){var b=0,c=0,d=!1,e=!1,f={inc:function(){c++},next:function(){b++,O(f.check,0)},check:function(){b>=c&&!d&&f.end()},isFail:function(){return d},fail:function(){!d&&a(d=!0)},end:function(){e||(e=!0,a())}};return f},each:Z,indexOf:$,afor:function(a,b){var c=0,d=a.length;Y(a)&&d--?!function e(){b(d!=c&&e,a[c],c++)}():b(!1)},extend:_,isFile:function(a){return E&&a&&(a instanceof z||a instanceof y)},isBlob:function(a){return E&&a&&a instanceof y},isCanvas:function(a){return a&&J.test(a.nodeName)},getFilesFilter:function(a){return a="string"==typeof a?a:a.getAttribute&&a.getAttribute("accept")||"",a?new RegExp("("+a.replace(/\./g,"\\.").replace(/,/g,"|")+")$","i"):/./},readAsDataURL:function(a,b){fb.isCanvas(a)?c(a,b,"load",fb.toDataURL(a)):e(a,b,"DataURL")},readAsBinaryString:function(a,b){d("BinaryString")?e(a,b,"BinaryString"):fb.readAsDataURL(a,function(a){if("load"==a.type)try{a.result=fb.toBinaryString(a.result)}catch(c){a.type="error",a.message=c.toString()}b(a)})},readAsArrayBuffer:function(a,b){e(a,b,"ArrayBuffer")},readAsText:function(a,b,c){c||(c=b,b="utf-8"),e(a,c,"Text",b)},toDataURL:function(a,b){return"string"==typeof a?a:a.toDataURL?a.toDataURL(b||"image/png"):void 0},toBinaryString:function(b){return a.atob(fb.toDataURL(b).replace(M,""))},readAsImage:function(a,b,d){if(fb.isFile(a))if(x){var e=fb.createURL(a);e?fb.readAsImage(e,b,d):c(a,b,"error")}else fb.readAsDataURL(a,function(e){"load"==e.type?fb.readAsImage(e.result,b,d):(d||"error"==e.type)&&c(a,b,e,null,{loaded:e.loaded,total:e.total})});else if(fb.isCanvas(a))c(a,b,"load",a);else if(I.test(a.nodeName))if(a.complete)c(a,b,"load",a);else{var f="error abort load";cb(a,f,function h(d){"load"==d.type&&x&&fb.revokeURL(a.src),bb(a,f,h),c(a,b,d,a)})}else if(a.iframe)c(a,b,{type:"error",message:"is iframe"});else{var g=fb.newImage(a.dataURL||a);fb.readAsImage(g,b,d)}},getMimeType:function(a){var b,c,d=a&&(a.type||String(a.name||a).split(".").pop()),e=fb.accept;if(!/^[^/]+\/[^/]+$/.test(d))for(c in e)if(b=new RegExp(e[c].replace(/\s/g,"|"),"i"),b.test(d)||fb.ext2mime[d]){d=fb.ext2mime[d]||c.split("/")[0]+"/"+d;break}return d},getDropFiles:function(a,b){var c=[],d=o(a),e=Y(d.items)&&d.items[0]&&i(d.items[0]),f=fb.queue(function(){b(c)});Z((e?d.items:d.files)||[],function(a){f.inc();try{e?j(a,function(a,b){a?fb.log("[err] getDropFiles:",a):c.push.apply(c,b),f.next()}):h(a,function(b){b&&c.push(a),f.next()})}catch(b){f.next(),fb.log("[err] getDropFiles: ",b)}}),f.check()},getFiles:function(a,b,c){var d=[];return c?(fb.filterFiles(fb.getFiles(a),b,c),null):(a.jquery&&(a.each(function(){d=d.concat(fb.getFiles(this))}),a=d,d=[]),"string"==typeof b&&(b=fb.getFilesFilter(b)),a.originalEvent?a=db(a.originalEvent):a.srcElement&&(a=db(a)),a.dataTransfer?a=a.dataTransfer:a.target&&(a=a.target),a.files?(d=a.files,E||(d[0].blob=a,d[0].iframe=!0)):!E&&n(a)?fb.trim(a.value)&&(d=[g(a.value)],d[0].blob=a,d[0].iframe=!0):Y(a)&&(d=a),fb.filter(d,function(a){return!b||b.test(a.name)}))},getTotalSize:function(a){for(var b=0,c=a&&a.length;c--;)b+=a[c].size;return b},getInfo:function(a,b){var c={},d=S.concat();fb.isFile(a)?!function e(){var f=d.shift();f?f.test(fb.getMimeType(a))?f(a,function(a,d){a?b(a):(_(c,d),e())}):e():b(!1,c)}():b("not_support_info",c)},addInfoReader:function(a,b){b.test=function(b){return a.test(b)},S.push(b)},filter:function(a,b){for(var c,d=[],e=0,f=a.length;f>e;e++)e in a&&(c=a[e],b.call(c,c,e,a)&&d.push(c));return d},filterFiles:function(a,b,c){if(a.length){var d,e=a.concat(),f=[],g=[];!function h(){e.length?(d=e.shift(),fb.getInfo(d,function(a,c){(b(d,a?!1:c)?f:g).push(d),h()})):c(f,g)}()}else c([],a)},upload:function(a,b,c){function d(){for(var a,b=0,c=t.length;c--;)a=t[c],b+=a.size*(a.loaded/a.total);return b}function e(){var a=g.splice(0,p?1:1e5),b=p?a[0]&&a[0].file:f.files,i=fb.getTotalSize(a),k=!1,v=m(c);if(a.loaded=0,a.size=a.total=i,t.push(a),r&&(b=null,fb.log("[warn] FileAPI.upload() — called without files")),"abort"==f.statusText&&!f.current||!a.length&&!r){if(!o){var w=200==f.status||201==f.status||204==f.status?!1:f.statusText||"error";w?h.reject(w,f,c):h.resolve(f,c),c.complete(w,f,c)}}else{if(r=!1,o++,f.currentFile=b,b&&c.prepare(b,v)===!1)return void e();v.file=b,l(v,a,function(i){n||c.upload(f,c);var l=new fb.XHR(_({},v,{upload:b?function(){p&&(u.push(b),l.activeFiles=u,c.fileupload(b,l,v))}:s,progress:b?function(e){k||(k=e.loaded==e.total,a.total=e.total,a.loaded=N.min(e.loaded,e.total),(p||q)&&c.fileprogress({type:"progress",total:a.total,loaded:a.loaded},b,l,v),h.notify({type:"progress",total:j,loaded:f.loaded=d()},b,l,v))}:s,complete:function(g){Z(U,function(a){f[a]=l[a]}),b&&(a.total=a.total||a.size,a.loaded=a.total,this.progress(a),k=!0,f.loaded=n=d(),p&&(u.splice($(u,b),1),c.filecomplete(g,l,b,v))),o--,O(function(){e()},0)}}));f.abort=function(a){a||(g.length=0),this.current=a,l.abort()},l.send(i)})}}c=b||"string"==typeof a?_({},c,{url:a,files:[].concat(b)}):a,c=_({jsonp:"callback",prepare:s,beforeupload:s,upload:s,fileupload:s,fileprogress:s,filecomplete:s,progress:s,complete:s,pause:s,serial:!0,parallel:0,postName:"files",chunkSize:fb.chunkSize,imageOriginal:!0,chunkUploadRetry:fb.chunkUploadRetry,uploadRetry:fb.uploadRetry},c),c.serial||(c.chunkSize&&(c.chunkSize=0,fb.log("[warn] FileAPI.upload: `chunkSize > 0` is not supported, if serial == false")),fb.flashEngine&&fb.log("[warn] FileAPI.upload: `serial == false` is not supported in Flash.")),c.parallel>0&&(c.serial=!0,fb.flashEngine&&fb.log("[warn] FileAPI.upload: `parallel > 0` is not supported in Flash.")),c.imageAutoOrientation&&!c.imageTransform&&(c.imageTransform={rotate:"auto"});var f=new fb.XHR(c),g=k(c.files,c.postName),h=fb.defer(),i=this,j=0,n=0,o=0,p=E&&c.serial,q=p&&c.parallel,r=!g.length,t=[],u=f.activeFiles=[];return Z(g,function(a){j+=a.size}),f.files=[],Z(g,function(a){f.files.push(a.file)}),f.total=j,f.loaded=0,f.filesLeft=g.length,c.beforeupload(f,c),h.progress(c.progress),h.done(c.success),h.fail(c.error),O(function(){for(var a=0;a<N.max(q,1);a++)e()},0),f.append=function(a,b){a=fb._getFilesDataArray([].concat(a)),Z(a,function(a){j+=a.size,f.files.push(a.file),b?g.unshift(a):g.push(a)}),f.statusText="",o||e.call(i)},f.remove=function(a){for(var b,c=g.length;c--;)g[c].file==a&&(b=g.splice(c,1),j-=b.size);return b},f.error=h.fail,f.success=h.done,_(f,h)},reset:function(a,b){var c,d;return C?(d=C(a).clone(!0).insertBefore(a).val("")[0],b||C(a).remove()):(c=a.parentNode,d=c.insertBefore(a.cloneNode(!0),a),d.value="",b||c.removeChild(a),Z(R[fb.uid(a)],function(b,c){Z(b,function(b){bb(a,c,b),ab(d,c,b)})})),d},load:function(a,b){var c=new fb.XHR(b=_(b||{},{url:a,type:"GET",cache:!0,responseType:"blob"})),d=c.defer.resolve;return c.defer.resolve=function(a,b){var c=a.response;return c&&y&&c instanceof y?d(c,a,b):a.defer.reject("load_not_supported",a,b)},l(b,[],function(a){c.send(a)}),c},saveAs:function(a,c){var d=fb.defer();if("string"==typeof a)c===b&&(c=a.split("/").pop()),fb.load(a).progress(d.notify).done(function(a){fb.saveAs(a,c).then(d.resolve,d.reject)}).fail(d.reject);else try{q(a,c)?d.resolve():d.reject("saveAs_not_support")}catch(e){fb.log("[err] FileAPI.saveAs: "+e.toString()),d.reject(e)}return d}};fb.addInfoReader(/^image/,function(a,b){if(!a.__dimensions){var c=a.__dimensions=fb.defer();fb.readAsImage(a,function(a){var b=a.target;c.resolve("load"==a.type?!1:"error",{width:b.width,height:b.height}),b.src=fb.EMPTY_PNG,b=null})}a.__dimensions.then(b)}),fb.event.dnd=function(a,b,c){var d,e;c||(c=b,b=s),A?(ab(a,"dragenter dragleave dragover",function(a){for(var c=o(a).types,f=c&&c.length,g=!1;f--;)if(~c[f].indexOf("File")){a[W](),e!==a.type&&(e=a.type,"dragleave"!=e&&b.call(a[V],!0,a),g=!0);break}g&&(P(d),d=O(function(){b.call(a[V],"dragleave"!=e,a)},50))}),ab(a,"drop",function(a){a[W](),e=0,b.call(a[V],!1,a),fb.getDropFiles(a,function(b){c.call(a[V],b,a)})})):fb.log("Drag'n'Drop -- not supported")},fb.event.dnd.off=function(a,b,c){bb(a,"dragenter dragleave dragover",b),bb(a,"drop",c)},C&&!C.fn.dnd&&(C.fn.dnd=function(a,b){return this.each(function(){fb.event.dnd(this,a,b)})},C.fn.offdnd=function(a,b){return this.each(function(){fb.event.dnd.off(this,a,b)})}),a.FileAPI=_(fb,a.FileAPI),fb.log("FileAPI: "+fb.version),fb.log("protocol: "+a.location.protocol),fb.log("doctype: ["+u.name+"] "+u.publicId+" "+u.systemId),Z(t.getElementsByTagName("meta"),function(a){/x-ua-compatible/i.test(a.getAttribute("http-equiv"))&&fb.log("meta.http-equiv: "+a.getAttribute("content"))}),fb.flashUrl||(fb.flashUrl=fb.staticPath+"FileAPI.flash.swf"),fb.flashImageUrl||(fb.flashImageUrl=fb.staticPath+"FileAPI.flash.image.swf"),fb.flashWebcamUrl||(fb.flashWebcamUrl=fb.staticPath+"FileAPI.flash.camera.swf")}(window,void 0),function(a,b,c){"use strict";function d(b){if(b instanceof d){var c=new d(b.file);return a.extend(c.matrix,b.matrix),c}return this instanceof d?(this.file=b,this.size=b.size||100,void(this.matrix={sx:0,sy:0,sw:0,sh:0,dx:0,dy:0,dw:0,dh:0,resize:0,deg:0,quality:1,filter:0,multipass:a.multiPassResize})):new d(b)}var e=Math.min,f=Math.round,g=function(){return b.createElement("canvas")},h=!1,i={8:270,3:180,6:90};try{h=g().toDataURL("image/png").indexOf("data:image/png")>-1}catch(j){}d.prototype={image:!0,constructor:d,set:function(b){return a.extend(this.matrix,b),this},crop:function(a,b,d,e){return d===c&&(d=a,e=b,a=b=0),this.set({sx:a,sy:b,sw:d,sh:e||d})},resize:function(a,b,c){return/min|max/.test(b)&&(c=b,b=a),this.set({dw:a,dh:b||a,resize:c})},preview:function(a,b){return this.resize(a,b||a,"preview")},rotate:function(a){return this.set({deg:a})},filter:function(a){return this.set({filter:a})},overlay:function(a){return this.set({overlay:a})},clone:function(){return new d(this)},_load:function(b,c){var d=this;/img|video/i.test(b.nodeName)?c.call(d,null,b):a.readAsImage(b,function(a){c.call(d,"load"!=a.type,a.result)})},_apply:function(b,c){var f,h=g(),i=this.getMatrix(b),j=h.getContext("2d"),k=b.videoWidth||b.width,l=b.videoHeight||b.height,m=i.deg,n=i.dw,o=i.dh,p=k,q=l,r=i.filter,s=b,t=i.overlay,u=a.queue(function(){b.src=a.EMPTY_PNG,c(!1,h)}),v=a.renderImageToCanvas;if(m-=360*Math.floor(m/360),b._type=this.file.type,i.multipass)for(;e(p/n,q/o)>2;)p=p/2+.5|0,q=q/2+.5|0,f=g(),f.width=p,f.height=q,s!==b?(v(f,s,0,0,s.width,s.height,0,0,p,q),s=f):(s=f,v(s,b,i.sx,i.sy,i.sw,i.sh,0,0,p,q),i.sx=i.sy=i.sw=i.sh=0);h.width=m%180?o:n,h.height=m%180?n:o,h.type=i.type,h.quality=i.quality,j.rotate(m*Math.PI/180),v(j.canvas,s,i.sx,i.sy,i.sw||s.width,i.sh||s.height,180==m||270==m?-n:0,90==m||180==m?-o:0,n,o),n=h.width,o=h.height,t&&a.each([].concat(t),function(b){u.inc();var c=new window.Image,d=function(){var e=0|b.x,f=0|b.y,g=b.w||c.width,h=b.h||c.height,i=b.rel;e=1==i||4==i||7==i?(n-g+e)/2:2==i||5==i||8==i?n-(g+e):e,f=3==i||4==i||5==i?(o-h+f)/2:i>=6?o-(h+f):f,a.event.off(c,"error load abort",d);try{j.globalAlpha=b.opacity||1,j.drawImage(c,e,f,g,h)}catch(k){}u.next()};a.event.on(c,"error load abort",d),c.src=b.src,c.complete&&d()}),r&&(u.inc(),d.applyFilter(h,r,u.next)),u.check()},getMatrix:function(b){var c=a.extend({},this.matrix),d=c.sw=c.sw||b.videoWidth||b.naturalWidth||b.width,g=c.sh=c.sh||b.videoHeight||b.naturalHeight||b.height,h=c.dw=c.dw||d,i=c.dh=c.dh||g,j=d/g,k=h/i,l=c.resize;if("preview"==l){if(h!=d||i!=g){var m,n;k>=j?(m=d,n=m/k):(n=g,m=n*k),(m!=d||n!=g)&&(c.sx=~~((d-m)/2),c.sy=~~((g-n)/2),d=m,g=n)}}else l&&(d>h||g>i?"min"==l?(h=f(k>j?e(d,h):i*j),i=f(k>j?h/j:e(g,i))):(h=f(j>=k?e(d,h):i*j),i=f(j>=k?h/j:e(g,i))):(h=d,i=g));return c.sw=d,c.sh=g,c.dw=h,c.dh=i,c.multipass=a.multiPassResize,c},_trans:function(b){this._load(this.file,function(c,d){if(c)b(c);else try{this._apply(d,b)}catch(c){a.log("[err] FileAPI.Image.fn._apply:",c),b(c)}})},get:function(b){if(a.support.transform){var c=this,d=c.matrix;"auto"==d.deg?a.getInfo(c.file,function(a,e){d.deg=i[e&&e.exif&&e.exif.Orientation]||0,c._trans(b)}):c._trans(b)}else b("not_support_transform");return this},toData:function(a){return this.get(a)}},d.exifOrientation=i,d.transform=function(b,e,f,g){function h(h,i){var j={},k=a.queue(function(a){g(a,j)});h?k.fail():a.each(e,function(a,e){if(!k.isFail()){var g=new d(i.nodeType?i:b);if("function"==typeof a?a(i,g):a.width?g[a.preview?"preview":"resize"](a.width,a.height,a.strategy):a.maxWidth&&(i.width>a.maxWidth||i.height>a.maxHeight)&&g.resize(a.maxWidth,a.maxHeight,"max"),a.crop){var h=a.crop;g.crop(0|h.x,0|h.y,h.w||h.width,h.h||h.height)}a.rotate===c&&f&&(a.rotate="auto"),g.set({deg:a.rotate,type:a.type||b.type||"image/png",quality:a.quality||1,overlay:a.overlay,filter:a.filter}),k.inc(),g.toData(function(a,b){a?k.fail():(j[e]=b,k.next())})}})}b.width?h(!1,b):a.getInfo(b,h)},a.each(["TOP","CENTER","BOTTOM"],function(b,c){a.each(["LEFT","CENTER","RIGHT"],function(a,e){d[b+"_"+a]=3*c+e,d[a+"_"+b]=3*c+e})}),d.toCanvas=function(a){var c=b.createElement("canvas");return c.width=a.videoWidth||a.width,c.height=a.videoHeight||a.height,c.getContext("2d").drawImage(a,0,0),c},d.fromDataURL=function(b,c,d){var e=a.newImage(b);a.extend(e,c),d(e)},d.applyFilter=function(b,c,e){"function"==typeof c?c(b,e):window.Caman&&window.Caman("IMG"==b.tagName?d.toCanvas(b):b,function(){"string"==typeof c?this[c]():a.each(c,function(a,b){this[b](a)},this),this.render(e)})},a.renderImageToCanvas=function(b,c,d,e,f,g,h,i,j,k){try{return b.getContext("2d").drawImage(c,d,e,f,g,h,i,j,k)}catch(l){throw a.log("renderImageToCanvas failed:",l),l}},a.support.canvas=a.support.transform=h,a.Image=d}(FileAPI,document),function(a){"use strict";a(FileAPI)}(function(a){"use strict";if(window.navigator&&window.navigator.platform&&/iP(hone|od|ad)/.test(window.navigator.platform)){var b=a.renderImageToCanvas;a.detectSubsampling=function(a){var b,c;return a.width*a.height>1048576?(b=document.createElement("canvas"),b.width=b.height=1,c=b.getContext("2d"),c.drawImage(a,-a.width+1,0),0===c.getImageData(0,0,1,1).data[3]):!1},a.detectVerticalSquash=function(a,b){var c,d,e,f,g,h=a.naturalHeight||a.height,i=document.createElement("canvas"),j=i.getContext("2d");for(b&&(h/=2),i.width=1,i.height=h,j.drawImage(a,0,0),c=j.getImageData(0,0,1,h).data,d=0,e=h,f=h;f>d;)g=c[4*(f-1)+3],0===g?e=f:d=f,f=e+d>>1;return f/h||1},a.renderImageToCanvas=function(c,d,e,f,g,h,i,j,k,l){if("image/jpeg"===d._type){var m,n,o,p,q=c.getContext("2d"),r=document.createElement("canvas"),s=1024,t=r.getContext("2d");if(r.width=s,r.height=s,q.save(),m=a.detectSubsampling(d),m&&(e/=2,f/=2,g/=2,h/=2),n=a.detectVerticalSquash(d,m),m||1!==n){for(f*=n,k=Math.ceil(s*k/g),l=Math.ceil(s*l/h/n),j=0,p=0;h>p;){for(i=0,o=0;g>o;)t.clearRect(0,0,s,s),t.drawImage(d,e,f,g,h,-o,-p,g,h),q.drawImage(r,0,0,s,s,i,j,k,l),o+=s,i+=k;p+=s,j+=l}return q.restore(),c}}return b(c,d,e,f,g,h,i,j,k,l)}}}),function(a,b){"use strict";function c(){this.items=[]}function d(b,c,d){var e=b.blob,f=b.file;if(f){if(!e.toDataURL)return void a.readAsBinaryString(e,function(a){"load"==a.type&&c(b,a.result)});var g={"image/jpeg":".jpe?g","image/png":".png"},h=g[b.type]?b.type:"image/png",i=g[h]||".png",j=e.quality||1;f.match(new RegExp(i+"$","i"))||(f+=i.replace("?","")),b.file=f,b.type=h,!d&&e.toBlob?e.toBlob(function(a){c(b,a)},h,j):c(b,a.toBinaryString(e.toDataURL(h,j)))}else c(b,e)}var e=b.FormData,f=b.document,g=b.unescape,h=b.encodeURIComponent;c.prototype={append:function(a,b,c,d){this.items.push({name:a,blob:b&&b.blob||(void 0==b?"":b),file:b&&(c||b.name),type:b&&(d||b.type)})},each:function(a){for(var b=0,c=this.items.length;c>b;b++)a.call(this,this.items[b])},toData:function(b,c){c._chunked=a.support.chunked&&c.chunkSize>0&&1==a.filter(this.items,function(a){return a.file}).length,a.support.html5?a.formData&&!this.multipart&&e?c._chunked?(a.log("FileAPI.Form.toPlainData"),this.toPlainData(b)):(a.log("FileAPI.Form.toFormData"),this.toFormData(b)):(a.log("FileAPI.Form.toMultipartData"),this.toMultipartData(b)):(a.log("FileAPI.Form.toHtmlData"),this.toHtmlData(b))},_to:function(b,c,d,e){var f=a.queue(function(){c(b)});this.each(function(a){d(a,b,f,e)}),f.check()},toHtmlData:function(b){this._to(f.createDocumentFragment(),b,function(b,c){var d,e=b.blob;b.file?(a.reset(e,!0),e.name=b.name,c.appendChild(e)):(d=f.createElement("input"),d.name=b.name,d.type="hidden",d.value=e,c.appendChild(d))})},toPlainData:function(a){this._to({},a,function(a,b,c){a.file&&(b.type=a.file),a.blob.toBlob?(c.inc(),d(a,function(a,d){b.name=a.name,b.file=d,b.size=d.length,b.type=a.type,c.next()})):a.file?(b.name=a.blob.name,b.file=a.blob,b.size=a.blob.size,b.type=a.type):(b.params||(b.params=[]),b.params.push(h(a.name)+"="+h(a.blob))),b.start=-1,b.end=b.file&&b.file.FileAPIReadPosition||-1,b.retry=0})},toFormData:function(a){this._to(new e,a,function(a,b,c){a.blob&&a.blob.toBlob?(c.inc(),d(a,function(a,d){b.append(a.name,d,a.file),c.next()})):a.file?b.append(a.name,a.blob,a.file):b.append(a.name,a.blob),a.file&&b.append("_"+a.name,a.file)})},toMultipartData:function(b){this._to([],b,function(a,b,c,e){c.inc(),d(a,function(a,d){b.push("--_"+e+'\r\nContent-Disposition: form-data; name="'+a.name+'"'+(a.file?'; filename="'+g(h(a.file))+'"':"")+(a.file?"\r\nContent-Type: "+(a.type||"application/octet-stream"):"")+"\r\n\r\n"+d+"\r\n"),c.next()},!0)},a.expando)}},a.Form=c}(FileAPI,window),function(a,b){"use strict";var c=b.F,d=a.document,e=function(a){var d=b.defer().progress(a.progress);this.uid=b.uid(),this.xhr={abort:c,getResponseHeader:c,getAllResponseHeaders:c},this.defer=d,this.options=b.extend({upload:c,complete:c,withCredentials:b.withCredentials},a),this.done=this.success=d.done,this.fail=this.error=d.fail,this.notify=d.notify,this.progress=d.progress},f={"":1,XML:1,Text:1,Body:1};e.prototype={status:0,statusText:"",constructor:e,getResponseHeader:function(a){return this.xhr.getResponseHeader(a)},getAllResponseHeaders:function(){return this.xhr.getAllResponseHeaders()||{}},end:function(d,e){var f=this,g=f.defer,h=f.options,i=200==d||201==d?!1:e||"unknown";f.end=f.abort=c,f.status=d,e&&(f.statusText=e),b.log("xhr.end:",d,e),i?g.reject(i,f,h):g.resolve(f,h),h.complete(i,f),f.xhr&&f.xhr.node&&setTimeout(function(){var b=f.xhr.node;try{b.parentNode.removeChild(b)}catch(c){}try{delete a[f.uid]}catch(c){}a[f.uid]=f.xhr.node=null},9)},abort:function(){this.end(0,"abort"),this.xhr&&(this.xhr.aborted=!0,this.xhr.abort())},send:function(a){var b=this,c=this.options;a.toData(function(a){c.upload(c,b),b._send.call(b,c,a)},c)},_send:function(c,e){var g,h=this,i=h.uid,j=c.url;if(b.log("XHR._send:",e),c.cache||(j+=(~j.indexOf("?")?"&":"?")+b.uid()),e.nodeName){var k=c.jsonp;j=j.replace(/([a-z]+)=(\?)/i,"$1="+i),c.upload(c,h),g=d.createElement("div"),g.innerHTML='<form target="'+i+'" action="'+j+'" method="POST" enctype="multipart/form-data" style="position: absolute; top: -1000px; overflow: hidden; width: 1px; height: 1px;"><iframe name="'+i+'" src="javascript:false;"></iframe>'+(k&&c.url.indexOf("=?")<0?'<input value="'+i+'" name="'+k+'" type="hidden"/>':"")+"</form>";var l=g.getElementsByTagName("form")[0],m=g.getElementsByTagName("iframe")[0];l.appendChild(e),b.log(l.parentNode.innerHTML),d.body.appendChild(g),h.xhr.node=g;var n=function(a){if(~j.indexOf(a.origin))try{var c=b.parseJSON(a.data);c.id==i&&o(c.status,c.statusText,c.response)}catch(d){o(0,d.message)}},o=a[i]=function(c,d,e){h.readyState=4,h.responseText=e,h.end(c,d),b.event.off(a,"message",n),a[i]=g=m=m.onload=null};h.xhr.abort=function(){try{m.stop?m.stop():m.contentWindow.stop?m.contentWindow.stop():m.contentWindow.document.execCommand("Stop")}catch(a){}o(0,"abort")},b.event.on(a,"message",n),m.onload=function(){try{var a=m.contentWindow,c=a.document,d=a.result||b.parseJSON(c.body.innerHTML);o(d.status,d.statusText,d.response)}catch(e){b.log("[transport.onload]",e)}},h.readyState=2,l.submit(),l=null}else{if(j=j.replace(/([a-z]+)=(\?)&?/i,""),this.xhr&&this.xhr.aborted)return void b.log("Error: already aborted");if(e.params&&(j+=(j.indexOf("?")<0?"?":"&")+e.params.join("&")),g=h.xhr=b.getXHR(),g.open(c.type||"POST",j,!0),c.responseType&&(g.responseType=c.responseType),c.withCredentials&&(g.withCredentials="true"),c.headers&&c.headers["X-Requested-With"]||g.setRequestHeader("X-Requested-With","XMLHttpRequest"),b.each(c.headers,function(a,b){g.setRequestHeader(b,a)}),c._chunked){g.upload&&g.upload.addEventListener("progress",b.throttle(function(a){e.retry||h.notify({type:a.type,total:e.size,loaded:e.start+a.loaded,totalSize:e.size},h,c)},100),!1),g.onreadystatechange=function(){var a=parseInt(g.getResponseHeader("X-Last-Known-Byte"),10);if(h.status=g.status,h.statusText=g.statusText,h.readyState=g.readyState,4==g.readyState){try{for(var d in f)h["response"+d]=g["response"+d]}catch(i){}if(g.onreadystatechange=null,!g.status||g.status-201>0)if(b.log("Error: "+g.status),(!g.status&&!g.aborted||500==g.status||416==g.status)&&++e.retry<=c.chunkUploadRetry){var j=g.status?0:b.chunkNetworkDownRetryTimeout;c.pause(e.file,c),b.log("X-Last-Known-Byte: "+a),a?e.end=a:(e.end=e.start-1,416==g.status&&(e.end=e.end-c.chunkSize)),setTimeout(function(){h._send(c,e)},j)}else h.end(g.status);else e.retry=0,e.end==e.size-1?h.end(g.status):(b.log("X-Last-Known-Byte: "+a),a&&(e.end=a),e.file.FileAPIReadPosition=e.end,setTimeout(function(){h._send(c,e)},0));g=null}},e.start=e.end+1,e.end=Math.max(Math.min(e.start+c.chunkSize,e.size)-1,e.start);var p=e.file,q=(p.slice||p.mozSlice||p.webkitSlice).call(p,e.start,e.end+1);e.size&&!q.size?setTimeout(function(){h.end(-1)}):(g.setRequestHeader("Content-Range","bytes "+e.start+"-"+e.end+"/"+e.size),g.setRequestHeader("Content-Disposition","attachment; filename="+encodeURIComponent(e.name)),g.setRequestHeader("Content-Type",e.type||"application/octet-stream"),g.send(q)),p=q=null}else if(g.upload&&(g.upload.addEventListener("progress",b.throttle(function(a){h.notify(a,h,c)},100),!1),b.event.on(g,"progress",function(a){h.notify(a,h,c)})),g.onreadystatechange=function(){if(h.status=g.status,h.statusText=g.statusText,h.readyState=g.readyState,4==g.readyState){try{for(var a in f)h["response"+a]=g["response"+a]}catch(d){}if(g.onreadystatechange=null,!g.status||g.status>201)if(b.log("Error: "+g.status),(!g.status&&!g.aborted||500==g.status)&&(c.retry||0)<c.uploadRetry){c.retry=(c.retry||0)+1;var i=b.networkDownRetryTimeout;c.pause(c.file,c),setTimeout(function(){h._send(c,e)},i)}else h.end(g.status);else h.end(g.status);g=null}},b.isArray(e)){g.setRequestHeader("Content-Type","multipart/form-data; boundary=_"+b.expando);var r=e.join("")+"--_"+b.expando+"--";if(g.sendAsBinary)g.sendAsBinary(r);else{var s=Array.prototype.map.call(r,function(a){return 255&a.charCodeAt(0)
});g.send(new Uint8Array(s).buffer)}}else g.send(e)}}},b.XHR=e}(window,FileAPI),function(a,b){"use strict";function c(a){return a>=0?a+"px":a}function d(a){var b,c=f.createElement("canvas"),d=!1;try{b=c.getContext("2d"),b.drawImage(a,0,0,1,1),d=255!=b.getImageData(0,0,1,1).data[4]}catch(e){}return d}var e=a.URL||a.webkitURL,f=a.document,g=a.navigator,h=g.getUserMedia||g.webkitGetUserMedia||g.mozGetUserMedia||g.msGetUserMedia,i=!!h;b.support.media=i;var j=function(a){this.video=a};j.prototype={isActive:function(){return!!this._active},start:function(a){var b,c,f=this,i=f.video,j=function(d){f._active=!d,clearTimeout(c),clearTimeout(b),a&&a(d,f)};h.call(g,{video:!0},function(a){f.stream=a,i.src=e.createObjectURL(a),b=setInterval(function(){d(i)&&j(null)},1e3),c=setTimeout(function(){j("timeout")},5e3),i.play()},j)},stop:function(){try{this._active=!1,this.video.pause(),this.stream.stop()}catch(a){}},shot:function(){return new k(this.video)}},j.get=function(a){return new j(a.firstChild)},j.publish=function(d,e,g){"function"==typeof e&&(g=e,e={}),e=b.extend({},{width:"100%",height:"100%",start:!0},e),d.jquery&&(d=d[0]);var h=function(a){if(a)g(a);else{var b=j.get(d);e.start?b.start(g):g(null,b)}};if(d.style.width=c(e.width),d.style.height=c(e.height),b.html5&&i){var k=f.createElement("video");k.style.width=c(e.width),k.style.height=c(e.height),a.jQuery?jQuery(d).empty():d.innerHTML="",d.appendChild(k),h()}else j.fallback(d,e,h)},j.fallback=function(a,b,c){c("not_support_camera")};var k=function(a){var c=a.nodeName?b.Image.toCanvas(a):a,d=b.Image(c);return d.type="image/png",d.width=c.width,d.height=c.height,d.size=c.width*c.height*4,d};j.Shot=k,b.Camera=j}(window,FileAPI),function(a,b,c){"use strict";var d=c.each,e=c.extend,f=[],g=c.Flash,h=g.wrap,i=g.unwrap;c.support.flash&&c.media&&!c.support.media&&(c.extend(g,{patchCamera:function(){c.Camera.fallback=function(a,b,d){var f=c.uid();c.log("FlashAPI.Camera.publish: "+f),g.publish(a,f,e(b,{camera:!0,onEvent:h(function j(a){"camera"===a.type&&(i(j),a.error?(c.log("FlashAPI.Camera.publish.error: "+a.error),d(a.error)):(c.log("FlashAPI.Camera.publish.success: "+f),d(null)))})}))},d(f,function(a){c.Camera.fallback.apply(c.Camera,a)}),f=[],e(c.Camera.prototype,{_id:function(){return this.video.id},start:function(a){var b=this;g.cmd(this._id(),"camera.on",{callback:h(function d(e){i(d),e.error?(c.log("FlashAPI.camera.on.error: "+e.error),a(e.error,b)):(c.log("FlashAPI.camera.on.success: "+b._id()),b._active=!0,a(null,b))})})},stop:function(){this._active=!1,g.cmd(this._id(),"camera.off")},shot:function(){c.log("FlashAPI.Camera.shot:",this._id());var a=g.cmd(this._id(),"shot",{});return a.type="image/png",a.flashId=this._id(),a.isShot=!0,new c.Camera.Shot(a)}})}}),c.Camera.fallback=function(){f.push(arguments)})}(window,window.jQuery,FileAPI),"function"==typeof define&&define.amd&&define("FileAPI",[],function(){return FileAPI});
View
6 dist/FileAPI.js
@@ -526,7 +526,7 @@
doneList =
failList = null;
-
+
progressList = [];
for( ; i < n; i++ ){
@@ -1611,7 +1611,7 @@
, type: api.getMimeType(name)
};
}
-
+
function _isRegularFile(file, callback){
// http://stackoverflow.com/questions/8856628/detecting-folders-directories-in-javascript-filelist-objects
@@ -1784,7 +1784,7 @@
if( isOrignTrans ){
// Convert to array for transform function
- trans = [trans];
+ trans = [].concat(trans);
}
api.Image.transform(file, trans, options.imageAutoOrientation, function (err, images){
View
4 dist/FileAPI.min.js
@@ -1,3 +1,3 @@
/*! FileAPI 2.1.0 - BSD | git://github.com/mailru/FileAPI.git */
-!function(a){"use strict";var b=a.HTMLCanvasElement&&a.HTMLCanvasElement.prototype,c=a.Blob&&function(){try{return Boolean(new Blob)}catch(a){return!1}}(),d=c&&a.Uint8Array&&function(){try{return 100===new Blob([new Uint8Array(100)]).size}catch(a){return!1}}(),e=a.BlobBuilder||a.WebKitBlobBuilder||a.MozBlobBuilder||a.MSBlobBuilder,f=(c||e)&&a.atob&&a.ArrayBuffer&&a.Uint8Array&&function(a){var b,f,g,h,i,j;for(b=a.split(",")[0].indexOf("base64")>=0?atob(a.split(",")[1]):decodeURIComponent(a.split(",")[1]),f=new ArrayBuffer(b.length),g=new Uint8Array(f),h=0;h<b.length;h+=1)g[h]=b.charCodeAt(h);return i=a.split(",")[0].split(":")[1].split(";")[0],c?new Blob([d?g:f],{type:i}):(j=new e,j.append(f),j.getBlob(i))};a.HTMLCanvasElement&&!b.toBlob&&(b.mozGetAsFile?b.toBlob=function(a,c,d){d&&b.toDataURL&&f?a(f(this.toDataURL(c,d))):a(this.mozGetAsFile("blob",c))}:b.toDataURL&&f&&(b.toBlob=function(a,b,c){a(f(this.toDataURL(b,c)))})),a.dataURLtoBlob=f}(window),function(a,b){"use strict";function c(a,b,c,d,e){var f={type:c.type||c,target:a,result:d};_(f,e),b(f)}function d(a){return A&&!!A.prototype["readAs"+a]}function e(a,e,f,g){if(fb.isBlob(a)&&d(f)){var h=new A;ab(h,T,function j(b){var d=b.type;"progress"==d?c(a,e,b,b.target.result,{loaded:b.loaded,total:b.total}):"loadend"==d?(bb(h,T,j),h=null):c(a,e,b,b.target.result)});try{g?h["readAs"+f](a,g):h["readAs"+f](a)}catch(i){c(a,e,"error",b,{error:i.toString()})}}else c(a,e,"error",b,{error:"filreader_not_support_"+f})}function f(a){return a&&(z&&a instanceof z||a.blob||a.image&&a.file||a.flashId)}function g(a){return{name:(a+"").split(/\\|\//g).pop(),type:fb.getMimeType(a)}}function h(a,b){if(!a.type&&a.size%4096===0&&a.size<=102400)if(A)try{var c=new A;cb(c,T,function(a){var d="error"!=a.type;b(d),d&&c.abort()}),c.readAsDataURL(a)}catch(d){b(!1)}else b(null);else b(!0)}function i(a){var b;return a.getAsEntry?b=a.getAsEntry():a.webkitGetAsEntry&&(b=a.webkitGetAsEntry()),b}function j(a,b){if(a)if(a.isFile)a.file(function(c){c.fullPath=a.fullPath,b(!1,[c])},function(a){b("FileError.code: "+a.code)});else if(a.isDirectory){var c=a.createReader(),d=[];c.readEntries(function(a){fb.afor(a,function(a,c){j(c,function(c,e){c?fb.log(c):d=d.concat(e),a?a():b(!1,d)})})},function(a){b("directory_reader: "+a)})}else j(i(a),b);else b("invalid entry")}function k(a,b){var c=[],d={};if(n(a)){var e=fb.getFiles(a);d[a.name||b]=null!==a.getAttribute("multiple")?e:e[0]}else Y(a)?n(a[0])?Z(a,function(a){d[a.name||b]=fb.getFiles(a)}):f(a[0])&&(d[b]=a):f(a)?d[b]=a:d=a;return Z(d,function g(a,b){Y(a)?Z(a,function(a){g(a,b)}):f(a)&&c.push({name:b,file:a,size:a.size,total:a.size,loaded:0})}),c}function l(a,b,c){var d=new fb.Form,e=fb.queue(function(){c(d)}),f=fb.support.transform&&a.imageTransform,g=f&&p(f),h=fb.postNameConcat;Z(b,function(b,c){var i=b.file,j=h(b.name,a.serial||a.chunkSize?null:c),k=i.name,l=i.type;!function m(b){b.image?(e.inc(),b.toData(function(a,b){k=k||(new Date).getTime()+".png",m(b),e.next()})):fb.Image&&f&&(/^image/.test(b.type)||K.test(b.nodeName))?(e.inc(),g&&(f=[f]),fb.Image.transform(b,f,a.imageAutoOrientation,function(c,i){if(g&&!c)H||fb.flashEngine||(d.multipart=!0),d.append(j,i[0],k,f[0].type||l);else{var m=0;c||Z(i,function(a,b){H||fb.flashEngine||(d.multipart=!0),f[b].postName||(m=1),d.append(f[b].postName||h(j,b),a,k,f[b].type||l)}),(c||a.imageOriginal)&&d.append(h(j,m?"original":null),b,k,l)}e.next()})):k!==fb.expando&&d.append(j,b,k)}(i)}),Z(a.data,function i(a,b){"object"==typeof a?Z(a,function(a,c){i(a,h(b,c))}):d.append(b,a)}),e.check()}function m(a){var b={};return Z(a,function(a,c){a&&"object"==typeof a&&null==a.nodeType&&(a=_({},a)),b[c]=a}),b}function n(a){return L.test(a&&a.tagName)}function o(a){return(a.originalEvent||a||"").dataTransfer||{}}function p(a){var b;for(b in a)if(a.hasOwnProperty(b)&&!(a[b]instanceof Object||"overlay"===b||"filter"===b))return!0;return!1}function q(a,b){var c=!1;if(v.msSaveBlob)c=v.msSaveBlob(a,b);else if(fb.support.download){var d=fb.createURL(a),e=t.body,f=X("a");d&&(f.href=d,f.download=b||a.name,f.style.top="-10000px",f.style.position="absolute",e.appendChild(f),f.click(),e.removeChild(f),c=!0,O(function(){fb.revokeURL(d)},1))}return c}var r=1,s=function(){},t=a.document,u=t.doctype||{},v=a.navigator,w=a.navigator.userAgent,x=a.createObjectURL&&a||a.URL&&URL.revokeObjectURL&&URL||a.webkitURL&&webkitURL,y=a.Blob,z=a.File,A=a.FileReader,B=a.FormData,C=a.jQuery,D=a.XMLHttpRequest,E=!(!(z&&A&&(a.Uint8Array||B||D.prototype.sendAsBinary))||/safari\//i.test(w)&&!/chrome\//i.test(w)&&/windows/i.test(w)),F=E&&"withCredentials"in new D,G=E&&!!y&&!!(y.prototype.webkitSlice||y.prototype.mozSlice||y.prototype.slice),H=a.dataURLtoBlob,I=/img/i,J=/canvas/i,K=/img|canvas/i,L=/input/i,M=/^data:[^,]+,/,N=a.Math,O=a.setTimeout,P=a.clearTimeout,Q=function(b){return b=new a.Number(N.pow(1024,b)),b.from=function(a){return N.round(a*this)},b},R={},S=[],T="abort progress error load loadend",U="status statusText readyState response responseXML responseText responseBody".split(" "),V="currentTarget",W="preventDefault",X=function(a){return t.createElement(a)},Y=function(a){return a&&"length"in a},Z=function(a,b,c){if(a)if(Y(a))for(var d=0,e=a.length;e>d;d++)d in a&&b.call(c,a[d],d,a);else for(var f in a)a.hasOwnProperty(f)&&b.call(c,a[f],f,a)},$=function(a,b){for(var c=-1,d=a&&a.length;d--;)if(a[d]===b){c=d;break}return c},_=function(a){for(var b=arguments,c=1,d=function(b,c){a[c]=b};c<b.length;c++)Z(b[c],d);return a},ab=function(a,b,c){if(a){var d=fb.uid(a);R[d]||(R[d]={});var e=A&&a&&a instanceof A;Z(b.split(/\s+/),function(b){C&&!e?C.event.add(a,b,c):(R[d][b]||(R[d][b]=[]),R[d][b].push(c),a.addEventListener?a.addEventListener(b,c,!1):a.attachEvent?a.attachEvent("on"+b,c):a["on"+b]=c)})}},bb=function(a,b,c){if(a){var d=fb.uid(a),e=R[d]||{},f=A&&a&&a instanceof A;Z(b.split(/\s+/),function(b){if(C&&!f)C.event.remove(a,b,c);else{for(var d=e[b]||[],g=d.length;g--;)if(d[g]===c){d.splice(g,1);break}a.addEventListener?a.removeEventListener(b,c,!1):a.detachEvent?a.detachEvent("on"+b,c):a["on"+b]=null}})}},cb=function(a,b,c){ab(a,b,function d(e){bb(a,b,d),c(e)})},db=function(b){return b.target||(b.target=a.event&&a.event.srcElement||t),3===b.target.nodeType&&(b.target=b.target.parentNode),b},eb=function(a){var b=X("input");return b.setAttribute("type","file"),a in b},fb={version:"2.1.0",cors:!1,html5:!0,media:!1,formData:!0,multiPassResize:!0,debug:!1,pingUrl:!1,multiFlash:!1,flashAbortTimeout:0,withCredentials:!0,staticPath:"./dist/",flashUrl:0,flashImageUrl:0,postNameConcat:function(a,b){return a+(null!=b?"["+b+"]":"")},support:{dnd:F&&"ondrop"in X("div"),cors:F,html5:E,chunked:G,dataURI:!0,accept:eb("accept"),multiple:eb("multiple"),saveAs:!!v.msSaveBlob,download:"download"in X("a")},ext2mime:{jpg:"image/jpeg",tif:"image/tiff",txt:"text/plain"},accept:{"image/*":"art bm bmp dwg dxf cbr cbz fif fpx gif ico iefs jfif jpe jpeg jpg jps jut mcf nap nif pbm pcx pgm pict pm png pnm qif qtif ras rast rf rp svf tga tif tiff xbm xbm xpm xwd","audio/*":"m4a flac aac rm mpa wav wma ogg mp3 mp2 m3u mod amf dmf dsm far gdm imf it m15 med okt s3m stm sfx ult uni xm sid ac3 dts cue aif aiff wpl ape mac mpc mpp shn wv nsf spc gym adplug adx dsp adp ymf ast afc hps xs","video/*":"m4v 3gp nsv ts ty strm rm rmvb m3u ifo mov qt divx xvid bivx vob nrg img iso pva wmv asf asx ogm m2v avi bin dat dvr-ms mpg mpeg mp4 mkv avc vp3 svq3 nuv viv dv fli flv wpl"},uploadRetry:0,networkDownRetryTimeout:5e3,chunkSize:0,chunkUploadRetry:0,chunkNetworkDownRetryTimeout:2e3,KB:Q(1),MB:Q(2),GB:Q(3),TB:Q(4),EMPTY_PNG:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQIW2NkAAIAAAoAAggA9GkAAAAASUVORK5CYII=",expando:"fileapi"+(new Date).getTime(),uid:function(a){return a?a[fb.expando]=a[fb.expando]||fb.uid():(++r,fb.expando+r)},log:function(){fb.debug&&a.console&&console.log&&(console.log.apply?console.log.apply(console,arguments):console.log([].join.call(arguments," ")))},newImage:function(a,b){var c=X("img");return b&&fb.event.one(c,"error load",function(a){b("error"==a.type,c),c=null}),c.src=a,c},getXHR:function(){var b;if(D)b=new D;else if(a.ActiveXObject)try{b=new ActiveXObject("MSXML2.XMLHttp.3.0")}catch(c){b=new ActiveXObject("Microsoft.XMLHTTP")}return b},createURL:function(a){return x?x.createObjectURL(a):null},revokeURL:function(a){return x&&x.revokeObjectURL(a)},isArray:Y,event:{on:ab,off:bb,one:cb,fix:db},throttle:function(b,c){var d,e;return function(){e=arguments,d||(b.apply(a,e),d=O(function(){d=0,b.apply(a,e)},c))}},F:s,parseJSON:function(b){var c;try{c=a.JSON&&JSON.parse?JSON.parse(b):new Function("return ("+b.replace(/([\r\n])/g,"\\$1")+");")()}catch(d){fb.log("[err] FileAPI.parseJSON: "+d)}return c},trim:function(a){return a=String(a),a.trim?a.trim():a.replace(/^\s+|\s+$/g,"")},defer:function(){var a=[],b=[],c=[],d=function(c,d){return d&&(c?a:b).push(d),this},e=function(f,g){var h=f?a:b,i=0,j=h.length;for(d=function(a,b){a===f&&b.apply(this,g)},e=s,a=b=null,c=[];j>i;i++)h[i]&&h[i].apply(this,g)},f={done:function(a){return d(1,a),this},fail:function(a){return d(0,a),this},resolve:function(){return e(1,arguments),this},reject:function(){return e(0,arguments),this},notify:function(){for(var a=0,b=c.length;b>a;a++)c[a].apply(this,arguments)},progress:function(a){return a&&c.push(a),this},then:function(a,b){return this.done(a).fail(b)},always:function(a){return this.then(a,a)},promise:function(){return this}};return f},queue:function(a){var b=0,c=0,d=!1,e=!1,f={inc:function(){c++},next:function(){b++,O(f.check,0)},check:function(){b>=c&&!d&&f.end()},isFail:function(){return d},fail:function(){!d&&a(d=!0)},end:function(){e||(e=!0,a())}};return f},each:Z,indexOf:$,afor:function(a,b){var c=0,d=a.length;Y(a)&&d--?!function e(){b(d!=c&&e,a[c],c++)}():b(!1)},extend:_,isFile:function(a){return E&&a&&(a instanceof z||a instanceof y)},isBlob:function(a){return E&&a&&a instanceof y},isCanvas:function(a){return a&&J.test(a.nodeName)},getFilesFilter:function(a){return a="string"==typeof a?a:a.getAttribute&&a.getAttribute("accept")||"",a?new RegExp("("+a.replace(/\./g,"\\.").replace(/,/g,"|")+")$","i"):/./},readAsDataURL:function(a,b){fb.isCanvas(a)?c(a,b,"load",fb.toDataURL(a)):e(a,b,"DataURL")},readAsBinaryString:function(a,b){d("BinaryString")?e(a,b,"BinaryString"):fb.readAsDataURL(a,function(a){if("load"==a.type)try{a.result=fb.toBinaryString(a.result)}catch(c){a.type="error",a.message=c.toString()}b(a)})},readAsArrayBuffer:function(a,b){e(a,b,"ArrayBuffer")},readAsText:function(a,b,c){c||(c=b,b="utf-8"),e(a,c,"Text",b)},toDataURL:function(a,b){return"string"==typeof a?a:a.toDataURL?a.toDataURL(b||"image/png"):void 0},toBinaryString:function(b){return a.atob(fb.toDataURL(b).replace(M,""))},readAsImage:function(a,b,d){if(fb.isFile(a))if(x){var e=fb.createURL(a);e?fb.readAsImage(e,b,d):c(a,b,"error")}else fb.readAsDataURL(a,function(e){"load"==e.type?fb.readAsImage(e.result,b,d):(d||"error"==e.type)&&c(a,b,e,null,{loaded:e.loaded,total:e.total})});else if(fb.isCanvas(a))c(a,b,"load",a);else if(I.test(a.nodeName))if(a.complete)c(a,b,"load",a);else{var f="error abort load";cb(a,f,function h(d){"load"==d.type&&x&&fb.revokeURL(a.src),bb(a,f,h),c(a,b,d,a)})}else if(a.iframe)c(a,b,{type:"error",message:"is iframe"});else{var g=fb.newImage(a.dataURL||a);fb.readAsImage(g,b,d)}},getMimeType:function(a){var b,c,d=a&&(a.type||String(a.name||a).split(".").pop()),e=fb.accept;if(!/^[^/]+\/[^/]+$/.test(d))for(c in e)if(b=new RegExp(e[c].replace(/\s/g,"|"),"i"),b.test(d)||fb.ext2mime[d]){d=fb.ext2mime[d]||c.split("/")[0]+"/"+d;break}return d},getDropFiles:function(a,b){var c=[],d=o(a),e=Y(d.items)&&d.items[0]&&i(d.items[0]),f=fb.queue(function(){b(c)});Z((e?d.items:d.files)||[],function(a){f.inc();try{e?j(a,function(a,b){a?fb.log("[err] getDropFiles:",a):c.push.apply(c,b),f.next()}):h(a,function(b){b&&c.push(a),f.next()})}catch(b){f.next(),fb.log("[err] getDropFiles: ",b)}}),f.check()},getFiles:function(a,b,c){var d=[];return c?(fb.filterFiles(fb.getFiles(a),b,c),null):(a.jquery&&(a.each(function(){d=d.concat(fb.getFiles(this))}),a=d,d=[]),"string"==typeof b&&(b=fb.getFilesFilter(b)),a.originalEvent?a=db(a.originalEvent):a.srcElement&&(a=db(a)),a.dataTransfer?a=a.dataTransfer:a.target&&(a=a.target),a.files?(d=a.files,E||(d[0].blob=a,d[0].iframe=!0)):!E&&n(a)?fb.trim(a.value)&&(d=[g(a.value)],d[0].blob=a,d[0].iframe=!0):Y(a)&&(d=a),fb.filter(d,function(a){return!b||b.test(a.name)}))},getTotalSize:function(a){for(var b=0,c=a&&a.length;c--;)b+=a[c].size;return b},getInfo:function(a,b){var c={},d=S.concat();fb.isFile(a)?!function e(){var f=d.shift();f?f.test(fb.getMimeType(a))?f(a,function(a,d){a?b(a):(_(c,d),e())}):e():b(!1,c)}():b("not_support_info",c)},addInfoReader:function(a,b){b.test=function(b){return a.test(b)},S.push(b)},filter:function(a,b){for(var c,d=[],e=0,f=a.length;f>e;e++)e in a&&(c=a[e],b.call(c,c,e,a)&&d.push(c));return d},filterFiles:function(a,b,c){if(a.length){var d,e=a.concat(),f=[],g=[];!function h(){e.length?(d=e.shift(),fb.getInfo(d,function(a,c){(b(d,a?!1:c)?f:g).push(d),h()})):c(f,g)}()}else c([],a)},upload:function(a,b,c){function d(){for(var a,b=0,c=t.length;c--;)a=t[c],b+=a.size*(a.loaded/a.total);return b}function e(){var a=g.splice(0,p?1:1e5),b=p?a[0]&&a[0].file:f.files,i=fb.getTotalSize(a),k=!1,v=m(c);if(a.loaded=0,a.size=a.total=i,t.push(a),r&&(b=null,fb.log("[warn] FileAPI.upload() — called without files")),"abort"==f.statusText&&!f.current||!a.length&&!r){if(!o){var w=200==f.status||201==f.status||204==f.status?!1:f.statusText||"error";w?h.reject(w,f,c):h.resolve(f,c),c.complete(w,f,c)}}else{if(r=!1,o++,f.currentFile=b,b&&c.prepare(b,v)===!1)return e(),void 0;v.file=b,l(v,a,function(i){n||c.upload(f,c);var l=new fb.XHR(_({},v,{upload:b?function(){p&&(u.push(b),l.activeFiles=u,c.fileupload(b,l,v))}:s,progress:b?function(e){k||(k=e.loaded==e.total,a.total=e.total,a.loaded=N.min(e.loaded,e.total),(p||q)&&c.fileprogress({type:"progress",total:a.total,loaded:a.loaded},b,l,v),h.notify({type:"progress",total:j,loaded:f.loaded=d()},b,l,v))}:s,complete:function(g){Z(U,function(a){f[a]=l[a]}),b&&(a.total=a.total||a.size,a.loaded=a.total,this.progress(a),k=!0,f.loaded=n=d(),p&&(u.splice($(u,b),1),c.filecomplete(g,l,b,v))),o--,O(function(){e()},0)}}));f.abort=function(a){a||(g.length=0),this.current=a,l.abort()},l.send(i)})}}c=b||"string"==typeof a?_({},c,{url:a,files:[].concat(b)}):a,c=_({jsonp:"callback",prepare:s,beforeupload:s,upload:s,fileupload:s,fileprogress:s,filecomplete:s,progress:s,complete:s,pause:s,serial:!0,parallel:0,postName:"files",chunkSize:fb.chunkSize,imageOriginal:!0,chunkUploadRetry:fb.chunkUploadRetry,uploadRetry:fb.uploadRetry},c),c.serial||(c.chunkSize&&(c.chunkSize=0,fb.log("[warn] FileAPI.upload: `chunkSize > 0` is not supported, if serial == false")),fb.flashEngine&&fb.log("[warn] FileAPI.upload: `serial == false` is not supported in Flash.")),c.parallel>0&&(c.serial=!0,fb.flashEngine&&fb.log("[warn] FileAPI.upload: `parallel > 0` is not supported in Flash.")),c.imageAutoOrientation&&!c.imageTransform&&(c.imageTransform={rotate:"auto"});var f=new fb.XHR(c),g=k(c.files,c.postName),h=fb.defer(),i=this,j=0,n=0,o=0,p=E&&c.serial,q=p&&c.parallel,r=!g.length,t=[],u=f.activeFiles=[];return Z(g,function(a){j+=a.size}),f.files=[],Z(g,function(a){f.files.push(a.file)}),f.total=j,f.loaded=0,f.filesLeft=g.length,c.beforeupload(f,c),h.progress(c.progress),h.done(c.success),h.fail(c.error),O(function(){for(var a=0;a<N.max(q,1);a++)e()},0),f.append=function(a,b){a=fb._getFilesDataArray([].concat(a)),Z(a,function(a){j+=a.size,f.files.push(a.file),b?g.unshift(a):g.push(a)}),f.statusText="",o||e.call(i)},f.remove=function(a){for(var b,c=g.length;c--;)g[c].file==a&&(b=g.splice(c,1),j-=b.size);return b},f.error=h.fail,f.success=h.done,_(f,h)},reset:function(a,b){var c,d;return C?(d=C(a).clone(!0).insertBefore(a).val("")[0],b||C(a).remove()):(c=a.parentNode,d=c.insertBefore(a.cloneNode(!0),a),d.value="",b||c.removeChild(a),Z(R[fb.uid(a)],function(b,c){Z(b,function(b){bb(a,c,b),ab(d,c,b)})})),d},load:function(a,b){var c=new fb.XHR(b=_(b||{},{url:a,type:"GET",cache:!0,responseType:"blob"})),d=c.defer.resolve;return c.defer.resolve=function(a,b){var c=a.response;return c&&y&&c instanceof y?d(c,a,b):a.defer.reject("load_not_supported",a,b)},l(b,[],function(a){c.send(a)}),c},saveAs:function(a,c){var d=fb.defer();if("string"==typeof a)c===b&&(c=a.split("/").pop()),fb.load(a).progress(d.notify).done(function(a){fb.saveAs(a,c).then(d.resolve,d.reject)}).fail(d.reject);else try{q(a,c)?d.resolve():d.reject("saveAs_not_support")}catch(e){fb.log("[err] FileAPI.saveAs: "+e.toString()),d.reject(e)}return d}};fb.addInfoReader(/^image/,function(a,b){if(!a.__dimensions){var c=a.__dimensions=fb.defer();fb.readAsImage(a,function(a){var b=a.target;c.resolve("load"==a.type?!1:"error",{width:b.width,height:b.height}),b.src=fb.EMPTY_PNG,b=null})}a.__dimensions.then(b)}),fb.event.dnd=function(a,b,c){var d,e;c||(c=b,b=s),A?(ab(a,"dragenter dragleave dragover",function(a){for(var c=o(a).types,f=c&&c.length,g=!1;f--;)if(~c[f].indexOf("File")){a[W](),e!==a.type&&(e=a.type,"dragleave"!=e&&b.call(a[V],!0,a),g=!0);break}g&&(P(d),d=O(function(){b.call(a[V],"dragleave"!=e,a)},50))}),ab(a,"drop",function(a){a[W](),e=0,b.call(a[V],!1,a),fb.getDropFiles(a,function(b){c.call(a[V],b,a)})})):fb.log("Drag'n'Drop -- not supported")},fb.event.dnd.off=function(a,b,c){bb(a,"dragenter dragleave dragover",b),bb(a,"drop",c)},C&&!C.fn.dnd&&(C.fn.dnd=function(a,b){return this.each(function(){fb.event.dnd(this,a,b)})},C.fn.offdnd=function(a,b){return this.each(function(){fb.event.dnd.off(this,a,b)})}),a.FileAPI=_(fb,a.FileAPI),fb.log("FileAPI: "+fb.version),fb.log("protocol: "+a.location.protocol),fb.log("doctype: ["+u.name+"] "+u.publicId+" "+u.systemId),Z(t.getElementsByTagName("meta"),function(a){/x-ua-compatible/i.test(a.getAttribute("http-equiv"))&&fb.log("meta.http-equiv: "+a.getAttribute("content"))}),fb.flashUrl||(fb.flashUrl=fb.staticPath+"FileAPI.flash.swf"),fb.flashImageUrl||(fb.flashImageUrl=fb.staticPath+"FileAPI.flash.image.swf"),fb.flashWebcamUrl||(fb.flashWebcamUrl=fb.staticPath+"FileAPI.flash.camera.swf")}(window,void 0),function(a,b,c){"use strict";function d(b){if(b instanceof d){var c=new d(b.file);return a.extend(c.matrix,b.matrix),c}return this instanceof d?(this.file=b,this.size=b.size||100,this.matrix={sx:0,sy:0,sw:0,sh:0,dx:0,dy:0,dw:0,dh:0,resize:0,deg:0,quality:1,filter:0,multipass:a.multiPassResize},void 0):new d(b)}var e=Math.min,f=Math.round,g=function(){return b.createElement("canvas")},h=!1,i={8:270,3:180,6:90};try{h=g().toDataURL("image/png").indexOf("data:image/png")>-1}catch(j){}d.prototype={image:!0,constructor:d,set:function(b){return a.extend(this.matrix,b),this},crop:function(a,b,d,e){return d===c&&(d=a,e=b,a=b=0),this.set({sx:a,sy:b,sw:d,sh:e||d})},resize:function(a,b,c){return/min|max/.test(b)&&(c=b,b=a),this.set({dw:a,dh:b||a,resize:c})},preview:function(a,b){return this.resize(a,b||a,"preview")},rotate:function(a){return this.set({deg:a})},filter:function(a){return this.set({filter:a})},overlay:function(a){return this.set({overlay:a})},clone:function(){return new d(this)},_load:function(b,c){var d=this;/img|video/i.test(b.nodeName)?c.call(d,null,b):a.readAsImage(b,function(a){c.call(d,"load"!=a.type,a.result)})},_apply:function(b,c){var f,h=g(),i=this.getMatrix(b),j=h.getContext("2d"),k=b.videoWidth||b.width,l=b.videoHeight||b.height,m=i.deg,n=i.dw,o=i.dh,p=k,q=l,r=i.filter,s=b,t=i.overlay,u=a.queue(function(){b.src=a.EMPTY_PNG,c(!1,h)}),v=a.renderImageToCanvas;if(m-=360*Math.floor(m/360),b._type=this.file.type,i.multipass)for(;e(p/n,q/o)>2;)p=p/2+.5|0,q=q/2+.5|0,f=g(),f.width=p,f.height=q,s!==b?(v(f,s,0,0,s.width,s.height,0,0,p,q),s=f):(s=f,v(s,b,i.sx,i.sy,i.sw,i.sh,0,0,p,q),i.sx=i.sy=i.sw=i.sh=0);h.width=m%180?o:n,h.height=m%180?n:o,h.type=i.type,h.quality=i.quality,j.rotate(m*Math.PI/180),v(j.canvas,s,i.sx,i.sy,i.sw||s.width,i.sh||s.height,180==m||270==m?-n:0,90==m||180==m?-o:0,n,o),n=h.width,o=h.height,t&&a.each([].concat(t),function(b){u.inc();var c=new window.Image,d=function(){var e=0|b.x,f=0|b.y,g=b.w||c.width,h=b.h||c.height,i=b.rel;e=1==i||4==i||7==i?(n-g+e)/2:2==i||5==i||8==i?n-(g+e):e,f=3==i||4==i||5==i?(o-h+f)/2:i>=6?o-(h+f):f,a.event.off(c,"error load abort",d);try{j.globalAlpha=b.opacity||1,j.drawImage(c,e,f,g,h)}catch(k){}u.next()};a.event.on(c,"error load abort",d),c.src=b.src,c.complete&&d()}),r&&(u.inc(),d.applyFilter(h,r,u.next)),u.check()},getMatrix:function(b){var c=a.extend({},this.matrix),d=c.sw=c.sw||b.videoWidth||b.naturalWidth||b.width,g=c.sh=c.sh||b.videoHeight||b.naturalHeight||b.height,h=c.dw=c.dw||d,i=c.dh=c.dh||g,j=d/g,k=h/i,l=c.resize;if("preview"==l){if(h!=d||i!=g){var m,n;k>=j?(m=d,n=m/k):(n=g,m=n*k),(m!=d||n!=g)&&(c.sx=~~((d-m)/2),c.sy=~~((g-n)/2),d=m,g=n)}}else l&&(d>h||g>i?"min"==l?(h=f(k>j?e(d,h):i*j),i=f(k>j?h/j:e(g,i))):(h=f(j>=k?e(d,h):i*j),i=f(j>=k?h/j:e(g,i))):(h=d,i=g));return c.sw=d,c.sh=g,c.dw=h,c.dh=i,c.multipass=a.multiPassResize,c},_trans:function(b){this._load(this.file,function(c,d){if(c)b(c);else try{this._apply(d,b)}catch(c){a.log("[err] FileAPI.Image.fn._apply:",c),b(c)}})},get:function(b){if(a.support.transform){var c=this,d=c.matrix;"auto"==d.deg?a.getInfo(c.file,function(a,e){d.deg=i[e&&e.exif&&e.exif.Orientation]||0,c._trans(b)}):c._trans(b)}else b("not_support_transform");return this},toData:function(a){return this.get(a)}},d.exifOrientation=i,d.transform=function(b,e,f,g){function h(h,i){var j={},k=a.queue(function(a){g(a,j)});h?k.fail():a.each(e,function(a,e){if(!k.isFail()){var g=new d(i.nodeType?i:b);if("function"==typeof a?a(i,g):a.width?g[a.preview?"preview":"resize"](a.width,a.height,a.strategy):a.maxWidth&&(i.width>a.maxWidth||i.height>a.maxHeight)&&g.resize(a.maxWidth,a.maxHeight,"max"),a.crop){var h=a.crop;g.crop(0|h.x,0|h.y,h.w||h.width,h.h||h.height)}a.rotate===c&&f&&(a.rotate="auto"),g.set({deg:a.rotate,type:a.type||b.type||"image/png",quality:a.quality||1,overlay:a.overlay,filter:a.filter}),k.inc(),g.toData(function(a,b){a?k.fail():(j[e]=b,k.next())})}})}b.width?h(!1,b):a.getInfo(b,h)},a.each(["TOP","CENTER","BOTTOM"],function(b,c){a.each(["LEFT","CENTER","RIGHT"],function(a,e){d[b+"_"+a]=3*c+e,d[a+"_"+b]=3*c+e})}),d.toCanvas=function(a){var c=b.createElement("canvas");return c.width=a.videoWidth||a.width,c.height=a.videoHeight||a.height,c.getContext("2d").drawImage(a,0,0),c},d.fromDataURL=function(b,c,d){var e=a.newImage(b);a.extend(e,c),d(e)},d.applyFilter=function(b,c,e){"function"==typeof c?c(b,e):window.Caman&&window.Caman("IMG"==b.tagName?d.toCanvas(b):b,function(){"string"==typeof c?this[c]():a.each(c,function(a,b){this[b](a)},this),this.render(e)})},a.renderImageToCanvas=function(b,c,d,e,f,g,h,i,j,k){try{return b.getContext("2d").drawImage(c,d,e,f,g,h,i,j,k)}catch(l){throw a.log("renderImageToCanvas failed:",l),l}},a.support.canvas=a.support.transform=h,a.Image=d}(FileAPI,document),function(a){"use strict";a(FileAPI)}(function(a){"use strict";if(window.navigator&&window.navigator.platform&&/iP(hone|od|ad)/.test(window.navigator.platform)){var b=a.renderImageToCanvas;a.detectSubsampling=function(a){var b,c;return a.width*a.height>1048576?(b=document.createElement("canvas"),b.width=b.height=1,c=b.getContext("2d"),c.drawImage(a,-a.width+1,0),0===c.getImageData(0,0,1,1).data[3]):!1},a.detectVerticalSquash=function(a,b){var c,d,e,f,g,h=a.naturalHeight||a.height,i=document.createElement("canvas"),j=i.getContext("2d");for(b&&(h/=2),i.width=1,i.height=h,j.drawImage(a,0,0),c=j.getImageData(0,0,1,h).data,d=0,e=h,f=h;f>d;)g=c[4*(f-1)+3],0===g?e=f:d=f,f=e+d>>1;return f/h||1},a.renderImageToCanvas=function(c,d,e,f,g,h,i,j,k,l){if("image/jpeg"===d._type){var m,n,o,p,q=c.getContext("2d"),r=document.createElement("canvas"),s=1024,t=r.getContext("2d");if(r.width=s,r.height=s,q.save(),m=a.detectSubsampling(d),m&&(e/=2,f/=2,g/=2,h/=2),n=a.detectVerticalSquash(d,m),m||1!==n){for(f*=n,k=Math.ceil(s*k/g),l=Math.ceil(s*l/h/n),j=0,p=0;h>p;){for(i=0,o=0;g>o;)t.clearRect(0,0,s,s),t.drawImage(d,e,f,g,h,-o,-p,g,h),q.drawImage(r,0,0,s,s,i,j,k,l),o+=s,i+=k;p+=s,j+=l}return q.restore(),c}}return b(c,d,e,f,g,h,i,j,k,l)}}}),function(a,b){"use strict";function c(){this.items=[]}function d(b,c,d){var e=b.blob,f=b.file;if(f){if(!e.toDataURL)return a.readAsBinaryString(e,function(a){"load"==a.type&&c(b,a.result)}),void 0;var g={"image/jpeg":".jpe?g","image/png":".png"},h=g[b.type]?b.type:"image/png",i=g[h]||".png",j=e.quality||1;f.match(new RegExp(i+"$","i"))||(f+=i.replace("?","")),b.file=f,b.type=h,!d&&e.toBlob?e.toBlob(function(a){c(b,a)},h,j):c(b,a.toBinaryString(e.toDataURL(h,j)))}else c(b,e)}var e=b.FormData,f=b.document,g=b.unescape,h=b.encodeURIComponent;c.prototype={append:function(a,b,c,d){this.items.push({name:a,blob:b&&b.blob||(void 0==b?"":b),file:b&&(c||b.name),type:b&&(d||b.type)})},each:function(a){for(var b=0,c=this.items.length;c>b;b++)a.call(this,this.items[b])},toData:function(b,c){c._chunked=a.support.chunked&&c.chunkSize>0&&1==a.filter(this.items,function(a){return a.file}).length,a.support.html5?a.formData&&!this.multipart&&e?c._chunked?(a.log("FileAPI.Form.toPlainData"),this.toPlainData(b)):(a.log("FileAPI.Form.toFormData"),this.toFormData(b)):(a.log("FileAPI.Form.toMultipartData"),this.toMultipartData(b)):(a.log("FileAPI.Form.toHtmlData"),this.toHtmlData(b))},_to:function(b,c,d,e){var f=a.queue(function(){c(b)});this.each(function(a){d(a,b,f,e)}),f.check()},toHtmlData:function(b){this._to(f.createDocumentFragment(),b,function(b,c){var d,e=b.blob;b.file?(a.reset(e,!0),e.name=b.name,c.appendChild(e)):(d=f.createElement("input"),d.name=b.name,d.type="hidden",d.value=e,c.appendChild(d))})},toPlainData:function(a){this._to({},a,function(a,b,c){a.file&&(b.type=a.file),a.blob.toBlob?(c.inc(),d(a,function(a,d){b.name=a.name,b.file=d,b.size=d.length,b.type=a.type,c.next()})):a.file?(b.name=a.blob.name,b.file=a.blob,b.size=a.blob.size,b.type=a.type):(b.params||(b.params=[]),b.params.push(h(a.name)+"="+h(a.blob))),b.start=-1,b.end=b.file&&b.file.FileAPIReadPosition||-1,b.retry=0})},toFormData:function(a){this._to(new e,a,function(a,b,c){a.blob&&a.blob.toBlob?(c.inc(),d(a,function(a,d){b.append(a.name,d,a.file),c.next()})):a.file?b.append(a.name,a.blob,a.file):b.append(a.name,a.blob),a.file&&b.append("_"+a.name,a.file)})},toMultipartData:function(b){this._to([],b,function(a,b,c,e){c.inc(),d(a,function(a,d){b.push("--_"+e+'\r\nContent-Disposition: form-data; name="'+a.name+'"'+(a.file?'; filename="'+g(h(a.file))+'"':"")+(a.file?"\r\nContent-Type: "+(a.type||"application/octet-stream"):"")+"\r\n\r\n"+d+"\r\n"),c.next()},!0)},a.expando)}},a.Form=c}(FileAPI,window),function(a,b){"use strict";var c=b.F,d=a.document,e=function(a){var d=b.defer().progress(a.progress);this.uid=b.uid(),this.xhr={abort:c,getResponseHeader:c,getAllResponseHeaders:c},this.defer=d,this.options=b.extend({upload:c,complete:c,withCredentials:b.withCredentials},a),this.done=this.success=d.done,this.fail=this.error=d.fail,this.notify=d.notify,this.progress=d.progress},f={"":1,XML:1,Text:1,Body:1};e.prototype={status:0,statusText:"",constructor:e,getResponseHeader:function(a){return this.xhr.getResponseHeader(a)},getAllResponseHeaders:function(){return this.xhr.getAllResponseHeaders()||{}},end:function(d,e){var f=this,g=f.defer,h=f.options,i=200==d||201==d?!1:e||"unknown";f.end=f.abort=c,f.status=d,e&&(f.statusText=e),b.log("xhr.end:",d,e),i?g.reject(i,f,h):g.resolve(f,h),h.complete(i,f),f.xhr&&f.xhr.node&&setTimeout(function(){var b=f.xhr.node;try{b.parentNode.removeChild(b)}catch(c){}try{delete a[f.uid]}catch(c){}a[f.uid]=f.xhr.node=null},9)},abort:function(){this.end(0,"abort"),this.xhr&&(this.xhr.aborted=!0,this.xhr.abort())},send:function(a){var b=this,c=this.options;a.toData(function(a){c.upload(c,b),b._send.call(b,c,a)},c)},_send:function(c,e){var g,h=this,i=h.uid,j=c.url;if(b.log("XHR._send:",e),c.cache||(j+=(~j.indexOf("?")?"&":"?")+b.uid()),e.nodeName){var k=c.jsonp;j=j.replace(/([a-z]+)=(\?)/i,"$1="+i),c.upload(c,h),g=d.createElement("div"),g.innerHTML='<form target="'+i+'" action="'+j+'" method="POST" enctype="multipart/form-data" style="position: absolute; top: -1000px; overflow: hidden; width: 1px; height: 1px;"><iframe name="'+i+'" src="javascript:false;"></iframe>'+(k&&c.url.indexOf("=?")<0?'<input value="'+i+'" name="'+k+'" type="hidden"/>':"")+"</form>";var l=g.getElementsByTagName("form")[0],m=g.getElementsByTagName("iframe")[0];l.appendChild(e),b.log(l.parentNode.innerHTML),d.body.appendChild(g),h.xhr.node=g;var n=function(a){if(~j.indexOf(a.origin))try{var c=b.parseJSON(a.data);c.id==i&&o(c.status,c.statusText,c.response)}catch(d){o(0,d.message)}},o=a[i]=function(c,d,e){h.readyState=4,h.responseText=e,h.end(c,d),b.event.off(a,"message",n),a[i]=g=m=m.onload=null};h.xhr.abort=function(){try{m.stop?m.stop():m.contentWindow.stop?m.contentWindow.stop():m.contentWindow.document.execCommand("Stop")}catch(a){}o(0,"abort")},b.event.on(a,"message",n),m.onload=function(){try{var a=m.contentWindow,c=a.document,d=a.result||b.parseJSON(c.body.innerHTML);o(d.status,d.statusText,d.response)}catch(e){b.log("[transport.onload]",e)}},h.readyState=2,l.submit(),l=null}else{if(j=j.replace(/([a-z]+)=(\?)&?/i,""),this.xhr&&this.xhr.aborted)return b.log("Error: already aborted"),void 0;if(e.params&&(j+=(j.indexOf("?")<0?"?":"&")+e.params.join("&")),g=h.xhr=b.getXHR(),g.open(c.type||"POST",j,!0),c.responseType&&(g.responseType=c.responseType),c.withCredentials&&(g.withCredentials="true"),c.headers&&c.headers["X-Requested-With"]||g.setRequestHeader("X-Requested-With","XMLHttpRequest"),b.each(c.headers,function(a,b){g.setRequestHeader(b,a)}),c._chunked){g.upload&&g.upload.addEventListener("progress",b.throttle(function(a){e.retry||h.notify({type:a.type,total:e.size,loaded:e.start+a.loaded,totalSize:e.size},h,c)},100),!1),g.onreadystatechange=function(){var a=parseInt(g.getResponseHeader("X-Last-Known-Byte"),10);if(h.status=g.status,h.statusText=g.statusText,h.readyState=g.readyState,4==g.readyState){try{for(var d in f)h["response"+d]=g["response"+d]}catch(i){}if(g.onreadystatechange=null,!g.status||g.status-201>0)if(b.log("Error: "+g.status),(!g.status&&!g.aborted||500==g.status||416==g.status)&&++e.retry<=c.chunkUploadRetry){var j=g.status?0:b.chunkNetworkDownRetryTimeout;c.pause(e.file,c),b.log("X-Last-Known-Byte: "+a),a?e.end=a:(e.end=e.start-1,416==g.status&&(e.end=e.end-c.chunkSize)),setTimeout(function(){h._send(c,e)},j)}else h.end(g.status);else e.retry=0,e.end==e.size-1?h.end(g.status):(b.log("X-Last-Known-Byte: "+a),a&&(e.end=a),e.file.FileAPIReadPosition=e.end,setTimeout(function(){h._send(c,e)},0));g=null}},e.start=e.end+1,e.end=Math.max(Math.min(e.start+c.chunkSize,e.size)-1,e.start);var p=e.file,q=(p.slice||p.mozSlice||p.webkitSlice).call(p,e.start,e.end+1);e.size&&!q.size?setTimeout(function(){h.end(-1)}):(g.setRequestHeader("Content-Range","bytes "+e.start+"-"+e.end+"/"+e.size),g.setRequestHeader("Content-Disposition","attachment; filename="+encodeURIComponent(e.name)),g.setRequestHeader("Content-Type",e.type||"application/octet-stream"),g.send(q)),p=q=null}else if(g.upload&&(g.upload.addEventListener("progress",b.throttle(function(a){h.notify(a,h,c)},100),!1),b.event.on(g,"progress",function(a){h.notify(a,h,c)})),g.onreadystatechange=function(){if(h.status=g.status,h.statusText=g.statusText,h.readyState=g.readyState,4==g.readyState){try{for(var a in f)h["response"+a]=g["response"+a]}catch(d){}if(g.onreadystatechange=null,!g.status||g.status>201)if(b.log("Error: "+g.status),(!g.status&&!g.aborted||500==g.status)&&(c.retry||0)<c.uploadRetry){c.retry=(c.retry||0)+1;var i=b.networkDownRetryTimeout;c.pause(c.file,c),setTimeout(function(){h._send(c,e)},i)}else h.end(g.status);else h.end(g.status);g=null}},b.isArray(e)){g.setRequestHeader("Content-Type","multipart/form-data; boundary=_"+b.expando);var r=e.join("")+"--_"+b.expando+"--";if(g.sendAsBinary)g.sendAsBinary(r);else{var s=Array.prototype.map.call(r,function(a){return 255&a.charCodeAt(0)
-});g.send(new Uint8Array(s).buffer)}}else g.send(e)}}},b.XHR=e}(window,FileAPI),function(a,b){"use strict";function c(a){return a>=0?a+"px":a}function d(a){var b,c=f.createElement("canvas"),d=!1;try{b=c.getContext("2d"),b.drawImage(a,0,0,1,1),d=255!=b.getImageData(0,0,1,1).data[4]}catch(e){}return d}var e=a.URL||a.webkitURL,f=a.document,g=a.navigator,h=g.getUserMedia||g.webkitGetUserMedia||g.mozGetUserMedia||g.msGetUserMedia,i=!!h;b.support.media=i;var j=function(a){this.video=a};j.prototype={isActive:function(){return!!this._active},start:function(a){var b,c,f=this,i=f.video,j=function(d){f._active=!d,clearTimeout(c),clearTimeout(b),a&&a(d,f)};h.call(g,{video:!0},function(a){f.stream=a,i.src=e.createObjectURL(a),b=setInterval(function(){d(i)&&j(null)},1e3),c=setTimeout(function(){j("timeout")},5e3),i.play()},j)},stop:function(){try{this._active=!1,this.video.pause(),this.stream.stop()}catch(a){}},shot:function(){return new k(this.video)}},j.get=function(a){return new j(a.firstChild)},j.publish=function(d,e,g){"function"==typeof e&&(g=e,e={}),e=b.extend({},{width:"100%",height:"100%",start:!0},e),d.jquery&&(d=d[0]);var h=function(a){if(a)g(a);else{var b=j.get(d);e.start?b.start(g):g(null,b)}};if(d.style.width=c(e.width),d.style.height=c(e.height),b.html5&&i){var k=f.createElement("video");k.style.width=c(e.width),k.style.height=c(e.height),a.jQuery?jQuery(d).empty():d.innerHTML="",d.appendChild(k),h()}else j.fallback(d,e,h)},j.fallback=function(a,b,c){c("not_support_camera")};var k=function(a){var c=a.nodeName?b.Image.toCanvas(a):a,d=b.Image(c);return d.type="image/png",d.width=c.width,d.height=c.height,d.size=c.width*c.height*4,d};j.Shot=k,b.Camera=j}(window,FileAPI),function(a,b,c){"use strict";var d=a.document,e=a.location,f=a.navigator,g=c.each;c.support.flash=function(){var b=f.mimeTypes,d=!1;if(f.plugins&&"object"==typeof f.plugins["Shockwave Flash"])d=f.plugins["Shockwave Flash"].description&&!(b&&b["application/x-shockwave-flash"]&&!b["application/x-shockwave-flash"].enabledPlugin);else try{d=!(!a.ActiveXObject||!new ActiveXObject("ShockwaveFlash.ShockwaveFlash"))}catch(g){c.log("Flash -- does not supported.")}return d&&/^file:/i.test(e)&&c.log("[warn] Flash does not work on `file:` protocol."),d}(),c.support.flash&&(0||!c.html5||!c.support.html5||c.cors&&!c.support.cors||c.media&&!c.support.media)&&function(){function h(a){return('<object id="#id#" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+(a.width||"100%")+'" height="'+(a.height||"100%")+'"><param name="movie" value="#src#" /><param name="flashvars" value="#flashvars#" /><param name="swliveconnect" value="true" /><param name="allowscriptaccess" value="always" /><param name="allownetworking" value="all" /><param name="menu" value="false" /><param name="wmode" value="#wmode#" /><embed flashvars="#flashvars#" swliveconnect="true" allownetworking="all" allowscriptaccess="always" name="#id#" src="#src#" width="'+(a.width||"100%")+'" height="'+(a.height||"100%")+'" menu="false" wmode="transparent" type="application/x-shockwave-flash"></embed></object>').replace(/#(\w+)#/gi,function(b,c){return a[c]})}function i(a,b){if(a&&a.style){var c,d;for(c in b){d=b[c],"number"==typeof d&&(d+="px");try{a.style[c]=d}catch(e){}}}}function j(a,b){g(b,function(b,c){var d=a[c];a[c]=function(){return this.parent=d,b.apply(this,arguments)}})}function k(a){return a&&!a.flashId}function l(a){var b=a.wid=c.uid();return v._fn[b]=a,"FileAPI.Flash._fn."+b}function m(a){try{v._fn[a.wid]=null,delete v._fn[a.wid]}catch(b){}}function n(a,b){if(!u.test(a)){if(/^\.\//.test(a)||"/"!=a.charAt(0)){var c=e.pathname;c=c.substr(0,c.lastIndexOf("/")),a=(c+"/"+a).replace("/./","/")}"//"!=a.substr(0,2)&&(a="//"+e.host+a),u.test(a)||(a=e.protocol+a)}return b&&(a+=(/\?/.test(a)?"&":"?")+b),a}function o(a,b,e){function f(){try{var a=v.get(j);a.setImage(b)}catch(d){c.log('[err] FlashAPI.Preview.setImage -- can not set "base64":',d)}}var g,j=c.uid(),k=d.createElement("div"),o=10;for(g in a)k.setAttribute(g,a[g]),k[g]=a[g];i(k,a),a.width="100%",a.height="100%",k.innerHTML=h(c.extend({id:j,src:n(c.flashImageUrl,"r="+c.uid()),wmode:"opaque",flashvars:"scale="+a.scale+"&callback="+l(function p(){return m(p),--o>0&&f(),!0})},a)),e(!1,k),k=null}function p(a){return{id:a.id,name:a.name,matrix:a.matrix,flashId:a.flashId}}function q(b){var c=b.getBoundingClientRect(),e=d.body,f=(b&&b.ownerDocument).documentElement;return{top:c.top+(a.pageYOffset||f.scrollTop)-(f.clientTop||e.clientTop||0),left:c.left+(a.pageXOffset||f.scrollLeft)-(f.clientLeft||e.clientLeft||0),width:c.right-c.left,height:c.bottom-c.top}}var r=c.uid(),s=0,t={},u=/^https?:/i,v={_fn:{},init:function(){var a=d.body&&d.body.firstChild;if(a)do if(1==a.nodeType){c.log("FlashAPI.state: awaiting");var b=d.createElement("div");return b.id="_"+r,i(b,{top:1,right:1,width:5,height:5,position:"absolute",zIndex:1e6+""}),a.parentNode.insertBefore(b,a),v.publish(b,r),void 0}while(a=a.nextSibling);10>s&&setTimeout(v.init,50*++s)},publish:function(a,b,d){d=d||{},a.innerHTML=h({id:b,src:n(c.flashUrl,"r="+c.version),wmode:d.camera?"":"transparent",flashvars:"callback="+(d.onEvent||"FileAPI.Flash.onEvent")+"&flashId="+b+"&storeKey="+f.userAgent.match(/\d/gi).join("")+"_"+c.version+(v.isReady||(c.pingUrl?"&ping="+c.pingUrl:""))+"&timeout="+c.flashAbortTimeout+(d.camera?"&useCamera="+n(c.flashWebcamUrl):"")+"&debug="+(c.debug?"1":"")},d)},ready:function(){c.log("FlashAPI.state: ready"),v.ready=c.F,v.isReady=!0,v.patch(),v.patchCamera&&v.patchCamera(),c.event.on(d,"mouseover",v.mouseover),c.event.on(d,"click",function(a){v.mouseover(a)&&(a.preventDefault?a.preventDefault():a.returnValue=!0)})},getEl:function(){return d.getElementById("_"+r)},getWrapper:function(a){do if(/js-fileapi-wrapper/.test(a.className))return a;while((a=a.parentNode)&&a!==d.body)},mouseover:function(a){var b=c.event.fix(a).target;if(/input/i.test(b.nodeName)&&"file"==b.type){var e=b.getAttribute(r),f=v.getWrapper(b);if(c.multiFlash){if("i"==e||"r"==e)return!1;if("p"!=e){b.setAttribute(r,"i");var g=d.createElement("div");if(!f)return c.log("[err] FlashAPI.mouseover: js-fileapi-wrapper not found"),void 0;i(g,{top:0,left:0,width:b.offsetWidth+100,height:b.offsetHeight+100,zIndex:1e6+"",position:"absolute"}),f.appendChild(g),v.publish(g,c.uid()),b.setAttribute(r,"p")}return!0}if(f){var h=q(f);i(v.getEl(),h),v.curInp=b}}else/object|embed/i.test(b.nodeName)||i(v.getEl(),{top:1,left:1,width:5,height:5})},onEvent:function(a){var b=a.type;if("ready"==b){try{v.getInput(a.flashId).setAttribute(r,"r")}catch(d){}return v.ready(),setTimeout(function(){v.mouseenter(a)},50),!0}"ping"===b?c.log("(flash -> js).ping:",[a.status,a.savedStatus],a.error):"log"===b?c.log("(flash -> js).log:",a.target):b in v&&setTimeout(function(){c.log("FlashAPI.event."+a.type+":",a),v[b](a)},1)},mouseenter:function(a){var b=v.getInput(a.flashId);if(b){v.cmd(a,"multiple",null!=b.getAttribute("multiple"));var d=[],e={};g((b.getAttribute("accept")||"").split(/,\s*/),function(a){c.accept[a]&&g(c.accept[a].split(" "),function(a){e[a]=1})}),g(e,function(a,b){d.push(b)}),v.cmd(a,"accept",d.length?d.join(",")+","+d.join(",").toUpperCase():"*")}},get:function(b){return d[b]||a[b]||d.embeds[b]},getInput:function(a){if(!c.multiFlash)return v.curInp;try{var b=v.getWrapper(v.get(a));if(b)return b.getElementsByTagName("input")[0]}catch(d){c.log('[err] Can not find "input" by flashId:',a,d)}},select:function(a){var e,f=v.getInput(a.flashId),h=c.uid(f),i=a.target.files;g(i,function(a){a.type=c.getMimeType(a)}),t[h]=i,d.createEvent?(e=d.createEvent("Event"),e.files=i,e.initEvent("change",!0,!0),f.dispatchEvent(e)):b?b(f).trigger({type:"change",files:i}):(e=d.createEventObject(),e.files=i,f.fireEvent("onchange",e))},cmd:function(a,b,d,e){try{return c.log("(js -> flash)."+b+":",d),v.get(a.flashId||a).cmd(b,d)}catch(f){c.log("(js -> flash).onError:",f),e||setTimeout(function(){v.cmd(a,b,d,!0)},50)}},patch:function(){c.flashEngine=!0,j(c,{readAsDataURL:function(a,b){k(a)?this.parent.apply(this,arguments):(c.log("FlashAPI.readAsBase64"),v.cmd(a,"readAsBase64",{id:a.id,callback:l(function d(e,f){m(d),c.log("FlashAPI.readAsBase64:",e),b({type:e?"error":"load",error:e,result:"data:"+a.type+";base64,"+f})})}))},readAsText:function(b,d,e){e?c.log("[warn] FlashAPI.readAsText not supported `encoding` param"):e=d,c.readAsDataURL(b,function(b){if("load"==b.type)try{b.result=a.atob(b.result.split(";base64,")[1])}catch(c){b.type="error",b.error=c.toString()}e(b)})},getFiles:function(a,b,d){if(d)return c.filterFiles(c.getFiles(a),b,d),null;var e=c.isArray(a)?a:t[c.uid(a.target||a.srcElement||a)];return e?(b&&(b=c.getFilesFilter(b),e=c.filter(e,function(a){return b.test(a.name)})),e):this.parent.apply(this,arguments)},getInfo:function(a,b){if(k(a))this.parent.apply(this,arguments);else if(a.isShot)b(null,a.info={width:a.width,height:a.height});else{if(!a.__info){var d=a.__info=c.defer();v.cmd(a,"getFileInfo",{id:a.id,callback:l(function e(b,c){m(e),d.resolve(b,a.info=c)})})}a.__info.then(b)}}}),c.support.transform=!0,c.Image&&j(c.Image.prototype,{get:function(a,b){return this.set({scaleMode:b||"noScale"}),this.parent(a)},_load:function(a,b){if(c.log("FlashAPI.Image._load:",a),k(a))this.parent.apply(this,arguments);else{var d=this;c.getInfo(a,function(c){b.call(d,c,a)})}},_apply:function(a,b){if(c.log("FlashAPI.Image._apply:",a),k(a))this.parent.apply(this,arguments);else{var d=this.getMatrix(a.info),e=b;v.cmd(a,"imageTransform",{id:a.id,matrix:d,callback:l(function f(g,h){c.log("FlashAPI.Image._apply.callback:",g),m(f),g?e(g):c.support.html5||c.support.dataURI&&!(h.length>3e4)?(d.filter&&(e=function(a,e){a?b(a):c.Image.applyFilter(e,d.filter,function(){b(a,this.canvas)})}),c.newImage("data:"+a.type+";base64,"+h,e)):o({width:d.deg%180?d.dh:d.dw,height:d.deg%180?d.dw:d.dh,scale:d.scaleMode},h,e)})})}},toData:function(a){var b=this.file,d=b.info,e=this.getMatrix(d);c.log("FlashAPI.Image.toData"),k(b)?this.parent.apply(this,arguments):("auto"==e.deg&&(e.deg=c.Image.exifOrientation[d&&d.exif&&d.exif.Orientation]||0),a.call(this,!b.info,{id:b.id,flashId:b.flashId,name:b.name,type:b.type,matrix:e}))}}),c.Image&&j(c.Image,{fromDataURL:function(a,b,d){!c.support.dataURI||a.length>3e4?o(c.extend({scale:"exactFit"},b),a.replace(/^data:[^,]+,/,""),function(a,b){d(b)}):this.parent(a,b,d)}}),j(c.Form.prototype,{toData:function(a){for(var b=this.items,d=b.length;d--;)if(b[d].file&&k(b[d].blob))return this.parent.apply(this,arguments);c.log("FlashAPI.Form.toData"),a(b)}}),j(c.XHR.prototype,{_send:function(a,b){if(b.nodeName||b.append&&c.support.html5||c.isArray(b)&&"string"==typeof b[0])return this.parent.apply(this,arguments);var d,e,f={},h={},i=this;if(g(b,function(a){a.file?(h[a.name]=a=p(a.blob),e=a.id,d=a.flashId):f[a.name]=a.blob}),e||(d=r),!d)return c.log("[err] FlashAPI._send: flashId -- undefined"),this.parent.apply(this,arguments);c.log("FlashAPI.XHR._send: "+d+" -> "+e),i.xhr={headers:{},abort:function(){v.cmd(d,"abort",{id:e})},getResponseHeader:function(a){return this.headers[a]},getAllResponseHeaders:function(){return this.headers}};var j=c.queue(function(){v.cmd(d,"upload",{url:n(a.url.replace(/([a-z]+)=(\?)&?/i,"")),data:f,files:e?h:null,headers:a.headers||{},callback:l(function b(d){var e=d.type,f=d.result;c.log("FlashAPI.upload."+e),"progress"==e?(d.loaded=Math.min(d.loaded,d.total),d.lengthComputable=!0,a.progress(d)):"complete"==e?(m(b),"string"==typeof f&&(i.responseText=f.replace(/%22/g,'"').replace(/%5c/g,"\\").replace(/%26/g,"&").replace(/%25/g,"%")),i.end(d.status||200)):("abort"==e||"error"==e)&&(i.end(d.status||0,d.message),m(b))})})});g(h,function(a){j.inc(),c.getInfo(a,j.next)}),j.check()}})}};v.wrap=l,v.unwrap=m,c.Flash=v,c.newImage("data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==",function(a,b){c.support.dataURI=!(1!=b.width||1!=b.height),v.init()})}()}(window,window.jQuery,FileAPI),function(a,b,c){"use strict";var d=c.each,e=c.extend,f=[],g=c.Flash,h=g.wrap,i=g.unwrap;c.support.flash&&c.media&&!c.support.media&&(c.extend(g,{patchCamera:function(){c.Camera.fallback=function(a,b,d){var f=c.uid();c.log("FlashAPI.Camera.publish: "+f),g.publish(a,f,e(b,{camera:!0,onEvent:h(function j(a){"camera"===a.type&&(i(j),a.error?(c.log("FlashAPI.Camera.publish.error: "+a.error),d(a.error)):(c.log("FlashAPI.Camera.publish.success: "+f),d(null)))})}))},d(f,function(a){c.Camera.fallback.apply(c.Camera,a)}),f=[],e(c.Camera.prototype,{_id:function(){return this.video.id},start:function(a){var b=this;g.cmd(this._id(),"camera.on",{callback:h(function d(e){i(d),e.error?(c.log("FlashAPI.camera.on.error: "+e.error),a(e.error,b)):(c.log("FlashAPI.camera.on.success: "+b._id()),b._active=!0,a(null,b))})})},stop:function(){this._active=!1,g.cmd(this._id(),"camera.off")},shot:function(){c.log("FlashAPI.Camera.shot:",this._id());var a=g.cmd(this._id(),"shot",{});return a.type="image/png",a.flashId=this._id(),a.isShot=!0,new c.Camera.Shot(a)}})}}),c.Camera.fallback=function(){f.push(arguments)})}(window,window.jQuery,FileAPI),"function"==typeof define&&define.amd&&define("FileAPI",[],function(){return FileAPI});
+!function(a){"use strict";var b=a.HTMLCanvasElement&&a.HTMLCanvasElement.prototype,c=a.Blob&&function(){try{return Boolean(new Blob)}catch(a){return!1}}(),d=c&&a.Uint8Array&&function(){try{return 100===new Blob([new Uint8Array(100)]).size}catch(a){return!1}}(),e=a.BlobBuilder||a.WebKitBlobBuilder||a.MozBlobBuilder||a.MSBlobBuilder,f=(c||e)&&a.atob&&a.ArrayBuffer&&a.Uint8Array&&function(a){var b,f,g,h,i,j;for(b=a.split(",")[0].indexOf("base64")>=0?atob(a.split(",")[1]):decodeURIComponent(a.split(",")[1]),f=new ArrayBuffer(b.length),g=new Uint8Array(f),h=0;h<b.length;h+=1)g[h]=b.charCodeAt(h);return i=a.split(",")[0].split(":")[1].split(";")[0],c?new Blob([d?g:f],{type:i}):(j=new e,j.append(f),j.getBlob(i))};a.HTMLCanvasElement&&!b.toBlob&&(b.mozGetAsFile?b.toBlob=function(a,c,d){a(d&&b.toDataURL&&f?f(this.toDataURL(c,d)):this.mozGetAsFile("blob",c))}:b.toDataURL&&f&&(b.toBlob=function(a,b,c){a(f(this.toDataURL(b,c)))})),a.dataURLtoBlob=f}(window),function(a,b){"use strict";function c(a,b,c,d,e){var f={type:c.type||c,target:a,result:d};_(f,e),b(f)}function d(a){return A&&!!A.prototype["readAs"+a]}function e(a,e,f,g){if(fb.isBlob(a)&&d(f)){var h=new A;ab(h,T,function j(b){var d=b.type;"progress"==d?c(a,e,b,b.target.result,{loaded:b.loaded,total:b.total}):"loadend"==d?(bb(h,T,j),h=null):c(a,e,b,b.target.result)});try{g?h["readAs"+f](a,g):h["readAs"+f](a)}catch(i){c(a,e,"error",b,{error:i.toString()})}}else c(a,e,"error",b,{error:"filreader_not_support_"+f})}function f(a){return a&&(z&&a instanceof z||a.blob||a.image&&a.file||a.flashId)}function g(a){return{name:(a+"").split(/\\|\//g).pop(),type:fb.getMimeType(a)}}function h(a,b){if(!a.type&&a.size%4096===0&&a.size<=102400)if(A)try{var c=new A;cb(c,T,function(a){var d="error"!=a.type;b(d),d&&c.abort()}),c.readAsDataURL(a)}catch(d){b(!1)}else b(null);else b(!0)}function i(a){var b;return a.getAsEntry?b=a.getAsEntry():a.webkitGetAsEntry&&(b=a.webkitGetAsEntry()),b}function j(a,b){if(a)if(a.isFile)a.file(function(c){c.fullPath=a.fullPath,b(!1,[c])},function(a){b("FileError.code: "+a.code)});else if(a.isDirectory){var c=a.createReader(),d=[];c.readEntries(function(a){fb.afor(a,function(a,c){j(c,function(c,e){c?fb.log(c):d=d.concat(e),a?a():b(!1,d)})})},function(a){b("directory_reader: "+a)})}else j(i(a),b);else b("invalid entry")}function k(a,b){var c=[],d={};if(n(a)){var e=fb.getFiles(a);d[a.name||b]=null!==a.getAttribute("multiple")?e:e[0]}else Y(a)?n(a[0])?Z(a,function(a){d[a.name||b]=fb.getFiles(a)}):f(a[0])&&(d[b]=a):f(a)?d[b]=a:d=a;return Z(d,function g(a,b){Y(a)?Z(a,function(a){g(a,b)}):f(a)&&c.push({name:b,file:a,size:a.size,total:a.size,loaded:0})}),c}function l(a,b,c){var d=new fb.Form,e=fb.queue(function(){c(d)}),f=fb.support.transform&&a.imageTransform,g=f&&p(f),h=fb.postNameConcat;Z(b,function(b,c){var i=b.file,j=h(b.name,a.serial||a.chunkSize?null:c),k=i.name,l=i.type;!function m(b){b.image?(e.inc(),b.toData(function(a,b){k=k||(new Date).getTime()+".png",m(b),e.next()})):fb.Image&&f&&(/^image/.test(b.type)||K.test(b.nodeName))?(e.inc(),g&&(f=[].concat(f)),fb.Image.transform(b,f,a.imageAutoOrientation,function(c,i){if(g&&!c)H||fb.flashEngine||(d.multipart=!0),d.append(j,i[0],k,f[0].type||l);else{var m=0;c||Z(i,function(a,b){H||fb.flashEngine||(d.multipart=!0),f[b].postName||(m=1),d.append(f[b].postName||h(j,b),a,k,f[b].type||l)}),(c||a.imageOriginal)&&d.append(h(j,m?"original":null),b,k,l)}e.next()})):k!==fb.expando&&d.append(j,b,k)}(i)}),Z(a.data,function i(a,b){"object"==typeof a?Z(a,function(a,c){i(a,h(b,c))}):d.append(b,a)}),e.check()}function m(a){var b={};return Z(a,function(a,c){a&&"object"==typeof a&&null==a.nodeType&&(a=_({},a)),b[c]=a}),b}function n(a){return L.test(a&&a.tagName)}function o(a){return(a.originalEvent||a||"").dataTransfer||{}}function p(a){var b;for(b in a)if(a.hasOwnProperty(b)&&!(a[b]instanceof Object||"overlay"===b||"filter"===b))return!0;return!1}function q(a,b){var c=!1;if(v.msSaveBlob)c=v.msSaveBlob(a,b);else if(fb.support.download){var d=fb.createURL(a),e=t.body,f=X("a");d&&(f.href=d,f.download=b||a.name,f.style.top="-10000px",f.style.position="absolute",e.appendChild(f),f.click(),e.removeChild(f),c=!0,O(function(){fb.revokeURL(d)},1))}return c}var r=1,s=function(){},t=a.document,u=t.doctype||{},v=a.navigator,w=a.navigator.userAgent,x=a.createObjectURL&&a||a.URL&&URL.revokeObjectURL&&URL||a.webkitURL&&webkitURL,y=a.Blob,z=a.File,A=a.FileReader,B=a.FormData,C=a.jQuery,D=a.XMLHttpRequest,E=!(!(z&&A&&(a.Uint8Array||B||D.prototype.sendAsBinary))||/safari\//i.test(w)&&!/chrome\//i.test(w)&&/windows/i.test(w)),F=E&&"withCredentials"in new D,G=E&&!!y&&!!(y.prototype.webkitSlice||y.prototype.mozSlice||y.prototype.slice),H=a.dataURLtoBlob,I=/img/i,J=/canvas/i,K=/img|canvas/i,L=/input/i,M=/^data:[^,]+,/,N=a.Math,O=a.setTimeout,P=a.clearTimeout,Q=function(b){return b=new a.Number(N.pow(1024,b)),b.from=function(a){return N.round(a*this)},b},R={},S=[],T="abort progress error load loadend",U="status statusText readyState response responseXML responseText responseBody".split(" "),V="currentTarget",W="preventDefault",X=function(a){return t.createElement(a)},Y=function(a){return a&&"length"in a},Z=function(a,b,c){if(a)if(Y(a))for(var d=0,e=a.length;e>d;d++)d in a&&b.call(c,a[d],d,a);else for(var f in a)a.hasOwnProperty(f)&&b.call(c,a[f],f,a)},$=function(a,b){for(var c=-1,d=a&&a.length;d--;)if(a[d]===b){c=d;break}return c},_=function(a){for(var b=arguments,c=1,d=function(b,c){a[c]=b};c<b.length;c++)Z(b[c],d);return a},ab=function(a,b,c){if(a){var d=fb.uid(a);R[d]||(R[d]={});var e=A&&a&&a instanceof A;Z(b.split(/\s+/),function(b){C&&!e?C.event.add(a,b,c):(R[d][b]||(R[d][b]=[]),R[d][b].push(c),a.addEventListener?a.addEventListener(b,c,!1):a.attachEvent?a.attachEvent("on"+b,c):a["on"+b]=c)})}},bb=function(a,b,c){if(a){var d=fb.uid(a),e=R[d]||{},f=A&&a&&a instanceof A;Z(b.split(/\s+/),function(b){if(C&&!f)C.event.remove(a,b,c);else{for(var d=e[b]||[],g=d.length;g--;)if(d[g]===c){d.splice(g,1);break}a.addEventListener?a.removeEventListener(b,c,!1):a.detachEvent?a.detachEvent("on"+b,c):a["on"+b]=null}})}},cb=function(a,b,c){ab(a,b,function d(e){bb(a,b,d),c(e)})},db=function(b){return b.target||(b.target=a.event&&a.event.srcElement||t),3===b.target.nodeType&&(b.target=b.target.parentNode),b},eb=function(a){var b=X("input");return b.setAttribute("type","file"),a in b},fb={version:"2.1.0",cors:!1,html5:!0,media:!1,formData:!0,multiPassResize:!0,debug:!1,pingUrl:!1,multiFlash:!1,flashAbortTimeout:0,withCredentials:!0,staticPath:"./dist/",flashUrl:0,flashImageUrl:0,postNameConcat:function(a,b){return a+(null!=b?"["+b+"]":"")},support:{dnd:F&&"ondrop"in X("div"),cors:F,html5:E,chunked:G,dataURI:!0,accept:eb("accept"),multiple:eb("multiple"),saveAs:!!v.msSaveBlob,download:"download"in X("a")},ext2mime:{jpg:"image/jpeg",tif:"image/tiff",txt:"text/plain"},accept:{"image/*":"art bm bmp dwg dxf cbr cbz fif fpx gif ico iefs jfif jpe jpeg jpg jps jut mcf nap nif pbm pcx pgm pict pm png pnm qif qtif ras rast rf rp svf tga tif tiff xbm xbm xpm xwd","audio/*":"m4a flac aac rm mpa wav wma ogg mp3 mp2 m3u mod amf dmf dsm far gdm imf it m15 med okt s3m stm sfx ult uni xm sid ac3 dts cue aif aiff wpl ape mac mpc mpp shn wv nsf spc gym adplug adx dsp adp ymf ast afc hps xs","video/*":"m4v 3gp nsv ts ty strm rm rmvb m3u ifo mov qt divx xvid bivx vob nrg img iso pva wmv asf asx ogm m2v avi bin dat dvr-ms mpg mpeg mp4 mkv avc vp3 svq3 nuv viv dv fli flv wpl"},uploadRetry:0,networkDownRetryTimeout:5e3,chunkSize:0,chunkUploadRetry:0,chunkNetworkDownRetryTimeout:2e3,KB:Q(1),MB:Q(2),GB:Q(3),TB:Q(4),EMPTY_PNG:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQIW2NkAAIAAAoAAggA9GkAAAAASUVORK5CYII=",expando:"fileapi"+(new Date).getTime(),uid:function(a){return a?a[fb.expando]=a[fb.expando]||fb.uid():(++r,fb.expando+r)},log:function(){fb.debug&&a.console&&console.log&&(console.log.apply?console.log.apply(console,arguments):console.log([].join.call(arguments," ")))},newImage:function(a,b){var c=X("img");return b&&fb.event.one(c,"error load",function(a){b("error"==a.type,c),c=null}),c.src=a,c},getXHR:function(){var b;if(D)b=new D;else if(a.ActiveXObject)try{b=new ActiveXObject("MSXML2.XMLHttp.3.0")}catch(c){b=new ActiveXObject("Microsoft.XMLHTTP")}return b},createURL:function(a){return x?x.createObjectURL(a):null},revokeURL:function(a){return x&&x.revokeObjectURL(a)},isArray:Y,event:{on:ab,off:bb,one:cb,fix:db},throttle:function(b,c){var d,e;return function(){e=arguments,d||(b.apply(a,e),d=O(function(){d=0,b.apply(a,e)},c))}},F:s,parseJSON:function(b){var c;try{c=a.JSON&&JSON.parse?JSON.parse(b):new Function("return ("+b.replace(/([\r\n])/g,"\\$1")+");")()}catch(d){fb.log("[err] FileAPI.parseJSON: "+d)}return c},trim:function(a){return a=String(a),a.trim?a.trim():a.replace(/^\s+|\s+$/g,"")},defer:function(){var a=[],b=[],c=[],d=function(c,d){return d&&(c?a:b).push(d),this},e=function(f,g){var h=f?a:b,i=0,j=h.length;for(d=function(a,b){a===f&&b.apply(this,g)},e=s,a=b=null,c=[];j>i;i++)h[i]&&h[i].apply(this,g)},f={done:function(a){return d(1,a),this},fail:function(a){return d(0,a),this},resolve:function(){return e(1,arguments),this},reject:function(){return e(0,arguments),this},notify:function(){for(var a=0,b=c.length;b>a;a++)c[a].apply(this,arguments)},progress:function(a){return a&&c.push(a),this},then:function(a,b){return this.done(a).fail(b)},always:function(a){return this.then(a,a)},promise:function(){return this}};return f},queue:function(a){var b=0,c=0,d=!1,e=!1,f={inc:function(){c++},next:function(){b++,O(f.check,0)},check:function(){b>=c&&!d&&f.end()},isFail:function(){return d},fail:function(){!d&&a(d=!0)},end:function(){e||(e=!0,a())}};return f},each:Z,indexOf:$,afor:function(a,b){var c=0,d=a.length;Y(a)&&d--?!function e(){b(d!=c&&e,a[c],c++)}():b(!1)},extend:_,isFile:function(a){return E&&a&&(a instanceof z||a instanceof y)},isBlob:function(a){return E&&a&&a instanceof y},isCanvas:function(a){return a&&J.test(a.nodeName)},getFilesFilter:function(a){return a="string"==typeof a?a:a.getAttribute&&a.getAttribute("accept")||"",a?new RegExp("("+a.replace(/\./g,"\\.").replace(/,/g,"|")+")$","i"):/./},readAsDataURL:function(a,b){fb.isCanvas(a)?c(a,b,"load",fb.toDataURL(a)):e(a,b,"DataURL")},readAsBinaryString:function(a,b){d("BinaryString")?e(a,b,"BinaryString"):fb.readAsDataURL(a,function(a){if("load"==a.type)try{a.result=fb.toBinaryString(a.result)}catch(c){a.type="error",a.message=c.toString()}b(a)})},readAsArrayBuffer:function(a,b){e(a,b,"ArrayBuffer")},readAsText:function(a,b,c){c||(c=b,b="utf-8"),e(a,c,"Text",b)},toDataURL:function(a,b){return"string"==typeof a?a:a.toDataURL?a.toDataURL(b||"image/png"):void 0},toBinaryString:function(b){return a.atob(fb.toDataURL(b).replace(M,""))},readAsImage:function(a,b,d){if(fb.isFile(a))if(x){var e=fb.createURL(a);e?fb.readAsImage(e,b,d):c(a,b,"error")}else fb.readAsDataURL(a,function(e){"load"==e.type?fb.readAsImage(e.result,b,d):(d||"error"==e.type)&&c(a,b,e,null,{loaded:e.loaded,total:e.total})});else if(fb.isCanvas(a))c(a,b,"load",a);else if(I.test(a.nodeName))if(a.complete)c(a,b,"load",a);else{var f="error abort load";cb(a,f,function h(d){"load"==d.type&&x&&fb.revokeURL(a.src),bb(a,f,h),c(a,b,d,a)})}else if(a.iframe)c(a,b,{type:"error",message:"is iframe"});else{var g=fb.newImage(a.dataURL||a);fb.readAsImage(g,b,d)}},getMimeType:function(a){var b,c,d=a&&(a.type||String(a.name||a).split(".").pop()),e=fb.accept;if(!/^[^/]+\/[^/]+$/.test(d))for(c in e)if(b=new RegExp(e[c].replace(/\s/g,"|"),"i"),b.test(d)||fb.ext2mime[d]){d=fb.ext2mime[d]||c.split("/")[0]+"/"+d;break}return d},getDropFiles:function(a,b){var c=[],d=o(a),e=Y(d.items)&&d.items[0]&&i(d.items[0]),f=fb.queue(function(){b(c)});Z((e?d.items:d.files)||[],function(a){f.inc();try{e?j(a,function(a,b){a?fb.log("[err] getDropFiles:",a):c.push.apply(c,b),f.next()}):h(a,function(b){b&&c.push(a),f.next()})}catch(b){f.next(),fb.log("[err] getDropFiles: ",b)}}),f.check()},getFiles:function(a,b,c){var d=[];return c?(fb.filterFiles(fb.getFiles(a),b,c),null):(a.jquery&&(a.each(function(){d=d.concat(fb.getFiles(this))}),a=d,d=[]),"string"==typeof b&&(b=fb.getFilesFilter(b)),a.originalEvent?a=db(a.originalEvent):a.srcElement&&(a=db(a)),a.dataTransfer?a=a.dataTransfer:a.target&&(a=a.target),a.files?(d=a.files,E||(d[0].blob=a,d[0].iframe=!0)):!E&&n(a)?fb.trim(a.value)&&(d=[g(a.value)],d[0].blob=a,d[0].iframe=!0):Y(a)&&(d=a),fb.filter(d,function(a){return!b||b.test(a.name)}))},getTotalSize:function(a){for(var b=0,c=a&&a.length;c--;)b+=a[c].size;return b},getInfo:function(a,b){var c={},d=S.concat();fb.isFile(a)?!function e(){var f=d.shift();f?f.test(fb.getMimeType(a))?f(a,function(a,d){a?b(a):(_(c,d),e())}):e():b(!1,c)}():b("not_support_info",c)},addInfoReader:function(a,b){b.test=function(b){return a.test(b)},S.push(b)},filter:function(a,b){for(var c,d=[],e=0,f=a.length;f>e;e++)e in a&&(c=a[e],b.call(c,c,e,a)&&d.push(c));return d},filterFiles:function(a,b,c){if(a.length){var d,e=a.concat(),f=[],g=[];!function h(){e.length?(d=e.shift(),fb.getInfo(d,function(a,c){(b(d,a?!1:c)?f:g).push(d),h()})):c(f,g)}()}else c([],a)},upload:function(a,b,c){function d(){for(var a,b=0,c=t.length;c--;)a=t[c],b+=a.size*(a.loaded/a.total);return b}function e(){var a=g.splice(0,p?1:1e5),b=p?a[0]&&a[0].file:f.files,i=fb.getTotalSize(a),k=!1,v=m(c);if(a.loaded=0,a.size=a.total=i,t.push(a),r&&(b=null,fb.log("[warn] FileAPI.upload() — called without files")),"abort"==f.statusText&&!f.current||!a.length&&!r){if(!o){var w=200==f.status||201==f.status||204==f.status?!1:f.statusText||"error";w?h.reject(w,f,c):h.resolve(f,c),c.complete(w,f,c)}}else{if(r=!1,o++,f.currentFile=b,b&&c.prepare(b,v)===!1)return void e();v.file=b,l(v,a,function(i){n||c.upload(f,c);var l=new fb.XHR(_({},v,{upload:b?function(){p&&(u.push(b),l.activeFiles=u,c.fileupload(b,l,v))}:s,progress:b?function(e){k||(k=e.loaded==e.total,a.total=e.total,a.loaded=N.min(e.loaded,e.total),(p||q)&&c.fileprogress({type:"progress",total:a.total,loaded:a.loaded},b,l,v),h.notify({type:"progress",total:j,loaded:f.loaded=d()},b,l,v))}:s,complete:function(g){Z(U,function(a){f[a]=l[a]}),b&&(a.total=a.total||a.size,a.loaded=a.total,this.progress(a),k=!0,f.loaded=n=d(),p&&(u.splice($(u,b),1),c.filecomplete(g,l,b,v))),o--,O(function(){e()},0)}}));f.abort=function(a){a||(g.length=0),this.current=a,l.abort()},l.send(i)})}}c=b||"string"==typeof a?_({},c,{url:a,files:[].concat(b)}):a,c=_({jsonp:"callback",prepare:s,beforeupload:s,upload:s,fileupload:s,fileprogress:s,filecomplete:s,progress:s,complete:s,pause:s,serial:!0,parallel:0,postName:"files",chunkSize:fb.chunkSize,imageOriginal:!0,chunkUploadRetry:fb.chunkUploadRetry,uploadRetry:fb.uploadRetry},c),c.serial||(c.chunkSize&&(c.chunkSize=0,fb.log("[warn] FileAPI.upload: `chunkSize > 0` is not supported, if serial == false")),fb.flashEngine&&fb.log("[warn] FileAPI.upload: `serial == false` is not supported in Flash.")),c.parallel>0&&(c.serial=!0,fb.flashEngine&&fb.log("[warn] FileAPI.upload: `parallel > 0` is not supported in Flash.")),c.imageAutoOrientation&&!c.imageTransform&&(c.imageTransform={rotate:"auto"});var f=new fb.XHR(c),g=k(c.files,c.postName),h=fb.defer(),i=this,j=0,n=0,o=0,p=E&&c.serial,q=p&&c.parallel,r=!g.length,t=[],u=f.activeFiles=[];return Z(g,function(a){j+=a.size}),f.files=[],Z(g,function(a){f.files.push(a.file)}),f.total=j,f.loaded=0,f.filesLeft=g.length,c.beforeupload(f,c),h.progress(c.progress),h.done(c.success),h.fail(c.error),O(function(){for(var a=0;a<N.max(q,1);a++)e()},0),f.append=function(a,b){a=fb._getFilesDataArray([].concat(a)),Z(a,function(a){j+=a.size,f.files.push(a.file),b?g.unshift(a):g.push(a)}),f.statusText="",o||e.call(i)},f.remove=function(a){for(var b,c=g.length;c--;)g[c].file==a&&(b=g.splice(c,1),j-=b.size);return b},f.error=h.fail,f.success=h.done,_(f,h)},reset:function(a,b){var c,d;return C?(d=C(a).clone(!0).insertBefore(a).val("")[0],b||C(a).remove()):(c=a.parentNode,d=c.insertBefore(a.cloneNode(!0),a),d.value="",b||c.removeChild(a),Z(R[fb.uid(a)],function(b,c){Z(b,function(b){bb(a,c,b),ab(d,c,b)})})),d},load:function(a,b){var c=new fb.XHR(b=_(b||{},{url:a,type:"GET",cache:!0,responseType:"blob"})),d=c.defer.resolve;return c.defer.resolve=function(a,b){var c=a.response;return c&&y&&c instanceof y?d(c,a,b):a.defer.reject("load_not_supported",a,b)},l(b,[],function(a){c.send(a)}),c},saveAs:function(a,c){var d=fb.defer();if("string"==typeof a)c===b&&(c=a.split("/").pop()),fb.load(a).progress(d.notify).done(function(a){fb.saveAs(a,c).then(d.resolve,d.reject)}).fail(d.reject);else try{q(a,c)?d.resolve():d.reject("saveAs_not_support")}catch(e){fb.log("[err] FileAPI.saveAs: "+e.toString()),d.reject(e)}return d}};fb.addInfoReader(/^image/,function(a,b){if(!a.__dimensions){var c=a.__dimensions=fb.defer();fb.readAsImage(a,function(a){var b=a.target;c.resolve("load"==a.type?!1:"error",{width:b.width,height:b.height}),b.src=fb.EMPTY_PNG,b=null})}a.__dimensions.then(b)}),fb.event.dnd=function(a,b,c){var d,e;c||(c=b,b=s),A?(ab(a,"dragenter dragleave dragover",function(a){for(var c=o(a).types,f=c&&c.length,g=!1;f--;)if(~c[f].indexOf("File")){a[W](),e!==a.type&&(e=a.type,"dragleave"!=e&&b.call(a[V],!0,a),g=!0);break}g&&(P(d),d=O(function(){b.call(a[V],"dragleave"!=e,a)},50))}),ab(a,"drop",function(a){a[W](),e=0,b.call(a[V],!1,a),fb.getDropFiles(a,function(b){c.call(a[V],b,a)})})):fb.log("Drag'n'Drop -- not supported")},fb.event.dnd.off=function(a,b,c){bb(a,"dragenter dragleave dragover",b),bb(a,"drop",c)},C&&!C.fn.dnd&&(C.fn.dnd=function(a,b){return this.each(function(){fb.event.dnd(this,a,b)})},C.fn.offdnd=function(a,b){return this.each(function(){fb.event.dnd.off(this,a,b)})}),a.FileAPI=_(fb,a.FileAPI),fb.log("FileAPI: "+fb.version),fb.log("protocol: "+a.location.protocol),fb.log("doctype: ["+u.name+"] "+u.publicId+" "+u.systemId),Z(t.getElementsByTagName("meta"),function(a){/x-ua-compatible/i.test(a.getAttribute("http-equiv"))&&fb.log("meta.http-equiv: "+a.getAttribute("content"))}),fb.flashUrl||(fb.flashUrl=fb.staticPath+"FileAPI.flash.swf"),fb.flashImageUrl||(fb.flashImageUrl=fb.staticPath+"FileAPI.flash.image.swf"),fb.flashWebcamUrl||(fb.flashWebcamUrl=fb.staticPath+"FileAPI.flash.camera.swf")}(window,void 0),function(a,b,c){"use strict";function d(b){if(b instanceof d){var c=new d(b.file);return a.extend(c.matrix,b.matrix),c}return this instanceof d?(this.file=b,this.size=b.size||100,void(this.matrix={sx:0,sy:0,sw:0,sh:0,dx:0,dy:0,dw:0,dh:0,resize:0,deg:0,quality:1,filter:0,multipass:a.multiPassResize})):new d(b)}var e=Math.min,f=Math.round,g=function(){return b.createElement("canvas")},h=!1,i={8:270,3:180,6:90};try{h=g().toDataURL("image/png").indexOf("data:image/png")>-1}catch(j){}d.prototype={image:!0,constructor:d,set:function(b){return a.extend(this.matrix,b),this},crop:function(a,b,d,e){return d===c&&(d=a,e=b,a=b=0),this.set({sx:a,sy:b,sw:d,sh:e||d})},resize:function(a,b,c){return/min|max/.test(b)&&(c=b,b=a),this.set({dw:a,dh:b||a,resize:c})},preview:function(a,b){return this.resize(a,b||a,"preview")},rotate:function(a){return this.set({deg:a})},filter:function(a){return this.set({filter:a})},overlay:function(a){return this.set({overlay:a})},clone:function(){return new d(this)},_load:function(b,c){var d=this;/img|video/i.test(b.nodeName)?c.call(d,null,b):a.readAsImage(b,function(a){c.call(d,"load"!=a.type,a.result)})},_apply:function(b,c){var f,h=g(),i=this.getMatrix(b),j=h.getContext("2d"),k=b.videoWidth||b.width,l=b.videoHeight||b.height,m=i.deg,n=i.dw,o=i.dh,p=k,q=l,r=i.filter,s=b,t=i.overlay,u=a.queue(function(){b.src=a.EMPTY_PNG,c(!1,h)}),v=a.renderImageToCanvas;if(m-=360*Math.floor(m/360),b._type=this.file.type,i.multipass)for(;e(p/n,q/o)>2;)p=p/2+.5|0,q=q/2+.5|0,f=g(),f.width=p,f.height=q,s!==b?(v(f,s,0,0,s.width,s.height,0,0,p,q),s=f):(s=f,v(s,b,i.sx,i.sy,i.sw,i.sh,0,0,p,q),i.sx=i.sy=i.sw=i.sh=0);h.width=m%180?o:n,h.height=m%180?n:o,h.type=i.type,h.quality=i.quality,j.rotate(m*Math.PI/180),v(j.canvas,s,i.sx,i.sy,i.sw||s.width,i.sh||s.height,180==m||270==m?-n:0,90==m||180==m?-o:0,n,o),n=h.width,o=h.height,t&&a.each([].concat(t),function(b){u.inc();var c=new window.Image,d=function(){var e=0|b.x,f=0|b.y,g=b.w||c.width,h=b.h||c.height,i=b.rel;e=1==i||4==i||7==i?(n-g+e)/2:2==i||5==i||8==i?n-(g+e):e,f=3==i||4==i||5==i?(o-h+f)/2:i>=6?o-(h+f):f,a.event.off(c,"error load abort",d);try{j.globalAlpha=b.opacity||1,j.drawImage(c,e,f,g,h)}catch(k){}u.next()};a.event.on(c,"error load abort",d),c.src=b.src,c.complete&&d()}),r&&(u.inc(),d.applyFilter(h,r,u.next)),u.check()},getMatrix:function(b){var c=a.extend({},this.matrix),d=c.sw=c.sw||b.videoWidth||b.naturalWidth||b.width,g=c.sh=c.sh||b.videoHeight||b.naturalHeight||b.height,h=c.dw=c.dw||d,i=c.dh=c.dh||g,j=d/g,k=h/i,l=c.resize;if("preview"==l){if(h!=d||i!=g){var m,n;k>=j?(m=d,n=m/k):(n=g,m=n*k),(m!=d||n!=g)&&(c.sx=~~((d-m)/2),c.sy=~~((g-n)/2),d=m,g=n)}}else l&&(d>h||g>i?"min"==l?(h=f(k>j?e(d,h):i*j),i=f(k>j?h/j:e(g,i))):(h=f(j>=k?e(d,h):i*j),i=f(j>=k?h/j:e(g,i))):(h=d,i=g));return c.sw=d,c.sh=g,c.dw=h,c.dh=i,c.multipass=a.multiPassResize,c},_trans:function(b){this._load(this.file,function(c,d){if(c)b(c);else try{this._apply(d,b)}catch(c){a.log("[err] FileAPI.Image.fn._apply:",c),b(c)}})},get:function(b){if(a.support.transform){var c=this,d=c.matrix;"auto"==d.deg?a.getInfo(c.file,function(a,e){d.deg=i[e&&e.exif&&e.exif.Orientation]||0,c._trans(b)}):c._trans(b)}else b("not_support_transform");return this},toData:function(a){return this.get(a)}},d.exifOrientation=i,d.transform=function(b,e,f,g){function h(h,i){var j={},k=a.queue(function(a){g(a,j)});h?k.fail():a.each(e,function(a,e){if(!k.isFail()){var g=new d(i.nodeType?i:b);if("function"==typeof a?a(i,g):a.width?g[a.preview?"preview":"resize"](a.width,a.height,a.strategy):a.maxWidth&&(i.width>a.maxWidth||i.height>a.maxHeight)&&g.resize(a.maxWidth,a.maxHeight,"max"),a.crop){var h=a.crop;g.crop(0|h.x,0|h.y,h.w||h.width,h.h||h.height)}a.rotate===c&&f&&(a.rotate="auto"),g.set({deg:a.rotate,type:a.type||b.type||"image/png",quality:a.quality||1,overlay:a.overlay,filter:a.filter}),k.inc(),g.toData(function(a,b){a?k.fail():(j[e]=b,k.next())})}})}b.width?h(!1,b):a.getInfo(b,h)},a.each(["TOP","CENTER","BOTTOM"],function(b,c){a.each(["LEFT","CENTER","RIGHT"],function(a,e){d[b+"_"+a]=3*c+e,d[a+"_"+b]=3*c+e})}),d.toCanvas=function(a){var c=b.createElement("canvas");return c.width=a.videoWidth||a.width,c.height=a.videoHeight||a.height,c.getContext("2d").drawImage(a,0,0),c},d.fromDataURL=function(b,c,d){var e=a.newImage(b);a.extend(e,c),d(e)},d.applyFilter=function(b,c,e){"function"==typeof c?c(b,e):window.Caman&&window.Caman("IMG"==b.tagName?d.toCanvas(b):b,function(){"string"==typeof c?this[c]():a.each(c,function(a,b){this[b](a)},this),this.render(e)})},a.renderImageToCanvas=function(b,c,d,e,f,g,h,i,j,k){try{return b.getContext("2d").drawImage(c,d,e,f,g,h,i,j,k)}catch(l){throw a.log("renderImageToCanvas failed:",l),l}},a.support.canvas=a.support.transform=h,a.Image=d}(FileAPI,document),function(a){"use strict";a(FileAPI)}(function(a){"use strict";if(window.navigator&&window.navigator.platform&&/iP(hone|od|ad)/.test(window.navigator.platform)){var b=a.renderImageToCanvas;a.detectSubsampling=function(a){var b,c;return a.width*a.height>1048576?(b=document.createElement("canvas"),b.width=b.height=1,c=b.getContext("2d"),c.drawImage(a,-a.width+1,0),0===c.getImageData(0,0,1,1).data[3]):!1},a.detectVerticalSquash=function(a,b){var c,d,e,f,g,h=a.naturalHeight||a.height,i=document.createElement("canvas"),j=i.getContext("2d");for(b&&(h/=2),i.width=1,i.height=h,j.drawImage(a,0,0),c=j.getImageData(0,0,1,h).data,d=0,e=h,f=h;f>d;)g=c[4*(f-1)+3],0===g?e=f:d=f,f=e+d>>1;return f/h||1},a.renderImageToCanvas=function(c,d,e,f,g,h,i,j,k,l){if("image/jpeg"===d._type){var m,n,o,p,q=c.getContext("2d"),r=document.createElement("canvas"),s=1024,t=r.getContext("2d");if(r.width=s,r.height=s,q.save(),m=a.detectSubsampling(d),m&&(e/=2,f/=2,g/=2,h/=2),n=a.detectVerticalSquash(d,m),m||1!==n){for(f*=n,k=Math.ceil(s*k/g),l=Math.ceil(s*l/h/n),j=0,p=0;h>p;){for(i=0,o=0;g>o;)t.clearRect(0,0,s,s),t.drawImage(d,e,f,g,h,-o,-p,g,h),q.drawImage(r,0,0,s,s,i,j,k,l),o+=s,i+=k;p+=s,j+=l}return q.restore(),c}}return b(c,d,e,f,g,h,i,j,k,l)}}}),function(a,b){"use strict";function c(){this.items=[]}function d(b,c,d){var e=b.blob,f=b.file;if(f){if(!e.toDataURL)return void a.readAsBinaryString(e,function(a){"load"==a.type&&c(b,a.result)});var g={"image/jpeg":".jpe?g","image/png":".png"},h=g[b.type]?b.type:"image/png",i=g[h]||".png",j=e.quality||1;f.match(new RegExp(i+"$","i"))||(f+=i.replace("?","")),b.file=f,b.type=h,!d&&e.toBlob?e.toBlob(function(a){c(b,a)},h,j):c(b,a.toBinaryString(e.toDataURL(h,j)))}else c(b,e)}var e=b.FormData,f=b.document,g=b.unescape,h=b.encodeURIComponent;c.prototype={append:function(a,b,c,d){this.items.push({name:a,blob:b&&b.blob||(void 0==b?"":b),file:b&&(c||b.name),type:b&&(d||b.type)})},each:function(a){for(var b=0,c=this.items.length;c>b;b++)a.call(this,this.items[b])},toData:function(b,c){c._chunked=a.support.chunked&&c.chunkSize>0&&1==a.filter(this.items,function(a){return a.file}).length,a.support.html5?a.formData&&!this.multipart&&e?c._chunked?(a.log("FileAPI.Form.toPlainData"),this.toPlainData(b)):(a.log("FileAPI.Form.toFormData"),this.toFormData(b)):(a.log("FileAPI.Form.toMultipartData"),this.toMultipartData(b)):(a.log("FileAPI.Form.toHtmlData"),this.toHtmlData(b))},_to:function(b,c,d,e){var f=a.queue(function(){c(b)});this.each(function(a){d(a,b,f,e)}),f.check()},toHtmlData:function(b){this._to(f.createDocumentFragment(),b,function(b,c){var d,e=b.blob;b.file?(a.reset(e,!0),e.name=b.name,c.appendChild(e)):(d=f.createElement("input"),d.name=b.name,d.type="hidden",d.value=e,c.appendChild(d))})},toPlainData:function(a){this._to({},a,function(a,b,c){a.file&&(b.type=a.file),a.blob.toBlob?(c.inc(),d(a,function(a,d){b.name=a.name,b.file=d,b.size=d.length,b.type=a.type,c.next()})):a.file?(b.name=a.blob.name,b.file=a.blob,b.size=a.blob.size,b.type=a.type):(b.params||(b.params=[]),b.params.push(h(a.name)+"="+h(a.blob))),b.start=-1,b.end=b.file&&b.file.FileAPIReadPosition||-1,b.retry=0})},toFormData:function(a){this._to(new e,a,function(a,b,c){a.blob&&a.blob.toBlob?(c.inc(),d(a,function(a,d){b.append(a.name,d,a.file),c.next()})):a.file?b.append(a.name,a.blob,a.file):b.append(a.name,a.blob),a.file&&b.append("_"+a.name,a.file)})},toMultipartData:function(b){this._to([],b,function(a,b,c,e){c.inc(),d(a,function(a,d){b.push("--_"+e+'\r\nContent-Disposition: form-data; name="'+a.name+'"'+(a.file?'; filename="'+g(h(a.file))+'"':"")+(a.file?"\r\nContent-Type: "+(a.type||"application/octet-stream"):"")+"\r\n\r\n"+d+"\r\n"),c.next()},!0)},a.expando)}},a.Form=c}(FileAPI,window),function(a,b){"use strict";var c=b.F,d=a.document,e=function(a){var d=b.defer().progress(a.progress);this.uid=b.uid(),this.xhr={abort:c,getResponseHeader:c,getAllResponseHeaders:c},this.defer=d,this.options=b.extend({upload:c,complete:c,withCredentials:b.withCredentials},a),this.done=this.success=d.done,this.fail=this.error=d.fail,this.notify=d.notify,this.progress=d.progress},f={"":1,XML:1,Text:1,Body:1};e.prototype={status:0,statusText:"",constructor:e,getResponseHeader:function(a){return this.xhr.getResponseHeader(a)},getAllResponseHeaders:function(){return this.xhr.getAllResponseHeaders()||{}},end:function(d,e){var f=this,g=f.defer,h=f.options,i=200==d||201==d?!1:e||"unknown";f.end=f.abort=c,f.status=d,e&&(f.statusText=e),b.log("xhr.end:",d,e),i?g.reject(i,f,h):g.resolve(f,h),h.complete(i,f),f.xhr&&f.xhr.node&&setTimeout(function(){var b=f.xhr.node;try{b.parentNode.removeChild(b)}catch(c){}try{delete a[f.uid]}catch(c){}a[f.uid]=f.xhr.node=null},9)},abort:function(){this.end(0,"abort"),this.xhr&&(this.xhr.aborted=!0,this.xhr.abort())},send:function(a){var b=this,c=this.options;a.toData(function(a){c.upload(c,b),b._send.call(b,c,a)},c)},_send:function(c,e){var g,h=this,i=h.uid,j=c.url;if(b.log("XHR._send:",e),c.cache||(j+=(~j.indexOf("?")?"&":"?")+b.uid()),e.nodeName){var k=c.jsonp;j=j.replace(/([a-z]+)=(\?)/i,"$1="+i),c.upload(c,h),g=d.createElement("div"),g.innerHTML='<form target="'+i+'" action="'+j+'" method="POST" enctype="multipart/form-data" style="position: absolute; top: -1000px; overflow: hidden; width: 1px; height: 1px;"><iframe name="'+i+'" src="javascript:false;"></iframe>'+(k&&c.url.indexOf("=?")<0?'<input value="'+i+'" name="'+k+'" type="hidden"/>':"")+"</form>";var l=g.getElementsByTagName("form")[0],m=g.getElementsByTagName("iframe")[0];l.appendChild(e),b.log(l.parentNode.innerHTML),d.body.appendChild(g),h.xhr.node=g;var n=function(a){if(~j.indexOf(a.origin))try{var c=b.parseJSON(a.data);c.id==i&&o(c.status,c.statusText,c.response)}catch(d){o(0,d.message)}},o=a[i]=function(c,d,e){h.readyState=4,h.responseText=e,h.end(c,d),b.event.off(a,"message",n),a[i]=g=m=m.onload=null};h.xhr.abort=function(){try{m.stop?m.stop():m.contentWindow.stop?m.contentWindow.stop():m.contentWindow.document.execCommand("Stop")}catch(a){}o(0,"abort")},b.event.on(a,"message",n),m.onload=function(){try{var a=m.contentWindow,c=a.document,d=a.result||b.parseJSON(c.body.innerHTML);o(d.status,d.statusText,d.response)}catch(e){b.log("[transport.onload]",e)}},h.readyState=2,l.submit(),l=null}else{if(j=j.replace(/([a-z]+)=(\?)&?/i,""),this.xhr&&this.xhr.aborted)return void b.log("Error: already aborted");if(e.params&&(j+=(j.indexOf("?")<0?"?":"&")+e.params.join("&")),g=h.xhr=b.getXHR(),g.open(c.type||"POST",j,!0),c.responseType&&(g.responseType=c.responseType),c.withCredentials&&(g.withCredentials="true"),c.headers&&c.headers["X-Requested-With"]||g.setRequestHeader("X-Requested-With","XMLHttpRequest"),b.each(c.headers,function(a,b){g.setRequestHeader(b,a)}),c._chunked){g.upload&&g.upload.addEventListener("progress",b.throttle(function(a){e.retry||h.notify({type:a.type,total:e.size,loaded:e.start+a.loaded,totalSize:e.size},h,c)},100),!1),g.onreadystatechange=function(){var a=parseInt(g.getResponseHeader("X-Last-Known-Byte"),10);if(h.status=g.status,h.statusText=g.statusText,h.readyState=g.readyState,4==g.readyState){try{for(var d in f)h["response"+d]=g["response"+d]}catch(i){}if(g.onreadystatechange=null,!g.status||g.status-201>0)if(b.log("Error: "+g.status),(!g.status&&!g.aborted||500==g.status||416==g.status)&&++e.retry<=c.chunkUploadRetry){var j=g.status?0:b.chunkNetworkDownRetryTimeout;c.pause(e.file,c),b.log("X-Last-Known-Byte: "+a),a?e.end=a:(e.end=e.start-1,416==g.status&&(e.end=e.end-c.chunkSize)),setTimeout(function(){h._send(c,e)},j)}else h.end(g.status);else e.retry=0,e.end==e.size-1?h.end(g.status):(b.log("X-Last-Known-Byte: "+a),a&&(e.end=a),e.file.FileAPIReadPosition=e.end,setTimeout(function(){h._send(c,e)},0));g=null}},e.start=e.end+1,e.end=Math.max(Math.min(e.start+c.chunkSize,e.size)-1,e.start);var p=e.file,q=(p.slice||p.mozSlice||p.webkitSlice).call(p,e.start,e.end+1);e.size&&!q.size?setTimeout(function(){h.end(-1)}):(g.setRequestHeader("Content-Range","bytes "+e.start+"-"+e.end+"/"+e.size),g.setRequestHeader("Content-Disposition","attachment; filename="+encodeURIComponent(e.name)),g.setRequestHeader("Content-Type",e.type||"application/octet-stream"),g.send(q)),p=q=null}else if(g.upload&&(g.upload.addEventListener("progress",b.throttle(function(a){h.notify(a,h,c)},100),!1),b.event.on(g,"progress",function(a){h.notify(a,h,c)})),g.onreadystatechange=function(){if(h.status=g.status,h.statusText=g.statusText,h.readyState=g.readyState,4==g.readyState){try{for(var a in f)h["response"+a]=g["response"+a]}catch(d){}if(g.onreadystatechange=null,!g.status||g.status>201)if(b.log("Error: "+g.status),(!g.status&&!g.aborted||500==g.status)&&(c.retry||0)<c.uploadRetry){c.retry=(c.retry||0)+1;var i=b.networkDownRetryTimeout;c.pause(c.file,c),setTimeout(function(){h._send(c,e)},i)}else h.end(g.status);else h.end(g.status);g=null}},b.isArray(e)){g.setRequestHeader("Content-Type","multipart/form-data; boundary=_"+b.expando);var r=e.join("")+"--_"+b.expando+"--";if(g.sendAsBinary)g.sendAsBinary(r);else{var s=Array.prototype.map.call(r,function(a){return 255&a.charCodeAt(0)
+});g.send(new Uint8Array(s).buffer)}}else g.send(e)}}},b.XHR=e}(window,FileAPI),function(a,b){"use strict";function c(a){return a>=0?a+"px":a}function d(a){var b,c=f.createElement("canvas"),d=!1;try{b=c.getContext("2d"),b.drawImage(a,0,0,1,1),d=255!=b.getImageData(0,0,1,1).data[4]}catch(e){}return d}var e=a.URL||a.webkitURL,f=a.document,g=a.navigator,h=g.getUserMedia||g.webkitGetUserMedia||g.mozGetUserMedia||g.msGetUserMedia,i=!!h;b.support.media=i;var j=function(a){this.video=a};j.prototype={isActive:function(){return!!this._active},start:function(a){var b,c,f=this,i=f.video,j=function(d){f._active=!d,clearTimeout(c),clearTimeout(b),a&&a(d,f)};h.call(g,{video:!0},function(a){f.stream=a,i.src=e.createObjectURL(a),b=setInterval(function(){d(i)&&j(null)},1e3),c=setTimeout(function(){j("timeout")},5e3),i.play()},j)},stop:function(){try{this._active=!1,this.video.pause(),this.stream.stop()}catch(a){}},shot:function(){return new k(this.video)}},j.get=function(a){return new j(a.firstChild)},j.publish=function(d,e,g){"function"==typeof e&&(g=e,e={}),e=b.extend({},{width:"100%",height:"100%",start:!0},e),d.jquery&&(d=d[0]);var h=function(a){if(a)g(a);else{var b=j.get(d);e.start?b.start(g):g(null,b)}};if(d.style.width=c(e.width),d.style.height=c(e.height),b.html5&&i){var k=f.createElement("video");k.style.width=c(e.width),k.style.height=c(e.height),a.jQuery?jQuery(d).empty():d.innerHTML="",d.appendChild(k),h()}else j.fallback(d,e,h)},j.fallback=function(a,b,c){c("not_support_camera")};var k=function(a){var c=a.nodeName?b.Image.toCanvas(a):a,d=b.Image(c);return d.type="image/png",d.width=c.width,d.height=c.height,d.size=c.width*c.height*4,d};j.Shot=k,b.Camera=j}(window,FileAPI),function(a,b,c){"use strict";var d=a.document,e=a.location,f=a.navigator,g=c.each;c.support.flash=function(){var b=f.mimeTypes,d=!1;if(f.plugins&&"object"==typeof f.plugins["Shockwave Flash"])d=f.plugins["Shockwave Flash"].description&&!(b&&b["application/x-shockwave-flash"]&&!b["application/x-shockwave-flash"].enabledPlugin);else try{d=!(!a.ActiveXObject||!new ActiveXObject("ShockwaveFlash.ShockwaveFlash"))}catch(g){c.log("Flash -- does not supported.")}return d&&/^file:/i.test(e)&&c.log("[warn] Flash does not work on `file:` protocol."),d}(),c.support.flash&&(0||!c.html5||!c.support.html5||c.cors&&!c.support.cors||c.media&&!c.support.media)&&function(){function h(a){return('<object id="#id#" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+(a.width||"100%")+'" height="'+(a.height||"100%")+'"><param name="movie" value="#src#" /><param name="flashvars" value="#flashvars#" /><param name="swliveconnect" value="true" /><param name="allowscriptaccess" value="always" /><param name="allownetworking" value="all" /><param name="menu" value="false" /><param name="wmode" value="#wmode#" /><embed flashvars="#flashvars#" swliveconnect="true" allownetworking="all" allowscriptaccess="always" name="#id#" src="#src#" width="'+(a.width||"100%")+'" height="'+(a.height||"100%")+'" menu="false" wmode="transparent" type="application/x-shockwave-flash"></embed></object>').replace(/#(\w+)#/gi,function(b,c){return a[c]})}function i(a,b){if(a&&a.style){var c,d;for(c in b){d=b[c],"number"==typeof d&&(d+="px");try{a.style[c]=d}catch(e){}}}}function j(a,b){g(b,function(b,c){var d=a[c];a[c]=function(){return this.parent=d,b.apply(this,arguments)}})}function k(a){return a&&!a.flashId}function l(a){var b=a.wid=c.uid();return v._fn[b]=a,"FileAPI.Flash._fn."+b}function m(a){try{v._fn[a.wid]=null,delete v._fn[a.wid]}catch(b){}}function n(a,b){if(!u.test(a)){if(/^\.\//.test(a)||"/"!=a.charAt(0)){var c=e.pathname;c=c.substr(0,c.lastIndexOf("/")),a=(c+"/"+a).replace("/./","/")}"//"!=a.substr(0,2)&&(a="//"+e.host+a),u.test(a)||(a=e.protocol+a)}return b&&(a+=(/\?/.test(a)?"&":"?")+b),a}function o(a,b,e){function f(){try{var a=v.get(j);a.setImage(b)}catch(d){c.log('[err] FlashAPI.Preview.setImage -- can not set "base64":',d)}}var g,j=c.uid(),k=d.createElement("div"),o=10;for(g in a)k.setAttribute(g,a[g]),k[g]=a[g];i(k,a),a.width="100%",a.height="100%",k.innerHTML=h(c.extend({id:j,src:n(c.flashImageUrl,"r="+c.uid()),wmode:"opaque",flashvars:"scale="+a.scale+"&callback="+l(function p(){return m(p),--o>0&&f(),!0})},a)),e(!1,k),k=null}function p(a){return{id:a.id,name:a.name,matrix:a.matrix,flashId:a.flashId}}function q(b){var c=b.getBoundingClientRect(),e=d.body,f=(b&&b.ownerDocument).documentElement;return{top:c.top+(a.pageYOffset||f.scrollTop)-(f.clientTop||e.clientTop||0),left:c.left+(a.pageXOffset||f.scrollLeft)-(f.clientLeft||e.clientLeft||0),width:c.right-c.left,height:c.bottom-c.top}}var r=c.uid(),s=0,t={},u=/^https?:/i,v={_fn:{},init:function(){var a=d.body&&d.body.firstChild;if(a)do if(1==a.nodeType){c.log("FlashAPI.state: awaiting");var b=d.createElement("div");return b.id="_"+r,i(b,{top:1,right:1,width:5,height:5,position:"absolute",zIndex:1e6+""}),a.parentNode.insertBefore(b,a),void v.publish(b,r)}while(a=a.nextSibling);10>s&&setTimeout(v.init,50*++s)},publish:function(a,b,d){d=d||{},a.innerHTML=h({id:b,src:n(c.flashUrl,"r="+c.version),wmode:d.camera?"":"transparent",flashvars:"callback="+(d.onEvent||"FileAPI.Flash.onEvent")+"&flashId="+b+"&storeKey="+f.userAgent.match(/\d/gi).join("")+"_"+c.version+(v.isReady||(c.pingUrl?"&ping="+c.pingUrl:""))+"&timeout="+c.flashAbortTimeout+(d.camera?"&useCamera="+n(c.flashWebcamUrl):"")+"&debug="+(c.debug?"1":"")},d)},ready:function(){c.log("FlashAPI.state: ready"),v.ready=c.F,v.isReady=!0,v.patch(),v.patchCamera&&v.patchCamera(),c.event.on(d,"mouseover",v.mouseover),c.event.on(d,"click",function(a){v.mouseover(a)&&(a.preventDefault?a.preventDefault():a.returnValue=!0)})},getEl:function(){return d.getElementById("_"+r)},getWrapper:function(a){do if(/js-fileapi-wrapper/.test(a.className))return a;while((a=a.parentNode)&&a!==d.body)},mouseover:function(a){var b=c.event.fix(a).target;if(/input/i.test(b.nodeName)&&"file"==b.type){var e=b.getAttribute(r),f=v.getWrapper(b);if(c.multiFlash){if("i"==e||"r"==e)return!1;if("p"!=e){b.setAttribute(r,"i");var g=d.createElement("div");if(!f)return void c.log("[err] FlashAPI.mouseover: js-fileapi-wrapper not found");i(g,{top:0,left:0,width:b.offsetWidth+100,height:b.offsetHeight+100,zIndex:1e6+"",position:"absolute"}),f.appendChild(g),v.publish(g,c.uid()),b.setAttribute(r,"p")}return!0}if(f){var h=q(f);i(v.getEl(),h),v.curInp=b}}else/object|embed/i.test(b.nodeName)||i(v.getEl(),{top:1,left:1,width:5,height:5})},onEvent:function(a){var b=a.type;if("ready"==b){try{v.getInput(a.flashId).setAttribute(r,"r")}catch(d){}return v.ready(),setTimeout(function(){v.mouseenter(a)},50),!0}"ping"===b?c.log("(flash -> js).ping:",[a.status,a.savedStatus],a.error):"log"===b?c.log("(flash -> js).log:",a.target):b in v&&setTimeout(function(){c.log("FlashAPI.event."+a.type+":",a),v[b](a)},1)},mouseenter:function(a){var b=v.getInput(a.flashId);if(b){v.cmd(a,"multiple",null!=b.getAttribute("multiple"));var d=[],e={};g((b.getAttribute("accept")||"").split(/,\s*/),function(a){c.accept[a]&&g(c.accept[a].split(" "),function(a){e[a]=1})}),g(e,function(a,b){d.push(b)}),v.cmd(a,"accept",d.length?d.join(",")+","+d.join(",").toUpperCase():"*")}},get:function(b){return d[b]||a[b]||d.embeds[b]},getInput:function(a){if(!c.multiFlash)return v.curInp;try{var b=v.getWrapper(v.get(a));if(b)return b.getElementsByTagName("input")[0]}catch(d){c.log('[err] Can not find "input" by flashId:',a,d)}},select:function(a){var e,f=v.getInput(a.flashId),h=c.uid(f),i=a.target.files;g(i,function(a){a.type=c.getMimeType(a)}),t[h]=i,d.createEvent?(e=d.createEvent("Event"),e.files=i,e.initEvent("change",!0,!0),f.dispatchEvent(e)):b?b(f).trigger({type:"change",files:i}):(e=d.createEventObject(),e.files=i,f.fireEvent("onchange",e))},cmd:function(a,b,d,e){try{return c.log("(js -> flash)."+b+":",d),v.get(a.flashId||a).cmd(b,d)}catch(f){c.log("(js -> flash).onError:",f),e||setTimeout(function(){v.cmd(a,b,d,!0)},50)}},patch:function(){c.flashEngine=!0,j(c,{readAsDataURL:function(a,b){k(a)?this.parent.apply(this,arguments):(c.log("FlashAPI.readAsBase64"),v.cmd(a,"readAsBase64",{id:a.id,callback:l(function d(e,f){m(d),c.log("FlashAPI.readAsBase64:",e),b({type:e?"error":"load",error:e,result:"data:"+a.type+";base64,"+f})})}))},readAsText:function(b,d,e){e?c.log("[warn] FlashAPI.readAsText not supported `encoding` param"):e=d,c.readAsDataURL(b,function(b){if("load"==b.type)try{b.result=a.atob(b.result.split(";base64,")[1])}catch(c){b.type="error",b.error=c.toString()}e(b)})},getFiles:function(a,b,d){if(d)return c.filterFiles(c.getFiles(a),b,d),null;var e=c.isArray(a)?a:t[c.uid(a.target||a.srcElement||a)];return e?(b&&(b=c.getFilesFilter(b),e=c.filter(e,function(a){return b.test(a.name)})),e):this.parent.apply(this,arguments)},getInfo:function(a,b){if(k(a))this.parent.apply(this,arguments);else if(a.isShot)b(null,a.info={width:a.width,height:a.height});else{if(!a.__info){var d=a.__info=c.defer();v.cmd(a,"getFileInfo",{id:a.id,callback:l(function e(b,c){m(e),d.resolve(b,a.info=c)})})}a.__info.then(b)}}}),c.support.transform=!0,c.Image&&j(c.Image.prototype,{get:function(a,b){return this.set({scaleMode:b||"noScale"}),this.parent(a)},_load:function(a,b){if(c.log("FlashAPI.Image._load:",a),k(a))this.parent.apply(this,arguments);else{var d=this;c.getInfo(a,function(c){b.call(d,c,a)})}},_apply:function(a,b){if(c.log("FlashAPI.Image._apply:",a),k(a))this.parent.apply(this,arguments);else{var d=this.getMatrix(a.info),e=b;v.cmd(a,"imageTransform",{id:a.id,matrix:d,callback:l(function f(g,h){c.log("FlashAPI.Image._apply.callback:",g),m(f),g?e(g):c.support.html5||c.support.dataURI&&!(h.length>3e4)?(d.filter&&(e=function(a,e){a?b(a):c.Image.applyFilter(e,d.filter,function(){b(a,this.canvas)})}),c.newImage("data:"+a.type+";base64,"+h,e)):o({width:d.deg%180?d.dh:d.dw,height:d.deg%180?d.dw:d.dh,scale:d.scaleMode},h,e)})})}},toData:function(a){var b=this.file,d=b.info,e=this.getMatrix(d);c.log("FlashAPI.Image.toData"),k(b)?this.parent.apply(this,arguments):("auto"==e.deg&&(e.deg=c.Image.exifOrientation[d&&d.exif&&d.exif.Orientation]||0),a.call(this,!b.info,{id:b.id,flashId:b.flashId,name:b.name,type:b.type,matrix:e}))}}),c.Image&&j(c.Image,{fromDataURL:function(a,b,d){!c.support.dataURI||a.length>3e4?o(c.extend({scale:"exactFit"},b),a.replace(/^data:[^,]+,/,""),function(a,b){d(b)}):this.parent(a,b,d)}}),j(c.Form.prototype,{toData:function(a){for(var b=this.items,d=b.length;d--;)if(b[d].file&&k(b[d].blob))return this.parent.apply(this,arguments);c.log("FlashAPI.Form.toData"),a(b)}}),j(c.XHR.prototype,{_send:function(a,b){if(b.nodeName||b.append&&c.support.html5||c.isArray(b)&&"string"==typeof b[0])return this.parent.apply(this,arguments);var d,e,f={},h={},i=this;if(g(b,function(a){a.file?(h[a.name]=a=p(a.blob),e=a.id,d=a.flashId):f[a.name]=a.blob}),e||(d=r),!d)return c.log("[err] FlashAPI._send: flashId -- undefined"),this.parent.apply(this,arguments);c.log("FlashAPI.XHR._send: "+d+" -> "+e),i.xhr={headers:{},abort:function(){v.cmd(d,"abort",{id:e})},getResponseHeader:function(a){return this.headers[a]},getAllResponseHeaders:function(){return this.headers}};var j=c.queue(function(){v.cmd(d,"upload",{url:n(a.url.replace(/([a-z]+)=(\?)&?/i,"")),data:f,files:e?h:null,headers:a.headers||{},callback:l(function b(d){var e=d.type,f=d.result;c.log("FlashAPI.upload."+e),"progress"==e?(d.loaded=Math.min(d.loaded,d.total),d.lengthComputable=!0,a.progress(d)):"complete"==e?(m(b),"string"==typeof f&&(i.responseText=f.replace(/%22/g,'"').replace(/%5c/g,"\\").replace(/%26/g,"&").replace(/%25/g,"%")),i.end(d.status||200)):("abort"==e||"error"==e)&&(i.end(d.status||0,d.message),m(b))})})});g(h,function(a){j.inc(),c.getInfo(a,j.next)}),j.check()}})}};v.wrap=l,v.unwrap=m,c.Flash=v,c.newImage("data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==",function(a,b){c.support.dataURI=!(1!=b.width||1!=b.height),v.init()})}()}(window,window.jQuery,FileAPI),function(a,b,c){"use strict";var d=c.each,e=c.extend,f=[],g=c.Flash,h=g.wrap,i=g.unwrap;c.support.flash&&c.media&&!c.support.media&&(c.extend(g,{patchCamera:function(){c.Camera.fallback=function(a,b,d){var f=c.uid();c.log("FlashAPI.Camera.publish: "+f),g.publish(a,f,e(b,{camera:!0,onEvent:h(function j(a){"camera"===a.type&&(i(j),a.error?(c.log("FlashAPI.Camera.publish.error: "+a.error),d(a.error)):(c.log("FlashAPI.Camera.publish.success: "+f),d(null)))})}))},d(f,function(a){c.Camera.fallback.apply(c.Camera,a)}),f=[],e(c.Camera.prototype,{_id:function(){return this.video.id},start:function(a){var b=this;g.cmd(this._id(),"camera.on",{callback:h(function d(e){i(d),e.error?(c.log("FlashAPI.camera.on.error: "+e.error),a(e.error,b)):(c.log("FlashAPI.camera.on.success: "+b._id()),b._active=!0,a(null,b))})})},stop:function(){this._active=!1,g.cmd(this._id(),"camera.off")},shot:function(){c.log("FlashAPI.Camera.shot:",this._id());var a=g.cmd(this._id(),"shot",{});return a.type="image/png",a.flashId=this._id(),a.isShot=!0,new c.Camera.Shot(a)}})}}),c.Camera.fallback=function(){f.push(arguments)})}(window,window.jQuery,FileAPI),"function"==typeof define&&define.amd&&define("FileAPI",[],function(){return FileAPI});
View
6 lib/FileAPI.core.js
@@ -432,7 +432,7 @@
doneList =
failList = null;
-
+
progressList = [];
for( ; i < n; i++ ){
@@ -1517,7 +1517,7 @@
, type: api.getMimeType(name)
};
}
-
+
function _isRegularFile(file, callback){
// http://stackoverflow.com/questions/8856628/detecting-folders-directories-in-javascript-filelist-objects
@@ -1690,7 +1690,7 @@
if( isOrignTrans ){
// Convert to array for transform function
- trans = [trans];
+ trans = [].concat(trans);
}
api.Image.transform(file, trans, options.imageAutoOrientation, function (err, images){
Something went wrong with that request. Please try again.