Permalink
Browse files

+ fix for Flash fallback

  • Loading branch information...
1 parent a0295b6 commit 80adf3b55c39a5fd3306e00dd4033436993dea82 @RubaXa RubaXa committed Nov 6, 2013
Showing with 117 additions and 73 deletions.
  1. +7 −3 dist/FileAPI.html5.js
  2. +1 −1 dist/FileAPI.html5.min.js
  3. +30 −12 dist/FileAPI.js
  4. +2 −2 dist/FileAPI.min.js
  5. +50 −46 examples/webcam.html
  6. +4 −0 lib/FileAPI.Camera.js
  7. +23 −9 lib/FileAPI.Flash.js
View
10 dist/FileAPI.html5.js
@@ -192,6 +192,7 @@
cors: false,
html5: true,
media: false,
+ formData: true,
debug: false,
pingUrl: false,
@@ -2139,7 +2140,7 @@
api.Image = Image;
})(FileAPI, document);
-/*global window, navigator, FileAPI */
+/*global window, FileAPI */
(function (api, window){
"use strict";
@@ -2149,7 +2150,6 @@
, FormData = window.FormData
, Form = function (){ this.items = []; }
, encodeURIComponent = window.encodeURIComponent
- , isPhantomJS = /phantomjs/i.test(navigator.userAgent)// @todo: fixed it
;
@@ -2180,7 +2180,7 @@
api.log('FileAPI.Form.toHtmlData');
this.toHtmlData(fn);
}
- else if( isPhantomJS || this.multipart || !FormData ){
+ else if( !api.formData || this.multipart || !FormData ){
api.log('FileAPI.Form.toMultipartData');
this.toMultipartData(fn);
}
@@ -2833,6 +2833,10 @@
};
+ el.style.width = _px(options.width);
+ el.style.height = _px(options.height);
+
+
if( api.html5 && html5 ){
// Create video element
var video = document.createElement('video');
View
2 dist/FileAPI.html5.min.js
@@ -1,2 +1,2 @@
/*! fileapi 2.0.1 - BSD | git://github.com/mailru/FileAPI.git */
-(function(e,t){"use strict";function n(e,t,n,a,i){var r={type:n.type||n,target:e,result:a};q(r,i),t(r)}function a(e){return b&&!!b.prototype["readAs"+e]}function i(e,i,r,o){if(J.isFile(e)&&a(r)){var s=new b;X(s,H,function l(t){var a=t.type;"progress"==a?n(e,i,t,t.target.result,{loaded:t.loaded,total:t.total}):"loadend"==a?(W(s,H,l),s=null):n(e,i,t,t.target.result)});try{o?s["readAs"+r](e,o):s["readAs"+r](e)}catch(u){n(e,i,"error",t,{error:""+u})}}else n(e,i,"error",t,{error:"filreader_not_support_"+r})}function r(e,t){if(!e.type&&0===e.size%4096&&102400>=e.size)if(b)try{var n=new b;G(n,H,function(e){var a="error"!=e.type;t(a),a&&n.abort()}),n.readAsDataURL(e)}catch(a){t(!1)}else t(null);else t(!0)}function o(e){var t;return e.getAsEntry?t=e.getAsEntry():e.webkitGetAsEntry&&(t=e.webkitGetAsEntry()),t}function s(e,t){if(e)if(e.isFile)e.file(function(n){n.fullPath=e.fullPath,t(!1,[n])},function(e){t("FileError.code: "+e.code)});else if(e.isDirectory){var n=e.createReader(),a=[];n.readEntries(function(e){J.afor(e,function(e,n){s(n,function(n,i){n?J.log(n):a=a.concat(i),e?e():t(!1,a)})})},function(e){t("directory_reader: "+e)})}else s(o(e),t);else t("invalid entry")}function l(e){var t={};return N(e,function(e,n){e&&"object"==typeof e&&void 0===e.nodeType&&(e=q({},e)),t[n]=e}),t}function u(e){return U.test(e&&e.tagName)}function c(e){return(e.originalEvent||e||"").dataTransfer||{}}function f(e){var t;for(t in e)if(e.hasOwnProperty(t)&&!(e[t]instanceof Object||"overlay"===t||"filter"===t))return!0;return!1}var d=1,p=function(){},h=e.document,m=h.doctype||{},g=e.navigator.userAgent,v=e.createObjectURL&&e||e.URL&&URL.revokeObjectURL&&URL||e.webkitURL&&webkitURL,y=e.Blob,w=e.File,b=e.FileReader,x=e.FormData,A=e.XMLHttpRequest,F=e.jQuery,I=!(!(w&&b&&(e.Uint8Array||x||A.prototype.sendAsBinary))||/safari\//i.test(g)&&!/chrome\//i.test(g)&&/windows/i.test(g)),R=I&&"withCredentials"in new A,T=I&&!!y&&!!(y.prototype.webkitSlice||y.prototype.mozSlice||y.prototype.slice),C=e.dataURLtoBlob,_=/img/i,D=/canvas/i,E=/img|canvas/i,U=/input/i,L=/^data:[^,]+,/,B=e.Math,k=function(t){return t=new e.Number(B.pow(1024,t)),t.from=function(e){return B.round(e*this)},t},P={},S=[],H="abort progress error load loadend",j="status statusText readyState response responseXML responseText responseBody".split(" "),z="currentTarget",M="preventDefault",O=function(e){return e&&"length"in e},N=function(e,t,n){if(e)if(O(e))for(var a=0,i=e.length;i>a;a++)a in e&&t.call(n,e[a],a,e);else for(var r in e)e.hasOwnProperty(r)&&t.call(n,e[r],r,e)},q=function(e){for(var t=arguments,n=1,a=function(t,n){e[n]=t};t.length>n;n++)N(t[n],a);return e},X=function(e,t,n){if(e){var a=J.uid(e);P[a]||(P[a]={}),N(t.split(/\s+/),function(t){F?F.event.add(e,t,n):(P[a][t]||(P[a][t]=[]),P[a][t].push(n),e.addEventListener?e.addEventListener(t,n,!1):e.attachEvent?e.attachEvent("on"+t,n):e["on"+t]=n)})}},W=function(e,t,n){if(e){var a=J.uid(e),i=P[a]||{};N(t.split(/\s+/),function(t){if(F)F.event.remove(e,t,n);else{for(var a=i[t]||[],r=a.length;r--;)if(a[r]===n){a.splice(r,1);break}e.addEventListener?e.removeEventListener(t,n,!1):e.detachEvent?e.detachEvent("on"+t,n):e["on"+t]=null}})}},G=function(e,t,n){X(e,t,function a(i){W(e,t,a),n(i)})},K=function(t){return t.target||(t.target=e.event&&e.event.srcElement||h),3===t.target.nodeType&&(t.target=t.target.parentNode),t},Q=function(e){var t=h.createElement("input");return t.setAttribute("type","file"),e in t},J={version:"2.0.1",cors:!1,html5:!0,media:!1,debug:!1,pingUrl:!1,multiFlash:!1,flashAbortTimeout:0,withCredentials:!0,staticPath:"./dist/",flashUrl:0,flashImageUrl:0,postNameConcat:function(e,t){return e+(null!=t?"["+t+"]":"")},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"},chunkSize:0,chunkUploadRetry:0,chunkNetworkDownRetryTimeout:2e3,KB:k(1),MB:k(2),GB:k(3),TB:k(4),expando:"fileapi"+(new Date).getTime(),uid:function(e){return e?e[J.expando]=e[J.expando]||J.uid():(++d,J.expando+d)},log:function(){J.debug&&e.console&&console.log&&(console.log.apply?console.log.apply(console,arguments):console.log([].join.call(arguments," ")))},newImage:function(e,t){var n=h.createElement("img");return t&&J.event.one(n,"error load",function(e){t("error"==e.type,n),n=null}),n.src=e,n},getXHR:function(){var t;if(A)t=new A;else if(e.ActiveXObject)try{t=new ActiveXObject("MSXML2.XMLHttp.3.0")}catch(n){t=new ActiveXObject("Microsoft.XMLHTTP")}return t},isArray:O,support:{dnd:R&&"ondrop"in h.createElement("div"),cors:R,html5:I,chunked:T,dataURI:!0,accept:Q("accept"),multiple:Q("multiple")},event:{on:X,off:W,one:G,fix:K},throttle:function(t,n){var a,i;return function(){i=arguments,a||(t.apply(e,i),a=setTimeout(function(){a=0,t.apply(e,i)},n))}},F:function(){},parseJSON:function(t){var n;return n=e.JSON&&JSON.parse?JSON.parse(t):Function("return ("+t.replace(/([\r\n])/g,"\\$1")+");")()},trim:function(e){return e+="",e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")},defer:function(){var e,n,a=[],i={resolve:function(t,r){for(i.resolve=p,n=t||!1,e=r;r=a.shift();)r(n,e)},then:function(i){n!==t?i(n,e):a.push(i)}};return i},queue:function(e){var t=0,n=0,a=!1,i=!1,r={inc:function(){n++},next:function(){t++,setTimeout(r.check,0)},check:function(){t>=n&&!a&&r.end()},isFail:function(){return a},fail:function(){!a&&e(a=!0)},end:function(){i||(i=!0,e())}};return r},each:N,afor:function(e,t){var n=0,a=e.length;O(e)&&a--?function i(){t(a!=n&&i,e[n],n++)}():t(!1)},extend:q,isFile:function(e){return I&&e&&e instanceof w},isCanvas:function(e){return e&&D.test(e.nodeName)},getFilesFilter:function(e){return e="string"==typeof e?e:e.getAttribute&&e.getAttribute("accept")||"",e?RegExp("("+e.replace(/\./g,"\\.").replace(/,/g,"|")+")$","i"):/./},readAsDataURL:function(e,t){J.isCanvas(e)?n(e,t,"load",J.toDataURL(e)):i(e,t,"DataURL")},readAsBinaryString:function(e,t){a("BinaryString")?i(e,t,"BinaryString"):i(e,function(e){if("load"==e.type)try{e.result=J.toBinaryString(e.result)}catch(n){e.type="error",e.message=""+n}t(e)},"DataURL")},readAsArrayBuffer:function(e,t){i(e,t,"ArrayBuffer")},readAsText:function(e,t,n){n||(n=t,t="utf-8"),i(e,n,"Text",t)},toDataURL:function(e,t){return"string"==typeof e?e:e.toDataURL?e.toDataURL(t||"image/png"):void 0},toBinaryString:function(t){return e.atob(J.toDataURL(t).replace(L,""))},readAsImage:function(e,a,i){if(J.isFile(e))if(v){var r=v.createObjectURL(e);r===t?n(e,a,"error"):J.readAsImage(r,a,i)}else J.readAsDataURL(e,function(t){"load"==t.type?J.readAsImage(t.result,a,i):(i||"error"==t.type)&&n(e,a,t,null,{loaded:t.loaded,total:t.total})});else if(J.isCanvas(e))n(e,a,"load",e);else if(_.test(e.nodeName))if(e.complete)n(e,a,"load",e);else{var o="error abort load";G(e,o,function s(t){"load"==t.type&&v&&v.revokeObjectURL(e.src),W(e,o,s),n(e,a,t,e)})}else if(e.iframe)n(e,a,{type:"error"});else{var l=J.newImage(e.dataURL||e);J.readAsImage(l,a,i)}},checkFileObj:function(e){var t={},n=J.accept;return"object"==typeof e?t=e:t.name=(e+"").split(/\\|\//g).pop(),null==t.type&&(t.type=t.name.split(".").pop()),N(n,function(e,n){e=RegExp(e.replace(/\s/g,"|"),"i"),(e.test(t.type)||J.ext2mime[t.type])&&(t.type=J.ext2mime[t.type]||n.split("/")[0]+"/"+t.type)}),t},getDropFiles:function(e,t){var n=[],a=c(e),i=O(a.items)&&a.items[0]&&o(a.items[0]),l=J.queue(function(){t(n)});N((i?a.items:a.files)||[],function(e){l.inc();try{i?s(e,function(e,t){e?J.log("[err] getDropFiles:",e):n.push.apply(n,t),l.next()}):r(e,function(t){t&&n.push(e),l.next()})}catch(t){l.next(),J.log("[err] getDropFiles: ",t)}}),l.check()},getFiles:function(e,t,n){var a=[];return n?(J.filterFiles(J.getFiles(e),t,n),null):(e.jquery&&(e.each(function(){a=a.concat(J.getFiles(this))}),e=a,a=[]),"string"==typeof t&&(t=J.getFilesFilter(t)),e.originalEvent?e=K(e.originalEvent):e.srcElement&&(e=K(e)),e.dataTransfer?e=e.dataTransfer:e.target&&(e=e.target),e.files?(a=e.files,I||(a[0].blob=e,a[0].iframe=!0)):!I&&u(e)?J.trim(e.value)&&(a=[J.checkFileObj(e.value)],a[0].blob=e,a[0].iframe=!0):O(e)&&(a=e),J.filter(a,function(e){return!t||t.test(e.name)}))},getTotalSize:function(e){for(var t=0,n=e&&e.length;n--;)t+=e[n].size;return t},getInfo:function(e,t){var n={},a=S.concat();J.isFile(e)?function i(){var r=a.shift();r?r.test(e.type)?r(e,function(e,a){e?t(e):(q(n,a),i())}):i():t(!1,n)}():t("not_support_info",n)},addInfoReader:function(e,t){t.test=function(t){return e.test(t)},S.push(t)},filter:function(e,t){for(var n,a=[],i=0,r=e.length;r>i;i++)i in e&&(n=e[i],t.call(n,n,i,e)&&a.push(n));return a},filterFiles:function(e,t,n){if(e.length){var a,i=e.concat(),r=[],o=[];(function s(){i.length?(a=i.shift(),J.getInfo(a,function(e,n){(t(a,e?!1:n)?r:o).push(a),s()})):n(r,o)})()}else n([],e)},upload:function(e){e=q({prepare:J.F,beforeupload:J.F,upload:J.F,fileupload:J.F,fileprogress:J.F,filecomplete:J.F,progress:J.F,complete:J.F,pause:J.F,imageOriginal:!0,chunkSize:J.chunkSize,chunkUpoloadRetry:J.chunkUploadRetry},e),e.imageAutoOrientation&&!e.imageTransform&&(e.imageTransform={rotate:"auto"});var t,n=new J.XHR(e),a=this._getFilesDataArray(e.files),i=this,r=0,o=0,s=!1;return N(a,function(e){r+=e.size}),n.files=[],N(a,function(e){n.files.push(e.file)}),n.total=r,n.loaded=0,n.filesLeft=a.length,e.beforeupload(n,e),t=function(){var u=a.shift(),c=u&&u.file,f=!1,d=l(e);n.filesLeft=a.length,c&&c.name===J.expando&&(c=null,J.log("[warn] FileAPI.upload() — called without files")),("abort"!=n.statusText||n.current)&&u?(s=!1,n.currentFile=c,c&&e.prepare(c,d),i._getFormData(d,u,function(s){o||e.upload(n,e);var l=new J.XHR(q({},d,{upload:c?function(){e.fileupload(c,l,d)}:p,progress:c?function(t){f||(e.fileprogress({type:"progress",total:u.total=t.total,loaded:u.loaded=t.loaded},c,l,d),e.progress({type:"progress",total:r,loaded:n.loaded=0|o+u.size*(t.loaded/t.total)},c,l,d))}:p,complete:function(a){f=!0,N(j,function(e){n[e]=l[e]}),c&&(u.loaded=u.total,this.progress(u),o+=u.size,n.loaded=o,e.filecomplete(a,l,c,d)),t.call(i)}}));n.abort=function(e){e||(a.length=0),this.current=e,l.abort()},l.send(s)})):(e.complete(200==n.status||201==n.status?!1:n.statusText||"error",n,e),s=!0)},setTimeout(t,0),n.append=function(e,o){e=J._getFilesDataArray([].concat(e)),N(e,function(e){r+=e.size,n.files.push(e.file),o?a.unshift(e):a.push(e)}),n.statusText="",s&&t.call(i)},n.remove=function(e){for(var t,n=a.length;n--;)a[n].file==e&&(t=a.splice(n,1),r-=t.size);return t},n},_getFilesDataArray:function(e){var t=[],n={};if(u(e)){var a=J.getFiles(e);n[e.name||"file"]=null!==e.getAttribute("multiple")?a:a[0]}else O(e)&&u(e[0])?N(e,function(e){n[e.name||"file"]=J.getFiles(e)}):n=e;return N(n,function i(e,n){O(e)?N(e,function(e){i(e,n)}):e&&(e.name||e.image)&&t.push({name:n,file:e,size:e.size,total:e.size,loaded:0})}),t.length||t.push({file:{name:J.expando}}),t},_getFormData:function(e,t,n){var a=t.file,i=t.name,r=a.name,o=a.type,s=J.support.transform&&e.imageTransform,l=new J.Form,u=J.queue(function(){n(l)}),c=s&&f(s),d=J.postNameConcat;(function p(t){t.image?(u.inc(),t.toData(function(e,t){r=r||(new Date).getTime()+".png",p(t),u.next()})):J.Image&&s&&(/^image/.test(t.type)||E.test(t.nodeName))?(u.inc(),c&&(s=[s]),J.Image.transform(t,s,e.imageAutoOrientation,function(n,a){if(c&&!n)C||J.flashEngine||(l.multipart=!0),l.append(i,a[0],r,s[0].type||o);else{var f=0;n||N(a,function(e,t){C||J.flashEngine||(l.multipart=!0),s[t].postName||(f=1),l.append(s[t].postName||d(i,t),e,r,s[t].type||o)}),(n||e.imageOriginal)&&l.append(d(i,f?"original":null),t,r,o)}u.next()})):r!==J.expando&&l.append(i,t,r)})(a),N(e.data,function h(e,t){"object"==typeof e?N(e,function(e,n){h(e,d(t,n))}):l.append(t,e)}),u.check()},reset:function(e,t){var n,a;return F?(a=F(e).clone(!0).insertBefore(e).val("")[0],t||F(e).remove()):(n=e.parentNode,a=n.insertBefore(e.cloneNode(!0),e),a.value="",t||n.removeChild(e),N(P[J.uid(e)],function(t,n){N(t,function(t){W(e,n,t),X(a,n,t)})})),a},load:function(e,t){var n=J.getXHR();return n?(n.open("GET",e,!0),n.overrideMimeType&&n.overrideMimeType("text/plain; charset=x-user-defined"),X(n,"progress",function(e){e.lengthComputable&&t({type:e.type,loaded:e.loaded,total:e.total},n)}),n.onreadystatechange=function(){if(4==n.readyState)if(n.onreadystatechange=null,200==n.status){e=e.split("/");var a={name:e[e.length-1],size:n.getResponseHeader("Content-Length"),type:n.getResponseHeader("Content-Type")};a.dataURL="data:"+a.type+";base64,"+J.encode64(n.responseBody||n.responseText),t({type:"load",result:a},n)}else t({type:"error"},n)},n.send(null)):t({type:"error"}),n},encode64:function(e){var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",n="",a=0;for("string"!=typeof e&&(e+="");e.length>a;){var i,r,o=255&e.charCodeAt(a++),s=255&e.charCodeAt(a++),l=255&e.charCodeAt(a++),u=o>>2,c=(3&o)<<4|s>>4;isNaN(s)?i=r=64:(i=(15&s)<<2|l>>6,r=isNaN(l)?64:63&l),n+=t.charAt(u)+t.charAt(c)+t.charAt(i)+t.charAt(r)}return n}};J.addInfoReader(/^image/,function(e,t){if(!e.__dimensions){var n=e.__dimensions=J.defer();J.readAsImage(e,function(e){var t=e.target;n.resolve("load"==e.type?!1:"error",{width:t.width,height:t.height}),t=null})}e.__dimensions.then(t)}),J.event.dnd=function(e,t,n){var a,i;n||(n=t,t=J.F),b?(X(e,"dragenter dragleave dragover",function(e){for(var n=c(e).types,r=n&&n.length,o=!1;r--;)if(~n[r].indexOf("File")){e[M](),i!==e.type&&(i=e.type,"dragleave"!=i&&t.call(e[z],!0,e),o=!0);break}o&&(clearTimeout(a),a=setTimeout(function(){t.call(e[z],"dragleave"!=i,e)},50))}),X(e,"drop",function(e){e[M](),i=0,t.call(e[z],!1,e),J.getDropFiles(e,function(t){n.call(e[z],t,e)})})):J.log("Drag'n'Drop -- not supported")},J.event.dnd.off=function(e,t,n){W(e,"dragenter dragleave dragover",t),W(e,"drop",n)},F&&!F.fn.dnd&&(F.fn.dnd=function(e,t){return this.each(function(){J.event.dnd(this,e,t)})},F.fn.offdnd=function(e,t){return this.each(function(){J.event.dnd.off(this,e,t)})}),e.FileAPI=q(J,e.FileAPI),J.log("FileAPI: "+J.version),J.log("protocol: "+e.location.protocol),J.log("doctype: ["+m.name+"] "+m.publicId+" "+m.systemId),N(h.getElementsByTagName("meta"),function(e){/x-ua-compatible/i.test(e.getAttribute("http-equiv"))&&J.log("meta.http-equiv: "+e.getAttribute("content"))}),J.flashUrl||(J.flashUrl=J.staticPath+"FileAPI.flash.swf"),J.flashImageUrl||(J.flashImageUrl=J.staticPath+"FileAPI.flash.image.swf")})(window,void 0),function(e,t,n){"use strict";function a(t){if(t instanceof a){var n=new a(t.file);return e.extend(n.matrix,t.matrix),n}return this instanceof a?(this.file=t,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},void 0):new a(t)}var i=Math.min,r=Math.round,o=function(){return t.createElement("canvas")},s=!1,l={8:270,3:180,6:90};try{s=o().toDataURL("image/png").indexOf("data:image/png")>-1}catch(u){}a.prototype={image:!0,constructor:a,set:function(t){return e.extend(this.matrix,t),this},crop:function(e,t,a,i){return a===n&&(a=e,i=t,e=t=0),this.set({sx:e,sy:t,sw:a,sh:i||a})},resize:function(e,t,n){return"string"==typeof t&&(n=t,t=e),this.set({dw:e,dh:t,resize:n})},preview:function(e,t){return this.resize(e,t||e,"preview")},rotate:function(e){return this.set({deg:e})},filter:function(e){return this.set({filter:e})},overlay:function(e){return this.set({overlay:e})},clone:function(){return new a(this)},_load:function(t,n){var a=this;/img|video/i.test(t.nodeName)?n.call(a,null,t):e.readAsImage(t,function(e){n.call(a,"load"!=e.type,e.result)})},_apply:function(t,n){var r,s=o(),l=this.getMatrix(t),u=s.getContext("2d"),c=t.videoWidth||t.width,f=t.videoHeight||t.height,d=l.deg,p=l.dw,h=l.dh,m=c,g=f,v=l.filter,y=t,w=l.overlay,b=e.queue(function(){n(!1,s)}),x=e.renderImageToCanvas;for(t._type=this.file.type;i(m/p,g/h)>2;)m=0|m/2+.5,g=0|g/2+.5,r=o(),r.width=m,r.height=g,y!==t?(x(r,y,0,0,y.width,y.height,0,0,m,g),y=r):(y=r,x(y,t,l.sx,l.sy,l.sw,l.sh,0,0,m,g),l.sx=l.sy=l.sw=l.sh=0);s.width=d%180?h:p,s.height=d%180?p:h,s.type=l.type,s.quality=l.quality,u.rotate(d*Math.PI/180),x(s,y,l.sx,l.sy,l.sw||y.width,l.sh||y.height,180==d||270==d?-p:0,90==d||180==d?-h:0,p,h),p=s.width,h=s.height,w&&e.each([].concat(w),function(t){b.inc();var n=new window.Image,a=function(){var i=0|t.x,r=0|t.y,o=t.w||n.width,s=t.h||n.height,l=t.rel;i=1==l||4==l||7==l?(p-o+i)/2:2==l||5==l||8==l?p-(o+i):i,r=3==l||4==l||5==l?(h-s+r)/2:l>=6?h-(s+r):r,e.event.off(n,"error load abort",a);try{u.globalAlpha=t.opacity||1,u.drawImage(n,i,r,o,s)}catch(c){}b.next()};e.event.on(n,"error load abort",a),n.src=t.src,n.complete&&a()}),v&&(b.inc(),a.applyFilter(s,v,b.next)),b.check()},getMatrix:function(t){var n=e.extend({},this.matrix),a=n.sw=n.sw||t.videoWidth||t.naturalWidth||t.width,o=n.sh=n.sh||t.videoHeight||t.naturalHeight||t.height,s=n.dw=n.dw||a,l=n.dh=n.dh||o,u=a/o,c=s/l,f=n.resize;if("preview"==f){if(s!=a||l!=o){var d,p;c>=u?(d=a,p=d/c):(p=o,d=p*c),(d!=a||p!=o)&&(n.sx=~~((a-d)/2),n.sy=~~((o-p)/2),a=d,o=p)}}else f&&(a>s||o>l?"min"==f?(s=r(c>u?i(a,s):l*u),l=r(c>u?s/u:i(o,l))):(s=r(u>=c?i(a,s):l*u),l=r(u>=c?s/u:i(o,l))):(s=a,l=o));return n.sw=a,n.sh=o,n.dw=s,n.dh=l,n},_trans:function(e){this._load(this.file,function(t,n){t?e(t):this._apply(n,e)})},get:function(t){if(e.support.transform){var n=this,a=n.matrix;"auto"==a.deg?e.getInfo(n.file,function(e,i){a.deg=l[i&&i.exif&&i.exif.Orientation]||0,n._trans(t)}):n._trans(t)}else t("not_support_transform")},toData:function(e){this.get(e)}},a.exifOrientation=l,a.transform=function(t,i,r,o){function s(s,l){var u={},c=e.queue(function(e){o(e,u)});s?c.fail():e.each(i,function(e,i){if(!c.isFail()){var o=new a(l.nodeType?l:t);if("function"==typeof e?e(l,o):e.width?o[e.preview?"preview":"resize"](e.width,e.height,e.type):e.maxWidth&&(l.width>e.maxWidth||l.height>e.maxHeight)&&o.resize(e.maxWidth,e.maxHeight,"max"),e.crop){var s=e.crop;o.crop(0|s.x,0|s.y,s.w||s.width,s.h||s.height)}e.rotate===n&&r&&(e.rotate="auto"),o.set({deg:e.rotate,type:e.type||t.type||"image/png",quality:e.quality||1,overlay:e.overlay,filter:e.filter}),c.inc(),o.toData(function(e,t){e?c.fail():(u[i]=t,c.next())})}})}t.width?s(!1,t):e.getInfo(t,s)},e.each(["TOP","CENTER","BOTTOM"],function(t,n){e.each(["LEFT","CENTER","RIGHT"],function(e,i){a[t+"_"+e]=3*n+i,a[e+"_"+t]=3*n+i})}),a.toCanvas=function(e){var n=t.createElement("canvas");return n.width=e.videoWidth||e.width,n.height=e.videoHeight||e.height,n.getContext("2d").drawImage(e,0,0),n},a.fromDataURL=function(t,n,a){var i=e.newImage(t);e.extend(i,n),a(i)},a.applyFilter=function(t,n,i){"function"==typeof n?n(t,i):window.Caman&&window.Caman("IMG"==t.tagName?a.toCanvas(t):t,function(){"string"==typeof n?this[n]():e.each(n,function(e,t){this[t](e)},this),this.render(i)})},e.renderImageToCanvas=function(e,t,n,a,i,r,o,s,l,u){return e.getContext("2d").drawImage(t,n,a,i,r,o,s,l,u),e},e.support.canvas=e.support.transform=s,e.Image=a}(FileAPI,document),function(e,t){"use strict";function n(t,n,a){var i=t.blob,r=t.file;if(r){if(!i.toDataURL)return e.readAsBinaryString(i,function(e){"load"==e.type&&n(t,e.result)}),void 0;var o={"image/jpeg":".jpe?g","image/png":".png"},s=o[t.type]?t.type:"image/png",l=o[s]||".png",u=i.quality||1;r.match(RegExp(l+"$","i"))||(r+=l.replace("?","")),t.file=r,t.type=s,!a&&i.toBlob?i.toBlob(function(e){n(t,e)},s,u):n(t,e.toBinaryString(i.toDataURL(s,u)))}else n(t,i)}var a=t.document,i=t.FormData,r=function(){this.items=[]},o=t.encodeURIComponent,s=/phantomjs/i.test(navigator.userAgent);r.prototype={append:function(e,t,n,a){this.items.push({name:e,blob:t&&t.blob||(void 0==t?"":t),file:t&&(n||t.name),type:t&&(a||t.type)})},each:function(e){for(var t=0,n=this.items.length;n>t;t++)e.call(this,this.items[t])},toData:function(t,n){n._chunked=e.support.chunked&&n.chunkSize>0&&1==e.filter(this.items,function(e){return e.file}).length,e.support.html5?s||this.multipart||!i?(e.log("FileAPI.Form.toMultipartData"),this.toMultipartData(t)):n._chunked?(e.log("FileAPI.Form.toPlainData"),this.toPlainData(t)):(e.log("FileAPI.Form.toFormData"),this.toFormData(t)):(e.log("FileAPI.Form.toHtmlData"),this.toHtmlData(t))},_to:function(t,n,a,i){var r=e.queue(function(){n(t)});this.each(function(e){a(e,t,r,i)}),r.check()},toHtmlData:function(t){this._to(a.createDocumentFragment(),t,function(t,n){var i,r=t.blob;t.file?(e.reset(r,!0),r.name=t.name,n.appendChild(r)):(i=a.createElement("input"),i.name=t.name,i.type="hidden",i.value=r,n.appendChild(i))})},toPlainData:function(e){this._to({},e,function(e,t,a){e.file&&(t.type=e.file),e.blob.toBlob?(a.inc(),n(e,function(e,n){t.name=e.name,t.file=n,t.size=n.length,t.type=e.type,a.next()})):e.file?(t.name=e.blob.name,t.file=e.blob,t.size=e.blob.size,t.type=e.type):(t.params||(t.params=[]),t.params.push(o(e.name)+"="+o(e.blob))),t.start=-1,t.end=t.file&&t.file.FileAPIReadPosition||-1,t.retry=0})},toFormData:function(e){this._to(new i,e,function(e,t,a){e.blob&&e.blob.toBlob?(a.inc(),n(e,function(e,n){t.append(e.name,n,e.file),a.next()})):e.file?t.append(e.name,e.blob,e.file):t.append(e.name,e.blob),e.file&&t.append("_"+e.name,e.file)})},toMultipartData:function(t){this._to([],t,function(e,t,a,i){a.inc(),n(e,function(e,n){t.push("--_"+i+('\r\nContent-Disposition: form-data; name="'+e.name+'"'+(e.file?'; filename="'+o(e.file)+'"':"")+(e.file?"\r\nContent-Type: "+(e.type||"application/octet-stream"):"")+"\r\n"+"\r\n"+(e.file?n:o(n))+"\r\n")),a.next()},!0)},e.expando)}},e.Form=r}(FileAPI,window),function(e,t){"use strict";var n=function(){},a=e.document,i=function(e){this.uid=t.uid(),this.xhr={abort:n,getResponseHeader:n,getAllResponseHeaders:n},this.options=e},r={"":1,XML:1,Text:1,Body:1};i.prototype={status:0,statusText:"",constructor:i,getResponseHeader:function(e){return this.xhr.getResponseHeader(e)},getAllResponseHeaders:function(){return this.xhr.getAllResponseHeaders()||{}},end:function(a,i){var r=this,o=r.options;r.end=r.abort=n,r.status=a,i&&(r.statusText=i),t.log("xhr.end:",a,i),o.complete(200==a||201==a?!1:r.statusText||"unknown",r),r.xhr&&r.xhr.node&&setTimeout(function(){var t=r.xhr.node;try{t.parentNode.removeChild(t)}catch(n){}try{delete e[r.uid]}catch(n){}e[r.uid]=r.xhr.node=null},9)},abort:function(){this.end(0,"abort"),this.xhr&&(this.xhr.aborted=!0,this.xhr.abort())},send:function(e){var t=this,n=this.options;e.toData(function(e){n.upload(n,t),t._send.call(t,n,e)},n)},_send:function(n,i){var o,s=this,l=s.uid,u=n.url;if(t.log("XHR._send:",i),n.cache||(u+=(~u.indexOf("?")?"&":"?")+t.uid()),i.nodeName){n.upload(n,s),o=a.createElement("div"),o.innerHTML='<form target="'+l+'" action="'+u+'" method="POST" enctype="multipart/form-data" style="position: absolute; top: -1000px; overflow: hidden; width: 1px; height: 1px;">'+'<iframe name="'+l+'" src="javascript:false;"></iframe>'+'<input value="'+l+'" name="callback" type="hidden"/>'+"</form>",s.xhr.abort=function(){var e=o.getElementsByTagName("iframe")[0];if(e)try{e.stop?e.stop():e.contentWindow.stop?e.contentWindow.stop():e.contentWindow.document.execCommand("Stop")}catch(t){}o=null};var c=o.getElementsByTagName("form")[0];c.appendChild(i),t.log(c.parentNode.innerHTML),a.body.appendChild(o),s.xhr.node=o,e[l]=function(e,t,n){s.readyState=4,s.responseText=n,s.end(e,t),o=null},s.readyState=2,c.submit(),c=null}else{if(this.xhr&&this.xhr.aborted)return t.log("Error: already aborted"),void 0;if(o=s.xhr=t.getXHR(),i.params&&(u+=(0>u.indexOf("?")?"?":"&")+i.params.join("&")),o.open("POST",u,!0),t.withCredentials&&(o.withCredentials="true"),n.headers&&n.headers["X-Requested-With"]||o.setRequestHeader("X-Requested-With","XMLHttpRequest"),t.each(n.headers,function(e,t){o.setRequestHeader(t,e)}),n._chunked){o.upload&&o.upload.addEventListener("progress",function(e){i.retry||n.progress({type:e.type,total:i.size,loaded:i.start+e.loaded,totalSize:i.size},s,n)},!1),o.onreadystatechange=function(){var e=parseInt(o.getResponseHeader("X-Last-Known-Byte"),10);if(s.status=o.status,s.statusText=o.statusText,s.readyState=o.readyState,4==o.readyState){for(var a in r)s["response"+a]=o["response"+a];if(o.onreadystatechange=null,!o.status||o.status-201>0)if(t.log("Error: "+o.status),(!o.status&&!o.aborted||500==o.status||416==o.status)&&++i.retry<=n.chunkUploadRetry){var l=o.status?0:t.chunkNetworkDownRetryTimeout;n.pause(i.file,n),t.log("X-Last-Known-Byte: "+e),i.end=e?e:i.start-1,setTimeout(function(){s._send(n,i)},l)}else s.end(o.status);else i.retry=0,i.end==i.size-1?s.end(o.status):(t.log("X-Last-Known-Byte: "+e),e&&(i.end=e),i.file.FileAPIReadPosition=i.end,setTimeout(function(){s._send(n,i)},0));o=null}},i.start=i.end+1,i.end=Math.max(Math.min(i.start+n.chunkSize,i.size)-1,i.start);var f;(f="slice")in i.file||(f="mozSlice")in i.file||(f="webkitSlice")in i.file,o.setRequestHeader("Content-Range","bytes "+i.start+"-"+i.end+"/"+i.size),o.setRequestHeader("Content-Disposition","attachment; filename="+encodeURIComponent(i.name)),o.setRequestHeader("Content-Type",i.type||"application/octet-stream"),f=i.file[f](i.start,i.end+1),o.send(f),f=null}else if(o.upload&&o.upload.addEventListener("progress",t.throttle(function(e){n.progress(e,s,n)},100),!1),o.onreadystatechange=function(){if(s.status=o.status,s.statusText=o.statusText,s.readyState=o.readyState,4==o.readyState){for(var e in r)s["response"+e]=o["response"+e];o.onreadystatechange=null,s.end(o.status),o=null}},t.isArray(i))if(o.setRequestHeader("Content-Type","multipart/form-data; boundary=_"+t.expando),i=i.join("")+"--_"+t.expando+"--",o.sendAsBinary)o.sendAsBinary(i);else{var d=Array.prototype.map.call(i,function(e){return 255&e.charCodeAt(0)});o.send(new Uint8Array(d).buffer)}else o.send(i)}}},t.XHR=i}(window,FileAPI),function(e,t){"use strict";function n(e){return e>=0?e+"px":e}function a(e){var t,n=r.createElement("canvas"),a=!1;try{t=n.getContext("2d"),t.drawImage(e,0,0,1,1),a=255!=t.getImageData(0,0,1,1).data[4]}catch(i){}return a}var i=e.URL||e.webkitURL,r=e.document,o=e.navigator,s=o.getUserMedia||o.webkitGetUserMedia||o.mozGetUserMedia||o.msGetUserMedia,l=!!s;t.support.media=l;var u=function(e){this.video=e};u.prototype={isActive:function(){return!!this._active},start:function(e){var t,n,r=this,l=r.video,u=function(a){r._active=!a,clearTimeout(n),clearTimeout(t),e&&e(a,r)};s.call(o,{video:!0},function(e){r.stream=e,l.src=i.createObjectURL(e),t=setInterval(function(){a(l)&&u(null)},1e3),n=setTimeout(function(){u("timeout")},5e3),l.play()},u)},stop:function(){try{this._active=!1,this.video.pause(),this.stream.stop()}catch(e){}},shot:function(){return new c(this.video)}},u.get=function(e){return new u(e.firstChild)},u.publish=function(a,i,o){"function"==typeof i&&(o=i,i={}),i=t.extend({},{width:"100%",height:"100%",start:!0},i),a.jquery&&(a=a[0]);var s=function(e){if(e)o(e);else{var t=u.get(a);i.start?t.start(o):o(null,t)}};if(t.html5&&l){var c=r.createElement("video");c.style.width=n(i.width),c.style.height=n(i.height),e.jQuery?jQuery(a).empty():a.innerHTML="",a.appendChild(c),s()}else u.fallback(a,i,s)},u.fallback=function(e,t,n){n("not_support_camera")};var c=function(e){var n=e.nodeName?t.Image.toCanvas(e):e,a=t.Image(n);return a.type="image/png",a.width=n.width,a.height=n.height,a.size=4*n.width*n.height,a};u.Shot=c,t.Camera=u}(window,FileAPI),function(e){"use strict";e(FileAPI)}(function(e){"use strict";if(window.navigator&&window.navigator.platform&&/iP(hone|od|ad)/.test(window.navigator.platform)){var t=e.renderImageToCanvas;e.detectSubsampling=function(e){var t,n;return e.width*e.height>1048576?(t=document.createElement("canvas"),t.width=t.height=1,n=t.getContext("2d"),n.drawImage(e,-e.width+1,0),0===n.getImageData(0,0,1,1).data[3]):!1},e.detectVerticalSquash=function(e,t){var n,a,i,r,o,s=e.naturalHeight||e.height,l=document.createElement("canvas"),u=l.getContext("2d");for(t&&(s/=2),l.width=1,l.height=s,u.drawImage(e,0,0),n=u.getImageData(0,0,1,s).data,a=0,i=s,r=s;r>a;)o=n[4*(r-1)+3],0===o?i=r:a=r,r=i+a>>1;return r/s||1},e.renderImageToCanvas=function(n,a,i,r,o,s,l,u,c,f){if("image/jpeg"===a._type){var d,p,h,m,g=n.getContext("2d"),v=document.createElement("canvas"),y=1024,w=v.getContext("2d");if(v.width=y,v.height=y,g.save(),d=e.detectSubsampling(a),d&&(i/=2,r/=2,o/=2,s/=2),p=e.detectVerticalSquash(a,d),d||1!==p){for(r*=p,c=Math.ceil(y*c/o),f=Math.ceil(y*f/s/p),u=0,m=0;s>m;){for(l=0,h=0;o>h;)w.clearRect(0,0,y,y),w.drawImage(a,i,r,o,s,-h,-m,o,s),g.drawImage(v,0,0,y,y,l,u,c,f),h+=y,l+=c;m+=y,u+=f}return g.restore(),n}}return t(n,a,i,r,o,s,l,u,c,f)}}}),function(e){"use strict";var t=e.HTMLCanvasElement&&e.HTMLCanvasElement.prototype,n=e.Blob&&function(){try{return Boolean(new Blob)}catch(e){return!1}}(),a=n&&e.Uint8Array&&function(){try{return 100===new Blob([new Uint8Array(100)]).size}catch(e){return!1}}(),i=e.BlobBuilder||e.WebKitBlobBuilder||e.MozBlobBuilder||e.MSBlobBuilder,r=(n||i)&&e.atob&&e.ArrayBuffer&&e.Uint8Array&&function(e){var t,r,o,s,l,u;for(t=e.split(",")[0].indexOf("base64")>=0?atob(e.split(",")[1]):decodeURIComponent(e.split(",")[1]),r=new ArrayBuffer(t.length),o=new Uint8Array(r),s=0;t.length>s;s+=1)o[s]=t.charCodeAt(s);return l=e.split(",")[0].split(":")[1].split(";")[0],n?new Blob([a?o:r],{type:l}):(u=new i,u.append(r),u.getBlob(l))};e.HTMLCanvasElement&&!t.toBlob&&(t.mozGetAsFile?t.toBlob=function(e,n,a){a&&t.toDataURL&&r?e(r(this.toDataURL(n,a))):e(this.mozGetAsFile("blob",n))}:t.toDataURL&&r&&(t.toBlob=function(e,t,n){e(r(this.toDataURL(t,n)))})),e.dataURLtoBlob=r}(window),"function"==typeof define&&define.amd&&define("FileAPI",[],function(){return FileAPI});
+!function(a,b){"use strict";function c(a,b,c,d,e){var f={type:c.type||c,target:a,result:d};R(f,e),b(f)}function d(a){return u&&!!u.prototype["readAs"+a]}function e(a,e,f,g){if(X.isFile(a)&&d(f)){var h=new u;S(h,L,function j(b){var d=b.type;"progress"==d?c(a,e,b,b.target.result,{loaded:b.loaded,total:b.total}):"loadend"==d?(T(h,L,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,b){if(!a.type&&0===a.size%4096&&a.size<=102400)if(u)try{var c=new u;U(c,L,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 g(a){var b;return a.getAsEntry?b=a.getAsEntry():a.webkitGetAsEntry&&(b=a.webkitGetAsEntry()),b}function h(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){X.afor(a,function(a,c){h(c,function(c,e){c?X.log(c):d=d.concat(e),a?a():b(!1,d)})})},function(a){b("directory_reader: "+a)})}else h(g(a),b);else b("invalid entry")}function i(a){var b={};return Q(a,function(a,c){a&&"object"==typeof a&&void 0===a.nodeType&&(a=R({},a)),b[c]=a}),b}function j(a){return F.test(a&&a.tagName)}function k(a){return(a.originalEvent||a||"").dataTransfer||{}}function l(a){var b;for(b in a)if(a.hasOwnProperty(b)&&!(a[b]instanceof Object||"overlay"===b||"filter"===b))return!0;return!1}var m=1,n=function(){},o=a.document,p=o.doctype||{},q=a.navigator.userAgent,r=a.createObjectURL&&a||a.URL&&URL.revokeObjectURL&&URL||a.webkitURL&&webkitURL,s=a.Blob,t=a.File,u=a.FileReader,v=a.FormData,w=a.XMLHttpRequest,x=a.jQuery,y=!(!(t&&u&&(a.Uint8Array||v||w.prototype.sendAsBinary))||/safari\//i.test(q)&&!/chrome\//i.test(q)&&/windows/i.test(q)),z=y&&"withCredentials"in new w,A=y&&!!s&&!!(s.prototype.webkitSlice||s.prototype.mozSlice||s.prototype.slice),B=a.dataURLtoBlob,C=/img/i,D=/canvas/i,E=/img|canvas/i,F=/input/i,G=/^data:[^,]+,/,H=a.Math,I=function(b){return b=new a.Number(H.pow(1024,b)),b.from=function(a){return H.round(a*this)},b},J={},K=[],L="abort progress error load loadend",M="status statusText readyState response responseXML responseText responseBody".split(" "),N="currentTarget",O="preventDefault",P=function(a){return a&&"length"in a},Q=function(a,b,c){if(a)if(P(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)},R=function(a){for(var b=arguments,c=1,d=function(b,c){a[c]=b};c<b.length;c++)Q(b[c],d);return a},S=function(a,b,c){if(a){var d=X.uid(a);J[d]||(J[d]={}),Q(b.split(/\s+/),function(b){x?x.event.add(a,b,c):(J[d][b]||(J[d][b]=[]),J[d][b].push(c),a.addEventListener?a.addEventListener(b,c,!1):a.attachEvent?a.attachEvent("on"+b,c):a["on"+b]=c)})}},T=function(a,b,c){if(a){var d=X.uid(a),e=J[d]||{};Q(b.split(/\s+/),function(b){if(x)x.event.remove(a,b,c);else{for(var d=e[b]||[],f=d.length;f--;)if(d[f]===c){d.splice(f,1);break}a.addEventListener?a.removeEventListener(b,c,!1):a.detachEvent?a.detachEvent("on"+b,c):a["on"+b]=null}})}},U=function(a,b,c){S(a,b,function d(e){T(a,b,d),c(e)})},V=function(b){return b.target||(b.target=a.event&&a.event.srcElement||o),3===b.target.nodeType&&(b.target=b.target.parentNode),b},W=function(a){var b=o.createElement("input");return b.setAttribute("type","file"),a in b},X={version:"2.0.1",cors:!1,html5:!0,media:!1,formData:!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+"]":"")},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"},chunkSize:0,chunkUploadRetry:0,chunkNetworkDownRetryTimeout:2e3,KB:I(1),MB:I(2),GB:I(3),TB:I(4),expando:"fileapi"+(new Date).getTime(),uid:function(a){return a?a[X.expando]=a[X.expando]||X.uid():(++m,X.expando+m)},log:function(){X.debug&&a.console&&console.log&&(console.log.apply?console.log.apply(console,arguments):console.log([].join.call(arguments," ")))},newImage:function(a,b){var c=o.createElement("img");return b&&X.event.one(c,"error load",function(a){b("error"==a.type,c),c=null}),c.src=a,c},getXHR:function(){var b;if(w)b=new w;else if(a.ActiveXObject)try{b=new ActiveXObject("MSXML2.XMLHttp.3.0")}catch(c){b=new ActiveXObject("Microsoft.XMLHTTP")}return b},isArray:P,support:{dnd:z&&"ondrop"in o.createElement("div"),cors:z,html5:y,chunked:A,dataURI:!0,accept:W("accept"),multiple:W("multiple")},event:{on:S,off:T,one:U,fix:V},throttle:function(b,c){var d,e;return function(){e=arguments,d||(b.apply(a,e),d=setTimeout(function(){d=0,b.apply(a,e)},c))}},F:function(){},parseJSON:function(b){var c;return c=a.JSON&&JSON.parse?JSON.parse(b):new Function("return ("+b.replace(/([\r\n])/g,"\\$1")+");")()},trim:function(a){return a=String(a),a.trim?a.trim():a.replace(/^\s+|\s+$/g,"")},defer:function(){var a,c,d=[],e={resolve:function(b,f){for(e.resolve=n,c=b||!1,a=f;f=d.shift();)f(c,a)},then:function(e){c!==b?e(c,a):d.push(e)}};return e},queue:function(a){var b=0,c=0,d=!1,e=!1,f={inc:function(){c++},next:function(){b++,setTimeout(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:Q,afor:function(a,b){var c=0,d=a.length;P(a)&&d--?!function e(){b(d!=c&&e,a[c],c++)}():b(!1)},extend:R,isFile:function(a){return y&&a&&a instanceof t},isCanvas:function(a){return a&&D.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){X.isCanvas(a)?c(a,b,"load",X.toDataURL(a)):e(a,b,"DataURL")},readAsBinaryString:function(a,b){d("BinaryString")?e(a,b,"BinaryString"):e(a,function(a){if("load"==a.type)try{a.result=X.toBinaryString(a.result)}catch(c){a.type="error",a.message=c.toString()}b(a)},"DataURL")},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(X.toDataURL(b).replace(G,""))},readAsImage:function(a,d,e){if(X.isFile(a))if(r){var f=r.createObjectURL(a);f===b?c(a,d,"error"):X.readAsImage(f,d,e)}else X.readAsDataURL(a,function(b){"load"==b.type?X.readAsImage(b.result,d,e):(e||"error"==b.type)&&c(a,d,b,null,{loaded:b.loaded,total:b.total})});else if(X.isCanvas(a))c(a,d,"load",a);else if(C.test(a.nodeName))if(a.complete)c(a,d,"load",a);else{var g="error abort load";U(a,g,function i(b){"load"==b.type&&r&&r.revokeObjectURL(a.src),T(a,g,i),c(a,d,b,a)})}else if(a.iframe)c(a,d,{type:"error"});else{var h=X.newImage(a.dataURL||a);X.readAsImage(h,d,e)}},checkFileObj:function(a){var b={},c=X.accept;return"object"==typeof a?b=a:b.name=(a+"").split(/\\|\//g).pop(),null==b.type&&(b.type=b.name.split(".").pop()),Q(c,function(a,c){a=new RegExp(a.replace(/\s/g,"|"),"i"),(a.test(b.type)||X.ext2mime[b.type])&&(b.type=X.ext2mime[b.type]||c.split("/")[0]+"/"+b.type)}),b},getDropFiles:function(a,b){var c=[],d=k(a),e=P(d.items)&&d.items[0]&&g(d.items[0]),i=X.queue(function(){b(c)});Q((e?d.items:d.files)||[],function(a){i.inc();try{e?h(a,function(a,b){a?X.log("[err] getDropFiles:",a):c.push.apply(c,b),i.next()}):f(a,function(b){b&&c.push(a),i.next()})}catch(b){i.next(),X.log("[err] getDropFiles: ",b)}}),i.check()},getFiles:function(a,b,c){var d=[];return c?(X.filterFiles(X.getFiles(a),b,c),null):(a.jquery&&(a.each(function(){d=d.concat(X.getFiles(this))}),a=d,d=[]),"string"==typeof b&&(b=X.getFilesFilter(b)),a.originalEvent?a=V(a.originalEvent):a.srcElement&&(a=V(a)),a.dataTransfer?a=a.dataTransfer:a.target&&(a=a.target),a.files?(d=a.files,y||(d[0].blob=a,d[0].iframe=!0)):!y&&j(a)?X.trim(a.value)&&(d=[X.checkFileObj(a.value)],d[0].blob=a,d[0].iframe=!0):P(a)&&(d=a),X.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=K.concat();X.isFile(a)?!function e(){var f=d.shift();f?f.test(a.type)?f(a,function(a,d){a?b(a):(R(c,d),e())}):e():b(!1,c)}():b("not_support_info",c)},addInfoReader:function(a,b){b.test=function(b){return a.test(b)},K.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(),X.getInfo(d,function(a,c){(b(d,a?!1:c)?f:g).push(d),h()})):c(f,g)}()}else c([],a)},upload:function(a){a=R({prepare:X.F,beforeupload:X.F,upload:X.F,fileupload:X.F,fileprogress:X.F,filecomplete:X.F,progress:X.F,complete:X.F,pause:X.F,imageOriginal:!0,chunkSize:X.chunkSize,chunkUpoloadRetry:X.chunkUploadRetry},a),a.imageAutoOrientation&&!a.imageTransform&&(a.imageTransform={rotate:"auto"});var b,c=new X.XHR(a),d=this._getFilesDataArray(a.files),e=this,f=0,g=0,h=!1;return Q(d,function(a){f+=a.size}),c.files=[],Q(d,function(a){c.files.push(a.file)}),c.total=f,c.loaded=0,c.filesLeft=d.length,a.beforeupload(c,a),b=function(){var j=d.shift(),k=j&&j.file,l=!1,m=i(a);c.filesLeft=d.length,k&&k.name===X.expando&&(k=null,X.log("[warn] FileAPI.upload() — called without files")),("abort"!=c.statusText||c.current)&&j?(h=!1,c.currentFile=k,k&&a.prepare(k,m),e._getFormData(m,j,function(h){g||a.upload(c,a);var i=new X.XHR(R({},m,{upload:k?function(){a.fileupload(k,i,m)}:n,progress:k?function(b){l||(a.fileprogress({type:"progress",total:j.total=b.total,loaded:j.loaded=b.loaded},k,i,m),a.progress({type:"progress",total:f,loaded:c.loaded=0|g+j.size*(b.loaded/b.total)},k,i,m))}:n,complete:function(d){l=!0,Q(M,function(a){c[a]=i[a]}),k&&(j.loaded=j.total,this.progress(j),g+=j.size,c.loaded=g,a.filecomplete(d,i,k,m)),b.call(e)}}));c.abort=function(a){a||(d.length=0),this.current=a,i.abort()},i.send(h)})):(a.complete(200==c.status||201==c.status?!1:c.statusText||"error",c,a),h=!0)},setTimeout(b,0),c.append=function(a,g){a=X._getFilesDataArray([].concat(a)),Q(a,function(a){f+=a.size,c.files.push(a.file),g?d.unshift(a):d.push(a)}),c.statusText="",h&&b.call(e)},c.remove=function(a){for(var b,c=d.length;c--;)d[c].file==a&&(b=d.splice(c,1),f-=b.size);return b},c},_getFilesDataArray:function(a){var b=[],c={};if(j(a)){var d=X.getFiles(a);c[a.name||"file"]=null!==a.getAttribute("multiple")?d:d[0]}else P(a)&&j(a[0])?Q(a,function(a){c[a.name||"file"]=X.getFiles(a)}):c=a;return Q(c,function e(a,c){P(a)?Q(a,function(a){e(a,c)}):a&&(a.name||a.image)&&b.push({name:c,file:a,size:a.size,total:a.size,loaded:0})}),b.length||b.push({file:{name:X.expando}}),b},_getFormData:function(a,b,c){var d=b.file,e=b.name,f=d.name,g=d.type,h=X.support.transform&&a.imageTransform,i=new X.Form,j=X.queue(function(){c(i)}),k=h&&l(h),m=X.postNameConcat;!function n(b){b.image?(j.inc(),b.toData(function(a,b){f=f||(new Date).getTime()+".png",n(b),j.next()})):X.Image&&h&&(/^image/.test(b.type)||E.test(b.nodeName))?(j.inc(),k&&(h=[h]),X.Image.transform(b,h,a.imageAutoOrientation,function(c,d){if(k&&!c)B||X.flashEngine||(i.multipart=!0),i.append(e,d[0],f,h[0].type||g);else{var l=0;c||Q(d,function(a,b){B||X.flashEngine||(i.multipart=!0),h[b].postName||(l=1),i.append(h[b].postName||m(e,b),a,f,h[b].type||g)}),(c||a.imageOriginal)&&i.append(m(e,l?"original":null),b,f,g)}j.next()})):f!==X.expando&&i.append(e,b,f)}(d),Q(a.data,function o(a,b){"object"==typeof a?Q(a,function(a,c){o(a,m(b,c))}):i.append(b,a)}),j.check()},reset:function(a,b){var c,d;return x?(d=x(a).clone(!0).insertBefore(a).val("")[0],b||x(a).remove()):(c=a.parentNode,d=c.insertBefore(a.cloneNode(!0),a),d.value="",b||c.removeChild(a),Q(J[X.uid(a)],function(b,c){Q(b,function(b){T(a,c,b),S(d,c,b)})})),d},load:function(a,b){var c=X.getXHR();return c?(c.open("GET",a,!0),c.overrideMimeType&&c.overrideMimeType("text/plain; charset=x-user-defined"),S(c,"progress",function(a){a.lengthComputable&&b({type:a.type,loaded:a.loaded,total:a.total},c)}),c.onreadystatechange=function(){if(4==c.readyState)if(c.onreadystatechange=null,200==c.status){a=a.split("/");var d={name:a[a.length-1],size:c.getResponseHeader("Content-Length"),type:c.getResponseHeader("Content-Type")};d.dataURL="data:"+d.type+";base64,"+X.encode64(c.responseBody||c.responseText),b({type:"load",result:d},c)}else b({type:"error"},c)},c.send(null)):b({type:"error"}),c},encode64:function(a){var b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",c="",d=0;for("string"!=typeof a&&(a=String(a));d<a.length;){var e,f,g=255&a.charCodeAt(d++),h=255&a.charCodeAt(d++),i=255&a.charCodeAt(d++),j=g>>2,k=(3&g)<<4|h>>4;isNaN(h)?e=f=64:(e=(15&h)<<2|i>>6,f=isNaN(i)?64:63&i),c+=b.charAt(j)+b.charAt(k)+b.charAt(e)+b.charAt(f)}return c}};X.addInfoReader(/^image/,function(a,b){if(!a.__dimensions){var c=a.__dimensions=X.defer();X.readAsImage(a,function(a){var b=a.target;c.resolve("load"==a.type?!1:"error",{width:b.width,height:b.height}),b=null})}a.__dimensions.then(b)}),X.event.dnd=function(a,b,c){var d,e;c||(c=b,b=X.F),u?(S(a,"dragenter dragleave dragover",function(a){for(var c=k(a).types,f=c&&c.length,g=!1;f--;)if(~c[f].indexOf("File")){a[O](),e!==a.type&&(e=a.type,"dragleave"!=e&&b.call(a[N],!0,a),g=!0);break}g&&(clearTimeout(d),d=setTimeout(function(){b.call(a[N],"dragleave"!=e,a)},50))}),S(a,"drop",function(a){a[O](),e=0,b.call(a[N],!1,a),X.getDropFiles(a,function(b){c.call(a[N],b,a)})})):X.log("Drag'n'Drop -- not supported")},X.event.dnd.off=function(a,b,c){T(a,"dragenter dragleave dragover",b),T(a,"drop",c)},x&&!x.fn.dnd&&(x.fn.dnd=function(a,b){return this.each(function(){X.event.dnd(this,a,b)})},x.fn.offdnd=function(a,b){return this.each(function(){X.event.dnd.off(this,a,b)})}),a.FileAPI=R(X,a.FileAPI),X.log("FileAPI: "+X.version),X.log("protocol: "+a.location.protocol),X.log("doctype: ["+p.name+"] "+p.publicId+" "+p.systemId),Q(o.getElementsByTagName("meta"),function(a){/x-ua-compatible/i.test(a.getAttribute("http-equiv"))&&X.log("meta.http-equiv: "+a.getAttribute("content"))}),X.flashUrl||(X.flashUrl=X.staticPath+"FileAPI.flash.swf"),X.flashImageUrl||(X.flashImageUrl=X.staticPath+"FileAPI.flash.image.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.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},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"string"==typeof b&&(c=b,b=a),this.set({dw:a,dh:b,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(){c(!1,h)}),v=a.renderImageToCanvas;for(b._type=this.file.type;e(p/n,q/o)>2;)p=0|p/2+.5,q=0|q/2+.5,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(h,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},_trans:function(a){this._load(this.file,function(b,c){b?a(b):this._apply(c,a)})},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")},toData:function(a){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.type):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(a,b,c,d,e,f,g,h,i,j){return a.getContext("2d").drawImage(b,c,d,e,f,g,h,i,j),a},a.support.canvas=a.support.transform=h,a.Image=d}(FileAPI,document),function(a,b){"use strict";function c(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 d=b.document,e=b.FormData,f=function(){this.items=[]},g=b.encodeURIComponent;f.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(d.createDocumentFragment(),b,function(b,c){var e,f=b.blob;b.file?(a.reset(f,!0),f.name=b.name,c.appendChild(f)):(e=d.createElement("input"),e.name=b.name,e.type="hidden",e.value=f,c.appendChild(e))})},toPlainData:function(a){this._to({},a,function(a,b,d){a.file&&(b.type=a.file),a.blob.toBlob?(d.inc(),c(a,function(a,c){b.name=a.name,b.file=c,b.size=c.length,b.type=a.type,d.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(g(a.name)+"="+g(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,d){a.blob&&a.blob.toBlob?(d.inc(),c(a,function(a,c){b.append(a.name,c,a.file),d.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,d,e){d.inc(),c(a,function(a,c){b.push("--_"+e+('\r\nContent-Disposition: form-data; name="'+a.name+'"'+(a.file?'; filename="'+g(a.file)+'"':"")+(a.file?"\r\nContent-Type: "+(a.type||"application/octet-stream"):"")+"\r\n\r\n"+(a.file?c:g(c))+"\r\n")),d.next()},!0)},a.expando)}},a.Form=f}(FileAPI,window),function(a,b){"use strict";var c=function(){},d=a.document,e=function(a){this.uid=b.uid(),this.xhr={abort:c,getResponseHeader:c,getAllResponseHeaders:c},this.options=a},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.options;f.end=f.abort=c,f.status=d,e&&(f.statusText=e),b.log("xhr.end:",d,e),g.complete(200==d||201==d?!1:f.statusText||"unknown",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){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><input value="'+i+'" name="callback" type="hidden"/></form>',h.xhr.abort=function(){var a=g.getElementsByTagName("iframe")[0];if(a)try{a.stop?a.stop():a.contentWindow.stop?a.contentWindow.stop():a.contentWindow.document.execCommand("Stop")}catch(b){}g=null};var k=g.getElementsByTagName("form")[0];k.appendChild(e),b.log(k.parentNode.innerHTML),d.body.appendChild(g),h.xhr.node=g,a[i]=function(a,b,c){h.readyState=4,h.responseText=c,h.end(a,b),g=null},h.readyState=2,k.submit(),k=null}else{if(this.xhr&&this.xhr.aborted)return b.log("Error: already aborted"),void 0;if(g=h.xhr=b.getXHR(),e.params&&(j+=(j.indexOf("?")<0?"?":"&")+e.params.join("&")),g.open("POST",j,!0),b.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",function(a){e.retry||c.progress({type:a.type,total:e.size,loaded:e.start+a.loaded,totalSize:e.size},h,c)},!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){for(var d in f)h["response"+d]=g["response"+d];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 i=g.status?0:b.chunkNetworkDownRetryTimeout;c.pause(e.file,c),b.log("X-Last-Known-Byte: "+a),e.end=a?a:e.start-1,setTimeout(function(){h._send(c,e)},i)}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 l;(l="slice")in e.file||(l="mozSlice")in e.file||(l="webkitSlice")in e.file,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"),l=e.file[l](e.start,e.end+1),g.send(l),l=null}else if(g.upload&&g.upload.addEventListener("progress",b.throttle(function(a){c.progress(a,h,c)},100),!1),g.onreadystatechange=function(){if(h.status=g.status,h.statusText=g.statusText,h.readyState=g.readyState,4==g.readyState){for(var a in f)h["response"+a]=g["response"+a];g.onreadystatechange=null,h.end(g.status),g=null}},b.isArray(e))if(g.setRequestHeader("Content-Type","multipart/form-data; boundary=_"+b.expando),e=e.join("")+"--_"+b.expando+"--",g.sendAsBinary)g.sendAsBinary(e);else{var m=Array.prototype.map.call(e,function(a){return 255&a.charCodeAt(0)});g.send(new Uint8Array(m).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=4*c.width*c.height,d};j.Shot=k,b.Camera=j}(window,FileAPI),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){"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"==typeof define&&define.amd&&define("FileAPI",[],function(){return FileAPI});
View
42 dist/FileAPI.js
@@ -192,6 +192,7 @@
cors: false,
html5: true,
media: false,
+ formData: true,
debug: false,
pingUrl: false,
@@ -2139,7 +2140,7 @@
api.Image = Image;
})(FileAPI, document);
-/*global window, navigator, FileAPI */
+/*global window, FileAPI */
(function (api, window){
"use strict";
@@ -2149,7 +2150,6 @@
, FormData = window.FormData
, Form = function (){ this.items = []; }
, encodeURIComponent = window.encodeURIComponent
- , isPhantomJS = /phantomjs/i.test(navigator.userAgent)// @todo: fixed it
;
@@ -2180,7 +2180,7 @@
api.log('FileAPI.Form.toHtmlData');
this.toHtmlData(fn);
}
- else if( isPhantomJS || this.multipart || !FormData ){
+ else if( !api.formData || this.multipart || !FormData ){
api.log('FileAPI.Form.toMultipartData');
this.toMultipartData(fn);
}
@@ -2833,6 +2833,10 @@
};
+ el.style.width = _px(options.width);
+ el.style.height = _px(options.height);
+
+
if( api.html5 && html5 ){
// Create video element
var video = document.createElement('video');
@@ -2927,6 +2931,9 @@
document = window.document
, location = window.location
, navigator = window.navigator
+
+ , _each = api.each
+ , _cameraQueue = []
;
@@ -3170,13 +3177,13 @@
// Set files filter
var accept = [], exts = {};
- api.each((node.getAttribute('accept') || '').split(/,\s*/), function (mime){
- api.accept[mime] && api.each(api.accept[mime].split(' '), function (ext){
+ _each((node.getAttribute('accept') || '').split(/,\s*/), function (mime){
+ api.accept[mime] && _each(api.accept[mime].split(' '), function (ext){
exts[ext] = 1;
});
});
- api.each(exts, function (i, ext){
+ _each(exts, function (i, ext){
accept.push( ext );
});
@@ -3214,7 +3221,7 @@
, event
;
- api.each(files, function (file){
+ _each(files, function (file){
api.checkFileObj(file);
});
@@ -3446,6 +3453,12 @@
}));
};
+ // Run
+ _each(_cameraQueue, function (args){
+ api.Camera.fallback.apply(api.Camera, args);
+ });
+ _cameraQueue = [];
+
// FileAPI.Camera:proto
_inherit(api.Camera.prototype, {
@@ -3465,15 +3478,15 @@
}
else {
api.log('FlashAPI.camera.on.success: ' + _this._id());
- _this.active = true;
+ _this._active = true;
callback(null, _this);
}
})
});
},
stop: function (){
- this.active = false;
+ this._active = false;
flash.cmd(this._id(), 'camera.off');
},
@@ -3528,7 +3541,7 @@
, fileId
;
- api.each(formData, function (item){
+ _each(formData, function (item){
if( item.file ){
files[item.name] = item = _getFileDescr(item.blob);
fileId = item.id;
@@ -3593,7 +3606,7 @@
// #2174: FileReference.load() call while FileReference.upload() or vice versa
- api.each(files, function (file){
+ _each(files, function (file){
queue.inc();
api.getInfo(file, queue.next);
});
@@ -3636,7 +3649,7 @@
function _inherit(obj, methods){
- api.each(methods, function (fn, name){
+ _each(methods, function (fn, name){
var prev = obj[name];
obj[name] = function (){
this.parent = prev;
@@ -3762,6 +3775,11 @@
}
+ api.Camera.fallback = function (){
+ _cameraQueue.push(arguments);
+ };
+
+
// @export
api.Flash = flash;
View
4 dist/FileAPI.min.js
@@ -1,3 +1,3 @@
/*! fileapi 2.0.1 - BSD | git://github.com/mailru/FileAPI.git */
-(function(e,t){"use strict";function n(e,t,n,a,i){var r={type:n.type||n,target:e,result:a};q(r,i),t(r)}function a(e){return b&&!!b.prototype["readAs"+e]}function i(e,i,r,o){if(J.isFile(e)&&a(r)){var s=new b;X(s,S,function l(t){var a=t.type;"progress"==a?n(e,i,t,t.target.result,{loaded:t.loaded,total:t.total}):"loadend"==a?(W(s,S,l),s=null):n(e,i,t,t.target.result)});try{o?s["readAs"+r](e,o):s["readAs"+r](e)}catch(u){n(e,i,"error",t,{error:""+u})}}else n(e,i,"error",t,{error:"filreader_not_support_"+r})}function r(e,t){if(!e.type&&0===e.size%4096&&102400>=e.size)if(b)try{var n=new b;G(n,S,function(e){var a="error"!=e.type;t(a),a&&n.abort()}),n.readAsDataURL(e)}catch(a){t(!1)}else t(null);else t(!0)}function o(e){var t;return e.getAsEntry?t=e.getAsEntry():e.webkitGetAsEntry&&(t=e.webkitGetAsEntry()),t}function s(e,t){if(e)if(e.isFile)e.file(function(n){n.fullPath=e.fullPath,t(!1,[n])},function(e){t("FileError.code: "+e.code)});else if(e.isDirectory){var n=e.createReader(),a=[];n.readEntries(function(e){J.afor(e,function(e,n){s(n,function(n,i){n?J.log(n):a=a.concat(i),e?e():t(!1,a)})})},function(e){t("directory_reader: "+e)})}else s(o(e),t);else t("invalid entry")}function l(e){var t={};return N(e,function(e,n){e&&"object"==typeof e&&void 0===e.nodeType&&(e=q({},e)),t[n]=e}),t}function u(e){return U.test(e&&e.tagName)}function c(e){return(e.originalEvent||e||"").dataTransfer||{}}function f(e){var t;for(t in e)if(e.hasOwnProperty(t)&&!(e[t]instanceof Object||"overlay"===t||"filter"===t))return!0;return!1}var d=1,p=function(){},h=e.document,m=h.doctype||{},g=e.navigator.userAgent,v=e.createObjectURL&&e||e.URL&&URL.revokeObjectURL&&URL||e.webkitURL&&webkitURL,y=e.Blob,w=e.File,b=e.FileReader,x=e.FormData,A=e.XMLHttpRequest,I=e.jQuery,F=!(!(w&&b&&(e.Uint8Array||x||A.prototype.sendAsBinary))||/safari\//i.test(g)&&!/chrome\//i.test(g)&&/windows/i.test(g)),R=F&&"withCredentials"in new A,T=F&&!!y&&!!(y.prototype.webkitSlice||y.prototype.mozSlice||y.prototype.slice),_=e.dataURLtoBlob,E=/img/i,C=/canvas/i,D=/img|canvas/i,U=/input/i,L=/^data:[^,]+,/,k=e.Math,B=function(t){return t=new e.Number(k.pow(1024,t)),t.from=function(e){return k.round(e*this)},t},P={},j=[],S="abort progress error load loadend",H="status statusText readyState response responseXML responseText responseBody".split(" "),M="currentTarget",z="preventDefault",O=function(e){return e&&"length"in e},N=function(e,t,n){if(e)if(O(e))for(var a=0,i=e.length;i>a;a++)a in e&&t.call(n,e[a],a,e);else for(var r in e)e.hasOwnProperty(r)&&t.call(n,e[r],r,e)},q=function(e){for(var t=arguments,n=1,a=function(t,n){e[n]=t};t.length>n;n++)N(t[n],a);return e},X=function(e,t,n){if(e){var a=J.uid(e);P[a]||(P[a]={}),N(t.split(/\s+/),function(t){I?I.event.add(e,t,n):(P[a][t]||(P[a][t]=[]),P[a][t].push(n),e.addEventListener?e.addEventListener(t,n,!1):e.attachEvent?e.attachEvent("on"+t,n):e["on"+t]=n)})}},W=function(e,t,n){if(e){var a=J.uid(e),i=P[a]||{};N(t.split(/\s+/),function(t){if(I)I.event.remove(e,t,n);else{for(var a=i[t]||[],r=a.length;r--;)if(a[r]===n){a.splice(r,1);break}e.addEventListener?e.removeEventListener(t,n,!1):e.detachEvent?e.detachEvent("on"+t,n):e["on"+t]=null}})}},G=function(e,t,n){X(e,t,function a(i){W(e,t,a),n(i)})},K=function(t){return t.target||(t.target=e.event&&e.event.srcElement||h),3===t.target.nodeType&&(t.target=t.target.parentNode),t},Q=function(e){var t=h.createElement("input");return t.setAttribute("type","file"),e in t},J={version:"2.0.1",cors:!1,html5:!0,media:!1,debug:!1,pingUrl:!1,multiFlash:!1,flashAbortTimeout:0,withCredentials:!0,staticPath:"./dist/",flashUrl:0,flashImageUrl:0,postNameConcat:function(e,t){return e+(null!=t?"["+t+"]":"")},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"},chunkSize:0,chunkUploadRetry:0,chunkNetworkDownRetryTimeout:2e3,KB:B(1),MB:B(2),GB:B(3),TB:B(4),expando:"fileapi"+(new Date).getTime(),uid:function(e){return e?e[J.expando]=e[J.expando]||J.uid():(++d,J.expando+d)},log:function(){J.debug&&e.console&&console.log&&(console.log.apply?console.log.apply(console,arguments):console.log([].join.call(arguments," ")))},newImage:function(e,t){var n=h.createElement("img");return t&&J.event.one(n,"error load",function(e){t("error"==e.type,n),n=null}),n.src=e,n},getXHR:function(){var t;if(A)t=new A;else if(e.ActiveXObject)try{t=new ActiveXObject("MSXML2.XMLHttp.3.0")}catch(n){t=new ActiveXObject("Microsoft.XMLHTTP")}return t},isArray:O,support:{dnd:R&&"ondrop"in h.createElement("div"),cors:R,html5:F,chunked:T,dataURI:!0,accept:Q("accept"),multiple:Q("multiple")},event:{on:X,off:W,one:G,fix:K},throttle:function(t,n){var a,i;return function(){i=arguments,a||(t.apply(e,i),a=setTimeout(function(){a=0,t.apply(e,i)},n))}},F:function(){},parseJSON:function(t){var n;return n=e.JSON&&JSON.parse?JSON.parse(t):Function("return ("+t.replace(/([\r\n])/g,"\\$1")+");")()},trim:function(e){return e+="",e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")},defer:function(){var e,n,a=[],i={resolve:function(t,r){for(i.resolve=p,n=t||!1,e=r;r=a.shift();)r(n,e)},then:function(i){n!==t?i(n,e):a.push(i)}};return i},queue:function(e){var t=0,n=0,a=!1,i=!1,r={inc:function(){n++},next:function(){t++,setTimeout(r.check,0)},check:function(){t>=n&&!a&&r.end()},isFail:function(){return a},fail:function(){!a&&e(a=!0)},end:function(){i||(i=!0,e())}};return r},each:N,afor:function(e,t){var n=0,a=e.length;O(e)&&a--?function i(){t(a!=n&&i,e[n],n++)}():t(!1)},extend:q,isFile:function(e){return F&&e&&e instanceof w},isCanvas:function(e){return e&&C.test(e.nodeName)},getFilesFilter:function(e){return e="string"==typeof e?e:e.getAttribute&&e.getAttribute("accept")||"",e?RegExp("("+e.replace(/\./g,"\\.").replace(/,/g,"|")+")$","i"):/./},readAsDataURL:function(e,t){J.isCanvas(e)?n(e,t,"load",J.toDataURL(e)):i(e,t,"DataURL")},readAsBinaryString:function(e,t){a("BinaryString")?i(e,t,"BinaryString"):i(e,function(e){if("load"==e.type)try{e.result=J.toBinaryString(e.result)}catch(n){e.type="error",e.message=""+n}t(e)},"DataURL")},readAsArrayBuffer:function(e,t){i(e,t,"ArrayBuffer")},readAsText:function(e,t,n){n||(n=t,t="utf-8"),i(e,n,"Text",t)},toDataURL:function(e,t){return"string"==typeof e?e:e.toDataURL?e.toDataURL(t||"image/png"):void 0},toBinaryString:function(t){return e.atob(J.toDataURL(t).replace(L,""))},readAsImage:function(e,a,i){if(J.isFile(e))if(v){var r=v.createObjectURL(e);r===t?n(e,a,"error"):J.readAsImage(r,a,i)}else J.readAsDataURL(e,function(t){"load"==t.type?J.readAsImage(t.result,a,i):(i||"error"==t.type)&&n(e,a,t,null,{loaded:t.loaded,total:t.total})});else if(J.isCanvas(e))n(e,a,"load",e);else if(E.test(e.nodeName))if(e.complete)n(e,a,"load",e);else{var o="error abort load";G(e,o,function s(t){"load"==t.type&&v&&v.revokeObjectURL(e.src),W(e,o,s),n(e,a,t,e)})}else if(e.iframe)n(e,a,{type:"error"});else{var l=J.newImage(e.dataURL||e);J.readAsImage(l,a,i)}},checkFileObj:function(e){var t={},n=J.accept;return"object"==typeof e?t=e:t.name=(e+"").split(/\\|\//g).pop(),null==t.type&&(t.type=t.name.split(".").pop()),N(n,function(e,n){e=RegExp(e.replace(/\s/g,"|"),"i"),(e.test(t.type)||J.ext2mime[t.type])&&(t.type=J.ext2mime[t.type]||n.split("/")[0]+"/"+t.type)}),t},getDropFiles:function(e,t){var n=[],a=c(e),i=O(a.items)&&a.items[0]&&o(a.items[0]),l=J.queue(function(){t(n)});N((i?a.items:a.files)||[],function(e){l.inc();try{i?s(e,function(e,t){e?J.log("[err] getDropFiles:",e):n.push.apply(n,t),l.next()}):r(e,function(t){t&&n.push(e),l.next()})}catch(t){l.next(),J.log("[err] getDropFiles: ",t)}}),l.check()},getFiles:function(e,t,n){var a=[];return n?(J.filterFiles(J.getFiles(e),t,n),null):(e.jquery&&(e.each(function(){a=a.concat(J.getFiles(this))}),e=a,a=[]),"string"==typeof t&&(t=J.getFilesFilter(t)),e.originalEvent?e=K(e.originalEvent):e.srcElement&&(e=K(e)),e.dataTransfer?e=e.dataTransfer:e.target&&(e=e.target),e.files?(a=e.files,F||(a[0].blob=e,a[0].iframe=!0)):!F&&u(e)?J.trim(e.value)&&(a=[J.checkFileObj(e.value)],a[0].blob=e,a[0].iframe=!0):O(e)&&(a=e),J.filter(a,function(e){return!t||t.test(e.name)}))},getTotalSize:function(e){for(var t=0,n=e&&e.length;n--;)t+=e[n].size;return t},getInfo:function(e,t){var n={},a=j.concat();J.isFile(e)?function i(){var r=a.shift();r?r.test(e.type)?r(e,function(e,a){e?t(e):(q(n,a),i())}):i():t(!1,n)}():t("not_support_info",n)},addInfoReader:function(e,t){t.test=function(t){return e.test(t)},j.push(t)},filter:function(e,t){for(var n,a=[],i=0,r=e.length;r>i;i++)i in e&&(n=e[i],t.call(n,n,i,e)&&a.push(n));return a},filterFiles:function(e,t,n){if(e.length){var a,i=e.concat(),r=[],o=[];(function s(){i.length?(a=i.shift(),J.getInfo(a,function(e,n){(t(a,e?!1:n)?r:o).push(a),s()})):n(r,o)})()}else n([],e)},upload:function(e){e=q({prepare:J.F,beforeupload:J.F,upload:J.F,fileupload:J.F,fileprogress:J.F,filecomplete:J.F,progress:J.F,complete:J.F,pause:J.F,imageOriginal:!0,chunkSize:J.chunkSize,chunkUpoloadRetry:J.chunkUploadRetry},e),e.imageAutoOrientation&&!e.imageTransform&&(e.imageTransform={rotate:"auto"});var t,n=new J.XHR(e),a=this._getFilesDataArray(e.files),i=this,r=0,o=0,s=!1;return N(a,function(e){r+=e.size}),n.files=[],N(a,function(e){n.files.push(e.file)}),n.total=r,n.loaded=0,n.filesLeft=a.length,e.beforeupload(n,e),t=function(){var u=a.shift(),c=u&&u.file,f=!1,d=l(e);n.filesLeft=a.length,c&&c.name===J.expando&&(c=null,J.log("[warn] FileAPI.upload() — called without files")),("abort"!=n.statusText||n.current)&&u?(s=!1,n.currentFile=c,c&&e.prepare(c,d),i._getFormData(d,u,function(s){o||e.upload(n,e);var l=new J.XHR(q({},d,{upload:c?function(){e.fileupload(c,l,d)}:p,progress:c?function(t){f||(e.fileprogress({type:"progress",total:u.total=t.total,loaded:u.loaded=t.loaded},c,l,d),e.progress({type:"progress",total:r,loaded:n.loaded=0|o+u.size*(t.loaded/t.total)},c,l,d))}:p,complete:function(a){f=!0,N(H,function(e){n[e]=l[e]}),c&&(u.loaded=u.total,this.progress(u),o+=u.size,n.loaded=o,e.filecomplete(a,l,c,d)),t.call(i)}}));n.abort=function(e){e||(a.length=0),this.current=e,l.abort()},l.send(s)})):(e.complete(200==n.status||201==n.status?!1:n.statusText||"error",n,e),s=!0)},setTimeout(t,0),n.append=function(e,o){e=J._getFilesDataArray([].concat(e)),N(e,function(e){r+=e.size,n.files.push(e.file),o?a.unshift(e):a.push(e)}),n.statusText="",s&&t.call(i)},n.remove=function(e){for(var t,n=a.length;n--;)a[n].file==e&&(t=a.splice(n,1),r-=t.size);return t},n},_getFilesDataArray:function(e){var t=[],n={};if(u(e)){var a=J.getFiles(e);n[e.name||"file"]=null!==e.getAttribute("multiple")?a:a[0]}else O(e)&&u(e[0])?N(e,function(e){n[e.name||"file"]=J.getFiles(e)}):n=e;return N(n,function i(e,n){O(e)?N(e,function(e){i(e,n)}):e&&(e.name||e.image)&&t.push({name:n,file:e,size:e.size,total:e.size,loaded:0})}),t.length||t.push({file:{name:J.expando}}),t},_getFormData:function(e,t,n){var a=t.file,i=t.name,r=a.name,o=a.type,s=J.support.transform&&e.imageTransform,l=new J.Form,u=J.queue(function(){n(l)}),c=s&&f(s),d=J.postNameConcat;(function p(t){t.image?(u.inc(),t.toData(function(e,t){r=r||(new Date).getTime()+".png",p(t),u.next()})):J.Image&&s&&(/^image/.test(t.type)||D.test(t.nodeName))?(u.inc(),c&&(s=[s]),J.Image.transform(t,s,e.imageAutoOrientation,function(n,a){if(c&&!n)_||J.flashEngine||(l.multipart=!0),l.append(i,a[0],r,s[0].type||o);else{var f=0;n||N(a,function(e,t){_||J.flashEngine||(l.multipart=!0),s[t].postName||(f=1),l.append(s[t].postName||d(i,t),e,r,s[t].type||o)}),(n||e.imageOriginal)&&l.append(d(i,f?"original":null),t,r,o)}u.next()})):r!==J.expando&&l.append(i,t,r)})(a),N(e.data,function h(e,t){"object"==typeof e?N(e,function(e,n){h(e,d(t,n))}):l.append(t,e)}),u.check()},reset:function(e,t){var n,a;return I?(a=I(e).clone(!0).insertBefore(e).val("")[0],t||I(e).remove()):(n=e.parentNode,a=n.insertBefore(e.cloneNode(!0),e),a.value="",t||n.removeChild(e),N(P[J.uid(e)],function(t,n){N(t,function(t){W(e,n,t),X(a,n,t)})})),a},load:function(e,t){var n=J.getXHR();return n?(n.open("GET",e,!0),n.overrideMimeType&&n.overrideMimeType("text/plain; charset=x-user-defined"),X(n,"progress",function(e){e.lengthComputable&&t({type:e.type,loaded:e.loaded,total:e.total},n)}),n.onreadystatechange=function(){if(4==n.readyState)if(n.onreadystatechange=null,200==n.status){e=e.split("/");var a={name:e[e.length-1],size:n.getResponseHeader("Content-Length"),type:n.getResponseHeader("Content-Type")};a.dataURL="data:"+a.type+";base64,"+J.encode64(n.responseBody||n.responseText),t({type:"load",result:a},n)}else t({type:"error"},n)},n.send(null)):t({type:"error"}),n},encode64:function(e){var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",n="",a=0;for("string"!=typeof e&&(e+="");e.length>a;){var i,r,o=255&e.charCodeAt(a++),s=255&e.charCodeAt(a++),l=255&e.charCodeAt(a++),u=o>>2,c=(3&o)<<4|s>>4;isNaN(s)?i=r=64:(i=(15&s)<<2|l>>6,r=isNaN(l)?64:63&l),n+=t.charAt(u)+t.charAt(c)+t.charAt(i)+t.charAt(r)}return n}};J.addInfoReader(/^image/,function(e,t){if(!e.__dimensions){var n=e.__dimensions=J.defer();J.readAsImage(e,function(e){var t=e.target;n.resolve("load"==e.type?!1:"error",{width:t.width,height:t.height}),t=null})}e.__dimensions.then(t)}),J.event.dnd=function(e,t,n){var a,i;n||(n=t,t=J.F),b?(X(e,"dragenter dragleave dragover",function(e){for(var n=c(e).types,r=n&&n.length,o=!1;r--;)if(~n[r].indexOf("File")){e[z](),i!==e.type&&(i=e.type,"dragleave"!=i&&t.call(e[M],!0,e),o=!0);break}o&&(clearTimeout(a),a=setTimeout(function(){t.call(e[M],"dragleave"!=i,e)},50))}),X(e,"drop",function(e){e[z](),i=0,t.call(e[M],!1,e),J.getDropFiles(e,function(t){n.call(e[M],t,e)})})):J.log("Drag'n'Drop -- not supported")},J.event.dnd.off=function(e,t,n){W(e,"dragenter dragleave dragover",t),W(e,"drop",n)},I&&!I.fn.dnd&&(I.fn.dnd=function(e,t){return this.each(function(){J.event.dnd(this,e,t)})},I.fn.offdnd=function(e,t){return this.each(function(){J.event.dnd.off(this,e,t)})}),e.FileAPI=q(J,e.FileAPI),J.log("FileAPI: "+J.version),J.log("protocol: "+e.location.protocol),J.log("doctype: ["+m.name+"] "+m.publicId+" "+m.systemId),N(h.getElementsByTagName("meta"),function(e){/x-ua-compatible/i.test(e.getAttribute("http-equiv"))&&J.log("meta.http-equiv: "+e.getAttribute("content"))}),J.flashUrl||(J.flashUrl=J.staticPath+"FileAPI.flash.swf"),J.flashImageUrl||(J.flashImageUrl=J.staticPath+"FileAPI.flash.image.swf")})(window,void 0),function(e,t,n){"use strict";function a(t){if(t instanceof a){var n=new a(t.file);return e.extend(n.matrix,t.matrix),n}return this instanceof a?(this.file=t,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},void 0):new a(t)}var i=Math.min,r=Math.round,o=function(){return t.createElement("canvas")},s=!1,l={8:270,3:180,6:90};try{s=o().toDataURL("image/png").indexOf("data:image/png")>-1}catch(u){}a.prototype={image:!0,constructor:a,set:function(t){return e.extend(this.matrix,t),this},crop:function(e,t,a,i){return a===n&&(a=e,i=t,e=t=0),this.set({sx:e,sy:t,sw:a,sh:i||a})},resize:function(e,t,n){return"string"==typeof t&&(n=t,t=e),this.set({dw:e,dh:t,resize:n})},preview:function(e,t){return this.resize(e,t||e,"preview")},rotate:function(e){return this.set({deg:e})},filter:function(e){return this.set({filter:e})},overlay:function(e){return this.set({overlay:e})},clone:function(){return new a(this)},_load:function(t,n){var a=this;/img|video/i.test(t.nodeName)?n.call(a,null,t):e.readAsImage(t,function(e){n.call(a,"load"!=e.type,e.result)})},_apply:function(t,n){var r,s=o(),l=this.getMatrix(t),u=s.getContext("2d"),c=t.videoWidth||t.width,f=t.videoHeight||t.height,d=l.deg,p=l.dw,h=l.dh,m=c,g=f,v=l.filter,y=t,w=l.overlay,b=e.queue(function(){n(!1,s)}),x=e.renderImageToCanvas;for(t._type=this.file.type;i(m/p,g/h)>2;)m=0|m/2+.5,g=0|g/2+.5,r=o(),r.width=m,r.height=g,y!==t?(x(r,y,0,0,y.width,y.height,0,0,m,g),y=r):(y=r,x(y,t,l.sx,l.sy,l.sw,l.sh,0,0,m,g),l.sx=l.sy=l.sw=l.sh=0);s.width=d%180?h:p,s.height=d%180?p:h,s.type=l.type,s.quality=l.quality,u.rotate(d*Math.PI/180),x(s,y,l.sx,l.sy,l.sw||y.width,l.sh||y.height,180==d||270==d?-p:0,90==d||180==d?-h:0,p,h),p=s.width,h=s.height,w&&e.each([].concat(w),function(t){b.inc();var n=new window.Image,a=function(){var i=0|t.x,r=0|t.y,o=t.w||n.width,s=t.h||n.height,l=t.rel;i=1==l||4==l||7==l?(p-o+i)/2:2==l||5==l||8==l?p-(o+i):i,r=3==l||4==l||5==l?(h-s+r)/2:l>=6?h-(s+r):r,e.event.off(n,"error load abort",a);try{u.globalAlpha=t.opacity||1,u.drawImage(n,i,r,o,s)}catch(c){}b.next()};e.event.on(n,"error load abort",a),n.src=t.src,n.complete&&a()}),v&&(b.inc(),a.applyFilter(s,v,b.next)),b.check()},getMatrix:function(t){var n=e.extend({},this.matrix),a=n.sw=n.sw||t.videoWidth||t.naturalWidth||t.width,o=n.sh=n.sh||t.videoHeight||t.naturalHeight||t.height,s=n.dw=n.dw||a,l=n.dh=n.dh||o,u=a/o,c=s/l,f=n.resize;if("preview"==f){if(s!=a||l!=o){var d,p;c>=u?(d=a,p=d/c):(p=o,d=p*c),(d!=a||p!=o)&&(n.sx=~~((a-d)/2),n.sy=~~((o-p)/2),a=d,o=p)}}else f&&(a>s||o>l?"min"==f?(s=r(c>u?i(a,s):l*u),l=r(c>u?s/u:i(o,l))):(s=r(u>=c?i(a,s):l*u),l=r(u>=c?s/u:i(o,l))):(s=a,l=o));return n.sw=a,n.sh=o,n.dw=s,n.dh=l,n},_trans:function(e){this._load(this.file,function(t,n){t?e(t):this._apply(n,e)})},get:function(t){if(e.support.transform){var n=this,a=n.matrix;"auto"==a.deg?e.getInfo(n.file,function(e,i){a.deg=l[i&&i.exif&&i.exif.Orientation]||0,n._trans(t)}):n._trans(t)}else t("not_support_transform")},toData:function(e){this.get(e)}},a.exifOrientation=l,a.transform=function(t,i,r,o){function s(s,l){var u={},c=e.queue(function(e){o(e,u)});s?c.fail():e.each(i,function(e,i){if(!c.isFail()){var o=new a(l.nodeType?l:t);if("function"==typeof e?e(l,o):e.width?o[e.preview?"preview":"resize"](e.width,e.height,e.type):e.maxWidth&&(l.width>e.maxWidth||l.height>e.maxHeight)&&o.resize(e.maxWidth,e.maxHeight,"max"),e.crop){var s=e.crop;o.crop(0|s.x,0|s.y,s.w||s.width,s.h||s.height)}e.rotate===n&&r&&(e.rotate="auto"),o.set({deg:e.rotate,type:e.type||t.type||"image/png",quality:e.quality||1,overlay:e.overlay,filter:e.filter}),c.inc(),o.toData(function(e,t){e?c.fail():(u[i]=t,c.next())})}})}t.width?s(!1,t):e.getInfo(t,s)},e.each(["TOP","CENTER","BOTTOM"],function(t,n){e.each(["LEFT","CENTER","RIGHT"],function(e,i){a[t+"_"+e]=3*n+i,a[e+"_"+t]=3*n+i})}),a.toCanvas=function(e){var n=t.createElement("canvas");return n.width=e.videoWidth||e.width,n.height=e.videoHeight||e.height,n.getContext("2d").drawImage(e,0,0),n},a.fromDataURL=function(t,n,a){var i=e.newImage(t);e.extend(i,n),a(i)},a.applyFilter=function(t,n,i){"function"==typeof n?n(t,i):window.Caman&&window.Caman("IMG"==t.tagName?a.toCanvas(t):t,function(){"string"==typeof n?this[n]():e.each(n,function(e,t){this[t](e)},this),this.render(i)})},e.renderImageToCanvas=function(e,t,n,a,i,r,o,s,l,u){return e.getContext("2d").drawImage(t,n,a,i,r,o,s,l,u),e},e.support.canvas=e.support.transform=s,e.Image=a}(FileAPI,document),function(e,t){"use strict";function n(t,n,a){var i=t.blob,r=t.file;if(r){if(!i.toDataURL)return e.readAsBinaryString(i,function(e){"load"==e.type&&n(t,e.result)}),void 0;var o={"image/jpeg":".jpe?g","image/png":".png"},s=o[t.type]?t.type:"image/png",l=o[s]||".png",u=i.quality||1;r.match(RegExp(l+"$","i"))||(r+=l.replace("?","")),t.file=r,t.type=s,!a&&i.toBlob?i.toBlob(function(e){n(t,e)},s,u):n(t,e.toBinaryString(i.toDataURL(s,u)))}else n(t,i)}var a=t.document,i=t.FormData,r=function(){this.items=[]},o=t.encodeURIComponent,s=/phantomjs/i.test(navigator.userAgent);r.prototype={append:function(e,t,n,a){this.items.push({name:e,blob:t&&t.blob||(void 0==t?"":t),file:t&&(n||t.name),type:t&&(a||t.type)})},each:function(e){for(var t=0,n=this.items.length;n>t;t++)e.call(this,this.items[t])},toData:function(t,n){n._chunked=e.support.chunked&&n.chunkSize>0&&1==e.filter(this.items,function(e){return e.file}).length,e.support.html5?s||this.multipart||!i?(e.log("FileAPI.Form.toMultipartData"),this.toMultipartData(t)):n._chunked?(e.log("FileAPI.Form.toPlainData"),this.toPlainData(t)):(e.log("FileAPI.Form.toFormData"),this.toFormData(t)):(e.log("FileAPI.Form.toHtmlData"),this.toHtmlData(t))},_to:function(t,n,a,i){var r=e.queue(function(){n(t)});this.each(function(e){a(e,t,r,i)}),r.check()},toHtmlData:function(t){this._to(a.createDocumentFragment(),t,function(t,n){var i,r=t.blob;t.file?(e.reset(r,!0),r.name=t.name,n.appendChild(r)):(i=a.createElement("input"),i.name=t.name,i.type="hidden",i.value=r,n.appendChild(i))})},toPlainData:function(e){this._to({},e,function(e,t,a){e.file&&(t.type=e.file),e.blob.toBlob?(a.inc(),n(e,function(e,n){t.name=e.name,t.file=n,t.size=n.length,t.type=e.type,a.next()})):e.file?(t.name=e.blob.name,t.file=e.blob,t.size=e.blob.size,t.type=e.type):(t.params||(t.params=[]),t.params.push(o(e.name)+"="+o(e.blob))),t.start=-1,t.end=t.file&&t.file.FileAPIReadPosition||-1,t.retry=0})},toFormData:function(e){this._to(new i,e,function(e,t,a){e.blob&&e.blob.toBlob?(a.inc(),n(e,function(e,n){t.append(e.name,n,e.file),a.next()})):e.file?t.append(e.name,e.blob,e.file):t.append(e.name,e.blob),e.file&&t.append("_"+e.name,e.file)})},toMultipartData:function(t){this._to([],t,function(e,t,a,i){a.inc(),n(e,function(e,n){t.push("--_"+i+('\r\nContent-Disposition: form-data; name="'+e.name+'"'+(e.file?'; filename="'+o(e.file)+'"':"")+(e.file?"\r\nContent-Type: "+(e.type||"application/octet-stream"):"")+"\r\n"+"\r\n"+(e.file?n:o(n))+"\r\n")),a.next()},!0)},e.expando)}},e.Form=r}(FileAPI,window),function(e,t){"use strict";var n=function(){},a=e.document,i=function(e){this.uid=t.uid(),this.xhr={abort:n,getResponseHeader:n,getAllResponseHeaders:n},this.options=e},r={"":1,XML:1,Text:1,Body:1};i.prototype={status:0,statusText:"",constructor:i,getResponseHeader:function(e){return this.xhr.getResponseHeader(e)},getAllResponseHeaders:function(){return this.xhr.getAllResponseHeaders()||{}},end:function(a,i){var r=this,o=r.options;r.end=r.abort=n,r.status=a,i&&(r.statusText=i),t.log("xhr.end:",a,i),o.complete(200==a||201==a?!1:r.statusText||"unknown",r),r.xhr&&r.xhr.node&&setTimeout(function(){var t=r.xhr.node;try{t.parentNode.removeChild(t)}catch(n){}try{delete e[r.uid]}catch(n){}e[r.uid]=r.xhr.node=null},9)},abort:function(){this.end(0,"abort"),this.xhr&&(this.xhr.aborted=!0,this.xhr.abort())},send:function(e){var t=this,n=this.options;e.toData(function(e){n.upload(n,t),t._send.call(t,n,e)},n)},_send:function(n,i){var o,s=this,l=s.uid,u=n.url;if(t.log("XHR._send:",i),n.cache||(u+=(~u.indexOf("?")?"&":"?")+t.uid()),i.nodeName){n.upload(n,s),o=a.createElement("div"),o.innerHTML='<form target="'+l+'" action="'+u+'" method="POST" enctype="multipart/form-data" style="position: absolute; top: -1000px; overflow: hidden; width: 1px; height: 1px;">'+'<iframe name="'+l+'" src="javascript:false;"></iframe>'+'<input value="'+l+'" name="callback" type="hidden"/>'+"</form>",s.xhr.abort=function(){var e=o.getElementsByTagName("iframe")[0];if(e)try{e.stop?e.stop():e.contentWindow.stop?e.contentWindow.stop():e.contentWindow.document.execCommand("Stop")}catch(t){}o=null};var c=o.getElementsByTagName("form")[0];c.appendChild(i),t.log(c.parentNode.innerHTML),a.body.appendChild(o),s.xhr.node=o,e[l]=function(e,t,n){s.readyState=4,s.responseText=n,s.end(e,t),o=null},s.readyState=2,c.submit(),c=null}else{if(this.xhr&&this.xhr.aborted)return t.log("Error: already aborted"),void 0;if(o=s.xhr=t.getXHR(),i.params&&(u+=(0>u.indexOf("?")?"?":"&")+i.params.join("&")),o.open("POST",u,!0),t.withCredentials&&(o.withCredentials="true"),n.headers&&n.headers["X-Requested-With"]||o.setRequestHeader("X-Requested-With","XMLHttpRequest"),t.each(n.headers,function(e,t){o.setRequestHeader(t,e)}),n._chunked){o.upload&&o.upload.addEventListener("progress",function(e){i.retry||n.progress({type:e.type,total:i.size,loaded:i.start+e.loaded,totalSize:i.size},s,n)},!1),o.onreadystatechange=function(){var e=parseInt(o.getResponseHeader("X-Last-Known-Byte"),10);if(s.status=o.status,s.statusText=o.statusText,s.readyState=o.readyState,4==o.readyState){for(var a in r)s["response"+a]=o["response"+a];if(o.onreadystatechange=null,!o.status||o.status-201>0)if(t.log("Error: "+o.status),(!o.status&&!o.aborted||500==o.status||416==o.status)&&++i.retry<=n.chunkUploadRetry){var l=o.status?0:t.chunkNetworkDownRetryTimeout;n.pause(i.file,n),t.log("X-Last-Known-Byte: "+e),i.end=e?e:i.start-1,setTimeout(function(){s._send(n,i)},l)}else s.end(o.status);else i.retry=0,i.end==i.size-1?s.end(o.status):(t.log("X-Last-Known-Byte: "+e),e&&(i.end=e),i.file.FileAPIReadPosition=i.end,setTimeout(function(){s._send(n,i)},0));o=null}},i.start=i.end+1,i.end=Math.max(Math.min(i.start+n.chunkSize,i.size)-1,i.start);var f;(f="slice")in i.file||(f="mozSlice")in i.file||(f="webkitSlice")in i.file,o.setRequestHeader("Content-Range","bytes "+i.start+"-"+i.end+"/"+i.size),o.setRequestHeader("Content-Disposition","attachment; filename="+encodeURIComponent(i.name)),o.setRequestHeader("Content-Type",i.type||"application/octet-stream"),f=i.file[f](i.start,i.end+1),o.send(f),f=null}else if(o.upload&&o.upload.addEventListener("progress",t.throttle(function(e){n.progress(e,s,n)},100),!1),o.onreadystatechange=function(){if(s.status=o.status,s.statusText=o.statusText,s.readyState=o.readyState,4==o.readyState){for(var e in r)s["response"+e]=o["response"+e];o.onreadystatechange=null,s.end(o.status),o=null}},t.isArray(i))if(o.setRequestHeader("Content-Type","multipart/form-data; boundary=_"+t.expando),i=i.join("")+"--_"+t.expando+"--",o.sendAsBinary)o.sendAsBinary(i);else{var d=Array.prototype.map.call(i,function(e){return 255&e.charCodeAt(0)});o.send(new Uint8Array(d).buffer)}else o.send(i)}}},t.XHR=i}(window,FileAPI),function(e,t){"use strict";function n(e){return e>=0?e+"px":e}function a(e){var t,n=r.createElement("canvas"),a=!1;try{t=n.getContext("2d"),t.drawImage(e,0,0,1,1),a=255!=t.getImageData(0,0,1,1).data[4]}catch(i){}return a}var i=e.URL||e.webkitURL,r=e.document,o=e.navigator,s=o.getUserMedia||o.webkitGetUserMedia||o.mozGetUserMedia||o.msGetUserMedia,l=!!s;t.support.media=l;var u=function(e){this.video=e};u.prototype={isActive:function(){return!!this._active},start:function(e){var t,n,r=this,l=r.video,u=function(a){r._active=!a,clearTimeout(n),clearTimeout(t),e&&e(a,r)};s.call(o,{video:!0},function(e){r.stream=e,l.src=i.createObjectURL(e),t=setInterval(function(){a(l)&&u(null)},1e3),n=setTimeout(function(){u("timeout")},5e3),l.play()},u)},stop:function(){try{this._active=!1,this.video.pause(),this.stream.stop()}catch(e){}},shot:function(){return new c(this.video)}},u.get=function(e){return new u(e.firstChild)},u.publish=function(a,i,o){"function"==typeof i&&(o=i,i={}),i=t.extend({},{width:"100%",height:"100%",start:!0},i),a.jquery&&(a=a[0]);var s=function(e){if(e)o(e);else{var t=u.get(a);i.start?t.start(o):o(null,t)}};if(t.html5&&l){var c=r.createElement("video");c.style.width=n(i.width),c.style.height=n(i.height),e.jQuery?jQuery(a).empty():a.innerHTML="",a.appendChild(c),s()}else u.fallback(a,i,s)},u.fallback=function(e,t,n){n("not_support_camera")};var c=function(e){var n=e.nodeName?t.Image.toCanvas(e):e,a=t.Image(n);return a.type="image/png",a.width=n.width,a.height=n.height,a.size=4*n.width*n.height,a};u.Shot=c,t.Camera=u}(window,FileAPI),function(e,t,n){"use strict";var a=e.document,i=e.location,r=e.navigator;n.support.flash=function(){var t=r.mimeTypes,a=!1;if(r.plugins&&"object"==typeof r.plugins["Shockwave Flash"])a=r.plugins["Shockwave Flash"].description&&!(t&&t["application/x-shockwave-flash"]&&!t["application/x-shockwave-flash"].enabledPlugin);else try{a=!(!e.ActiveXObject||!new ActiveXObject("ShockwaveFlash.ShockwaveFlash"))}catch(o){n.log("Flash -- does not supported.")}return a&&/^file:/i.test(i)&&n.log("[warn] Flash does not work on `file:` protocol."),a}(),n.support.flash&&(0||!n.html5||!n.support.html5||n.cors&&!n.support.cors||n.media&&!n.support.media)&&function(){function o(e){return('<object id="#id#" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+(e.width||"100%")+'" height="'+(e.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="'+(e.width||"100%")+'" height="'+(e.height||"100%")+'" menu="false" wmode="transparent" type="application/x-shockwave-flash"></embed>'+"</object>").replace(/#(\w+)#/gi,function(t,n){return e[n]})}function s(e,t){if(e&&e.style){var n,a;for(n in t){a=t[n],"number"==typeof a&&(a+="px");try{e.style[n]=a}catch(i){}}}}function l(e,t){n.each(t,function(t,n){var a=e[n];e[n]=function(){return this.parent=a,t.apply(this,arguments)}})}function u(e){return e&&!e.flashId}function c(e){var t=e.wid=n.uid();return b._fn[t]=e,"FileAPI.Flash._fn."+t}function f(e){try{b._fn[e.wid]=null,delete b._fn[e.wid]}catch(t){}}function d(e,t){if(!w.test(e)){if(/^\.\//.test(e)||"/"!=e.charAt(0)){var n=i.pathname;n=n.substr(0,n.lastIndexOf("/")),e=(n+"/"+e).replace("/./","/")}"//"!=e.substr(0,2)&&(e="//"+i.host+e),w.test(e)||(e=i.protocol+e)}return t&&(e+=(/\?/.test(e)?"&":"?")+t),e}function p(e,t,i){function r(){try{var e=b.get(u);e.setImage(t)}catch(a){n.log('[err] FlashAPI.Preview.setImage -- can not set "base64":',a)}}var l,u=n.uid(),p=a.createElement("div"),h=10;for(l in e)p.setAttribute(l,e[l]),p[l]=e[l];s(p,e),e.width="100%",e.height="100%",p.innerHTML=o(n.extend({id:u,src:d(n.flashImageUrl,"r="+n.uid()),wmode:"opaque",flashvars:"scale="+e.scale+"&callback="+c(function m(){return f(m),--h>0&&r(),!0})},e)),i(!1,p),p=null}function h(e){return{id:e.id,name:e.name,matrix:e.matrix,flashId:e.flashId}}function m(t){var n=t.getBoundingClientRect(),i=a.body,r=(t&&t.ownerDocument).documentElement;return{top:n.top+(e.pageYOffset||r.scrollTop)-(r.clientTop||i.clientTop||0),left:n.left+(e.pageXOffset||r.scrollLeft)-(r.clientLeft||i.clientLeft||0),width:n.right-n.left,height:n.bottom-n.top}}var g=n.uid(),v=0,y={},w=/^https?:/i,b={_fn:{},init:function(){var e=a.body&&a.body.firstChild;if(e)do if(1==e.nodeType){n.log("FlashAPI.state: awaiting");var t=a.createElement("div");return t.id="_"+g,s(t,{top:1,right:1,width:5,height:5,position:"absolute",zIndex:1e6+""}),e.parentNode.insertBefore(t,e),b.publish(t,g),void 0}while(e=e.nextSibling);10>v&&setTimeout(b.init,50*++v)},publish:function(e,t,a){a=a||{},e.innerHTML=o({id:t,src:d(n.flashUrl,"r="+n.version),wmode:a.camera?"":"transparent",flashvars:"callback="+(a.onEvent||"FileAPI.Flash.onEvent")+"&flashId="+t+"&storeKey="+r.userAgent.match(/\d/gi).join("")+"_"+n.version+(b.isReady||(n.pingUrl?"&ping="+n.pingUrl:""))+"&timeout="+n.flashAbortTimeout+(a.camera?"&useCamera=1":"")},a)},ready:function(){n.log("FlashAPI.state: ready"),b.ready=n.F,b.isReady=!0,b.patch(),n.event.on(a,"mouseover",b.mouseover),n.event.on(a,"click",function(e){b.mouseover(e)&&(e.preventDefault?e.preventDefault():e.returnValue=!0)})},getEl:function(){return a.getElementById("_"+g)},getWrapper:function(e){do if(/js-fileapi-wrapper/.test(e.className))return e;while((e=e.parentNode)&&e!==a.body)},mouseover:function(e){var t=n.event.fix(e).target;if(/input/i.test(t.nodeName)&&"file"==t.type){var i=t.getAttribute(g),r=b.getWrapper(t);if(n.multiFlash){if("i"==i||"r"==i)return!1;if("p"!=i){t.setAttribute(g,"i");var o=a.createElement("div");if(!r)return n.log("[err] FlashAPI.mouseover: js-fileapi-wrapper not found"),void 0;
-s(o,{top:0,left:0,width:t.offsetWidth+100,height:t.offsetHeight+100,zIndex:1e6+"",position:"absolute"}),r.appendChild(o),b.publish(o,n.uid()),t.setAttribute(g,"p")}return!0}if(r){var l=m(r);s(b.getEl(),l),b.curInp=t}}else/object|embed/i.test(t.nodeName)||s(b.getEl(),{top:1,left:1,width:5,height:5})},onEvent:function(e){var t=e.type;if("ready"==t){try{b.getInput(e.flashId).setAttribute(g,"r")}catch(a){}return b.ready(),setTimeout(function(){b.mouseenter(e)},50),!0}"ping"===t?n.log("(flash -> js).ping:",[e.status,e.savedStatus],e.error):"log"===t?n.log("(flash -> js).log:",e.target):t in b&&setTimeout(function(){n.log("FlashAPI.event."+e.type+":",e),b[t](e)},1)},mouseenter:function(e){var t=b.getInput(e.flashId);if(t){b.cmd(e,"multiple",null!=t.getAttribute("multiple"));var a=[],i={};n.each((t.getAttribute("accept")||"").split(/,\s*/),function(e){n.accept[e]&&n.each(n.accept[e].split(" "),function(e){i[e]=1})}),n.each(i,function(e,t){a.push(t)}),b.cmd(e,"accept",a.length?a.join(",")+","+a.join(",").toUpperCase():"*")}},get:function(t){return a[t]||e[t]||a.embeds[t]},getInput:function(e){if(!n.multiFlash)return b.curInp;try{var t=b.getWrapper(b.get(e));if(t)return t.getElementsByTagName("input")[0]}catch(a){n.log('[err] Can not find "input" by flashId:',e,a)}},select:function(e){var i,r=b.getInput(e.flashId),o=n.uid(r),s=e.target.files;n.each(s,function(e){n.checkFileObj(e)}),y[o]=s,a.createEvent?(i=a.createEvent("Event"),i.files=s,i.initEvent("change",!0,!0),r.dispatchEvent(i)):t?t(r).trigger({type:"change",files:s}):(i=a.createEventObject(),i.files=s,r.fireEvent("onchange",i))},cmd:function(e,t,a,i){try{return n.log("(js -> flash)."+t+":",a),b.get(e.flashId||e).cmd(t,a)}catch(r){n.log("(js -> flash).onError:",r),i||setTimeout(function(){b.cmd(e,t,a,!0)},50)}},patch:function(){n.flashEngine=n.support.transform=!0,l(n,{getFiles:function(e,t,a){if(a)return n.filterFiles(n.getFiles(e),t,a),null;var i=n.isArray(e)?e:y[n.uid(e.target||e.srcElement||e)];return i?(t&&(t=n.getFilesFilter(t),i=n.filter(i,function(e){return t.test(e.name)})),i):this.parent.apply(this,arguments)},getInfo:function(e,t){if(u(e))this.parent.apply(this,arguments);else if(e.isShot)t(null,e.info={width:e.width,height:e.height});else{if(!e.__info){var a=e.__info=n.defer();b.cmd(e,"getFileInfo",{id:e.id,callback:c(function i(t,n){f(i),a.resolve(t,e.info=n)})})}e.__info.then(t)}}}),n.support.transform=!0,n.Image&&l(n.Image.prototype,{get:function(e,t){this.set({scaleMode:t||"noScale"}),this.parent(e)},_load:function(e,t){if(n.log("FlashAPI.Image._load:",e),u(e))this.parent.apply(this,arguments);else{var a=this;n.getInfo(e,function(n){t.call(a,n,e)})}},_apply:function(e,t){if(n.log("FlashAPI.Image._apply:",e),u(e))this.parent.apply(this,arguments);else{var a=this.getMatrix(e.info),i=t;b.cmd(e,"imageTransform",{id:e.id,matrix:a,callback:c(function r(o,s){n.log("FlashAPI.Image._apply.callback:",o),f(r),o?i(o):n.support.html5||n.support.dataURI&&!(s.length>3e4)?(a.filter&&(i=function(e,i){e?t(e):n.Image.applyFilter(i,a.filter,function(){t(e,this.canvas)})}),n.newImage("data:"+e.type+";base64,"+s,i)):p({width:a.deg%180?a.dh:a.dw,height:a.deg%180?a.dw:a.dh,scale:a.scaleMode},s,i)})})}},toData:function(e){var t=this.file,a=t.info,i=this.getMatrix(a);u(t)?this.parent.apply(this,arguments):("auto"==i.deg&&(i.deg=n.Image.exifOrientation[a&&a.exif&&a.exif.Orientation]||0),e.call(this,!t.info,{id:t.id,flashId:t.flashId,name:t.name,type:t.type,matrix:i}))}}),n.Image&&l(n.Image,{fromDataURL:function(e,t,a){!n.support.dataURI||e.length>3e4?p(n.extend({scale:"exactFit"},t),e.replace(/^data:[^,]+,/,""),function(e,t){a(t)}):this.parent(e,t,a)}}),n.Camera.fallback=function(e,t,a){var i=n.uid();n.log("FlashAPI.Camera.publish: "+i),b.publish(e,i,n.extend(t,{camera:!0,onEvent:c(function r(e){"camera"==e.type&&(f(r),e.error?(n.log("FlashAPI.Camera.publish.error: "+e.error),a(e.error)):(n.log("FlashAPI.Camera.publish.success: "+i),a(null)))})}))},l(n.Camera.prototype,{_id:function(){return this.video.id},start:function(e){var t=this;b.cmd(this._id(),"camera.on",{callback:c(function a(i){f(a),i.error?(n.log("FlashAPI.camera.on.error: "+i.error),e(i.error,t)):(n.log("FlashAPI.camera.on.success: "+t._id()),t.active=!0,e(null,t))})})},stop:function(){this.active=!1,b.cmd(this._id(),"camera.off")},shot:function(){n.log("FlashAPI.Camera.shot:",this._id());var e=b.cmd(this._id(),"shot",{});return e.type="image/png",e.flashId=this._id(),e.isShot=!0,new n.Camera.Shot(e)}}),l(n.Form.prototype,{toData:function(e){for(var t=this.items,a=t.length;a--;)if(t[a].file&&u(t[a].blob))return this.parent.apply(this,arguments);n.log("FlashAPI.Form.toData"),e(t)}}),l(n.XHR.prototype,{_send:function(e,t){if(t.nodeName||t.append&&n.support.html5||n.isArray(t)&&"string"==typeof t[0])return this.parent.apply(this,arguments);var a,i,r={},o={},s=this;if(n.each(t,function(e){e.file?(o[e.name]=e=h(e.blob),i=e.id,a=e.flashId):r[e.name]=e.blob}),i||(a=g),!a)return n.log("[err] FlashAPI._send: flashId -- undefined"),this.parent.apply(this,arguments);n.log("FlashAPI.XHR._send: "+a+" -> "+i,o),s.xhr={headers:{},abort:function(){b.cmd(a,"abort",{id:i})},getResponseHeader:function(e){return this.headers[e]},getAllResponseHeaders:function(){return this.headers}};var l=n.queue(function(){b.cmd(a,"upload",{url:d(e.url),data:r,files:i?o:null,headers:e.headers||{},callback:c(function t(a){var i=a.type,r=a.result;n.log("FlashAPI.upload."+i+":",a),"progress"==i?(a.loaded=Math.min(a.loaded,a.total),a.lengthComputable=!0,e.progress(a)):"complete"==i?(f(t),"string"==typeof r&&(s.responseText=r.replace(/%22/g,'"').replace(/%5c/g,"\\").replace(/%26/g,"&").replace(/%25/g,"%")),s.end(a.status||200)):("abort"==i||"error"==i)&&(s.end(a.status||0,a.message),f(t))})})});n.each(o,function(e){l.inc(),n.getInfo(e,l.next)}),l.check()}})}};n.Flash=b,n.newImage("data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==",function(e,t){n.support.dataURI=!(1!=t.width||1!=t.height),b.init()})}()}(window,window.jQuery,FileAPI),function(e){"use strict";e(FileAPI)}(function(e){"use strict";if(window.navigator&&window.navigator.platform&&/iP(hone|od|ad)/.test(window.navigator.platform)){var t=e.renderImageToCanvas;e.detectSubsampling=function(e){var t,n;return e.width*e.height>1048576?(t=document.createElement("canvas"),t.width=t.height=1,n=t.getContext("2d"),n.drawImage(e,-e.width+1,0),0===n.getImageData(0,0,1,1).data[3]):!1},e.detectVerticalSquash=function(e,t){var n,a,i,r,o,s=e.naturalHeight||e.height,l=document.createElement("canvas"),u=l.getContext("2d");for(t&&(s/=2),l.width=1,l.height=s,u.drawImage(e,0,0),n=u.getImageData(0,0,1,s).data,a=0,i=s,r=s;r>a;)o=n[4*(r-1)+3],0===o?i=r:a=r,r=i+a>>1;return r/s||1},e.renderImageToCanvas=function(n,a,i,r,o,s,l,u,c,f){if("image/jpeg"===a._type){var d,p,h,m,g=n.getContext("2d"),v=document.createElement("canvas"),y=1024,w=v.getContext("2d");if(v.width=y,v.height=y,g.save(),d=e.detectSubsampling(a),d&&(i/=2,r/=2,o/=2,s/=2),p=e.detectVerticalSquash(a,d),d||1!==p){for(r*=p,c=Math.ceil(y*c/o),f=Math.ceil(y*f/s/p),u=0,m=0;s>m;){for(l=0,h=0;o>h;)w.clearRect(0,0,y,y),w.drawImage(a,i,r,o,s,-h,-m,o,s),g.drawImage(v,0,0,y,y,l,u,c,f),h+=y,l+=c;m+=y,u+=f}return g.restore(),n}}return t(n,a,i,r,o,s,l,u,c,f)}}}),function(e){"use strict";var t=e.HTMLCanvasElement&&e.HTMLCanvasElement.prototype,n=e.Blob&&function(){try{return Boolean(new Blob)}catch(e){return!1}}(),a=n&&e.Uint8Array&&function(){try{return 100===new Blob([new Uint8Array(100)]).size}catch(e){return!1}}(),i=e.BlobBuilder||e.WebKitBlobBuilder||e.MozBlobBuilder||e.MSBlobBuilder,r=(n||i)&&e.atob&&e.ArrayBuffer&&e.Uint8Array&&function(e){var t,r,o,s,l,u;for(t=e.split(",")[0].indexOf("base64")>=0?atob(e.split(",")[1]):decodeURIComponent(e.split(",")[1]),r=new ArrayBuffer(t.length),o=new Uint8Array(r),s=0;t.length>s;s+=1)o[s]=t.charCodeAt(s);return l=e.split(",")[0].split(":")[1].split(";")[0],n?new Blob([a?o:r],{type:l}):(u=new i,u.append(r),u.getBlob(l))};e.HTMLCanvasElement&&!t.toBlob&&(t.mozGetAsFile?t.toBlob=function(e,n,a){a&&t.toDataURL&&r?e(r(this.toDataURL(n,a))):e(this.mozGetAsFile("blob",n))}:t.toDataURL&&r&&(t.toBlob=function(e,t,n){e(r(this.toDataURL(t,n)))})),e.dataURLtoBlob=r}(window),"function"==typeof define&&define.amd&&define("FileAPI",[],function(){return FileAPI});
+!function(a,b){"use strict";function c(a,b,c,d,e){var f={type:c.type||c,target:a,result:d};R(f,e),b(f)}function d(a){return u&&!!u.prototype["readAs"+a]}function e(a,e,f,g){if(X.isFile(a)&&d(f)){var h=new u;S(h,L,function j(b){var d=b.type;"progress"==d?c(a,e,b,b.target.result,{loaded:b.loaded,total:b.total}):"loadend"==d?(T(h,L,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,b){if(!a.type&&0===a.size%4096&&a.size<=102400)if(u)try{var c=new u;U(c,L,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 g(a){var b;return a.getAsEntry?b=a.getAsEntry():a.webkitGetAsEntry&&(b=a.webkitGetAsEntry()),b}function h(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){X.afor(a,function(a,c){h(c,function(c,e){c?X.log(c):d=d.concat(e),a?a():b(!1,d)})})},function(a){b("directory_reader: "+a)})}else h(g(a),b);else b("invalid entry")}function i(a){var b={};return Q(a,function(a,c){a&&"object"==typeof a&&void 0===a.nodeType&&(a=R({},a)),b[c]=a}),b}function j(a){return F.test(a&&a.tagName)}function k(a){return(a.originalEvent||a||"").dataTransfer||{}}function l(a){var b;for(b in a)if(a.hasOwnProperty(b)&&!(a[b]instanceof Object||"overlay"===b||"filter"===b))return!0;return!1}var m=1,n=function(){},o=a.document,p=o.doctype||{},q=a.navigator.userAgent,r=a.createObjectURL&&a||a.URL&&URL.revokeObjectURL&&URL||a.webkitURL&&webkitURL,s=a.Blob,t=a.File,u=a.FileReader,v=a.FormData,w=a.XMLHttpRequest,x=a.jQuery,y=!(!(t&&u&&(a.Uint8Array||v||w.prototype.sendAsBinary))||/safari\//i.test(q)&&!/chrome\//i.test(q)&&/windows/i.test(q)),z=y&&"withCredentials"in new w,A=y&&!!s&&!!(s.prototype.webkitSlice||s.prototype.mozSlice||s.prototype.slice),B=a.dataURLtoBlob,C=/img/i,D=/canvas/i,E=/img|canvas/i,F=/input/i,G=/^data:[^,]+,/,H=a.Math,I=function(b){return b=new a.Number(H.pow(1024,b)),b.from=function(a){return H.round(a*this)},b},J={},K=[],L="abort progress error load loadend",M="status statusText readyState response responseXML responseText responseBody".split(" "),N="currentTarget",O="preventDefault",P=function(a){return a&&"length"in a},Q=function(a,b,c){if(a)if(P(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)},R=function(a){for(var b=arguments,c=1,d=function(b,c){a[c]=b};c<b.length;c++)Q(b[c],d);return a},S=function(a,b,c){if(a){var d=X.uid(a);J[d]||(J[d]={}),Q(b.split(/\s+/),function(b){x?x.event.add(a,b,c):(J[d][b]||(J[d][b]=[]),J[d][b].push(c),a.addEventListener?a.addEventListener(b,c,!1):a.attachEvent?a.attachEvent("on"+b,c):a["on"+b]=c)})}},T=function(a,b,c){if(a){var d=X.uid(a),e=J[d]||{};Q(b.split(/\s+/),function(b){if(x)x.event.remove(a,b,c);else{for(var d=e[b]||[],f=d.length;f--;)if(d[f]===c){d.splice(f,1);break}a.addEventListener?a.removeEventListener(b,c,!1):a.detachEvent?a.detachEvent("on"+b,c):a["on"+b]=null}})}},U=function(a,b,c){S(a,b,function d(e){T(a,b,d),c(e)})},V=function(b){return b.target||(b.target=a.event&&a.event.srcElement||o),3===b.target.nodeType&&(b.target=b.target.parentNode),b},W=function(a){var b=o.createElement("input");return b.setAttribute("type","file"),a in b},X={version:"2.0.1",cors:!1,html5:!0,media:!1,formData:!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+"]":"")},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"},chunkSize:0,chunkUploadRetry:0,chunkNetworkDownRetryTimeout:2e3,KB:I(1),MB:I(2),GB:I(3),TB:I(4),expando:"fileapi"+(new Date).getTime(),uid:function(a){return a?a[X.expando]=a[X.expando]||X.uid():(++m,X.expando+m)},log:function(){X.debug&&a.console&&console.log&&(console.log.apply?console.log.apply(console,arguments):console.log([].join.call(arguments," ")))},newImage:function(a,b){var c=o.createElement("img");return b&&X.event.one(c,"error load",function(a){b("error"==a.type,c),c=null}),c.src=a,c},getXHR:function(){var b;if(w)b=new w;else if(a.ActiveXObject)try{b=new ActiveXObject("MSXML2.XMLHttp.3.0")}catch(c){b=new ActiveXObject("Microsoft.XMLHTTP")}return b},isArray:P,support:{dnd:z&&"ondrop"in o.createElement("div"),cors:z,html5:y,chunked:A,dataURI:!0,accept:W("accept"),multiple:W("multiple")},event:{on:S,off:T,one:U,fix:V},throttle:function(b,c){var d,e;return function(){e=arguments,d||(b.apply(a,e),d=setTimeout(function(){d=0,b.apply(a,e)},c))}},F:function(){},parseJSON:function(b){var c;return c=a.JSON&&JSON.parse?JSON.parse(b):new Function("return ("+b.replace(/([\r\n])/g,"\\$1")+");")()},trim:function(a){return a=String(a),a.trim?a.trim():a.replace(/^\s+|\s+$/g,"")},defer:function(){var a,c,d=[],e={resolve:function(b,f){for(e.resolve=n,c=b||!1,a=f;f=d.shift();)f(c,a)},then:function(e){c!==b?e(c,a):d.push(e)}};return e},queue:function(a){var b=0,c=0,d=!1,e=!1,f={inc:function(){c++},next:function(){b++,setTimeout(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:Q,afor:function(a,b){var c=0,d=a.length;P(a)&&d--?!function e(){b(d!=c&&e,a[c],c++)}():b(!1)},extend:R,isFile:function(a){return y&&a&&a instanceof t},isCanvas:function(a){return a&&D.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){X.isCanvas(a)?c(a,b,"load",X.toDataURL(a)):e(a,b,"DataURL")},readAsBinaryString:function(a,b){d("BinaryString")?e(a,b,"BinaryString"):e(a,function(a){if("load"==a.type)try{a.result=X.toBinaryString(a.result)}catch(c){a.type="error",a.message=c.toString()}b(a)},"DataURL")},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(X.toDataURL(b).replace(G,""))},readAsImage:function(a,d,e){if(X.isFile(a))if(r){var f=r.createObjectURL(a);f===b?c(a,d,"error"):X.readAsImage(f,d,e)}else X.readAsDataURL(a,function(b){"load"==b.type?X.readAsImage(b.result,d,e):(e||"error"==b.type)&&c(a,d,b,null,{loaded:b.loaded,total:b.total})});else if(X.isCanvas(a))c(a,d,"load",a);else if(C.test(a.nodeName))if(a.complete)c(a,d,"load",a);else{var g="error abort load";U(a,g,function i(b){"load"==b.type&&r&&r.revokeObjectURL(a.src),T(a,g,i),c(a,d,b,a)})}else if(a.iframe)c(a,d,{type:"error"});else{var h=X.newImage(a.dataURL||a);X.readAsImage(h,d,e)}},checkFileObj:function(a){var b={},c=X.accept;return"object"==typeof a?b=a:b.name=(a+"").split(/\\|\//g).pop(),null==b.type&&(b.type=b.name.split(".").pop()),Q(c,function(a,c){a=new RegExp(a.replace(/\s/g,"|"),"i"),(a.test(b.type)||X.ext2mime[b.type])&&(b.type=X.ext2mime[b.type]||c.split("/")[0]+"/"+b.type)}),b},getDropFiles:function(a,b){var c=[],d=k(a),e=P(d.items)&&d.items[0]&&g(d.items[0]),i=X.queue(function(){b(c)});Q((e?d.items:d.files)||[],function(a){i.inc();try{e?h(a,function(a,b){a?X.log("[err] getDropFiles:",a):c.push.apply(c,b),i.next()}):f(a,function(b){b&&c.push(a),i.next()})}catch(b){i.next(),X.log("[err] getDropFiles: ",b)}}),i.check()},getFiles:function(a,b,c){var d=[];return c?(X.filterFiles(X.getFiles(a),b,c),null):(a.jquery&&(a.each(function(){d=d.concat(X.getFiles(this))}),a=d,d=[]),"string"==typeof b&&(b=X.getFilesFilter(b)),a.originalEvent?a=V(a.originalEvent):a.srcElement&&(a=V(a)),a.dataTransfer?a=a.dataTransfer:a.target&&(a=a.target),a.files?(d=a.files,y||(d[0].blob=a,d[0].iframe=!0)):!y&&j(a)?X.trim(a.value)&&(d=[X.checkFileObj(a.value)],d[0].blob=a,d[0].iframe=!0):P(a)&&(d=a),X.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=K.concat();X.isFile(a)?!function e(){var f=d.shift();f?f.test(a.type)?f(a,function(a,d){a?b(a):(R(c,d),e())}):e():b(!1,c)}():b("not_support_info",c)},addInfoReader:function(a,b){b.test=function(b){return a.test(b)},K.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(),X.getInfo(d,function(a,c){(b(d,a?!1:c)?f:g).push(d),h()})):c(f,g)}()}else c([],a)},upload:function(a){a=R({prepare:X.F,beforeupload:X.F,upload:X.F,fileupload:X.F,fileprogress:X.F,filecomplete:X.F,progress:X.F,complete:X.F,pause:X.F,imageOriginal:!0,chunkSize:X.chunkSize,chunkUpoloadRetry:X.chunkUploadRetry},a),a.imageAutoOrientation&&!a.imageTransform&&(a.imageTransform={rotate:"auto"});var b,c=new X.XHR(a),d=this._getFilesDataArray(a.files),e=this,f=0,g=0,h=!1;return Q(d,function(a){f+=a.size}),c.files=[],Q(d,function(a){c.files.push(a.file)}),c.total=f,c.loaded=0,c.filesLeft=d.length,a.beforeupload(c,a),b=function(){var j=d.shift(),k=j&&j.file,l=!1,m=i(a);c.filesLeft=d.length,k&&k.name===X.expando&&(k=null,X.log("[warn] FileAPI.upload() — called without files")),("abort"!=c.statusText||c.current)&&j?(h=!1,c.currentFile=k,k&&a.prepare(k,m),e._getFormData(m,j,function(h){g||a.upload(c,a);var i=new X.XHR(R({},m,{upload:k?function(){a.fileupload(k,i,m)}:n,progress:k?function(b){l||(a.fileprogress({type:"progress",total:j.total=b.total,loaded:j.loaded=b.loaded},k,i,m),a.progress({type:"progress",total:f,loaded:c.loaded=0|g+j.size*(b.loaded/b.total)},k,i,m))}:n,complete:function(d){l=!0,Q(M,function(a){c[a]=i[a]}),k&&(j.loaded=j.total,this.progress(j),g+=j.size,c.loaded=g,a.filecomplete(d,i,k,m)),b.call(e)}}));c.abort=function(a){a||(d.length=0),this.current=a,i.abort()},i.send(h)})):(a.complete(200==c.status||201==c.status?!1:c.statusText||"error",c,a),h=!0)},setTimeout(b,0),c.append=function(a,g){a=X._getFilesDataArray([].concat(a)),Q(a,function(a){f+=a.size,c.files.push(a.file),g?d.unshift(a):d.push(a)}),c.statusText="",h&&b.call(e)},c.remove=function(a){for(var b,c=d.length;c--;)d[c].file==a&&(b=d.splice(c,1),f-=b.size);return b},c},_getFilesDataArray:function(a){var b=[],c={};if(j(a)){var d=X.getFiles(a);c[a.name||"file"]=null!==a.getAttribute("multiple")?d:d[0]}else P(a)&&j(a[0])?Q(a,function(a){c[a.name||"file"]=X.getFiles(a)}):c=a;return Q(c,function e(a,c){P(a)?Q(a,function(a){e(a,c)}):a&&(a.name||a.image)&&b.push({name:c,file:a,size:a.size,total:a.size,loaded:0})}),b.length||b.push({file:{name:X.expando}}),b},_getFormData:function(a,b,c){var d=b.file,e=b.name,f=d.name,g=d.type,h=X.support.transform&&a.imageTransform,i=new X.Form,j=X.queue(function(){c(i)}),k=h&&l(h),m=X.postNameConcat;!function n(b){b.image?(j.inc(),b.toData(function(a,b){f=f||(new Date).getTime()+".png",n(b),j.next()})):X.Image&&h&&(/^image/.test(b.type)||E.test(b.nodeName))?(j.inc(),k&&(h=[h]),X.Image.transform(b,h,a.imageAutoOrientation,function(c,d){if(k&&!c)B||X.flashEngine||(i.multipart=!0),i.append(e,d[0],f,h[0].type||g);else{var l=0;c||Q(d,function(a,b){B||X.flashEngine||(i.multipart=!0),h[b].postName||(l=1),i.append(h[b].postName||m(e,b),a,f,h[b].type||g)}),(c||a.imageOriginal)&&i.append(m(e,l?"original":null),b,f,g)}j.next()})):f!==X.expando&&i.append(e,b,f)}(d),Q(a.data,function o(a,b){"object"==typeof a?Q(a,function(a,c){o(a,m(b,c))}):i.append(b,a)}),j.check()},reset:function(a,b){var c,d;return x?(d=x(a).clone(!0).insertBefore(a).val("")[0],b||x(a).remove()):(c=a.parentNode,d=c.insertBefore(a.cloneNode(!0),a),d.value="",b||c.removeChild(a),Q(J[X.uid(a)],function(b,c){Q(b,function(b){T(a,c,b),S(d,c,b)})})),d},load:function(a,b){var c=X.getXHR();return c?(c.open("GET",a,!0),c.overrideMimeType&&c.overrideMimeType("text/plain; charset=x-user-defined"),S(c,"progress",function(a){a.lengthComputable&&b({type:a.type,loaded:a.loaded,total:a.total},c)}),c.onreadystatechange=function(){if(4==c.readyState)if(c.onreadystatechange=null,200==c.status){a=a.split("/");var d={name:a[a.length-1],size:c.getResponseHeader("Content-Length"),type:c.getResponseHeader("Content-Type")};d.dataURL="data:"+d.type+";base64,"+X.encode64(c.responseBody||c.responseText),b({type:"load",result:d},c)}else b({type:"error"},c)},c.send(null)):b({type:"error"}),c},encode64:function(a){var b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",c="",d=0;for("string"!=typeof a&&(a=String(a));d<a.length;){var e,f,g=255&a.charCodeAt(d++),h=255&a.charCodeAt(d++),i=255&a.charCodeAt(d++),j=g>>2,k=(3&g)<<4|h>>4;isNaN(h)?e=f=64:(e=(15&h)<<2|i>>6,f=isNaN(i)?64:63&i),c+=b.charAt(j)+b.charAt(k)+b.charAt(e)+b.charAt(f)}return c}};X.addInfoReader(/^image/,function(a,b){if(!a.__dimensions){var c=a.__dimensions=X.defer();X.readAsImage(a,function(a){var b=a.target;c.resolve("load"==a.type?!1:"error",{width:b.width,height:b.height}),b=null})}a.__dimensions.then(b)}),X.event.dnd=function(a,b,c){var d,e;c||(c=b,b=X.F),u?(S(a,"dragenter dragleave dragover",function(a){for(var c=k(a).types,f=c&&c.length,g=!1;f--;)if(~c[f].indexOf("File")){a[O](),e!==a.type&&(e=a.type,"dragleave"!=e&&b.call(a[N],!0,a),g=!0);break}g&&(clearTimeout(d),d=setTimeout(function(){b.call(a[N],"dragleave"!=e,a)},50))}),S(a,"drop",function(a){a[O](),e=0,b.call(a[N],!1,a),X.getDropFiles(a,function(b){c.call(a[N],b,a)})})):X.log("Drag'n'Drop -- not supported")},X.event.dnd.off=function(a,b,c){T(a,"dragenter dragleave dragover",b),T(a,"drop",c)},x&&!x.fn.dnd&&(x.fn.dnd=function(a,b){return this.each(function(){X.event.dnd(this,a,b)})},x.fn.offdnd=function(a,b){return this.each(function(){X.event.dnd.off(this,a,b)})}),a.FileAPI=R(X,a.FileAPI),X.log("FileAPI: "+X.version),X.log("protocol: "+a.location.protocol),X.log("doctype: ["+p.name+"] "+p.publicId+" "+p.systemId),Q(o.getElementsByTagName("meta"),function(a){/x-ua-compatible/i.test(a.getAttribute("http-equiv"))&&X.log("meta.http-equiv: "+a.getAttribute("content"))}),X.flashUrl||(X.flashUrl=X.staticPath+"FileAPI.flash.swf"),X.flashImageUrl||(X.flashImageUrl=X.staticPath+"FileAPI.flash.image.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.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},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"string"==typeof b&&(c=b,b=a),this.set({dw:a,dh:b,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(){c(!1,h)}),v=a.renderImageToCanvas;for(b._type=this.file.type;e(p/n,q/o)>2;)p=0|p/2+.5,q=0|q/2+.5,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(h,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},_trans:function(a){this._load(this.file,function(b,c){b?a(b):this._apply(c,a)})},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")},toData:function(a){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.type):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(a,b,c,d,e,f,g,h,i,j){return a.getContext("2d").drawImage(b,c,d,e,f,g,h,i,j),a},a.support.canvas=a.support.transform=h,a.Image=d}(FileAPI,document),function(a,b){"use strict";function c(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 d=b.document,e=b.FormData,f=function(){this.items=[]},g=b.encodeURIComponent;f.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(d.createDocumentFragment(),b,function(b,c){var e,f=b.blob;b.file?(a.reset(f,!0),f.name=b.name,c.appendChild(f)):(e=d.createElement("input"),e.name=b.name,e.type="hidden",e.value=f,c.appendChild(e))})},toPlainData:function(a){this._to({},a,function(a,b,d){a.file&&(b.type=a.file),a.blob.toBlob?(d.inc(),c(a,function(a,c){b.name=a.name,b.file=c,b.size=c.length,b.type=a.type,d.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(g(a.name)+"="+g(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,d){a.blob&&a.blob.toBlob?(d.inc(),c(a,function(a,c){b.append(a.name,c,a.file),d.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,d,e){d.inc(),c(a,function(a,c){b.push("--_"+e+('\r\nContent-Disposition: form-data; name="'+a.name+'"'+(a.file?'; filename="'+g(a.file)+'"':"")+(a.file?"\r\nContent-Type: "+(a.type||"application/octet-stream"):"")+"\r\n\r\n"+(a.file?c:g(c))+"\r\n")),d.next()},!0)},a.expando)}},a.Form=f}(FileAPI,window),function(a,b){"use strict";var c=function(){},d=a.document,e=function(a){this.uid=b.uid(),this.xhr={abort:c,getResponseHeader:c,getAllResponseHeaders:c},this.options=a},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.options;f.end=f.abort=c,f.status=d,e&&(f.statusText=e),b.log("xhr.end:",d,e),g.complete(200==d||201==d?!1:f.statusText||"unknown",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){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><input value="'+i+'" name="callback" type="hidden"/></form>',h.xhr.abort=function(){var a=g.getElementsByTagName("iframe")[0];if(a)try{a.stop?a.stop():a.contentWindow.stop?a.contentWindow.stop():a.contentWindow.document.execCommand("Stop")}catch(b){}g=null};var k=g.getElementsByTagName("form")[0];k.appendChild(e),b.log(k.parentNode.innerHTML),d.body.appendChild(g),h.xhr.node=g,a[i]=function(a,b,c){h.readyState=4,h.responseText=c,h.end(a,b),g=null},h.readyState=2,k.submit(),k=null}else{if(this.xhr&&this.xhr.aborted)return b.log("Error: already aborted"),void 0;if(g=h.xhr=b.getXHR(),e.params&&(j+=(j.indexOf("?")<0?"?":"&")+e.params.join("&")),g.open("POST",j,!0),b.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",function(a){e.retry||c.progress({type:a.type,total:e.size,loaded:e.start+a.loaded,totalSize:e.size},h,c)},!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){for(var d in f)h["response"+d]=g["response"+d];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 i=g.status?0:b.chunkNetworkDownRetryTimeout;c.pause(e.file,c),b.log("X-Last-Known-Byte: "+a),e.end=a?a:e.start-1,setTimeout(function(){h._send(c,e)},i)}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 l;(l="slice")in e.file||(l="mozSlice")in e.file||(l="webkitSlice")in e.file,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"),l=e.file[l](e.start,e.end+1),g.send(l),l=null}else if(g.upload&&g.upload.addEventListener("progress",b.throttle(function(a){c.progress(a,h,c)},100),!1),g.onreadystatechange=function(){if(h.status=g.status,h.statusText=g.statusText,h.readyState=g.readyState,4==g.readyState){for(var a in f)h["response"+a]=g["response"+a];g.onreadystatechange=null,h.end(g.status),g=null}},b.isArray(e))if(g.setRequestHeader("Content-Type","multipart/form-data; boundary=_"+b.expando),e=e.join("")+"--_"+b.expando+"--",g.sendAsBinary)g.sendAsBinary(e);else{var m=Array.prototype.map.call(e,function(a){return 255&a.charCodeAt(0)});g.send(new Uint8Array(m).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=4*c.width*c.height,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,h=[];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 i(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 j(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 k(a,b){g(b,function(b,c){var d=a[c];a[c]=function(){return this.parent=d,b.apply(this,arguments)}})}function l(a){return a&&!a.flashId}function m(a){var b=a.wid=c.uid();return w._fn[b]=a,"FileAPI.Flash._fn."+b}function n(a){try{w._fn[a.wid]=null,delete w._fn[a.wid]}catch(b){}}function o(a,b){if(!v.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),v.test(a)||(a=e.protocol+a)}return b&&(a+=(/\?/.test(a)?"&":"?")+b),a}function p(a,b,e){function f(){try{var a=w.get(h);a.setImage(b)}catch(d){c.log('[err] FlashAPI.Preview.setImage -- can not set "base64":',d)}}var g,h=c.uid(),k=d.createElement("div"),l=10;for(g in a)k.setAttribute(g,a[g]),k[g]=a[g];j(k,a),a.width="100%",a.height="100%",k.innerHTML=i(c.extend({id:h,src:o(c.flashImageUrl,"r="+c.uid()),wmode:"opaque",flashvars:"scale="+a.scale+"&callback="+m(function p(){return n(p),--l>0&&f(),!0})},a)),e(!1,k),k=null}function q(a){return{id:a.id,name:a.name,matrix:a.matrix,flashId:a.flashId}}function r(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 s=c.uid(),t=0,u={},v=/^https?:/i,w={_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="_"+s,j(b,{top:1,right:1,width:5,height:5,position:"absolute",zIndex:1e6+""}),a.parentNode.insertBefore(b,a),w.publish(b,s),void 0}while(a=a.nextSibling);10>t&&setTimeout(w.init,50*++t)},publish:function(a,b,d){d=d||{},a.innerHTML=i({id:b,src:o(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+(w.isReady||(c.pingUrl?"&ping="+c.pingUrl:""))+"&timeout="+c.flashAbortTimeout+(d.camera?"&useCamera=1":"")},d)},ready:function(){c.log("FlashAPI.state: ready"),w.ready=c.F,w.isReady=!0,w.patch(),c.event.on(d,"mouseover",w.mouseover),c.event.on(d,"click",function(a){w.mouseover(a)&&(a.preventDefault?a.preventDefault():a.returnValue=!0)})},getEl:function(){return d.getElementById("_"+s)},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(s),f=w.getWrapper(b);if(c.multiFlash){if("i"==e||"r"==e)return!1;if("p"!=e){b.setAttribute(s,"i");var g=d.createElement("div");if(!f)return c.log("[err] FlashAPI.mouseover: js-fileapi-wrapper not found"),void 0;
+j(g,{top:0,left:0,width:b.offsetWidth+100,height:b.offsetHeight+100,zIndex:1e6+"",position:"absolute"}),f.appendChild(g),w.publish(g,c.uid()),b.setAttribute(s,"p")}return!0}if(f){var h=r(f);j(w.getEl(),h),w.curInp=b}}else/object|embed/i.test(b.nodeName)||j(w.getEl(),{top:1,left:1,width:5,height:5})},onEvent:function(a){var b=a.type;if("ready"==b){try{w.getInput(a.flashId).setAttribute(s,"r")}catch(d){}return w.ready(),setTimeout(function(){w.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 w&&setTimeout(function(){c.log("FlashAPI.event."+a.type+":",a),w[b](a)},1)},mouseenter:function(a){var b=w.getInput(a.flashId);if(b){w.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)}),w.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 w.curInp;try{var b=w.getWrapper(w.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=w.getInput(a.flashId),h=c.uid(f),i=a.target.files;g(i,function(a){c.checkFileObj(a)}),u[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),w.get(a.flashId||a).cmd(b,d)}catch(f){c.log("(js -> flash).onError:",f),e||setTimeout(function(){w.cmd(a,b,d,!0)},50)}},patch:function(){c.flashEngine=c.support.transform=!0,k(c,{getFiles:function(a,b,d){if(d)return c.filterFiles(c.getFiles(a),b,d),null;var e=c.isArray(a)?a:u[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(l(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();w.cmd(a,"getFileInfo",{id:a.id,callback:m(function e(b,c){n(e),d.resolve(b,a.info=c)})})}a.__info.then(b)}}}),c.support.transform=!0,c.Image&&k(c.Image.prototype,{get:function(a,b){this.set({scaleMode:b||"noScale"}),this.parent(a)},_load:function(a,b){if(c.log("FlashAPI.Image._load:",a),l(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),l(a))this.parent.apply(this,arguments);else{var d=this.getMatrix(a.info),e=b;w.cmd(a,"imageTransform",{id:a.id,matrix:d,callback:m(function f(g,h){c.log("FlashAPI.Image._apply.callback:",g),n(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)):p({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);l(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&&k(c.Image,{fromDataURL:function(a,b,d){!c.support.dataURI||a.length>3e4?p(c.extend({scale:"exactFit"},b),a.replace(/^data:[^,]+,/,""),function(a,b){d(b)}):this.parent(a,b,d)}}),c.Camera.fallback=function(a,b,d){var e=c.uid();c.log("FlashAPI.Camera.publish: "+e),w.publish(a,e,c.extend(b,{camera:!0,onEvent:m(function f(a){"camera"==a.type&&(n(f),a.error?(c.log("FlashAPI.Camera.publish.error: "+a.error),d(a.error)):(c.log("FlashAPI.Camera.publish.success: "+e),d(null)))})}))},g(h,function(a){c.Camera.fallback.apply(c.Camera,a)}),h=[],k(c.Camera.prototype,{_id:function(){return this.video.id},start:function(a){var b=this;w.cmd(this._id(),"camera.on",{callback:m(function d(e){n(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,w.cmd(this._id(),"camera.off")},shot:function(){c.log("FlashAPI.Camera.shot:",this._id());var a=w.cmd(this._id(),"shot",{});return a.type="image/png",a.flashId=this._id(),a.isShot=!0,new c.Camera.Shot(a)}}),k(c.Form.prototype,{toData:function(a){for(var b=this.items,d=b.length;d--;)if(b[d].file&&l(b[d].blob))return this.parent.apply(this,arguments);c.log("FlashAPI.Form.toData"),a(b)}}),k(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=q(a.blob),e=a.id,d=a.flashId):f[a.name]=a.blob}),e||(d=s),!d)return c.log("[err] FlashAPI._send: flashId -- undefined"),this.parent.apply(this,arguments);c.log("FlashAPI.XHR._send: "+d+" -> "+e,h),i.xhr={headers:{},abort:function(){w.cmd(d,"abort",{id:e})},getResponseHeader:function(a){return this.headers[a]},getAllResponseHeaders:function(){return this.headers}};var j=c.queue(function(){w.cmd(d,"upload",{url:o(a.url),data:f,files:e?h:null,headers:a.headers||{},callback:m(function b(d){var e=d.type,f=d.result;c.log("FlashAPI.upload."+e+":",d),"progress"==e?(d.loaded=Math.min(d.loaded,d.total),d.lengthComputable=!0,a.progress(d)):"complete"==e?(n(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),n(b))})})});g(h,function(a){j.inc(),c.getInfo(a,j.next)}),j.check()}})}};c.Camera.fallback=function(){h.push(arguments)},c.Flash=w,c.newImage("data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==",function(a,b){c.support.dataURI=!(1!=b.width||1!=b.height),w.init()})}()}(window,window.jQuery,FileAPI),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){"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"==typeof define&&define.amd&&define("FileAPI",[],function(){return FileAPI});
View
96 examples/webcam.html
@@ -77,52 +77,56 @@
<script>
(function (){
FileAPI.Camera.publish(box, { width: 320, height: 240 }, function (err, cam){
- readyBox.style.display = '';
-
- FileAPI.event.on(startBtn, 'click', function (){
- cam.start();
- });
-
- FileAPI.event.on(stopBtn, 'click', function (){
- cam.stop();
- });
-
- FileAPI.event.on(shotBtn, 'click', function (){
- if( cam.isActive() ){
- var shot = cam.shot();
-
- shot
- .clone()
- .preview(100, 100)
- .get(function (err, img){
- img.style.marginRight = '5px';
- shots.insertBefore(img, shots.firstChild);
- })
- ;
-
- var file = shot
- .preview(200, 200)
- .overlay({
- x: 5
- , y: 5
- , src: '../statics/watermark.png'
- , rel: FileAPI.Image.RIGHT_TOP
- })
- ;
-
- FileAPI.upload({
- url: 'http://rubaxa.org/FileAPI/server/ctrl.php'
- , files: { shot: file }
- , complete: function (err, xhr){
- var res = JSON.parse(xhr.responseText);
- var img = new Image;
- img.src = res.images.shot.dataURL;
- img.style.marginRight = '5px';
- server.insertBefore(img, server.firstChild);
- }
- });
- }
- });
+ if( err ){
+ alert('WebCam or Flash not supported :[');
+ } else {
+ readyBox.style.display = '';
+
+ FileAPI.event.on(startBtn, 'click', function (){
+ cam.start();
+ });
+
+ FileAPI.event.on(stopBtn, 'click', function (){
+ cam.stop();
+ });
+
+ FileAPI.event.on(shotBtn, 'click', function (){
+ if( cam.isActive() ){
+ var shot = cam.shot();
+
+ shot
+ .clone()
+ .preview(100, 100)
+ .get(function (err, img){
+ img.style.marginRight = '5px';
+ shots.insertBefore(img, shots.firstChild);
+ })
+ ;
+
+ var file = shot
+ .preview(200, 200)
+ .overlay({
+ x: 5
+ , y: 5
+ , src: '../statics/watermark.png'
+ , rel: FileAPI.Image.RIGHT_TOP
+ })
+ ;
+
+ FileAPI.upload({
+ url: 'http://rubaxa.org/FileAPI/server/ctrl.php'
+ , files: { shot: file }
+ , complete: function (err, xhr){
+ var res = JSON.parse(xhr.responseText);
+ var img = new Image;
+ img.src = res.images.shot.dataURL;
+ img.style.marginRight = '5px';
+ server.insertBefore(img, server.firstChild);
+ }
+ });
+ }
+ });
+ }
});
})();
</script>
View
4 lib/FileAPI.Camera.js
@@ -163,6 +163,10 @@
};
+ el.style.width = _px(options.width);
+ el.style.height = _px(options.height);
+
+
if( api.html5 && html5 ){
// Create video element
var video = document.createElement('video');
View
32 lib/FileAPI.Flash.js
@@ -12,6 +12,9 @@
document = window.document
, location = window.location
, navigator = window.navigator
+
+ , _each = api.each
+ , _cameraQueue = []
;
@@ -255,13 +258,13 @@
// Set files filter
var accept = [], exts = {};
- api.each((node.getAttribute('accept') || '').split(/,\s*/), function (mime){
- api.accept[mime] && api.each(api.accept[mime].split(' '), function (ext){
+ _each((node.getAttribute('accept') || '').split(/,\s*/), function (mime){
+ api.accept[mime] && _each(api.accept[mime].split(' '), function (ext){
exts[ext] = 1;
});
});
- api.each(exts, function (i, ext){
+ _each(exts, function (i, ext){
accept.push( ext );
});
@@ -299,7 +302,7 @@
, event
;
- api.each(files, function (file){
+ _each(files, function (file){
api.checkFileObj(file);
});
@@ -531,6 +534,12 @@
}));
};
+ // Run
+ _each(_cameraQueue, function (args){
+ api.Camera.fallback.apply(api.Camera, args);
+ });
+ _cameraQueue = [];
+
// FileAPI.Camera:proto
_inherit(api.Camera.prototype, {
@@ -550,15 +559,15 @@
}
else {
api.log('FlashAPI.camera.on.success: ' + _this._id());
- _this.active = true;
+ _this._active = true;
callback(null, _this);
}
})
});
},
stop: function (){
- this.active = false;
+ this._active = false;
flash.cmd(this._id(), 'camera.off');
},
@@ -613,7 +622,7 @@
, fileId
;
- api.each(formData, function (item){
+ _each(formData, function (item){
if( item.file ){
files[item.name] = item = _getFileDescr(item.blob);
fileId = item.id;
@@ -678,7 +687,7 @@
// #2174: FileReference.load() call while FileReference.upload() or vice versa
- api.each(files, function (file){
+ _each(files, function (file){
queue.inc();
api.getInfo(file, queue.next);
});
@@ -721,7 +730,7 @@
function _inherit(obj, methods){
- api.each(methods, function (fn, name){
+ _each(methods, function (fn, name){
var prev = obj[name];
obj[name] = function (){
this.parent = prev;
@@ -847,6 +856,11 @@
}
+ api.Camera.fallback = function (){
+ _cameraQueue.push(arguments);
+ };
+
+
// @export
api.Flash = flash;

0 comments on commit 80adf3b

Please sign in to comment.