").append(x.parseHTML(e)).find(i):e)}).complete(r&&function(e,t){s.each(r,o||[e.responseText,t,e])}),this},x.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){x.fn[t]=function(e){return this.on(t,e)}}),x.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:yn,type:"GET",isLocal:Cn.test(mn[1]),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Dn,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":x.parseJSON,"text xml":x.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,t){return t?_n(_n(e,x.ajaxSettings),t):_n(x.ajaxSettings,e)},ajaxPrefilter:Hn(An),ajaxTransport:Hn(jn),ajax:function(e,n){"object"==typeof e&&(n=e,e=t),n=n||{};var r,i,o,a,s,l,u,c,p=x.ajaxSetup({},n),f=p.context||p,d=p.context&&(f.nodeType||f.jquery)?x(f):x.event,h=x.Deferred(),g=x.Callbacks("once memory"),m=p.statusCode||{},y={},v={},b=0,w="canceled",C={readyState:0,getResponseHeader:function(e){var t;if(2===b){if(!c){c={};while(t=Tn.exec(a))c[t[1].toLowerCase()]=t[2]}t=c[e.toLowerCase()]}return null==t?null:t},getAllResponseHeaders:function(){return 2===b?a:null},setRequestHeader:function(e,t){var n=e.toLowerCase();return b||(e=v[n]=v[n]||e,y[e]=t),this},overrideMimeType:function(e){return b||(p.mimeType=e),this},statusCode:function(e){var t;if(e)if(2>b)for(t in e)m[t]=[m[t],e[t]];else C.always(e[C.status]);return this},abort:function(e){var t=e||w;return u&&u.abort(t),k(0,t),this}};if(h.promise(C).complete=g.add,C.success=C.done,C.error=C.fail,p.url=((e||p.url||yn)+"").replace(xn,"").replace(kn,mn[1]+"//"),p.type=n.method||n.type||p.method||p.type,p.dataTypes=x.trim(p.dataType||"*").toLowerCase().match(T)||[""],null==p.crossDomain&&(r=En.exec(p.url.toLowerCase()),p.crossDomain=!(!r||r[1]===mn[1]&&r[2]===mn[2]&&(r[3]||("http:"===r[1]?"80":"443"))===(mn[3]||("http:"===mn[1]?"80":"443")))),p.data&&p.processData&&"string"!=typeof p.data&&(p.data=x.param(p.data,p.traditional)),qn(An,p,n,C),2===b)return C;l=p.global,l&&0===x.active++&&x.event.trigger("ajaxStart"),p.type=p.type.toUpperCase(),p.hasContent=!Nn.test(p.type),o=p.url,p.hasContent||(p.data&&(o=p.url+=(bn.test(o)?"&":"?")+p.data,delete p.data),p.cache===!1&&(p.url=wn.test(o)?o.replace(wn,"$1_="+vn++):o+(bn.test(o)?"&":"?")+"_="+vn++)),p.ifModified&&(x.lastModified[o]&&C.setRequestHeader("If-Modified-Since",x.lastModified[o]),x.etag[o]&&C.setRequestHeader("If-None-Match",x.etag[o])),(p.data&&p.hasContent&&p.contentType!==!1||n.contentType)&&C.setRequestHeader("Content-Type",p.contentType),C.setRequestHeader("Accept",p.dataTypes[0]&&p.accepts[p.dataTypes[0]]?p.accepts[p.dataTypes[0]]+("*"!==p.dataTypes[0]?", "+Dn+"; q=0.01":""):p.accepts["*"]);for(i in p.headers)C.setRequestHeader(i,p.headers[i]);if(p.beforeSend&&(p.beforeSend.call(f,C,p)===!1||2===b))return C.abort();w="abort";for(i in{success:1,error:1,complete:1})C[i](p[i]);if(u=qn(jn,p,n,C)){C.readyState=1,l&&d.trigger("ajaxSend",[C,p]),p.async&&p.timeout>0&&(s=setTimeout(function(){C.abort("timeout")},p.timeout));try{b=1,u.send(y,k)}catch(N){if(!(2>b))throw N;k(-1,N)}}else k(-1,"No Transport");function k(e,n,r,i){var c,y,v,w,T,N=n;2!==b&&(b=2,s&&clearTimeout(s),u=t,a=i||"",C.readyState=e>0?4:0,c=e>=200&&300>e||304===e,r&&(w=Mn(p,C,r)),w=On(p,w,C,c),c?(p.ifModified&&(T=C.getResponseHeader("Last-Modified"),T&&(x.lastModified[o]=T),T=C.getResponseHeader("etag"),T&&(x.etag[o]=T)),204===e||"HEAD"===p.type?N="nocontent":304===e?N="notmodified":(N=w.state,y=w.data,v=w.error,c=!v)):(v=N,(e||!N)&&(N="error",0>e&&(e=0))),C.status=e,C.statusText=(n||N)+"",c?h.resolveWith(f,[y,N,C]):h.rejectWith(f,[C,N,v]),C.statusCode(m),m=t,l&&d.trigger(c?"ajaxSuccess":"ajaxError",[C,p,c?y:v]),g.fireWith(f,[C,N]),l&&(d.trigger("ajaxComplete",[C,p]),--x.active||x.event.trigger("ajaxStop")))}return C},getJSON:function(e,t,n){return x.get(e,t,n,"json")},getScript:function(e,n){return x.get(e,t,n,"script")}}),x.each(["get","post"],function(e,n){x[n]=function(e,r,i,o){return x.isFunction(r)&&(o=o||i,i=r,r=t),x.ajax({url:e,type:n,dataType:o,data:r,success:i})}});function Mn(e,n,r){var i,o,a,s,l=e.contents,u=e.dataTypes;while("*"===u[0])u.shift(),o===t&&(o=e.mimeType||n.getResponseHeader("Content-Type"));if(o)for(s in l)if(l[s]&&l[s].test(o)){u.unshift(s);break}if(u[0]in r)a=u[0];else{for(s in r){if(!u[0]||e.converters[s+" "+u[0]]){a=s;break}i||(i=s)}a=a||i}return a?(a!==u[0]&&u.unshift(a),r[a]):t}function On(e,t,n,r){var i,o,a,s,l,u={},c=e.dataTypes.slice();if(c[1])for(a in e.converters)u[a.toLowerCase()]=e.converters[a];o=c.shift();while(o)if(e.responseFields[o]&&(n[e.responseFields[o]]=t),!l&&r&&e.dataFilter&&(t=e.dataFilter(t,e.dataType)),l=o,o=c.shift())if("*"===o)o=l;else if("*"!==l&&l!==o){if(a=u[l+" "+o]||u["* "+o],!a)for(i in u)if(s=i.split(" "),s[1]===o&&(a=u[l+" "+s[0]]||u["* "+s[0]])){a===!0?a=u[i]:u[i]!==!0&&(o=s[0],c.unshift(s[1]));break}if(a!==!0)if(a&&e["throws"])t=a(t);else try{t=a(t)}catch(p){return{state:"parsererror",error:a?p:"No conversion from "+l+" to "+o}}}return{state:"success",data:t}}x.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/(?:java|ecma)script/},converters:{"text script":function(e){return x.globalEval(e),e}}}),x.ajaxPrefilter("script",function(e){e.cache===t&&(e.cache=!1),e.crossDomain&&(e.type="GET",e.global=!1)}),x.ajaxTransport("script",function(e){if(e.crossDomain){var n,r=a.head||x("head")[0]||a.documentElement;return{send:function(t,i){n=a.createElement("script"),n.async=!0,e.scriptCharset&&(n.charset=e.scriptCharset),n.src=e.url,n.onload=n.onreadystatechange=function(e,t){(t||!n.readyState||/loaded|complete/.test(n.readyState))&&(n.onload=n.onreadystatechange=null,n.parentNode&&n.parentNode.removeChild(n),n=null,t||i(200,"success"))},r.insertBefore(n,r.firstChild)},abort:function(){n&&n.onload(t,!0)}}}});var Fn=[],Bn=/(=)\?(?=&|$)|\?\?/;x.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=Fn.pop()||x.expando+"_"+vn++;return this[e]=!0,e}}),x.ajaxPrefilter("json jsonp",function(n,r,i){var o,a,s,l=n.jsonp!==!1&&(Bn.test(n.url)?"url":"string"==typeof n.data&&!(n.contentType||"").indexOf("application/x-www-form-urlencoded")&&Bn.test(n.data)&&"data");return l||"jsonp"===n.dataTypes[0]?(o=n.jsonpCallback=x.isFunction(n.jsonpCallback)?n.jsonpCallback():n.jsonpCallback,l?n[l]=n[l].replace(Bn,"$1"+o):n.jsonp!==!1&&(n.url+=(bn.test(n.url)?"&":"?")+n.jsonp+"="+o),n.converters["script json"]=function(){return s||x.error(o+" was not called"),s[0]},n.dataTypes[0]="json",a=e[o],e[o]=function(){s=arguments},i.always(function(){e[o]=a,n[o]&&(n.jsonpCallback=r.jsonpCallback,Fn.push(o)),s&&x.isFunction(a)&&a(s[0]),s=a=t}),"script"):t});var Pn,Rn,Wn=0,$n=e.ActiveXObject&&function(){var e;for(e in Pn)Pn[e](t,!0)};function In(){try{return new e.XMLHttpRequest}catch(t){}}function zn(){try{return new e.ActiveXObject("Microsoft.XMLHTTP")}catch(t){}}x.ajaxSettings.xhr=e.ActiveXObject?function(){return!this.isLocal&&In()||zn()}:In,Rn=x.ajaxSettings.xhr(),x.support.cors=!!Rn&&"withCredentials"in Rn,Rn=x.support.ajax=!!Rn,Rn&&x.ajaxTransport(function(n){if(!n.crossDomain||x.support.cors){var r;return{send:function(i,o){var a,s,l=n.xhr();if(n.username?l.open(n.type,n.url,n.async,n.username,n.password):l.open(n.type,n.url,n.async),n.xhrFields)for(s in n.xhrFields)l[s]=n.xhrFields[s];n.mimeType&&l.overrideMimeType&&l.overrideMimeType(n.mimeType),n.crossDomain||i["X-Requested-With"]||(i["X-Requested-With"]="XMLHttpRequest");try{for(s in i)l.setRequestHeader(s,i[s])}catch(u){}l.send(n.hasContent&&n.data||null),r=function(e,i){var s,u,c,p;try{if(r&&(i||4===l.readyState))if(r=t,a&&(l.onreadystatechange=x.noop,$n&&delete Pn[a]),i)4!==l.readyState&&l.abort();else{p={},s=l.status,u=l.getAllResponseHeaders(),"string"==typeof l.responseText&&(p.text=l.responseText);try{c=l.statusText}catch(f){c=""}s||!n.isLocal||n.crossDomain?1223===s&&(s=204):s=p.text?200:404}}catch(d){i||o(-1,d)}p&&o(s,c,p,u)},n.async?4===l.readyState?setTimeout(r):(a=++Wn,$n&&(Pn||(Pn={},x(e).unload($n)),Pn[a]=r),l.onreadystatechange=r):r()},abort:function(){r&&r(t,!0)}}}});var Xn,Un,Vn=/^(?:toggle|show|hide)$/,Yn=RegExp("^(?:([+-])=|)("+w+")([a-z%]*)$","i"),Jn=/queueHooks$/,Gn=[nr],Qn={"*":[function(e,t){var n=this.createTween(e,t),r=n.cur(),i=Yn.exec(t),o=i&&i[3]||(x.cssNumber[e]?"":"px"),a=(x.cssNumber[e]||"px"!==o&&+r)&&Yn.exec(x.css(n.elem,e)),s=1,l=20;if(a&&a[3]!==o){o=o||a[3],i=i||[],a=+r||1;do s=s||".5",a/=s,x.style(n.elem,e,a+o);while(s!==(s=n.cur()/r)&&1!==s&&--l)}return i&&(a=n.start=+a||+r||0,n.unit=o,n.end=i[1]?a+(i[1]+1)*i[2]:+i[2]),n}]};function Kn(){return setTimeout(function(){Xn=t}),Xn=x.now()}function Zn(e,t,n){var r,i=(Qn[t]||[]).concat(Qn["*"]),o=0,a=i.length;for(;a>o;o++)if(r=i[o].call(n,t,e))return r}function er(e,t,n){var r,i,o=0,a=Gn.length,s=x.Deferred().always(function(){delete l.elem}),l=function(){if(i)return!1;var t=Xn||Kn(),n=Math.max(0,u.startTime+u.duration-t),r=n/u.duration||0,o=1-r,a=0,l=u.tweens.length;for(;l>a;a++)u.tweens[a].run(o);return s.notifyWith(e,[u,o,n]),1>o&&l?n:(s.resolveWith(e,[u]),!1)},u=s.promise({elem:e,props:x.extend({},t),opts:x.extend(!0,{specialEasing:{}},n),originalProperties:t,originalOptions:n,startTime:Xn||Kn(),duration:n.duration,tweens:[],createTween:function(t,n){var r=x.Tween(e,u.opts,t,n,u.opts.specialEasing[t]||u.opts.easing);return u.tweens.push(r),r},stop:function(t){var n=0,r=t?u.tweens.length:0;if(i)return this;for(i=!0;r>n;n++)u.tweens[n].run(1);return t?s.resolveWith(e,[u,t]):s.rejectWith(e,[u,t]),this}}),c=u.props;for(tr(c,u.opts.specialEasing);a>o;o++)if(r=Gn[o].call(u,e,c,u.opts))return r;return x.map(c,Zn,u),x.isFunction(u.opts.start)&&u.opts.start.call(e,u),x.fx.timer(x.extend(l,{elem:e,anim:u,queue:u.opts.queue})),u.progress(u.opts.progress).done(u.opts.done,u.opts.complete).fail(u.opts.fail).always(u.opts.always)}function tr(e,t){var n,r,i,o,a;for(n in e)if(r=x.camelCase(n),i=t[r],o=e[n],x.isArray(o)&&(i=o[1],o=e[n]=o[0]),n!==r&&(e[r]=o,delete e[n]),a=x.cssHooks[r],a&&"expand"in a){o=a.expand(o),delete e[r];for(n in o)n in e||(e[n]=o[n],t[n]=i)}else t[r]=i}x.Animation=x.extend(er,{tweener:function(e,t){x.isFunction(e)?(t=e,e=["*"]):e=e.split(" ");var n,r=0,i=e.length;for(;i>r;r++)n=e[r],Qn[n]=Qn[n]||[],Qn[n].unshift(t)},prefilter:function(e,t){t?Gn.unshift(e):Gn.push(e)}});function nr(e,t,n){var r,i,o,a,s,l,u=this,c={},p=e.style,f=e.nodeType&&nn(e),d=x._data(e,"fxshow");n.queue||(s=x._queueHooks(e,"fx"),null==s.unqueued&&(s.unqueued=0,l=s.empty.fire,s.empty.fire=function(){s.unqueued||l()}),s.unqueued++,u.always(function(){u.always(function(){s.unqueued--,x.queue(e,"fx").length||s.empty.fire()})})),1===e.nodeType&&("height"in t||"width"in t)&&(n.overflow=[p.overflow,p.overflowX,p.overflowY],"inline"===x.css(e,"display")&&"none"===x.css(e,"float")&&(x.support.inlineBlockNeedsLayout&&"inline"!==ln(e.nodeName)?p.zoom=1:p.display="inline-block")),n.overflow&&(p.overflow="hidden",x.support.shrinkWrapBlocks||u.always(function(){p.overflow=n.overflow[0],p.overflowX=n.overflow[1],p.overflowY=n.overflow[2]}));for(r in t)if(i=t[r],Vn.exec(i)){if(delete t[r],o=o||"toggle"===i,i===(f?"hide":"show"))continue;c[r]=d&&d[r]||x.style(e,r)}if(!x.isEmptyObject(c)){d?"hidden"in d&&(f=d.hidden):d=x._data(e,"fxshow",{}),o&&(d.hidden=!f),f?x(e).show():u.done(function(){x(e).hide()}),u.done(function(){var t;x._removeData(e,"fxshow");for(t in c)x.style(e,t,c[t])});for(r in c)a=Zn(f?d[r]:0,r,u),r in d||(d[r]=a.start,f&&(a.end=a.start,a.start="width"===r||"height"===r?1:0))}}function rr(e,t,n,r,i){return new rr.prototype.init(e,t,n,r,i)}x.Tween=rr,rr.prototype={constructor:rr,init:function(e,t,n,r,i,o){this.elem=e,this.prop=n,this.easing=i||"swing",this.options=t,this.start=this.now=this.cur(),this.end=r,this.unit=o||(x.cssNumber[n]?"":"px")},cur:function(){var e=rr.propHooks[this.prop];return e&&e.get?e.get(this):rr.propHooks._default.get(this)},run:function(e){var t,n=rr.propHooks[this.prop];return this.pos=t=this.options.duration?x.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):e,this.now=(this.end-this.start)*t+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),n&&n.set?n.set(this):rr.propHooks._default.set(this),this}},rr.prototype.init.prototype=rr.prototype,rr.propHooks={_default:{get:function(e){var t;return null==e.elem[e.prop]||e.elem.style&&null!=e.elem.style[e.prop]?(t=x.css(e.elem,e.prop,""),t&&"auto"!==t?t:0):e.elem[e.prop]},set:function(e){x.fx.step[e.prop]?x.fx.step[e.prop](e):e.elem.style&&(null!=e.elem.style[x.cssProps[e.prop]]||x.cssHooks[e.prop])?x.style(e.elem,e.prop,e.now+e.unit):e.elem[e.prop]=e.now}}},rr.propHooks.scrollTop=rr.propHooks.scrollLeft={set:function(e){e.elem.nodeType&&e.elem.parentNode&&(e.elem[e.prop]=e.now)}},x.each(["toggle","show","hide"],function(e,t){var n=x.fn[t];x.fn[t]=function(e,r,i){return null==e||"boolean"==typeof e?n.apply(this,arguments):this.animate(ir(t,!0),e,r,i)}}),x.fn.extend({fadeTo:function(e,t,n,r){return this.filter(nn).css("opacity",0).show().end().animate({opacity:t},e,n,r)},animate:function(e,t,n,r){var i=x.isEmptyObject(e),o=x.speed(t,n,r),a=function(){var t=er(this,x.extend({},e),o);(i||x._data(this,"finish"))&&t.stop(!0)};return a.finish=a,i||o.queue===!1?this.each(a):this.queue(o.queue,a)},stop:function(e,n,r){var i=function(e){var t=e.stop;delete e.stop,t(r)};return"string"!=typeof e&&(r=n,n=e,e=t),n&&e!==!1&&this.queue(e||"fx",[]),this.each(function(){var t=!0,n=null!=e&&e+"queueHooks",o=x.timers,a=x._data(this);if(n)a[n]&&a[n].stop&&i(a[n]);else for(n in a)a[n]&&a[n].stop&&Jn.test(n)&&i(a[n]);for(n=o.length;n--;)o[n].elem!==this||null!=e&&o[n].queue!==e||(o[n].anim.stop(r),t=!1,o.splice(n,1));(t||!r)&&x.dequeue(this,e)})},finish:function(e){return e!==!1&&(e=e||"fx"),this.each(function(){var t,n=x._data(this),r=n[e+"queue"],i=n[e+"queueHooks"],o=x.timers,a=r?r.length:0;for(n.finish=!0,x.queue(this,e,[]),i&&i.stop&&i.stop.call(this,!0),t=o.length;t--;)o[t].elem===this&&o[t].queue===e&&(o[t].anim.stop(!0),o.splice(t,1));for(t=0;a>t;t++)r[t]&&r[t].finish&&r[t].finish.call(this);delete n.finish})}});function ir(e,t){var n,r={height:e},i=0;for(t=t?1:0;4>i;i+=2-t)n=Zt[i],r["margin"+n]=r["padding"+n]=e;return t&&(r.opacity=r.width=e),r}x.each({slideDown:ir("show"),slideUp:ir("hide"),slideToggle:ir("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(e,t){x.fn[e]=function(e,n,r){return this.animate(t,e,n,r)}}),x.speed=function(e,t,n){var r=e&&"object"==typeof e?x.extend({},e):{complete:n||!n&&t||x.isFunction(e)&&e,duration:e,easing:n&&t||t&&!x.isFunction(t)&&t};return r.duration=x.fx.off?0:"number"==typeof r.duration?r.duration:r.duration in x.fx.speeds?x.fx.speeds[r.duration]:x.fx.speeds._default,(null==r.queue||r.queue===!0)&&(r.queue="fx"),r.old=r.complete,r.complete=function(){x.isFunction(r.old)&&r.old.call(this),r.queue&&x.dequeue(this,r.queue)},r},x.easing={linear:function(e){return e},swing:function(e){return.5-Math.cos(e*Math.PI)/2}},x.timers=[],x.fx=rr.prototype.init,x.fx.tick=function(){var e,n=x.timers,r=0;for(Xn=x.now();n.length>r;r++)e=n[r],e()||n[r]!==e||n.splice(r--,1);n.length||x.fx.stop(),Xn=t},x.fx.timer=function(e){e()&&x.timers.push(e)&&x.fx.start()},x.fx.interval=13,x.fx.start=function(){Un||(Un=setInterval(x.fx.tick,x.fx.interval))},x.fx.stop=function(){clearInterval(Un),Un=null},x.fx.speeds={slow:600,fast:200,_default:400},x.fx.step={},x.expr&&x.expr.filters&&(x.expr.filters.animated=function(e){return x.grep(x.timers,function(t){return e===t.elem}).length}),x.fn.offset=function(e){if(arguments.length)return e===t?this:this.each(function(t){x.offset.setOffset(this,e,t)});var n,r,o={top:0,left:0},a=this[0],s=a&&a.ownerDocument;if(s)return n=s.documentElement,x.contains(n,a)?(typeof a.getBoundingClientRect!==i&&(o=a.getBoundingClientRect()),r=or(s),{top:o.top+(r.pageYOffset||n.scrollTop)-(n.clientTop||0),left:o.left+(r.pageXOffset||n.scrollLeft)-(n.clientLeft||0)}):o},x.offset={setOffset:function(e,t,n){var r=x.css(e,"position");"static"===r&&(e.style.position="relative");var i=x(e),o=i.offset(),a=x.css(e,"top"),s=x.css(e,"left"),l=("absolute"===r||"fixed"===r)&&x.inArray("auto",[a,s])>-1,u={},c={},p,f;l?(c=i.position(),p=c.top,f=c.left):(p=parseFloat(a)||0,f=parseFloat(s)||0),x.isFunction(t)&&(t=t.call(e,n,o)),null!=t.top&&(u.top=t.top-o.top+p),null!=t.left&&(u.left=t.left-o.left+f),"using"in t?t.using.call(e,u):i.css(u)}},x.fn.extend({position:function(){if(this[0]){var e,t,n={top:0,left:0},r=this[0];return"fixed"===x.css(r,"position")?t=r.getBoundingClientRect():(e=this.offsetParent(),t=this.offset(),x.nodeName(e[0],"html")||(n=e.offset()),n.top+=x.css(e[0],"borderTopWidth",!0),n.left+=x.css(e[0],"borderLeftWidth",!0)),{top:t.top-n.top-x.css(r,"marginTop",!0),left:t.left-n.left-x.css(r,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var e=this.offsetParent||s;while(e&&!x.nodeName(e,"html")&&"static"===x.css(e,"position"))e=e.offsetParent;return e||s})}}),x.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(e,n){var r=/Y/.test(n);x.fn[e]=function(i){return x.access(this,function(e,i,o){var a=or(e);return o===t?a?n in a?a[n]:a.document.documentElement[i]:e[i]:(a?a.scrollTo(r?x(a).scrollLeft():o,r?o:x(a).scrollTop()):e[i]=o,t)},e,i,arguments.length,null)}});function or(e){return x.isWindow(e)?e:9===e.nodeType?e.defaultView||e.parentWindow:!1}x.each({Height:"height",Width:"width"},function(e,n){x.each({padding:"inner"+e,content:n,"":"outer"+e},function(r,i){x.fn[i]=function(i,o){var a=arguments.length&&(r||"boolean"!=typeof i),s=r||(i===!0||o===!0?"margin":"border");return x.access(this,function(n,r,i){var o;return x.isWindow(n)?n.document.documentElement["client"+e]:9===n.nodeType?(o=n.documentElement,Math.max(n.body["scroll"+e],o["scroll"+e],n.body["offset"+e],o["offset"+e],o["client"+e])):i===t?x.css(n,r,s):x.style(n,r,i,s)},n,a?i:t,a,null)}})}),x.fn.size=function(){return this.length},x.fn.andSelf=x.fn.addBack,"object"==typeof module&&module&&"object"==typeof module.exports?module.exports=x:(e.jQuery=e.$=x,"function"==typeof define&&define.amd&&define("jquery",[],function(){return x}))})(window);
// from https://github.com/kossnocorp/role
!function($){
function rewriteSelector(context, name, argPos){
var original = context[name];
if (!original) return;
context[name] = function(){
arguments[argPos] = arguments[argPos].replace(/@([\w\u00c0-\uFFFF\-]+)/g, '[role~="$1"]');
return original.apply(context, arguments);
};
$.extend(context[name], original);
}
rewriteSelector($, 'find', 0);
rewriteSelector($, 'multiFilter', 0);
rewriteSelector($.find, 'matchesSelector', 1);
rewriteSelector($.find, 'matches', 0);
function parse(roleString, without){
var role, result = [], roles = $.trim(roleString).split(/\s+/);
for(var i=0; i
o.distance || Math.abs(eMove.pageY - eDown.pageY) > o.distance)) {
dragged = true;
$fake = $dragged.clone()
.css({position: 'absolute', zIndex: o.zIndex,
width: $dragged.width()})
.appendTo($dragged.offsetParent());
o.start({
event: eMove,
dragged: $dragged,
fake: $fake
});
}
if ( ! dragged) {
return;
}
eMove.preventDefault();
var dx = o.axis == 'y' ? 0 : eMove.pageX - eDown.pageX;
var dy = o.axis == 'x' ? 0 : eMove.pageY - eDown.pageY;
$fake.css({left: dx + originalPos.left, top: dy + originalPos.top});
o.move({
event: eMove,
dragged: $dragged,
fake: $fake,
dx: dx,
dy: dy
});
});
$(document).on('mouseup.moveable touchend.movable touchcancel.movable touchleave.movable', function(eUp) {
fixTouch(eUp);
$(document).off('mousemove.moveable touchmove.movable');
$(document).off('mouseup.moveable touchend.movable touchcancel.movable touchleave.movable');
if ( ! dragged) {
return;
}
eUp.preventDefault();
var dx = eUp.pageX - eDown.pageX;
var dy = eUp.pageY - eDown.pageY;
dragged = false;
o.finish({
event: eUp,
dragged: $dragged,
fake: $fake,
dx: dx,
dy: dy
});
if ( ! o.keepFake) {
$fake.remove();
}
});
});
},
sortable: function(o) {
var oMovable = $.extend({
items: '>*'
}, o);
var o = $.extend({
checkBounds: function () {return true;},
start: $.noop,
attach: $.noop,
move: $.noop,
finish: $.noop
}, o);
var finder;
var initialNext = false;
var parent = this;
oMovable.start = function(info) {
o.start(info);
finder = new nearestFinder(parent.find(oMovable.items));
initialNext = info.dragged.next();
};
oMovable.move = function(info) {
info.nearest = null;
if (o.checkBounds(info)) {
var offset = info.fake.offset();
var nearest = finder.findNotLast(
offset.left + info.dragged.width() / 2, offset.top);
info.nearest = $(nearest);
if (nearest && nearest != info.dragged[0]) {
if (info.dragged.nextAll().filter(nearest).length > 0) {
info.dragged.insertAfter(nearest);
} else {
info.dragged.insertBefore(nearest);
}
o.attach(info);
finder.last = null;
finder.update();
}
} else if (finder.last !== null) {
finder.last = null;
if (initialNext.length) {
info.dragged.insertBefore(initialNext);
} else {
info.dragged.parent().append(info.dragged);
}
o.attach(info);
finder.update();
}
o.move(info);
};
oMovable.finish = function(info) {
var offset = info.fake.offset();
info.nearest = null;
if (o.checkBounds(info)) {
info.nearest = $(finder.find(
offset.left + info.dragged.width() / 2, offset.top));
}
o.finish(info);
finder = null;
};
return this.moveable(oMovable);
}
});
})(jQuery);
(function() {
uploadcare.jQuery = jQuery;
jQuery.noConflict(true);
}).call(this);
// changed:
// Pusher.dependency_suffix = '.min'; (was '')
// window.WEB_SOCKET_SWF_LOCATION = "https://s3.amazonaws.com/uploadcare-static/WebSocketMainInsecure.swf"
/*!
* Pusher JavaScript Library v1.12.2
* http://pusherapp.com/
*
* Copyright 2011, Pusher
* Released under the MIT licence.
*/
;(function() {
if (Function.prototype.scopedTo === undefined) {
Function.prototype.scopedTo = function(context, args) {
var f = this;
return function() {
return f.apply(context, Array.prototype.slice.call(args || [])
.concat(Array.prototype.slice.call(arguments)));
};
};
}
var Pusher = function(app_key, options) {
this.options = options || {};
this.key = app_key;
this.channels = new Pusher.Channels();
this.global_emitter = new Pusher.EventsDispatcher()
var self = this;
this.checkAppKey();
this.connection = new Pusher.Connection(this.key, this.options);
// Setup / teardown connection
this.connection
.bind('connected', function() {
self.subscribeAll();
})
.bind('message', function(params) {
var internal = (params.event.indexOf('pusher_internal:') === 0);
if (params.channel) {
var channel;
if (channel = self.channel(params.channel)) {
channel.emit(params.event, params.data);
}
}
// Emit globaly [deprecated]
if (!internal) self.global_emitter.emit(params.event, params.data);
})
.bind('disconnected', function() {
self.channels.disconnect();
})
.bind('error', function(err) {
Pusher.warn('Error', err);
});
Pusher.instances.push(this);
if (Pusher.isReady) self.connect();
};
Pusher.instances = [];
Pusher.prototype = {
channel: function(name) {
return this.channels.find(name);
},
connect: function() {
this.connection.connect();
},
disconnect: function() {
this.connection.disconnect();
},
bind: function(event_name, callback) {
this.global_emitter.bind(event_name, callback);
return this;
},
bind_all: function(callback) {
this.global_emitter.bind_all(callback);
return this;
},
subscribeAll: function() {
var channel;
for (channelName in this.channels.channels) {
if (this.channels.channels.hasOwnProperty(channelName)) {
this.subscribe(channelName);
}
}
},
subscribe: function(channel_name) {
var self = this;
var channel = this.channels.add(channel_name, this);
if (this.connection.state === 'connected') {
channel.authorize(this.connection.socket_id, this.options, function(err, data) {
if (err) {
channel.emit('pusher:subscription_error', data);
} else {
self.send_event('pusher:subscribe', {
channel: channel_name,
auth: data.auth,
channel_data: data.channel_data
});
}
});
}
return channel;
},
unsubscribe: function(channel_name) {
this.channels.remove(channel_name);
if (this.connection.state === 'connected') {
this.send_event('pusher:unsubscribe', {
channel: channel_name
});
}
},
send_event: function(event_name, data, channel) {
return this.connection.send_event(event_name, data, channel);
},
checkAppKey: function() {
if(this.key === null || this.key === undefined) {
Pusher.warn('Warning', 'You must pass your app key when you instantiate Pusher.');
}
}
};
Pusher.Util = {
extend: function extend(target, extensions) {
for (var property in extensions) {
if (extensions[property] && extensions[property].constructor &&
extensions[property].constructor === Object) {
target[property] = extend(target[property] || {}, extensions[property]);
} else {
target[property] = extensions[property];
}
}
return target;
},
stringify: function stringify() {
var m = ["Pusher"]
for (var i = 0; i < arguments.length; i++){
if (typeof arguments[i] === "string") {
m.push(arguments[i])
} else {
if (window['JSON'] == undefined) {
m.push(arguments[i].toString());
} else {
m.push(JSON.stringify(arguments[i]))
}
}
};
return m.join(" : ")
},
arrayIndexOf: function(array, item) { // MSIE doesn't have array.indexOf
var nativeIndexOf = Array.prototype.indexOf;
if (array == null) return -1;
if (nativeIndexOf && array.indexOf === nativeIndexOf) return array.indexOf(item);
for (i = 0, l = array.length; i < l; i++) if (array[i] === item) return i;
return -1;
}
};
// To receive log output provide a Pusher.log function, for example
// Pusher.log = function(m){console.log(m)}
Pusher.debug = function() {
if (!Pusher.log) return
Pusher.log(Pusher.Util.stringify.apply(this, arguments))
}
Pusher.warn = function() {
if (window.console && window.console.warn) {
window.console.warn(Pusher.Util.stringify.apply(this, arguments));
} else {
if (!Pusher.log) return
Pusher.log(Pusher.Util.stringify.apply(this, arguments));
}
};
// Pusher defaults
Pusher.VERSION = '1.12.2';
Pusher.host = 'ws.pusherapp.com';
Pusher.ws_port = 80;
Pusher.wss_port = 443;
Pusher.channel_auth_endpoint = '/pusher/auth';
Pusher.cdn_http = 'http://js.pusher.com/'
Pusher.cdn_https = 'https://d3dy5gmtp8yhk7.cloudfront.net/'
Pusher.dependency_suffix = '.min';
Pusher.channel_auth_transport = 'ajax';
Pusher.activity_timeout = 120000;
Pusher.pong_timeout = 30000;
Pusher.isReady = false;
Pusher.ready = function() {
Pusher.isReady = true;
for (var i = 0, l = Pusher.instances.length; i < l; i++) {
Pusher.instances[i].connect();
}
};
this.Pusher = Pusher;
}).call(this);
;(function() {
/* Abstract event binding
Example:
var MyEventEmitter = function(){};
MyEventEmitter.prototype = new Pusher.EventsDispatcher;
var emitter = new MyEventEmitter();
// Bind to single event
emitter.bind('foo_event', function(data){ alert(data)} );
// Bind to all
emitter.bind_all(function(eventName, data){ alert(data) });
--------------------------------------------------------*/
function CallbackRegistry() {
this._callbacks = {};
};
CallbackRegistry.prototype.get = function(eventName) {
return this._callbacks[this._prefix(eventName)];
};
CallbackRegistry.prototype.add = function(eventName, callback) {
var prefixedEventName = this._prefix(eventName);
this._callbacks[prefixedEventName] = this._callbacks[prefixedEventName] || [];
this._callbacks[prefixedEventName].push(callback);
};
CallbackRegistry.prototype.remove = function(eventName, callback) {
if(this.get(eventName)) {
var index = Pusher.Util.arrayIndexOf(this.get(eventName), callback);
this._callbacks[this._prefix(eventName)].splice(index, 1);
}
};
CallbackRegistry.prototype._prefix = function(eventName) {
return "_" + eventName;
};
function EventsDispatcher(failThrough) {
this.callbacks = new CallbackRegistry();
this.global_callbacks = [];
// Run this function when dispatching an event when no callbacks defined
this.failThrough = failThrough;
}
EventsDispatcher.prototype.bind = function(eventName, callback) {
this.callbacks.add(eventName, callback);
return this;// chainable
};
EventsDispatcher.prototype.unbind = function(eventName, callback) {
this.callbacks.remove(eventName, callback);
return this;
};
EventsDispatcher.prototype.emit = function(eventName, data) {
// Global callbacks
for (var i = 0; i < this.global_callbacks.length; i++) {
this.global_callbacks[i](eventName, data);
}
// Event callbacks
var callbacks = this.callbacks.get(eventName);
if (callbacks) {
for (var i = 0; i < callbacks.length; i++) {
callbacks[i](data);
}
} else if (this.failThrough) {
this.failThrough(eventName, data)
}
return this;
};
EventsDispatcher.prototype.bind_all = function(callback) {
this.global_callbacks.push(callback);
return this;
};
this.Pusher.EventsDispatcher = EventsDispatcher;
}).call(this);
;(function() {
var Pusher = this.Pusher;
/*-----------------------------------------------
Helpers:
-----------------------------------------------*/
function capitalize(str) {
return str.substr(0, 1).toUpperCase() + str.substr(1);
}
function safeCall(method, obj, data) {
if (obj[method] !== undefined) {
obj[method](data);
}
}
/*-----------------------------------------------
The State Machine
-----------------------------------------------*/
function Machine(initialState, transitions, stateActions) {
Pusher.EventsDispatcher.call(this);
this.state = undefined;
this.errors = [];
// functions for each state
this.stateActions = stateActions;
// set up the transitions
this.transitions = transitions;
this.transition(initialState);
};
Machine.prototype.transition = function(nextState, data) {
var prevState = this.state;
var stateCallbacks = this.stateActions;
if (prevState && (Pusher.Util.arrayIndexOf(this.transitions[prevState], nextState) == -1)) {
this.emit('invalid_transition_attempt', {
oldState: prevState,
newState: nextState
});
throw new Error('Invalid transition [' + prevState + ' to ' + nextState + ']');
}
// exit
safeCall(prevState + 'Exit', stateCallbacks, data);
// tween
safeCall(prevState + 'To' + capitalize(nextState), stateCallbacks, data);
// pre
safeCall(nextState + 'Pre', stateCallbacks, data);
// change state:
this.state = nextState;
// handy to bind to
this.emit('state_change', {
oldState: prevState,
newState: nextState
});
// Post:
safeCall(nextState + 'Post', stateCallbacks, data);
};
Machine.prototype.is = function(state) {
return this.state === state;
};
Machine.prototype.isNot = function(state) {
return this.state !== state;
};
Pusher.Util.extend(Machine.prototype, Pusher.EventsDispatcher.prototype);
this.Pusher.Machine = Machine;
}).call(this);
;(function() {
/*
A little bauble to interface with window.navigator.onLine,
window.ononline and window.onoffline. Easier to mock.
*/
var NetInfo = function() {
var self = this;
Pusher.EventsDispatcher.call(this);
// This is okay, as IE doesn't support this stuff anyway.
if (window.addEventListener !== undefined) {
window.addEventListener("online", function() {
self.emit('online', null);
}, false);
window.addEventListener("offline", function() {
self.emit('offline', null);
}, false);
}
};
// Offline means definitely offline (no connection to router).
// Inverse does NOT mean definitely online (only currently supported in Safari
// and even there only means the device has a connection to the router).
NetInfo.prototype.isOnLine = function() {
if (window.navigator.onLine === undefined) {
return true;
} else {
return window.navigator.onLine;
}
};
Pusher.Util.extend(NetInfo.prototype, Pusher.EventsDispatcher.prototype);
this.Pusher.NetInfo = NetInfo;
}).call(this);
;(function() {
var Pusher = this.Pusher;
var machineTransitions = {
'initialized': ['waiting', 'failed'],
'waiting': ['connecting', 'permanentlyClosed'],
'connecting': ['open', 'permanentlyClosing', 'impermanentlyClosing', 'waiting'],
'open': ['connected', 'permanentlyClosing', 'impermanentlyClosing', 'waiting'],
'connected': ['permanentlyClosing', 'waiting'],
'impermanentlyClosing': ['waiting', 'permanentlyClosing'],
'permanentlyClosing': ['permanentlyClosed'],
'permanentlyClosed': ['waiting', 'failed'],
'failed': ['permanentlyClosed']
};
// Amount to add to time between connection attemtpts per failed attempt.
var UNSUCCESSFUL_CONNECTION_ATTEMPT_ADDITIONAL_WAIT = 2000;
var UNSUCCESSFUL_OPEN_ATTEMPT_ADDITIONAL_TIMEOUT = 2000;
var UNSUCCESSFUL_CONNECTED_ATTEMPT_ADDITIONAL_TIMEOUT = 2000;
var MAX_CONNECTION_ATTEMPT_WAIT = 5 * UNSUCCESSFUL_CONNECTION_ATTEMPT_ADDITIONAL_WAIT;
var MAX_OPEN_ATTEMPT_TIMEOUT = 5 * UNSUCCESSFUL_OPEN_ATTEMPT_ADDITIONAL_TIMEOUT;
var MAX_CONNECTED_ATTEMPT_TIMEOUT = 5 * UNSUCCESSFUL_CONNECTED_ATTEMPT_ADDITIONAL_TIMEOUT;
function resetConnectionParameters(connection) {
connection.connectionWait = 0;
if (Pusher.TransportType === 'flash') {
// Flash needs a bit more time
connection.openTimeout = 5000;
} else {
connection.openTimeout = 2000;
}
connection.connectedTimeout = 2000;
connection.connectionSecure = connection.compulsorySecure;
connection.connectionAttempts = 0;
}
function Connection(key, options) {
var self = this;
Pusher.EventsDispatcher.call(this);
this.options = Pusher.Util.extend({encrypted: false}, options);
this.netInfo = new Pusher.NetInfo();
this.netInfo.bind('online', function(){
if (self._machine.is('waiting')) {
self._machine.transition('connecting');
updateState('connecting');
}
});
this.netInfo.bind('offline', function() {
if (self._machine.is('connected')) {
// These are for Chrome 15, which ends up
// having two sockets hanging around.
self.socket.onclose = undefined;
self.socket.onmessage = undefined;
self.socket.onerror = undefined;
self.socket.onopen = undefined;
self.socket.close();
self.socket = undefined;
self._machine.transition('waiting');
}
});
// define the state machine that runs the connection
this._machine = new Pusher.Machine('initialized', machineTransitions, {
initializedPre: function() {
self.compulsorySecure = self.options.encrypted;
self.key = key;
self.socket = null;
self.socket_id = null;
self.state = 'initialized';
},
waitingPre: function() {
if (self.connectionWait > 0) {
self.emit('connecting_in', self.connectionWait);
}
if (self.netInfo.isOnLine() && self.connectionAttempts <= 4) {
updateState('connecting');
} else {
updateState('unavailable');
}
// When in the unavailable state we attempt to connect, but don't
// broadcast that fact
if (self.netInfo.isOnLine()) {
self._waitingTimer = setTimeout(function() {
self._machine.transition('connecting');
}, connectionDelay());
}
},
waitingExit: function() {
clearTimeout(self._waitingTimer);
},
connectingPre: function() {
// Case that a user manages to get to the connecting
// state even when offline.
if (self.netInfo.isOnLine() === false) {
self._machine.transition('waiting');
updateState('unavailable');
return;
}
var url = formatURL(self.key, self.connectionSecure);
Pusher.debug('Connecting', url);
self.socket = new Pusher.Transport(url);
// now that the socket connection attempt has been started,
// set up the callbacks fired by the socket for different outcomes
self.socket.onopen = ws_onopen;
self.socket.onclose = transitionToWaiting;
self.socket.onerror = ws_onError;
// allow time to get ws_onOpen, otherwise close socket and try again
self._connectingTimer = setTimeout(TransitionToImpermanentlyClosing, self.openTimeout);
},
connectingExit: function() {
clearTimeout(self._connectingTimer);
self.socket.onopen = undefined; // unbind to avoid open events that are no longer relevant
},
connectingToWaiting: function() {
updateConnectionParameters();
// FUTURE: update only ssl
},
connectingToImpermanentlyClosing: function() {
updateConnectionParameters();
// FUTURE: update only timeout
},
openPre: function() {
self.socket.onmessage = ws_onMessageOpen;
self.socket.onerror = ws_onError;
self.socket.onclose = transitionToWaiting;
// allow time to get connected-to-Pusher message, otherwise close socket, try again
self._openTimer = setTimeout(TransitionToImpermanentlyClosing, self.connectedTimeout);
},
openExit: function() {
clearTimeout(self._openTimer);
self.socket.onmessage = undefined; // unbind to avoid messages that are no longer relevant
},
openToWaiting: function() {
updateConnectionParameters();
},
openToImpermanentlyClosing: function() {
updateConnectionParameters();
},
connectedPre: function(socket_id) {
self.socket_id = socket_id;
self.socket.onmessage = ws_onMessageConnected;
self.socket.onerror = ws_onError;
self.socket.onclose = transitionToWaiting;
resetConnectionParameters(self);
self.connectedAt = new Date().getTime();
resetActivityCheck();
},
connectedPost: function() {
updateState('connected');
},
connectedExit: function() {
stopActivityCheck();
updateState('disconnected');
},
impermanentlyClosingPost: function() {
if (self.socket) {
self.socket.onclose = transitionToWaiting;
self.socket.close();
}
},
permanentlyClosingPost: function() {
if (self.socket) {
self.socket.onclose = function() {
resetConnectionParameters(self);
self._machine.transition('permanentlyClosed');
};
self.socket.close();
} else {
resetConnectionParameters(self);
self._machine.transition('permanentlyClosed');
}
},
failedPre: function() {
updateState('failed');
Pusher.debug('WebSockets are not available in this browser.');
},
permanentlyClosedPost: function() {
updateState('disconnected');
}
});
/*-----------------------------------------------
-----------------------------------------------*/
function updateConnectionParameters() {
if (self.connectionWait < MAX_CONNECTION_ATTEMPT_WAIT) {
self.connectionWait += UNSUCCESSFUL_CONNECTION_ATTEMPT_ADDITIONAL_WAIT;
}
if (self.openTimeout < MAX_OPEN_ATTEMPT_TIMEOUT) {
self.openTimeout += UNSUCCESSFUL_OPEN_ATTEMPT_ADDITIONAL_TIMEOUT;
}
if (self.connectedTimeout < MAX_CONNECTED_ATTEMPT_TIMEOUT) {
self.connectedTimeout += UNSUCCESSFUL_CONNECTED_ATTEMPT_ADDITIONAL_TIMEOUT;
}
if (self.compulsorySecure !== true) {
self.connectionSecure = !self.connectionSecure;
}
self.connectionAttempts++;
}
function formatURL(key, isSecure) {
var port = Pusher.ws_port;
var protocol = 'ws://';
// Always connect with SSL if the current page has
// been loaded via HTTPS.
//
// FUTURE: Always connect using SSL.
//
if (isSecure || document.location.protocol === 'https:') {
port = Pusher.wss_port;
protocol = 'wss://';
}
var flash = (Pusher.TransportType === "flash") ? "true" : "false";
return protocol + Pusher.host + ':' + port + '/app/' + key + '?protocol=5&client=js'
+ '&version=' + Pusher.VERSION
+ '&flash=' + flash;
}
// callback for close and retry. Used on timeouts.
function TransitionToImpermanentlyClosing() {
self._machine.transition('impermanentlyClosing');
}
function resetActivityCheck() {
if (self._activityTimer) { clearTimeout(self._activityTimer); }
// Send ping after inactivity
self._activityTimer = setTimeout(function() {
self.send_event('pusher:ping', {})
// Wait for pong response
self._activityTimer = setTimeout(function() {
self.socket.close();
}, (self.options.pong_timeout || Pusher.pong_timeout))
}, (self.options.activity_timeout || Pusher.activity_timeout))
}
function stopActivityCheck() {
if (self._activityTimer) { clearTimeout(self._activityTimer); }
}
// Returns the delay before the next connection attempt should be made
//
// This function guards against attempting to connect more frequently than
// once every second
//
function connectionDelay() {
var delay = self.connectionWait;
if (delay === 0) {
if (self.connectedAt) {
var t = 1000;
var connectedFor = new Date().getTime() - self.connectedAt;
if (connectedFor < t) {
delay = t - connectedFor;
}
}
}
return delay;
}
/*-----------------------------------------------
WebSocket Callbacks
-----------------------------------------------*/
// no-op, as we only care when we get pusher:connection_established
function ws_onopen() {
self._machine.transition('open');
};
function handleCloseCode(code, message) {
// first inform the end-developer of this error
self.emit('error', {type: 'PusherError', data: {code: code, message: message}});
if (code === 4000) {
// SSL only app
self.compulsorySecure = true;
self.connectionSecure = true;
self.options.encrypted = true;
TransitionToImpermanentlyClosing();
} else if (code < 4100) {
// Permentently close connection
self._machine.transition('permanentlyClosing')
} else if (code < 4200) {
// Backoff before reconnecting
self.connectionWait = 1000;
self._machine.transition('waiting')
} else if (code < 4300) {
// Reconnect immediately
TransitionToImpermanentlyClosing();
} else {
// Unknown error
self._machine.transition('permanentlyClosing')
}
}
function ws_onMessageOpen(event) {
var params = parseWebSocketEvent(event);
if (params !== undefined) {
if (params.event === 'pusher:connection_established') {
self._machine.transition('connected', params.data.socket_id);
} else if (params.event === 'pusher:error') {
handleCloseCode(params.data.code, params.data.message)
}
}
}
function ws_onMessageConnected(event) {
resetActivityCheck();
var params = parseWebSocketEvent(event);
if (params !== undefined) {
Pusher.debug('Event recd', params);
switch (params.event) {
case 'pusher:error':
self.emit('error', {type: 'PusherError', data: params.data});
break;
case 'pusher:ping':
self.send_event('pusher:pong', {})
break;
}
self.emit('message', params);
}
}
/**
* Parses an event from the WebSocket to get
* the JSON payload that we require
*
* @param {MessageEvent} event The event from the WebSocket.onmessage handler.
**/
function parseWebSocketEvent(event) {
try {
var params = JSON.parse(event.data);
if (typeof params.data === 'string') {
try {
params.data = JSON.parse(params.data);
} catch (e) {
if (!(e instanceof SyntaxError)) {
throw e;
}
}
}
return params;
} catch (e) {
self.emit('error', {type: 'MessageParseError', error: e, data: event.data});
}
}
function transitionToWaiting() {
self._machine.transition('waiting');
}
function ws_onError(error) {
// just emit error to user - socket will already be closed by browser
self.emit('error', { type: 'WebSocketError', error: error });
}
// Updates the public state information exposed by connection
//
// This is distinct from the internal state information used by _machine
// to manage the connection
//
function updateState(newState, data) {
var prevState = self.state;
self.state = newState;
// Only emit when the state changes
if (prevState !== newState) {
Pusher.debug('State changed', prevState + ' -> ' + newState);
self.emit('state_change', {previous: prevState, current: newState});
self.emit(newState, data);
}
}
};
Connection.prototype.connect = function() {
// no WebSockets
if (!this._machine.is('failed') && !Pusher.Transport) {
this._machine.transition('failed');
}
// initial open of connection
else if(this._machine.is('initialized')) {
resetConnectionParameters(this);
this._machine.transition('waiting');
}
// user skipping connection wait
else if (this._machine.is('waiting') && this.netInfo.isOnLine() === true) {
this._machine.transition('connecting');
}
// user re-opening connection after closing it
else if(this._machine.is("permanentlyClosed")) {
resetConnectionParameters(this);
this._machine.transition('waiting');
}
};
Connection.prototype.send = function(data) {
if (this._machine.is('connected')) {
// Workaround for MobileSafari bug (see https://gist.github.com/2052006)
var self = this;
setTimeout(function() {
self.socket.send(data);
}, 0);
return true;
} else {
return false;
}
};
Connection.prototype.send_event = function(event_name, data, channel) {
var payload = {
event: event_name,
data: data
};
if (channel) payload['channel'] = channel;
Pusher.debug('Event sent', payload);
return this.send(JSON.stringify(payload));
}
Connection.prototype.disconnect = function() {
if (this._machine.is('permanentlyClosed')) return;
if (this._machine.is('waiting') || this._machine.is('failed')) {
this._machine.transition('permanentlyClosed');
} else {
this._machine.transition('permanentlyClosing');
}
};
Pusher.Util.extend(Connection.prototype, Pusher.EventsDispatcher.prototype);
this.Pusher.Connection = Connection;
}).call(this);
;(function() {
Pusher.Channels = function() {
this.channels = {};
};
Pusher.Channels.prototype = {
add: function(channel_name, pusher) {
var existing_channel = this.find(channel_name);
if (!existing_channel) {
var channel = Pusher.Channel.factory(channel_name, pusher);
this.channels[channel_name] = channel;
return channel;
} else {
return existing_channel;
}
},
find: function(channel_name) {
return this.channels[channel_name];
},
remove: function(channel_name) {
delete this.channels[channel_name];
},
disconnect: function () {
for(var channel_name in this.channels){
this.channels[channel_name].disconnect()
}
}
};
Pusher.Channel = function(channel_name, pusher) {
var self = this;
Pusher.EventsDispatcher.call(this, function(event_name, event_data) {
Pusher.debug('No callbacks on ' + channel_name + ' for ' + event_name);
});
this.pusher = pusher;
this.name = channel_name;
this.subscribed = false;
this.bind('pusher_internal:subscription_succeeded', function(data) {
self.onSubscriptionSucceeded(data);
});
};
Pusher.Channel.prototype = {
// inheritable constructor
init: function() {},
disconnect: function() {
this.subscribed = false;
this.emit("pusher_internal:disconnected");
},
onSubscriptionSucceeded: function(data) {
this.subscribed = true;
this.emit('pusher:subscription_succeeded');
},
authorize: function(socketId, options, callback){
return callback(false, {}); // normal channels don't require auth
},
trigger: function(event, data) {
return this.pusher.send_event(event, data, this.name);
}
};
Pusher.Util.extend(Pusher.Channel.prototype, Pusher.EventsDispatcher.prototype);
Pusher.Channel.PrivateChannel = {
authorize: function(socketId, options, callback){
var self = this;
var authorizer = new Pusher.Channel.Authorizer(this, Pusher.channel_auth_transport, options);
return authorizer.authorize(socketId, function(err, authData) {
if(!err) {
self.emit('pusher_internal:authorized', authData);
}
callback(err, authData);
});
}
};
Pusher.Channel.PresenceChannel = {
init: function(){
this.members = new Members(this); // leeches off channel events
},
onSubscriptionSucceeded: function(data) {
this.subscribed = true;
// We override this because we want the Members obj to be responsible for
// emitting the pusher:subscription_succeeded. It will do this after it has done its work.
}
};
var Members = function(channel) {
var self = this;
var reset = function() {
this._members_map = {};
this.count = 0;
this.me = null;
};
reset.call(this);
channel.bind('pusher_internal:authorized', function(authorizedData) {
var channelData = JSON.parse(authorizedData.channel_data);
channel.bind("pusher_internal:subscription_succeeded", function(subscriptionData) {
self._members_map = subscriptionData.presence.hash;
self.count = subscriptionData.presence.count;
self.me = self.get(channelData.user_id);
channel.emit('pusher:subscription_succeeded', self);
});
});
channel.bind('pusher_internal:member_added', function(data) {
if(self.get(data.user_id) === null) { // only incr if user_id does not already exist
self.count++;
}
self._members_map[data.user_id] = data.user_info;
channel.emit('pusher:member_added', self.get(data.user_id));
});
channel.bind('pusher_internal:member_removed', function(data) {
var member = self.get(data.user_id);
if(member) {
delete self._members_map[data.user_id];
self.count--;
channel.emit('pusher:member_removed', member);
}
});
channel.bind('pusher_internal:disconnected', function() {
reset.call(self);
});
};
Members.prototype = {
each: function(callback) {
for(var i in this._members_map) {
callback(this.get(i));
}
},
get: function(user_id) {
if (this._members_map.hasOwnProperty(user_id)) { // have heard of this user user_id
return {
id: user_id,
info: this._members_map[user_id]
}
} else { // have never heard of this user
return null;
}
}
};
Pusher.Channel.factory = function(channel_name, pusher){
var channel = new Pusher.Channel(channel_name, pusher);
if (channel_name.indexOf('private-') === 0) {
Pusher.Util.extend(channel, Pusher.Channel.PrivateChannel);
} else if (channel_name.indexOf('presence-') === 0) {
Pusher.Util.extend(channel, Pusher.Channel.PrivateChannel);
Pusher.Util.extend(channel, Pusher.Channel.PresenceChannel);
};
channel.init();
return channel;
};
}).call(this);
;(function() {
Pusher.Channel.Authorizer = function(channel, type, options) {
this.channel = channel;
this.type = type;
this.authOptions = (options || {}).auth || {};
};
Pusher.Channel.Authorizer.prototype = {
composeQuery: function(socketId) {
var query = '&socket_id=' + encodeURIComponent(socketId)
+ '&channel_name=' + encodeURIComponent(this.channel.name);
for(var i in this.authOptions.params) {
query += "&" + encodeURIComponent(i) + "=" + encodeURIComponent(this.authOptions.params[i]);
}
return query;
},
authorize: function(socketId, callback) {
return Pusher.authorizers[this.type].call(this, socketId, callback);
}
};
Pusher.auth_callbacks = {};
Pusher.authorizers = {
ajax: function(socketId, callback){
var self = this, xhr;
if (Pusher.XHR) {
xhr = new Pusher.XHR();
} else {
xhr = (window.XMLHttpRequest ? new window.XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP"));
}
xhr.open("POST", Pusher.channel_auth_endpoint, true);
// add request headers
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
for(var headerName in this.authOptions.headers) {
xhr.setRequestHeader(headerName, this.authOptions.headers[headerName]);
}
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
if (xhr.status == 200) {
var data, parsed = false;
try {
data = JSON.parse(xhr.responseText);
parsed = true;
} catch (e) {
callback(true, 'JSON returned from webapp was invalid, yet status code was 200. Data was: ' + xhr.responseText);
}
if (parsed) { // prevents double execution.
callback(false, data);
}
} else {
Pusher.warn("Couldn't get auth info from your webapp", xhr.status);
callback(true, xhr.status);
}
}
};
xhr.send(this.composeQuery(socketId));
return xhr;
},
jsonp: function(socketId, callback){
if(this.authOptions.headers !== undefined) {
Pusher.warn("Warn", "To send headers with the auth request, you must use AJAX, rather than JSONP.");
}
var script = document.createElement("script");
// Hacked wrapper.
Pusher.auth_callbacks[this.channel.name] = function(data) {
callback(false, data);
};
var callback_name = "Pusher.auth_callbacks['" + this.channel.name + "']";
script.src = Pusher.channel_auth_endpoint
+ '?callback='
+ encodeURIComponent(callback_name)
+ this.composeQuery(socketId);
var head = document.getElementsByTagName("head")[0] || document.documentElement;
head.insertBefore( script, head.firstChild );
}
};
}).call(this);
// _require(dependencies, callback) takes an array of dependency urls and a
// callback to call when all the dependecies have finished loading
var _require = (function() {
function handleScriptLoaded(elem, callback) {
if (document.addEventListener) {
elem.addEventListener('load', callback, false);
} else {
elem.attachEvent('onreadystatechange', function () {
if (elem.readyState == 'loaded' || elem.readyState == 'complete') {
callback();
}
});
}
}
function addScript(src, callback) {
var head = document.getElementsByTagName('head')[0];
var script = document.createElement('script');
script.setAttribute('src', src);
script.setAttribute("type","text/javascript");
script.setAttribute('async', true);
handleScriptLoaded(script, function() {
callback();
});
head.appendChild(script);
}
return function(deps, callback) {
var deps_loaded = 0;
for (var i = 0; i < deps.length; i++) {
addScript(deps[i], function() {
if (deps.length == ++deps_loaded) {
// This setTimeout is a workaround for an Opera issue
setTimeout(callback, 0);
}
});
}
}
})();
;(function() {
// Support Firefox versions which prefix WebSocket
if (!window['WebSocket'] && window['MozWebSocket']) {
window['WebSocket'] = window['MozWebSocket']
}
if (window['WebSocket']) {
Pusher.Transport = window['WebSocket'];
Pusher.TransportType = 'native';
}
var cdn = (document.location.protocol == 'http:') ? Pusher.cdn_http : Pusher.cdn_https;
var root = cdn + Pusher.VERSION;
var deps = [];
if (!window['JSON']) {
deps.push(root + '/json2' + Pusher.dependency_suffix + '.js');
}
if (!window['WebSocket']) {
// We manually initialize web-socket-js to iron out cross browser issues
window.WEB_SOCKET_DISABLE_AUTO_INITIALIZATION = true;
deps.push(root + '/flashfallback' + Pusher.dependency_suffix + '.js');
}
var initialize = function() {
if (window['WebSocket']) {
// Initialize function in the case that we have native WebSocket support
return function() {
Pusher.ready();
}
} else {
// Initialize function for fallback case
return function() {
if (window['WebSocket']) {
// window['WebSocket'] is a flash emulation of WebSocket
Pusher.Transport = window['WebSocket'];
Pusher.TransportType = 'flash';
// window.WEB_SOCKET_SWF_LOCATION = root + "/WebSocketMain.swf";
window.WEB_SOCKET_SWF_LOCATION = "https://s3.amazonaws.com/uploadcare-static/WebSocketMainInsecure.swf"
WebSocket.__addTask(function() {
Pusher.ready();
})
WebSocket.__initialize();
} else {
// Flash must not be installed
Pusher.Transport = null;
Pusher.TransportType = 'none';
Pusher.ready();
}
}
}
}();
// Allows calling a function when the document body is available
var ondocumentbody = function(callback) {
var load_body = function() {
document.body ? callback() : setTimeout(load_body, 0);
}
load_body();
};
var initializeOnDocumentBody = function() {
ondocumentbody(initialize);
}
if (deps.length > 0) {
_require(deps, initializeOnDocumentBody);
} else {
initializeOnDocumentBody();
}
})();
(function() {
}).call(this);
(function() {
uploadcare.namespace('uploadcare.utils.abilities', function(ns) {
ns.canFileAPI = !!window.FileList;
ns.dragAndDrop = (function() {
var el;
el = document.createElement("div");
return ("draggable" in el) || ("ondragstart" in el && "ondrop" in el);
})();
ns.canvas = (function() {
var el;
el = document.createElement("canvas");
return !!(el.getContext && el.getContext('2d'));
})();
return ns.fileDragAndDrop = ns.canFileAPI && ns.dragAndDrop;
});
}).call(this);
(function() {
uploadcare.namespace('uploadcare.utils.pusher', function(ns) {
var hasOwners, pusherInstance, pusherWrapped, pushers, releasePusher, updateConnection;
pushers = {};
ns.getPusher = function(key, owner) {
if (!(key in pushers)) {
pushers[key] = {
instance: null,
owners: {}
};
}
if (!pushers[key].owners[owner]) {
pushers[key].owners[owner] = true;
}
updateConnection(key);
return pusherWrapped(key, owner);
};
releasePusher = function(key, owner) {
if (!pushers[key].owners[owner]) {
return;
}
pushers[key].owners[owner] = false;
return updateConnection(key);
};
hasOwners = function(key) {
var owner;
return ((function() {
var _results;
_results = [];
for (owner in pushers[key].owners) {
if (pushers[key].owners[owner]) {
_results.push(owner);
}
}
return _results;
})()).length > 0;
};
updateConnection = function(key) {
var instance;
instance = pusherInstance(key);
if (hasOwners(key)) {
return instance.connect();
} else {
return setTimeout((function() {
if (!hasOwners(key)) {
return instance.disconnect();
}
}), 5000);
}
};
pusherInstance = function(key) {
var _ref;
if (((_ref = pushers[key]) != null ? _ref.instance : void 0) != null) {
return pushers[key].instance;
}
return pushers[key].instance = new Pusher(key);
};
return pusherWrapped = function(key, owner) {
var Wrapped;
Wrapped = function() {
this.owner = owner;
this.release = function() {
return releasePusher(key, owner);
};
return this;
};
Wrapped.prototype = pusherInstance(key);
return new Wrapped();
};
});
}).call(this);
(function() {
var $, namespace,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; },
__slice = [].slice;
namespace = uploadcare.namespace, $ = uploadcare.jQuery;
namespace('uploadcare.utils', function(utils) {
utils.Collection = (function() {
function Collection(items) {
var item, _i, _len;
if (items == null) {
items = [];
}
this.onAdd = $.Callbacks();
this.onRemove = $.Callbacks();
this.onReplaced = $.Callbacks();
this.onSorted = $.Callbacks();
this.__items = [];
for (_i = 0, _len = items.length; _i < _len; _i++) {
item = items[_i];
this.add(item);
}
}
Collection.prototype.add = function(item) {
this.__items.push(item);
return this.onAdd.fire(item);
};
Collection.prototype.remove = function(item) {
if (utils.remove(this.__items, item)) {
return this.onRemove.fire(item);
}
};
Collection.prototype.clear = function() {
var item, _i, _len, _ref, _results;
_ref = this.get();
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
item = _ref[_i];
_results.push(this.remove(item));
}
return _results;
};
Collection.prototype.replace = function(oldItem, newItem) {
var i, item, _i, _len, _ref, _results;
if (oldItem !== newItem) {
_ref = this.__items;
_results = [];
for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) {
item = _ref[i];
if (item === oldItem) {
_results.push(this.__replace(oldItem, newItem, i));
} else {
_results.push(void 0);
}
}
return _results;
}
};
Collection.prototype.__replace = function(oldItem, newItem, i) {
this.__items[i] = newItem;
return this.onReplaced.fire(oldItem, newItem, i);
};
Collection.prototype.sort = function(comparator) {
this.__items.sort(comparator);
return this.onSorted.fire();
};
Collection.prototype.get = function(index) {
if (index != null) {
return this.__items[index];
} else {
return this.__items.slice(0);
}
};
Collection.prototype.length = function() {
return this.__items.length;
};
return Collection;
})();
utils.UniqCollection = (function(_super) {
__extends(UniqCollection, _super);
function UniqCollection() {
return UniqCollection.__super__.constructor.apply(this, arguments);
}
UniqCollection.prototype.add = function(item) {
if (__indexOf.call(this.__items, item) >= 0) {
return;
}
return UniqCollection.__super__.add.apply(this, arguments);
};
UniqCollection.prototype.__replace = function(oldItem, newItem, i) {
if (__indexOf.call(this.__items, newItem) >= 0) {
return this.remove(oldItem);
} else {
return UniqCollection.__super__.__replace.apply(this, arguments);
}
};
return UniqCollection;
})(utils.Collection);
return utils.CollectionOfPromises = (function(_super) {
__extends(CollectionOfPromises, _super);
function CollectionOfPromises() {
this.onAnyDone = $.Callbacks();
this.onAnyFail = $.Callbacks();
this.onAnyProgress = $.Callbacks();
this.onAnyProgress.add(function(item, firstArgument) {
return $(item).data('lastProgress', firstArgument);
});
CollectionOfPromises.__super__.constructor.apply(this, arguments);
}
CollectionOfPromises.prototype.lastProgresses = function() {
var item, _i, _len, _ref, _results;
_ref = this.__items;
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
item = _ref[_i];
_results.push($(item).data('lastProgress'));
}
return _results;
};
CollectionOfPromises.prototype.add = function(item) {
if (!(item && item.done && item.fail && item.then)) {
return;
}
CollectionOfPromises.__super__.add.apply(this, arguments);
return this.__watchItem(item);
};
CollectionOfPromises.prototype.__watchItem = function(item) {
var handler,
_this = this;
handler = function(callbacks) {
return function() {
var args;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
if (__indexOf.call(_this.__items, item) >= 0) {
args.unshift(item);
return callbacks.fire.apply(callbacks, args);
}
};
};
return item.then(handler(this.onAnyDone), handler(this.onAnyFail), handler(this.onAnyProgress));
};
CollectionOfPromises.prototype.__replace = function(oldItem, newItem, i) {
if (!(newItem && newItem.done && newItem.fail && newItem.then)) {
return this.remove(oldItem);
} else {
CollectionOfPromises.__super__.__replace.apply(this, arguments);
return this.__watchItem(newItem);
}
};
return CollectionOfPromises;
})(utils.UniqCollection);
});
}).call(this);
(function() {
var namespace;
namespace = uploadcare.namespace;
namespace('uploadcare.utils', function(ns) {
var common, messages;
ns.log = function(msg) {
if (window.console && console.log) {
return console.log(msg);
} else {
}
};
ns.warn = function(msg) {
if (window.console && console.warn) {
return console.warn(msg);
} else {
return ns.log("Warning: " + msg);
}
};
messages = {};
ns.warnOnce = function(msg) {
if (messages[msg] == null) {
messages[msg] = true;
return ns.warn(msg);
}
};
common = {
autostore: "You have enabled autostore in the widget, but not on the server.\nTo use autostore, make sure it's enabled in project settings.\n\nhttps://uploadcare.com/accounts/settings/",
publicKey: "Global public key not set. Uploads may not work!\nAdd this to the tag to set your key:\n\n"
};
return ns.commonWarning = function(name) {
if (common[name] != null) {
return ns.warnOnce(common[name]);
}
};
});
}).call(this);
(function() {
var $, namespace,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
namespace = uploadcare.namespace, $ = uploadcare.jQuery;
namespace('uploadcare.utils', function(ns) {
var own;
own = Object.prototype.hasOwnProperty;
ns.own = function(o, prop) {
return own.call(o, prop);
};
ns.uniq = function(arr, cond) {
var item, result, _i, _len;
if (cond == null) {
cond = function() {
return true;
};
}
result = [];
for (_i = 0, _len = arr.length; _i < _len; _i++) {
item = arr[_i];
if (cond(item) && __indexOf.call(result, item) < 0) {
result.push(item);
}
}
return result;
};
ns.defer = function(fn) {
return setTimeout(fn, 0);
};
ns.once = function(fn) {
var called, result;
called = false;
result = null;
return function() {
if (!called) {
result = fn.apply(this, arguments);
called = true;
}
return result;
};
};
ns.wrapToPromise = function(value) {
return $.Deferred().resolve(value).promise();
};
ns.remove = function(array, item) {
var index;
index = $.inArray(item, array);
if (index !== -1) {
array.splice(index, 1);
return true;
} else {
return false;
}
};
ns.then = function(pr, doneFilter, failFilter, progressFilter) {
var compose, df;
df = $.Deferred();
compose = function(fn1, fn2) {
if (fn1 && fn2) {
return function() {
return fn2.call(this, fn1.apply(this, arguments));
};
} else {
return fn1 || fn2;
}
};
pr.then(compose(doneFilter, df.resolve), compose(failFilter, df.reject), compose(progressFilter, df.notify));
return df.promise();
};
ns.bindAll = function(source, methods) {
var target;
target = {};
$.each(methods, function(i, method) {
var fn;
fn = source[method];
if ($.isFunction(fn)) {
return target[method] = function() {
var result;
result = fn.apply(source, arguments);
if (result === source) {
return target;
} else {
return result;
}
};
} else {
return target[method] = fn;
}
});
return target;
};
ns.upperCase = function(s) {
return s.replace(/-/g, '_').toUpperCase();
};
ns.publicCallbacks = function(callbacks) {
var result;
result = callbacks.add;
result.add = callbacks.add;
result.remove = callbacks.remove;
return result;
};
ns.uuid = function() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r, v;
r = Math.random() * 16 | 0;
v = c === 'x' ? r : r & 3 | 8;
return v.toString(16);
});
};
ns.splitUrlRegex = /^(?:([^:\/?#]+):)?(?:\/\/([^\/?\#]*))?([^?\#]*)\??([^\#]*)\#?(.*)$/;
ns.uuidRegex = /[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/i;
ns.groupIdRegex = new RegExp("" + ns.uuidRegex.source + "~[0-9]+", 'i');
ns.cdnUrlRegex = new RegExp("^/?(" + ns.uuidRegex.source + ")(?:/(-/(?:[^/]+/)+)?([^/]*))?$", 'i');
ns.splitCdnUrl = function(url) {
return ns.cdnUrlRegex.exec(ns.splitUrlRegex.exec(url)[3]);
};
ns.escapeRegExp = function(str) {
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
};
ns.normalizeUrl = function(url) {
if (!url.match(/^([a-z][a-z0-9+\-\.]*:)?\/\//i)) {
url = "https://" + url;
}
return url.replace(/\/+$/, '');
};
ns.fitText = function(text, max) {
var head, tail;
if (text.length > max) {
head = Math.ceil((max - 3) / 2);
tail = Math.floor((max - 3) / 2);
return text.slice(0, head) + '...' + text.slice(-tail);
} else {
return text;
}
};
ns.fitSizeInCdnLimit = function(objSize) {
return ns.fitSize(objSize, [1600, 1600]);
};
ns.fitSize = function(objSize, boxSize, upscale) {
var heightRation, widthRatio;
if (objSize[0] > boxSize[0] || objSize[1] > boxSize[1] || upscale) {
widthRatio = boxSize[0] / objSize[0];
heightRation = boxSize[1] / objSize[1];
if (!boxSize[0] || (boxSize[1] && widthRatio > heightRation)) {
return [Math.round(heightRation * objSize[0]), boxSize[1]];
} else {
return [boxSize[0], Math.round(widthRatio * objSize[1])];
}
} else {
return objSize.slice();
}
};
ns.fileInput = function(container, multiple, fn) {
var input;
container.find('input:file').remove();
input = multiple ? $(' ') : $(' ');
input.css({
position: 'absolute',
top: 0,
opacity: 0,
margin: 0,
padding: 0,
width: 'auto',
height: 'auto',
cursor: container.css('cursor')
});
container.css({
position: 'relative',
overflow: 'hidden'
}).append(input);
input.on('change', function(e) {
fn(e);
input.remove();
return ns.fileInput(container, multiple, fn);
});
return container.mousemove(function(e) {
var left, top, width, _ref;
_ref = $(this).offset(), left = _ref.left, top = _ref.top;
width = input.width();
return input.css({
left: e.pageX - left - width + 10,
top: e.pageY - top - 10
});
});
};
ns.readableFileSize = function(value, onNaN, prefix, postfix) {
var i, label, labels, _i, _len;
if (onNaN == null) {
onNaN = '';
}
if (prefix == null) {
prefix = '';
}
if (postfix == null) {
postfix = '';
}
value = parseInt(value, 10);
if (isNaN(value)) {
return onNaN;
}
labels = 'B KB MB GB TB PB EB ZB YB'.split(' ');
for (i = _i = 0, _len = labels.length; _i < _len; i = ++_i) {
label = labels[i];
if (value < 512 || i === labels.length - 1) {
return "" + prefix + value + " " + label + postfix;
}
value = Math.round(value / 1024);
}
};
ns.imagePath = function(name) {
return uploadcare.settings.build().scriptBase + 'images/' + name;
};
ns.ajaxDefaults = {
dataType: 'json',
crossDomain: true,
cache: false
};
ns.jsonp = function(url, type, data) {
if ($.isPlainObject(type)) {
data = type;
type = 'GET';
}
return $.ajax($.extend({
url: url,
type: type,
data: data
}, ns.ajaxDefaults)).then(function(data) {
var text;
if (data.error) {
text = data.error.content || data.error;
ns.warn("JSONP error: " + text + " while loading " + url);
return $.Deferred().reject(text);
} else {
return data;
}
}, function(_, textStatus, errorThrown) {
var text;
text = "" + textStatus + " (" + errorThrown + ")";
ns.warn("JSONP unexpected error: " + text + " while loading " + url);
return text;
});
};
return ns.plugin = function(fn) {
return fn(uploadcare);
};
});
}).call(this);
(function() {
var $, expose, namespace, utils,
__hasProp = {}.hasOwnProperty,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
expose = uploadcare.expose, namespace = uploadcare.namespace, utils = uploadcare.utils, $ = uploadcare.jQuery;
namespace('uploadcare.settings', function(ns) {
var arrayOptions, defaults, flagOptions, intOptions, key, normalize, parseCrop, presets, publicDefaults, str2arr, urlOptions, value, waitForSettingsCb;
defaults = {
'live': true,
'manual-start': false,
'locale': null,
'locale-pluralize': null,
'locale-translations': null,
'crop': 'disabled',
'preview-step': false,
'images-only': false,
'clearable': false,
'multiple': false,
'multiple-max': 0,
'multiple-min': 1,
'path-value': false,
'tabs': 'file url facebook gdrive instagram evernote box skydrive',
'autostore': false,
'public-key': null,
'pusher-key': '79ae88bd931ea68464d9',
'cdn-base': 'http://www.ucarecdn.com',
'url-base': 'https://upload.uploadcare.com',
'social-base': 'https://social.uploadcare.com',
'script-base': typeof SCRIPT_BASE !== "undefined" && SCRIPT_BASE !== null ? SCRIPT_BASE : ''
};
presets = {
'tabs': {
all: 'file url facebook vk dropbox gdrive instagram evernote box skydrive',
"default": defaults.tabs
}
};
str2arr = function(value) {
if (!$.isArray(value)) {
value = $.trim(value);
value = value ? value.split(' ') : [];
}
return value;
};
arrayOptions = function(settings, keys) {
var key, name, preset, presetList, value, _i, _len;
for (_i = 0, _len = keys.length; _i < _len; _i++) {
key = keys[_i];
value = str2arr(settings[key]);
presetList = presets[key];
for (name in presetList) {
if (!__hasProp.call(presetList, name)) continue;
preset = presetList[name];
if (__indexOf.call(value, name) >= 0) {
value = value.concat(str2arr(preset));
}
}
settings[key] = utils.uniq(value, function(x) {
return !utils.own(presetList, x);
});
}
return settings;
};
urlOptions = function(settings, keys) {
var key, _i, _len;
for (_i = 0, _len = keys.length; _i < _len; _i++) {
key = keys[_i];
if (settings[key] != null) {
settings[key] = utils.normalizeUrl(settings[key]);
}
}
return settings;
};
flagOptions = function(settings, keys) {
var key, value, _i, _len;
for (_i = 0, _len = keys.length; _i < _len; _i++) {
key = keys[_i];
if (!(settings[key] != null)) {
continue;
}
value = settings[key];
if ($.type(value) === 'string') {
value = $.trim(value).toLowerCase();
settings[key] = !(value === 'false' || value === 'disabled');
} else {
settings[key] = !!value;
}
}
return settings;
};
intOptions = function(settings, keys) {
var key, _i, _len;
for (_i = 0, _len = keys.length; _i < _len; _i++) {
key = keys[_i];
if (settings[key] != null) {
settings[key] = parseInt(settings[key]);
}
}
return settings;
};
parseCrop = function(cropValue) {
var crop, ratio, reDisabled, reRatio;
crop = {
enabled: true
};
reDisabled = /^(disabled|false)$/i;
reRatio = /^([0-9]+)([x:])([0-9]+)(\s+(upscale|minimum))?$/i;
if (cropValue.match(reDisabled)) {
crop.enabled = false;
} else if (ratio = cropValue.toLowerCase().match(reRatio)) {
crop.preferedSize = [+ratio[1], +ratio[3]];
if (ratio[2] === 'x') {
crop.scale = true;
}
if (ratio[5]) {
crop.upscale = true;
if (ratio[5] === 'minimum') {
crop.notLess = true;
}
}
}
return crop;
};
normalize = function(settings) {
arrayOptions(settings, ['tabs']);
urlOptions(settings, ['cdnBase', 'socialBase', 'urlBase']);
flagOptions(settings, ['autostore', 'imagesOnly', 'multiple', 'clearable', 'pathValue', 'previewStep']);
intOptions(settings, ['multipleMax', 'multipleMin']);
if (!$.isPlainObject(settings.crop)) {
if (settings.multiple) {
settings.crop = {
enabled: false
};
} else {
settings.crop = parseCrop($.trim(settings.crop));
}
}
if (settings.crop.enabled || settings.multiple) {
settings.previewStep = true;
}
return settings;
};
publicDefaults = {};
for (key in defaults) {
if (!__hasProp.call(defaults, key)) continue;
value = defaults[key];
publicDefaults[$.camelCase(key)] = value;
}
expose('defaults', publicDefaults);
ns.globals = utils.once(function() {
var fallback, values;
values = {};
for (key in defaults) {
if (!__hasProp.call(defaults, key)) continue;
fallback = defaults[key];
value = window["UPLOADCARE_" + (utils.upperCase(key))];
values[$.camelCase(key)] = value != null ? value : fallback;
}
if (!values.publicKey) {
utils.commonWarning('publicKey');
}
return normalize(values);
});
ns.common = utils.once(function(settings) {
var result;
result = normalize($.extend({}, ns.globals(), settings || {}));
waitForSettingsCb.fire(result);
return result;
});
ns.build = function(settings) {
return normalize($.extend({}, ns.common(), settings || {}));
};
waitForSettingsCb = $.Callbacks("once memory");
ns.waitForSettings = function(settings, fn) {
return waitForSettingsCb.add(function(common) {
return fn(normalize($.extend({}, common, settings || {})));
});
};
ns.CssCollector = (function() {
function CssCollector() {
this.urls = [];
this.styles = [];
}
CssCollector.prototype.addUrl = function(url) {
if (!/^https?:\/\//i.test(url)) {
throw new Error('Embedded urls should be absolute. ' + url);
}
if (__indexOf.call(this.urls, url) < 0) {
return this.urls.push(url);
}
};
CssCollector.prototype.addStyle = function(style) {
return this.styles.push(style);
};
return CssCollector;
})();
return uploadcare.tabsCss = new ns.CssCollector;
});
}).call(this);
(function() {
uploadcare.namespace('uploadcare.locale.translations', function(ns) {
return ns.en = {
ready: 'Upload from',
uploading: 'Uploading... Please wait.',
loadingInfo: 'Loading info...',
errors: {
"default": 'Error',
baddata: 'Incorrect value',
size: 'File too big',
upload: 'Can’t upload',
user: 'Upload canceled',
info: 'Can’t load info',
image: 'Only images allowed',
createGroup: 'Can’t create file group',
deleted: 'File was deleted'
},
draghere: 'Drop a file here',
file: {
one: '%1 file',
other: '%1 files'
},
buttons: {
cancel: 'Cancel',
remove: 'Remove',
file: 'Computer'
},
dialog: {
done: 'Done',
showFiles: 'Show files',
tabs: {
file: {
drag: 'Drop a file here',
nodrop: 'Upload files from your computer',
or: 'or',
button: 'Choose a file from computer',
also: 'You can also choose it from',
tabNames: {
facebook: 'Facebook',
dropbox: 'Dropbox',
gdrive: 'Google Drive',
instagram: 'Instagram',
vk: 'VK',
evernote: 'Evernote',
box: 'Box',
skydrive: 'SkyDrive',
url: 'Arbitrary Links'
}
},
url: {
title: 'Files from the Web',
line1: 'Grab any file off the web.',
line2: 'Just provide the link.',
input: 'Paste your link here...',
button: 'Upload'
},
preview: {
unknownName: 'unknown',
change: 'Cancel',
back: 'Back',
done: 'Add',
unknown: {
title: 'Uploading... Please wait for a preview.',
done: 'Skip preview and accept'
},
regular: {
title: 'Add this file?',
line1: 'You are about to add the file above.',
line2: 'Please confirm.'
},
image: {
title: 'Add this image?',
change: 'Cancel'
},
crop: {
title: 'Crop and add this image',
done: 'Done'
},
error: {
"default": {
title: 'Oops!',
text: 'Something went wrong during the upload.',
back: 'Please try again'
},
image: {
title: 'Only image files are accepted.',
text: 'Please try again with another file.',
back: 'Choose image'
},
size: {
title: 'The file you selected exceeds the limit.',
text: 'Please try again with another file.'
}
},
multiple: {
title: 'You’ve chosen %files%',
question: 'Do you want to add all of these files?',
tooManyFiles: 'You’ve chosen too many files. %max% is maximum.',
tooFewFiles: 'You’ve chosen %files%. At least %min% required.',
clear: 'Remove all',
done: 'Done'
}
}
},
footer: {
text: 'Uploading, storing and processing files by',
link: 'Uploadcare.com'
}
},
crop: {
error: {
title: 'Error',
text: 'Can’t load image'
},
done: 'Done'
}
};
});
uploadcare.namespace('uploadcare.locale.pluralize', function(ns) {
return ns.en = function(n) {
if (n === 1) {
return 'one';
}
return 'other';
};
});
}).call(this);
(function() {
uploadcare.namespace('uploadcare.locale.translations', function(ns) {
return ns.es = {
ready: 'Subir desde',
uploading: 'Subiendo... Por favor espere.',
loadingInfo: 'Cargando Información...',
errors: {
"default": 'Error',
baddata: 'Valor incorrecto',
size: 'Demasiado grande',
upload: 'No se ha podido subir',
user: 'Subida cancelada',
info: 'No se pudo cargar la información',
image: 'Sólo se permiten imagenes'
},
draghere: 'Arrastra los archivos hasta aquí',
file: {
one: '%1 archivo',
other: '%1 archivos'
},
buttons: {
cancel: 'Cancelar',
remove: 'Eliminar',
file: 'Computadora'
},
dialog: {
tabs: {
file: {
drag: 'Arrastra una archivo aquí',
nodrop: 'Sube fotos desde tu computadora',
or: 'o',
button: 'Elige un archivo desde tu computadora',
also: 'Tambien puedes seleccionarlo de',
tabNames: {
facebook: 'Facebook',
dropbox: 'Dropbox',
gdrive: 'Google Drive',
instagram: 'Instagram',
vk: 'VK',
evernote: 'Evernote',
url: 'Una dirección cualquiera'
}
},
url: {
title: 'Archivos de la web',
line1: 'Selecciona cualquier archivo de la web.',
line2: 'Sólo danos el link.',
input: 'Copia tu link aquí...',
button: 'Subir'
},
preview: {
unknownName: 'desconocido',
change: 'Cancelar',
back: 'Atras',
done: 'Subir',
unknown: {
title: 'Subiendo. Por favor espera para una vista previa.',
done: 'Saltar vista previa y aceptar'
},
regular: {
title: '¿Quieres subir este archivo?',
line1: 'Estás por subir el archivo de arriba.',
line2: 'Confirma por favor.'
},
image: {
title: '¿Quieres subir esta imagen?',
change: 'Cancelar'
},
crop: {
title: 'Cortar y subir esta imagen'
},
error: {
"default": {
title: 'La subida falló',
line1: 'Algo salio mal durante la subida.',
line2: 'Por favor, trata de nuevo.'
},
image: {
title: 'Sólo imagenes',
line1: 'Sólo se aceptan archivos de imagenes.',
line2: 'Por favor, trata de nuevo con otro archivo.'
},
size: {
title: 'Límite de tamaño',
line1: 'El archivo que has seleccinado sobrepasa el límite de los 100MB.',
line2: 'Por favor trata de nuevo con otro archivo.'
}
}
}
},
footer: {
text: 'Los archivos ha sido subidos, gestionados y procesados por',
link: 'Uploadcare.com'
}
},
crop: {
error: {
title: 'Error',
text: 'No se pudo cargar la imangen'
},
done: 'Listo'
}
};
});
uploadcare.namespace('uploadcare.locale.pluralize', function(ns) {
return ns.es = function(n) {
if (n === 1) {
return 'one';
}
return 'other';
};
});
}).call(this);
(function() {
uploadcare.namespace('uploadcare.locale.translations', function(ns) {
return ns.fr = {
ready: 'Envoi depuis',
uploading: 'Envoi en cours... Merci de patientier.',
loadingInfo: 'Chargement des informations...',
errors: {
"default": 'Erreur',
baddata: 'Valeur incorrecte',
size: 'Fichier trop volumineux',
upload: 'Envoi impossible',
user: 'Envoi annulé',
info: 'Impossible de charger les informations',
image: 'Seules les images sont autorisées',
createGroup: 'Création d\'1 groupe impossible',
deleted: 'Le fichier a été supprimé'
},
draghere: 'Glissez-déposez un fichier ici',
file: {
one: '%1 fichier',
other: '%1 fichiers'
},
buttons: {
cancel: 'Annuler',
remove: 'Supprimer',
file: 'Ordinateur'
},
dialog: {
done: 'Terminer',
showFiles: 'Voir les fichiers',
tabs: {
file: {
drag: 'Glissez-déposez un fichier ici',
nodrop: 'Envoyez des fichiers depuis votre ordinateur',
or: 'ou',
button: 'Choisissez un fichier depuis votre ordinateur',
also: 'Vous pouvez également le sélectionner depuis',
tabNames: {
facebook: 'Facebook',
dropbox: 'Dropbox',
gdrive: 'Google Drive',
instagram: 'Instagram',
vk: 'VK',
evernote: 'Evernote',
url: 'Une adresse web'
}
},
url: {
title: 'Fichiers depuis le Web',
line1: 'Prenez n\'importe quel fichier depuis un site web.',
line2: 'Saisissez simplement son adresse.',
input: 'Collez le lien ici...',
button: 'Envoi'
},
preview: {
unknownName: 'inconnu',
change: 'Annuler',
back: 'Retour',
done: 'Ajouter',
unknown: {
title: 'Envoi en cours... Merci de patientier pour prévisualiser.',
done: 'Passer la prévisualisation et accepter'
},
regular: {
title: 'Ajouter ce fichier ?',
line1: 'Vous êtes sur le point d\'ajouter le fichier ci-dessus.',
line2: 'Merci de confirmer.'
},
image: {
title: 'Ajouter cette image ?',
change: 'Annuler'
},
crop: {
title: 'Recadrer et ajouter cette image',
done: 'Terminer'
},
error: {
"default": {
title: 'Oups!',
text: 'Quelque chose n\'a pas fonctionné pendant l\'envoi.',
back: 'Merci de bien vouloir recommencer'
},
image: {
title: 'Seules les images sont acceptées.',
text: 'Merci de bien vouloir recommencer avec un autre fichier.',
back: 'Choisir une image'
},
size: {
title: 'Le fichier sélectionné est trop volumineux.',
text: 'Merci de bien vouloir recommencer avec un autre fichier.'
}
},
multiple: {
title: 'Vous avez choisi %files%',
question: 'Voulez vous ajouter tous ces fichiers ?',
clear: 'Tout retirer',
done: 'Terminer'
}
}
},
footer: {
text: 'Envoi, stockage et traitement des fichiers par',
link: 'Uploadcare.com'
}
},
crop: {
error: {
title: 'Erreur',
text: 'Impossible de charger l\'image'
},
done: 'Terminer'
}
};
});
uploadcare.namespace('uploadcare.locale.pluralize', function(ns) {
return ns.fr = function(n) {
if (n === 1) {
return 'one';
}
return 'other';
};
});
}).call(this);
(function() {
uploadcare.namespace('uploadcare.locale.translations', function(ns) {
return ns.lv = {
ready: 'Izvēlieties failu',
uploading: 'Augšupielādē... Lūdzu, gaidiet.',
errors: {
"default": 'Kļūda',
image: 'Atļauti tikai attēli'
},
draghere: 'Velciet failus šeit',
file: {
zero: '%1 failu',
one: '%1 fails',
other: '%1 faili'
},
buttons: {
cancel: 'Atcelt',
remove: 'Dzēst',
file: 'Dators'
},
dialog: {
title: 'Ielādēt jebko no jebkurienes',
poweredby: 'Darbināts ar',
support: {
images: 'Attēli',
audio: 'Audio',
video: 'Video',
documents: 'Dokumenti'
},
tabs: {
file: {
title: 'Mans dators',
line1: 'Paņemiet jebkuru failu no jūsu datora.',
line2: 'Izvēlēties ar dialogu vai ievelciet iekšā.',
button: 'Meklēt failus'
},
url: {
title: 'Faili no tīmekļa',
line1: 'Paņemiet jebkuru failu no tīmekļa.',
line2: 'Tikai uzrādiet linku.',
input: 'Ielīmējiet linku šeit...',
button: 'Ielādēt'
}
}
}
};
});
uploadcare.namespace('uploadcare.locale.pluralize', function(ns) {
return ns.lv = function(n) {
if (n === 0) {
return 'zero';
}
if ((n % 10 === 1) && (n % 100 !== 11)) {
return 'one';
}
return 'other';
};
});
}).call(this);
(function() {
var __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
uploadcare.namespace('uploadcare.locale.translations', function(ns) {
return ns.pl = {
ready: 'Prześlij z',
uploading: 'Przesyłanie... Proszę czekać.',
errors: {
"default": 'Błąd'
},
draghere: 'Upuść plik tutaj',
buttons: {
cancel: 'Anuluj',
remove: 'Usuń',
file: 'Komputer'
},
dialog: {
tabs: {
file: {
title: 'Mój komputer'
},
url: {
title: 'Pliki z sieci'
}
}
}
};
});
uploadcare.namespace('uploadcare.locale.pluralize', function(ns) {
return ns.pl = function(n) {
var _ref, _ref1, _ref2, _ref3;
if (n === 1) {
return 'one';
}
if ((_ref = n % 10, __indexOf.call([2, 3, 4], _ref) >= 0) && (_ref1 = n % 100, __indexOf.call([12, 13, 14], _ref1) < 0)) {
return 'few';
}
if ((n !== 1) && ((_ref2 = n % 10, __indexOf.call([2, 3, 4], _ref2) < 0) || (_ref3 = n % 100, __indexOf.call([12, 13, 14], _ref3) >= 0))) {
return 'many';
}
return 'other';
};
});
}).call(this);
(function() {
uploadcare.namespace('uploadcare.locale.translations', function(ns) {
return ns.pt = {
ready: 'Fazer upload de',
uploading: 'Fazendo upload... Aguarde.',
loadingInfo: 'Carregando informações...',
errors: {
"default": 'Erro',
baddata: 'Valor incorreto',
size: 'Arquivo muito grande',
upload: 'Não foi possível fazer o upload',
user: 'Upload cancelado',
info: 'Não foi possível carregar as informações',
image: 'Apenas imagens são permitidas',
createGroup: 'Não foi possível criar o grupo de arquivos',
deleted: 'O arquivo foi excluído'
},
draghere: 'Arraste um arquivo para cá',
file: {
one: '%1 arquivo',
other: '%1 arquivos'
},
buttons: {
cancel: 'Cancelar',
remove: 'Excluir',
file: 'Computador'
},
dialog: {
done: 'OK',
showFiles: 'Mostrar arquivos',
tabs: {
file: {
drag: 'Arraste um arquivo para cá',
nodrop: 'Faça upload de arquivos do seu computador',
or: 'ou',
button: 'Escolha um arquivo do computador',
also: 'Você também pode escolher arquivos de',
tabNames: {
facebook: 'Facebook',
dropbox: 'Dropbox',
gdrive: 'Google Drive',
instagram: 'Instagram',
vk: 'VK',
evernote: 'Evernote',
url: 'Link da web'
}
},
url: {
title: 'Arquivos da web',
line1: 'Faça upload de qualquer arquivo da web.',
line2: 'Apenas informe o link.',
input: 'Cole seu link aqui...',
button: 'Upload'
},
preview: {
unknownName: 'desconhecido',
change: 'Cancelar',
back: 'Voltar',
done: 'Adicionar',
unknown: {
title: 'Fazendo upload... Aguarde o preview.',
done: 'Pular preview e aceitar'
},
regular: {
title: 'Adicionar esse arquivo?',
line1: 'Você está prestes a adicionar o arquivo acima.',
line2: 'Por favor, confirme.'
},
image: {
title: 'Adicionar essa imagem?',
change: 'Cancelar'
},
crop: {
title: 'Cortar e adicionar essa imagem',
done: 'OK'
},
error: {
"default": {
title: 'Oops!',
text: 'Alguma coisa deu errado durante o upload.',
back: 'Por favor, tente novamente'
},
image: {
title: 'Apenas arquivos de imagem são aceitos.',
text: 'Por favor, tente novamente com outro arquivo.',
back: 'Escolher a imagem'
},
size: {
title: 'O arquivo que você escolheu excede o limite.',
text: 'Por favor, tente novamente com outro arquivo.'
}
},
multiple: {
title: 'Você escolheu',
question: 'Você quer adicionar todos esses arquivos?',
clear: 'Excluir todos',
done: 'OK'
}
}
},
footer: {
text: 'Upload, armazenamento e processamento dos arquivos feito por',
link: 'Uploadcare.com'
}
},
crop: {
error: {
title: 'Erro',
text: 'Não foi possível carregar a imagem'
},
done: 'OK'
}
};
});
uploadcare.namespace('uploadcare.locale.pluralize', function(ns) {
return ns.pt = function(n) {
if (n === 1) {
return 'one';
}
return 'other';
};
});
}).call(this);
(function() {
var __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
uploadcare.namespace('uploadcare.locale.translations', function(ns) {
return ns.ru = {
ready: 'Выберите файл',
uploading: 'Идет загрузка',
loadingInfo: 'Загрузка информации...',
errors: {
"default": 'Ошибка',
baddata: 'Некорректные данные',
size: 'Слишком большой файл',
upload: 'Ошибка при загрузке',
user: 'Загрузка прервана',
info: 'Ошибка при загрузке информации',
image: 'Разрешены только изображения',
createGroup: 'Не удалось создать группу файлов',
deleted: 'Файл удалён'
},
draghere: 'Перетащите файл сюда',
file: {
one: '%1 файл',
few: '%1 файла',
many: '%1 файлов',
other: '%1 файла'
},
buttons: {
cancel: 'Отмена',
remove: 'Удалить',
file: 'Компьютер'
},
dialog: {
done: 'Готово',
showFiles: 'Показать файлы',
tabs: {
file: {
drag: 'Перетащите файл сюда',
nodrop: 'Загрузка файлов с вашего компьютера',
or: 'или',
button: 'Выберите файл с компьютера',
also: 'Вы также можете загрузить файлы, используя:',
tabNames: {
facebook: 'Facebook',
dropbox: 'Dropbox',
gdrive: 'Google Drive',
instagram: 'Instagram',
vk: 'ВКонтакте',
evernote: 'Evernote',
url: 'Произвольную ссылку'
}
},
url: {
title: 'Файлы с других сайтов',
line1: 'Загрузите любой файл из сети.',
line2: '',
input: 'Укажите здесь ссылку...',
button: 'Загрузить'
},
preview: {
unknownName: 'неизвестно',
change: 'Отмена',
back: 'Назад',
done: 'Добавить',
unknown: {
title: 'Загрузка... Пожалуйста подождите.',
done: 'Пропустить предварительный просмотр'
},
regular: {
title: 'Загрузить этот файл?',
line1: 'Вы собираетесь добавить этот файл:',
line2: 'Пожалуйста, подтвердите.'
},
image: {
title: 'Добавить это изображение?',
change: 'Отмена'
},
crop: {
title: 'Обрезать и добавить это изображение',
done: 'Готово'
},
error: {
"default": {
title: 'Ой!',
text: 'Что-то пошло не так во время загрузки.',
back: 'Пожалуйста, попробуйте ещё раз'
},
image: {
title: 'Можно загружать только изображения.',
text: 'Попробуйте загрузить другой файл.',
back: 'Выберите изображение'
},
size: {
title: 'Размер выбранного файла превышает лимит.',
text: 'Попробуйте загрузить другой файл.'
}
},
multiple: {
title: 'Вы выбрали %files%',
question: 'Вы хотите добавить все эти файлы?',
tooManyFiles: 'Вы выбрали слишком много файлов. %max% максимум.',
tooFewFiles: 'Вы выбрали %files%. Нужно не меньше %min%.',
clear: 'Удалить все',
done: 'Готово'
}
}
},
footer: {
text: 'Для загрузки, хранения и обработки файлов используется',
link: 'Uploadcare.com'
}
},
crop: {
error: {
title: 'Ошибка',
text: 'Изображение не удалось загрузить'
},
done: 'ОК'
}
};
});
uploadcare.namespace('uploadcare.locale.pluralize', function(ns) {
return ns.ru = function(n) {
var _ref, _ref1, _ref2, _ref3;
if ((n % 10 === 1) && (n % 100 !== 11)) {
return 'one';
}
if ((_ref = n % 10, __indexOf.call([2, 3, 4], _ref) >= 0) && (_ref1 = n % 100, __indexOf.call([12, 13, 14], _ref1) < 0)) {
return 'few';
}
if ((n % 10 === 0) || (_ref2 = n % 10, __indexOf.call([5, 6, 7, 8, 9], _ref2) >= 0) || (_ref3 = n % 100, __indexOf.call([11, 12, 13, 14], _ref3) >= 0)) {
return 'many';
}
return 'other';
};
});
}).call(this);
(function() {
uploadcare.namespace('uploadcare.locale.translations', function(ns) {
return ns.zh = {
ready: '上传自',
uploading: '上传中...请等待',
loadingInfo: '正在读取信息...',
errors: {
"default": '错误',
baddata: '错误数据',
size: '文件太大',
upload: '无法上传',
user: '上传被取消',
info: '无法读取信息',
image: '只允许图形文件',
createGroup: '无法建立文件组',
deleted: '文件已被删除'
},
draghere: '拖放文件到这里',
file: {
other: '%1 个文件'
},
buttons: {
cancel: '取消',
remove: '删除',
file: '计算机'
},
dialog: {
done: '完成',
showFiles: '显示文件',
tabs: {
file: {
drag: '拖放文件到这里',
nodrop: '从你的电脑中上传',
or: '或者',
button: '从电脑中选取文件',
also: '你也可以选自',
tabNames: {
facebook: 'Facebook',
dropbox: 'Dropbox',
gdrive: 'Google Drive',
instagram: 'Instagram',
vk: 'VK',
evernote: 'Evernote',
url: '任意图片链接'
}
},
url: {
title: '来自互联网的文件',
line1: '从互联网选取文件',
line2: '只需提供链接',
input: '将链接拷贝至此...',
button: '上传'
},
preview: {
unknownName: '未知',
change: '取消',
back: '返回',
done: '添加',
unknown: {
title: '上传中...请等待预览',
done: '跳过预览,直接接受'
},
regular: {
title: '添加这个文件?',
line1: '你将添加上面的文件。',
line2: '请确认。'
},
image: {
title: '添加这个图片?',
change: '取消'
},
crop: {
title: '剪裁并添加这个图片',
done: '完成'
},
error: {
"default": {
title: '错误!',
text: '上传过程中出错。',
back: '请重试'
},
image: {
title: '只允许上传图片文件。',
text: '请选择其他文件重新上传。',
back: '选择图片'
},
size: {
title: '你选取的文件超过了100MB的上限',
text: '请用另一个文件再试一次。'
}
},
multiple: {
title: '你已经选择 %files%',
question: '你要添加所有文件吗?',
tooManyFiles: '你选了太多的文件. 最多可选择%max%. 请删除一些。',
clear: '清空',
done: '完成'
}
}
},
footer: {
text: '为您提供文件上传、存储和编辑功能。 Copyright ©',
link: 'Uploadcare.com'
}
},
crop: {
error: {
title: '错误',
text: '无法读取图片'
},
done: '完成'
}
};
});
uploadcare.namespace('uploadcare.locale.pluralize', function(ns) {
return ns.zh = function() {
return 'other';
};
});
}).call(this);
(function() {
var $, namespace, s, utils;
namespace = uploadcare.namespace, utils = uploadcare.utils, s = uploadcare.settings, $ = uploadcare.jQuery;
namespace('uploadcare.locale', function(ns) {
var build, defaultLang, defaults, translate, _build;
defaultLang = 'en';
defaults = {
lang: defaultLang,
translations: ns.translations[defaultLang],
pluralize: ns.pluralize[defaultLang]
};
_build = function(settings) {
var lang, pluralize, translations;
lang = settings.locale || defaults.lang;
translations = $.extend(true, {}, ns.translations[lang], settings.localeTranslations);
pluralize = $.isFunction(settings.localePluralize) ? settings.localePluralize : ns.pluralize[lang];
return {
lang: lang,
translations: translations,
pluralize: pluralize
};
};
build = utils.once(function() {
return _build(s.build());
});
ns.rebuild = function(settings) {
var result;
result = _build(s.build(settings));
return build = function() {
return result;
};
};
translate = function(key, node) {
var path, subkey, _i, _len;
path = key.split('.');
for (_i = 0, _len = path.length; _i < _len; _i++) {
subkey = path[_i];
if (node == null) {
return null;
}
node = node[subkey];
}
return node;
};
return ns.t = function(key, n) {
var locale, value, _ref;
locale = build();
value = translate(key, locale.translations);
if (!(value != null) && locale.lang !== defaults.lang) {
locale = defaults;
value = translate(key, locale.translations);
}
if (n != null) {
if (locale.pluralize != null) {
value = ((_ref = value[locale.pluralize(n)]) != null ? _ref.replace('%1', n) : void 0) || n;
} else {
value = '';
}
}
return value || '';
};
});
}).call(this);
(function() {
this.JST || (this.JST = {});
this.JST["uploadcare/templates/circle-text"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('\n');}return __p.join('');};
}).call(this);
(function() {
this.JST || (this.JST = {});
this.JST["uploadcare/templates/crop-widget"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('\n');}return __p.join('');};
}).call(this);
(function() {
this.JST || (this.JST = {});
this.JST["uploadcare/templates/dialog"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('\n');}return __p.join('');};
}).call(this);
(function() {
this.JST || (this.JST = {});
this.JST["uploadcare/templates/panel"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('\n');}return __p.join('');};
}).call(this);
(function() {
this.JST || (this.JST = {});
this.JST["uploadcare/templates/source-tab-base"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('
\n\n\n');}return __p.join('');};
}).call(this);
(function() {
this.JST || (this.JST = {});
this.JST["uploadcare/templates/styles"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('\n\n\n\n\n\n.uploadcare-dialog-tab:after,.uploadcare-dialog-tab:hover:after,.uploadcare-dialog-disabled-tab:hover:after{background-image:url("', utils.imagePath('tab-icons.png') ,'")}.uploadcare-dialog-selected-tab:after,.uploadcare-dialog-selected-tab:hover:after{background-image:url("', utils.imagePath('tab-icons-active.png') ,'")}.uploadcare-widget-buttons .uploadcare-widget-button.uploadcare-widget-buttons-dialog,.uploadcare-widget-buttons .uploadcare-widget-button.uploadcare-widget-buttons-file,.uploadcare-widget-buttons .uploadcare-widget-button.uploadcare-widget-buttons-url{background-image:url("', utils.imagePath('buttons.png') ,'")}.uploadcare-crop-widget .jcrop-vline,.uploadcare-crop-widget .jcrop-hline{background-image:url("', utils.imagePath('crop-border-bg.gif') ,'")}.uploadcare-dialog-file-sources:before{background-image:url("', utils.imagePath('arrow.png') ,'")}.uploadcare-crop-widget--loading{background-image:url("', utils.imagePath('loading-spinner.gif') ,'");background-size:25px 25px}.uploadcare-dpm-file-remove{background-image:url("', utils.imagePath('remove-button.png') ,'")}.uploadcare-dpm-file-error:before{background-image:url("', utils.imagePath('error-icon.png') ,'")}.uploadcare-dpm-file-name:before{background-image:url("', utils.imagePath('file-icon.png') ,'")}.uloadcare-dialog-error-tab-illustration{background-image:url("', utils.imagePath('error-default.png') ,'")}.uloadcare-dialog-error-tab-image .uloadcare-dialog-error-tab-illustration{background-image:url("', utils.imagePath('error-image.png') ,'")}.uploadcare-dialog{background:url("', utils.imagePath('dialog-overlay.png') ,'");background:rgba(48,48,48,0.95)}.uploadcare-dialog{font-family:"Helvetica Neue",Helvetica,Arial,"Lucida Grande",sans-serif;position:fixed;left:0;top:0;width:100%;height:100%;z-index:10000;overflow:auto}.uploadcare-dialog *{margin:0;padding:0}.uploadcare-dialog .uploadcare-dialog-panel{margin:0 auto;width:900px;border-radius:8px;-ms-box-shadow:0 1px 2px rgba(0,0,0,0.35);-moz-box-shadow:0 1px 2px rgba(0,0,0,0.35);-webkit-box-shadow:0 1px 2px rgba(0,0,0,0.35);-o-box-shadow:0 1px 2px rgba(0,0,0,0.35);box-shadow:0 1px 2px rgba(0,0,0,0.35)}.uploadcare-dialog-inner-wrap1{position:relative;display:table;width:100%;height:100%}.uploadcare-dialog-inner-wrap2{display:table-cell;vertical-align:middle;padding:0 44px}.uploadcare-dialog-close{margin:0;padding:0;border:none;background:none;width:33px;height:33px;line-height:33px;font-size:29.7px;font-weight:bold;color:#1d1d1d;cursor:pointer;position:absolute;right:0;top:4px}.uploadcare-dialog-panel{overflow:hidden;background:#efefef;font-weight:normal}.uploadcare-dialog-panel a{text-decoration:none;border-bottom:1px dotted}.uploadcare-dialog-panel a:link,.uploadcare-dialog-panel a:visited{color:#1a85ad;border-bottom-color:#1a85ad}.uploadcare-dialog-panel a:hover,.uploadcare-dialog-panel a:active{color:#252525;border-bottom-color:#252525}.uploadcare-dialog-tabs{-ms-box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;-o-box-sizing:border-box;box-sizing:border-box;width:75px;height:616px;float:left;list-style:none;list-style-type:none;margin:0;padding:0;background:#dee0e1;border-right:1px solid #c5cace}.uploadcare-dialog-tab{-ms-box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;-o-box-sizing:border-box;box-sizing:border-box;height:56px;border-bottom:1px solid #c5cace;cursor:pointer;position:relative}.uploadcare-dialog-tab:after{content:\'\';display:block;position:absolute;width:50px;height:50px;top:50%;left:50%;margin-top:-25px;margin-left:-25px;border:none;opacity:.66}.uploadcare-dialog-tab:hover{background-color:#e5e7e8}.uploadcare-dialog-tab:hover:after{opacity:1}.uploadcare-dialog-selected-tab{margin-right:-1px;border-right:1px solid #efefef}.uploadcare-dialog-selected-tab,.uploadcare-dialog-selected-tab:hover{background-color:#efefef}.uploadcare-dialog-selected-tab:after{opacity:1}.uploadcare-dialog-disabled-tab{cursor:default}.uploadcare-dialog-disabled-tab:hover{background-color:#dee0e1}.uploadcare-dialog-tab-preview:after{display:none}.uploadcare-dialog-tab-file:after{background-position:0 -50px}.uploadcare-dialog-tab-url:after{background-position:0 -100px}.uploadcare-dialog-tab-facebook:after{background-position:0 -150px}.uploadcare-dialog-tab-dropbox:after{background-position:0 -200px}.uploadcare-dialog-tab-gdrive:after{background-position:0 -250px}.uploadcare-dialog-tab-instagram:after{background-position:0 -300px}.uploadcare-dialog-tab-vk:after{background-position:0 -350px}.uploadcare-dialog-tab-evernote:after{background-position:0 -400px}.uploadcare-dialog-tab-box:after{background-position:0 -450px}.uploadcare-dialog-tab-skydrive:after{background-position:0 -500px}.uploadcare-dialog-tabs-panel{position:relative;-ms-box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;-o-box-sizing:border-box;box-sizing:border-box;margin-left:75px;padding:22px 25px;height:616px;line-height:22px;font-size:16px;color:black}.uploadcare-dialog-input{-ms-box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;-o-box-sizing:border-box;box-sizing:border-box;width:100%;height:44px;margin-bottom:22px;padding:11px 12.5px;font-family:inherit;font-size:16px;border:1px solid #c5cace;background:white;color:black}.uploadcare-dialog-drop-file{background:white;border:1px dashed #c5cace;border-radius:3px;height:99px;padding-top:77px;text-align:center;color:#545454}.uploadcare-pre{white-space:pre;font-family:monospace;margin:22px auto;padding:22px 25px;background-color:white;border:1px solid #c5cace;border-radius:3px;text-align:left;font-size:15px;line-height:22px}.uploadcare-dialog-footer{font-size:13px;text-align:center;color:#888;margin-top:15px}.uploadcare-dialog .uploadcare-dialog-footer a{color:#c2c2c2;text-decoration:none}.uploadcare-dialog .uploadcare-dialog-footer a:hover{text-decoration:underline}.uploadcare-dialog-title{font-size:25px;line-height:1;margin-bottom:25px}.uploadcare-dialog-title2{font-size:20px;line-height:1;padding-bottom:11px}.uploadcare-dialog-big-title{font-size:40px;font-weight:bold;line-height:1em;margin-bottom:50px}.uploadcare-dialog-label{font-size:15px;line-height:25px;margin-bottom:12.5px}.uploadcare-dialog-large-text{font-size:20px;font-weight:normal;line-height:1.5em}.uploadcare-dialog-large-text .uploadcare-pre{display:inline-block;font-size:18px}.uploadcare-dialog-section{margin-bottom:22px}.uploadcare-dialog-normal-text{font-size:13px;color:#545454}.uploadcare-dialog-button{display:inline-block;font-size:13px;line-height:31px;padding:0 22px;margin-right:.5em;border:solid 1px;border-radius:3px;cursor:pointer;color:#444}.uploadcare-dialog-button,.uploadcare-dialog-button[disabled]:active,.uploadcare-dialog-button.uploadcare-disabled-el:active,.uploadcare-dialog-button[disabled]:hover,.uploadcare-dialog-button.uploadcare-disabled-el:hover{background:#f3f3f3;background:-webkit-linear-gradient(whitesmoke,#f1f1f1);background:-moz-linear-gradient(whitesmoke,#f1f1f1);background:-o-linear-gradient(whitesmoke,#f1f1f1);background:linear-gradient(whitesmoke,#f1f1f1);-ms-box-shadow:none;-moz-box-shadow:none;-webkit-box-shadow:none;-o-box-shadow:none;box-shadow:none;border-color:gainsboro}.uploadcare-dialog-button:hover{background:#f8f8f8;background:-webkit-linear-gradient(#fbfbfb,#f6f6f6);background:-moz-linear-gradient(#fbfbfb,#f6f6f6);background:-o-linear-gradient(#fbfbfb,#f6f6f6);background:linear-gradient(#fbfbfb,#f6f6f6);-ms-box-shadow:inset 0 -1px 3px rgba(0,0,0,0.05);-moz-box-shadow:inset 0 -1px 3px rgba(0,0,0,0.05);-webkit-box-shadow:inset 0 -1px 3px rgba(0,0,0,0.05);-o-box-shadow:inset 0 -1px 3px rgba(0,0,0,0.05);box-shadow:inset 0 -1px 3px rgba(0,0,0,0.05)}.uploadcare-dialog-button:active{background:#f3f3f3;background:-webkit-linear-gradient(whitesmoke,#f1f1f1);background:-moz-linear-gradient(whitesmoke,#f1f1f1);background:-o-linear-gradient(whitesmoke,#f1f1f1);background:linear-gradient(whitesmoke,#f1f1f1);-ms-box-shadow:inset 0 2px 2px rgba(0,0,0,0.05);-moz-box-shadow:inset 0 2px 2px rgba(0,0,0,0.05);-webkit-box-shadow:inset 0 2px 2px rgba(0,0,0,0.05);-o-box-shadow:inset 0 2px 2px rgba(0,0,0,0.05);box-shadow:inset 0 2px 2px rgba(0,0,0,0.05)}.uploadcare-dialog-button[disabled],.uploadcare-dialog-button.uploadcare-disabled-el{cursor:default;opacity:.6}.uploadcare-dialog-button:active,.uploadcare-dialog-button:hover{border-color:#cbcbcb}.uploadcare-dialog-button-success{display:inline-block;font-size:13px;line-height:31px;padding:0 22px;margin-right:.5em;border:solid 1px;border-radius:3px;cursor:pointer;color:white}.uploadcare-dialog-button-success,.uploadcare-dialog-button-success[disabled]:active,.uploadcare-dialog-button-success.uploadcare-disabled-el:active,.uploadcare-dialog-button-success[disabled]:hover,.uploadcare-dialog-button-success.uploadcare-disabled-el:hover{background:#3786eb;background:-webkit-linear-gradient(#3b8df7,#347fdf);background:-moz-linear-gradient(#3b8df7,#347fdf);background:-o-linear-gradient(#3b8df7,#347fdf);background:linear-gradient(#3b8df7,#347fdf);-ms-box-shadow:none;-moz-box-shadow:none;-webkit-box-shadow:none;-o-box-shadow:none;box-shadow:none;border-color:#266fcb}.uploadcare-dialog-button-success:hover{background:#3279d6;background:-webkit-linear-gradient(#3986ea,#2c6dc2);background:-moz-linear-gradient(#3986ea,#2c6dc2);background:-o-linear-gradient(#3986ea,#2c6dc2);background:linear-gradient(#3986ea,#2c6dc2);-ms-box-shadow:inset 0 -1px 3px rgba(0,0,0,0.05);-moz-box-shadow:inset 0 -1px 3px rgba(0,0,0,0.05);-webkit-box-shadow:inset 0 -1px 3px rgba(0,0,0,0.05);-o-box-shadow:inset 0 -1px 3px rgba(0,0,0,0.05);box-shadow:inset 0 -1px 3px rgba(0,0,0,0.05)}.uploadcare-dialog-button-success:active{background:#3177d3;background:-webkit-linear-gradient(#3680e1,#2c6fc5);background:-moz-linear-gradient(#3680e1,#2c6fc5);background:-o-linear-gradient(#3680e1,#2c6fc5);background:linear-gradient(#3680e1,#2c6fc5);-ms-box-shadow:inset 0 2px 2px rgba(0,0,0,0.05);-moz-box-shadow:inset 0 2px 2px rgba(0,0,0,0.05);-webkit-box-shadow:inset 0 2px 2px rgba(0,0,0,0.05);-o-box-shadow:inset 0 2px 2px rgba(0,0,0,0.05);box-shadow:inset 0 2px 2px rgba(0,0,0,0.05)}.uploadcare-dialog-button-success[disabled],.uploadcare-dialog-button-success.uploadcare-disabled-el{cursor:default;opacity:.6}.uploadcare-dialog-button-success:active,.uploadcare-dialog-button-success:hover{border-color:#266eca #1f62b7 #1753a1}.uploadcare-dialog-button-success:hover{-ms-box-shadow:inset 0 -1px 3px rgba(22,82,160,0.5);-moz-box-shadow:inset 0 -1px 3px rgba(22,82,160,0.5);-webkit-box-shadow:inset 0 -1px 3px rgba(22,82,160,0.5);-o-box-shadow:inset 0 -1px 3px rgba(22,82,160,0.5);box-shadow:inset 0 -1px 3px rgba(22,82,160,0.5)}.uploadcare-dialog-button-success:active{-ms-box-shadow:inset 0 1px 3px rgba(22,82,160,0.4);-moz-box-shadow:inset 0 1px 3px rgba(22,82,160,0.4);-webkit-box-shadow:inset 0 1px 3px rgba(22,82,160,0.4);-o-box-shadow:inset 0 1px 3px rgba(22,82,160,0.4);box-shadow:inset 0 1px 3px rgba(22,82,160,0.4)}.uploadcare-dialog-big-button{border-radius:100px;font-size:20px;font-weight:normal;letter-spacing:1px;color:white;line-height:64px;border:solid 1px #276fcb;text-shadow:0 -1px #2a7ce5;display:inline-block;padding:0 2em;cursor:pointer;-ms-box-shadow:inset 0 -2px #1f66c1;-moz-box-shadow:inset 0 -2px #1f66c1;-webkit-box-shadow:inset 0 -2px #1f66c1;-o-box-shadow:inset 0 -2px #1f66c1;box-shadow:inset 0 -2px #1f66c1;background:#458dee;background:-webkit-linear-gradient(#4892f6,#4289e6);background:-moz-linear-gradient(#4892f6,#4289e6);background:-o-linear-gradient(#4892f6,#4289e6);background:linear-gradient(#4892f6,#4289e6)}.uploadcare-dialog-big-button:hover{-ms-box-shadow:inset 0 -2px #1652a0;-moz-box-shadow:inset 0 -2px #1652a0;-webkit-box-shadow:inset 0 -2px #1652a0;-o-box-shadow:inset 0 -2px #1652a0;box-shadow:inset 0 -2px #1652a0;background:#3279d6;background:-webkit-linear-gradient(#3986eb,#2c6dc2);background:-moz-linear-gradient(#3986eb,#2c6dc2);background:-o-linear-gradient(#3986eb,#2c6dc2);background:linear-gradient(#3986eb,#2c6dc2)}.uploadcare-dialog-big-button:active{border:none;line-height:66px;-ms-box-shadow:inset 0 2px #2561b9;-moz-box-shadow:inset 0 2px #2561b9;-webkit-box-shadow:inset 0 2px #2561b9;-o-box-shadow:inset 0 2px #2561b9;box-shadow:inset 0 2px #2561b9;background:#2c6ec3;background:-webkit-linear-gradient(#2c6ec3,#2c6ec3);background:-moz-linear-gradient(#2c6ec3,#2c6ec3);background:-o-linear-gradient(#2c6ec3,#2c6ec3);background:linear-gradient(#2c6ec3,#2c6ec3)}.uploadcare-dialog-preview-image-wrap1{width:100%;height:456px;margin-bottom:22px;display:table}.uploadcare-dialog-preview-image-wrap2{display:table-cell;vertical-align:middle}.uploadcare-dialog-preview-image{max-width:100%;max-height:456px;display:block;margin:0 auto}.uploadcare-dialog-inner-footer{background:#fff3be;border-top:1px solid #efe2a9;height:33px;padding:16px 30px;margin:0 -25px -22px}.uploadcare-dialog-inner-footer .uploadcare-dialog-button-success{float:right}.uploadcare-dialog-inner-footer .uploadcare-dialog-button{float:left}.uploadcare-dialog-inner-footer .uploadcare-dialog-button-success,.uploadcare-dialog-inner-footer .uploadcare-dialog-button{width:112.5px;padding:0;text-align:center;margin-right:0}.uploadcare-dialog-inner-footer-text{text-align:center;color:#85732c;font-size:15px;line-height:33px}.uploadcare-dialog-inner-footer-text.uploadcare-error{color:red}.uploadcare-dialog-message-center{text-align:center;padding-top:110px}.uploadcare-dialog-preview-center{text-align:center;padding-top:176px}.uploadcare-dialog-preview-circle{width:66px;height:66px;display:inline-block;margin-bottom:22px}.uloadcare-dialog-error-tab-wrap{height:100%;text-align:center}.uloadcare-dialog-error-tab-wrap:before{vertical-align:middle;display:inline-block;content:\'\';height:100%}.uloadcare-dialog-error-tab-wrap .uploadcare-dialog-title{margin-bottom:12px}.uloadcare-dialog-error-tab-wrap .uloadcare-dialog-error-tab-illustration,.uloadcare-dialog-error-tab-wrap .uploadcare-dialog-normal-text{margin-bottom:38px}.uloadcare-dialog-error-tab-wrap .uploadcare-dialog-button-success{margin:0}.uloadcare-dialog-error-tab-wrap2{vertical-align:middle;display:inline-block;margin-top:-22px}.uloadcare-dialog-error-tab-illustration{display:inline-block;width:170px;height:120px;background-position:center;background-repeat:no-repeat}.uploadcare-no-draganddrop .uploadcare-if-draganddrop{display:none}.uploadcare-draganddrop .uploadcare-if-no-draganddrop{display:none}.uploadcare-dialog-file-drop-area{width:100%;height:100%;-ms-box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;-o-box-sizing:border-box;box-sizing:border-box;background:rgba(255,255,255,0.64);border:dashed 3px #c5cacd;text-align:center;border-radius:3px;padding-top:70px}.uploadcare-dialog-file-drop-area .uploadcare-dialog-big-button{margin-top:11px;margin-bottom:55px}.uploadcare-no-draganddrop .uploadcare-dialog-file-drop-area{border:none;padding-top:73px;background:transparent}.uploadcare-dialog-file-title{font-size:40px;line-height:1;color:#dee0e1;font-weight:bold;margin-bottom:66px;text-shadow:0 1px white}.uploadcare-no-draganddrop .uploadcare-dialog-file-title{text-shadow:none;color:black;margin-top:66px}.uploadcare-dialog-file-or{font-size:13px;color:#8f9498;margin-bottom:44px}.uploadcare-dialog-file-sources{position:relative;display:inline-block;padding:0 80px 0 100px;line-height:2em}.uploadcare-dialog-file-sources:before{background-repeat:no-repeat;content:\'\';display:block;position:absolute;width:67px;height:44px;padding:0;top:-30px;left:10px}.uploadcare-dialog-file-source{display:inline;font-size:15px;margin-right:.2em;cursor:pointer;font-weight:300;white-space:nowrap}.uploadcare-dialog-file-source:after{content:\'\\00B7\';color:#b7babc;margin-left:.5em}.uploadcare-dialog-file-source:last-child:after{display:none}.uploadcare-dragging .uploadcare-dialog-file-or,.uploadcare-dragging .uploadcare-dialog-file-sources,.uploadcare-dragging .uploadcare-dialog-file-drop-area .uploadcare-dialog-big-button{display:none}.uploadcare-dragging .uploadcare-dialog-file-drop-area{background-color:#f0f0f0;border-color:#b3b5b6;padding-top:264px}.uploadcare-dragging .uploadcare-dialog-file-title{color:#707478}.uploadcare-dragging.uploadcare-dialog-file-drop-area{background-color:#f2f7fe;border-color:#438ae7}.uploadcare-dragging.uploadcare-dialog-file-drop-area .uploadcare-dialog-file-title{color:#438ae7}.uploadcare-dpm-file-list{height:478px;overflow:auto;margin:0 -25px;padding:0 25px}.uploadcare-dpm-file-item{border-top:1px solid #e3e3e3;border-bottom:1px solid #e3e3e3;margin-bottom:-1px;padding:10px 0;font-size:13px;line-height:1;word-wrap:break-word}.uploadcare-dpm-file-item:last-child{margin-bottom:0}.uploadcare-dpm-file-item:hover,.uploadcare-dpm-file-item.ui-sortable-helper{background:#ececec}.uploadcare-dpm-file-item:hover .uploadcare-dpm-file-remove,.uploadcare-dpm-file-item.ui-sortable-helper .uploadcare-dpm-file-remove{display:inline-block}.uploadcare-dpm-file-item.ui-sortable-helper{cursor:move}.uploadcare-dpm-file-item.uploadcare-dpm-image .uploadcare-dpm-file-preview-wrap{display:inline-block}.uploadcare-dpm-file-item.uploadcare-dpm-image .uploadcare-dpm-file-name{width:60%}.uploadcare-dpm-file-item.uploadcare-dpm-image .uploadcare-dpm-file-name:before{display:none}.uploadcare-dpm-file-item.uploadcare-dpm-uploaded .uploadcare-dpm-file-progressbar-value{background:#8ac54c}.uploadcare-dpm-file-item.uploadcare-dpm-error .uploadcare-dpm-file-error{display:inline-block}.uploadcare-dpm-file-item.uploadcare-dpm-error .uploadcare-dpm-file-size,.uploadcare-dpm-file-item.uploadcare-dpm-error .uploadcare-dpm-file-progressbar-wrap{display:none}.uploadcare-dpm-file-preview-wrap,.uploadcare-dpm-file-name,.uploadcare-dpm-file-size,.uploadcare-dpm-file-progressbar-wrap,.uploadcare-dpm-file-error,.uploadcare-dpm-file-remove-wrap{vertical-align:middle;display:inline-block;-ms-box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;-o-box-sizing:border-box;box-sizing:border-box;padding:0 10px}.uploadcare-dpm-file-preview-wrap{text-align:center;width:8%;height:45px;display:none;padding:0;line-height:0}.uploadcare-dpm-file-name,.uploadcare-dpm-file-size,.uploadcare-dpm-file-error{padding-top:4px;padding-bottom:4px}.uploadcare-dpm-file-name:before,.uploadcare-dpm-file-error:before{content:\'\';display:inline-block;width:20px;height:20px;margin:-3.5px .7em -3.5px 0}.uploadcare-dpm-file-name{width:68%}.uploadcare-dpm-file-name:before{width:16px}.uploadcare-dpm-file-size{width:10%;padding-right:0;text-align:left}.uploadcare-dpm-file-progressbar-wrap{width:14%}.uploadcare-dpm-file-progressbar{width:80px;height:8px;background:#e0e0e0;border-radius:100px}.uploadcare-dpm-file-progressbar-value{height:100%;background:#d6b849;border-radius:100px}.uploadcare-dpm-file-error{width:24%;display:none;color:#f5444b}.uploadcare-dpm-file-remove-wrap{padding:0;padding-right:10px;width:8%;text-align:right;line-height:0}.uploadcare-dpm-file-remove{display:none;width:20px;height:20px;cursor:pointer}.uploadcare-dialog-source-base-wrap{height:616px;margin:-22px -25px;padding:22px 25px;-ms-box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;-o-box-sizing:border-box;box-sizing:border-box}.uploadcare-dialog-multiple .uploadcare-dialog-source-base-wrap{height:550px;margin:-22px -25px 0}.uploadcare-dialog-remote-iframe-wrap{padding:0}.uploadcare-dialog-source-base-footer{display:none}.uploadcare-dialog-multiple .uploadcare-dialog-source-base-footer{display:block}.uploadcare-crop-widget .jcrop-holder{direction:ltr;text-align:left}.uploadcare-crop-widget .jcrop-vline,.uploadcare-crop-widget .jcrop-hline{background-color:white;background-position:top left;background-repeat:repeat;font-size:0;position:absolute}.uploadcare-crop-widget .jcrop-vline{height:100%;width:1px!important}.uploadcare-crop-widget .jcrop-hline{height:1px!important;width:100%}.uploadcare-crop-widget .jcrop-vline.right{right:0}.uploadcare-crop-widget .jcrop-hline.bottom{bottom:0}.uploadcare-crop-widget .jcrop-handle{background-color:#333;border:1px #eee solid;font-size:1px}.uploadcare-crop-widget .jcrop-tracker{height:100%;width:100%;-webkit-tap-highlight-color:transparent;-webkit-touch-callout:none;-webkit-user-select:none}.uploadcare-crop-widget .jcrop-handle.ord-n{left:50%;margin-left:-4px;margin-top:-4px;top:0}.uploadcare-crop-widget .jcrop-handle.ord-s{bottom:0;left:50%;margin-bottom:-4px;margin-left:-4px}.uploadcare-crop-widget .jcrop-handle.ord-e{margin-right:-4px;margin-top:-4px;right:0;top:50%}.uploadcare-crop-widget .jcrop-handle.ord-w{left:0;margin-left:-4px;margin-top:-4px;top:50%}.uploadcare-crop-widget .jcrop-handle.ord-nw{left:0;margin-left:-4px;margin-top:-4px;top:0}.uploadcare-crop-widget .jcrop-handle.ord-ne{margin-right:-4px;margin-top:-4px;right:0;top:0}.uploadcare-crop-widget .jcrop-handle.ord-se{bottom:0;margin-bottom:-4px;margin-right:-4px;right:0}.uploadcare-crop-widget .jcrop-handle.ord-sw{bottom:0;left:0;margin-bottom:-4px;margin-left:-4px}.uploadcare-crop-widget .jcrop-dragbar.ord-n,.uploadcare-crop-widget .jcrop-dragbar.ord-s{height:7px;width:100%}.uploadcare-crop-widget .jcrop-dragbar.ord-e,.uploadcare-crop-widget .jcrop-dragbar.ord-w{height:100%;width:7px}.uploadcare-crop-widget .jcrop-dragbar.ord-n{margin-top:-4px}.uploadcare-crop-widget .jcrop-dragbar.ord-s{bottom:0;margin-bottom:-4px}.uploadcare-crop-widget .jcrop-dragbar.ord-e{margin-right:-4px;right:0}.uploadcare-crop-widget .jcrop-dragbar.ord-w{margin-left:-4px}.uploadcare-crop-widget .jcrop-light .jcrop-vline,.uploadcare-crop-widget .jcrop-light .jcrop-hline{background:#FFF;filter:Alpha(opacity=70)!important;opacity:.70!important}.uploadcare-crop-widget .jcrop-light .jcrop-handle{-moz-border-radius:3px;-webkit-border-radius:3px;background-color:#000;border-color:#FFF;border-radius:3px}.uploadcare-crop-widget .jcrop-dark .jcrop-vline,.uploadcare-crop-widget .jcrop-dark .jcrop-hline{background:#000;filter:Alpha(opacity=70)!important;opacity:.7!important}.uploadcare-crop-widget .jcrop-dark .jcrop-handle{-moz-border-radius:3px;-webkit-border-radius:3px;background-color:#FFF;border-color:#000;border-radius:3px}.uploadcare-crop-widget .jcrop-holder img,.uploadcare-crop-widget img.jcrop-preview{max-width:none}.uploadcare-crop-widget{font-family:"Helvetica Neue",Helvetica,Arial,"Lucida Grande",sans-serif;position:relative}.uploadcare-crop-widget .jcrop-holder{margin:0 auto;-webkit-transform:translateZ(0)}.uploadcare-crop-widget--loading{background-repeat:no-repeat;background-position:center}.uploadcare-crop-widget img{display:block}.uploadcare-crop-widget__error{text-align:center;display:none}.uploadcare-crop-widget--error .uploadcare-crop-widget__error{display:block}.uploadcare-crop-widget__error__title{font-size:20px}.uploadcare-crop-widget__error__text{font-size:15px}.uploadcare-widget{display:inline-block!important;position:relative;vertical-align:middle;padding:0 5px}.uploadcare-widget[data-status=loaded] .uploadcare-widget-button,.uploadcare-widget[data-status=started] .uploadcare-widget-button{display:none}.uploadcare-widget[data-status=started] .uploadcare-widget-buttons .uploadcare-widget-buttons-cancel,.uploadcare-widget[data-status=loaded] .uploadcare-widget-buttons .uploadcare-widget-buttons-remove{display:inline-block}.uploadcare-widget .uploadcare-widget-circle{width:25px;height:25px;top:-1px;float:left;margin-right:1ex}.uploadcare-widget-circle{position:relative}.uploadcare-widget-circle--text .uploadcare-widget-circle-back{position:relative;width:100%;height:100%;border-radius:50%;display:table}.uploadcare-widget-circle--text .uploadcare-widget-circle-text{display:table-cell;vertical-align:middle;text-align:center;font-size:60%;line-height:1}.uploadcare-widget-buttons{position:relative;top:-1px;float:left;overflow:hidden;margin:0;padding:0;list-style:none}.uploadcare-widget-buttons .uploadcare-widget-button{display:inline-block;height:24px;float:left;font-size:11px;color:#8f9295;line-height:25px;width:36px;padding:0 6px;margin:0 3px 1px 0;list-style:none;-ms-box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;-o-box-sizing:border-box;box-sizing:border-box;border-radius:2px;background:#e1e5e7;cursor:default}.uploadcare-widget-buttons .uploadcare-widget-button.uploadcare-widget-buttons-dialog,.uploadcare-widget-buttons .uploadcare-widget-button.uploadcare-widget-buttons-file,.uploadcare-widget-buttons .uploadcare-widget-button.uploadcare-widget-buttons-url{background-position:0 0;background-repeat:no-repeat;padding-left:30px}.uploadcare-widget-buttons .uploadcare-widget-button.uploadcare-widget-buttons-dialog,.uploadcare-widget-buttons .uploadcare-widget-button.uploadcare-widget-buttons-url{background-position:0 -24px}.uploadcare-widget-buttons .uploadcare-widget-button.uploadcare-widget-buttons-cancel,.uploadcare-widget-buttons .uploadcare-widget-button.uploadcare-widget-buttons-remove{font-size:.9em;display:none;width:auto}.uploadcare-widget-status-text{float:left;overflow:hidden;line-height:25px;height:25px;margin-right:1ex;white-space:nowrap;padding:0 5px}.uploadcare-widget-file-name{cursor:pointer;color:#1a85ad;border-bottom-color:#1a85ad;text-decoration:none;border-bottom:1px dotted}.uploadcare-widget-dragndrop-area{display:none;position:absolute;top:-8px;left:0;width:100%;height:41px;line-height:41px;text-align:center;background-color:#f0f0f0;color:#707478;border:1px dashed #b3b5b6;border-radius:20.5px}.uploadcare-widget.uploadcare-dragging .uploadcare-widget-dragndrop-area{background-color:#f2f7fe;border-color:#438ae7;color:#438ae7}.uploadcare-dragging .uploadcare-widget-dragndrop-area{display:block}.uploadcare-dialog-opened .uploadcare-widget-dragndrop-area{display:none}\n');}return __p.join('');};
}).call(this);
(function() {
this.JST || (this.JST = {});
this.JST["uploadcare/templates/tab-file"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('\n
\n ',(''+ t('dialog.tabs.file.drag') ).replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"').replace(/'/g, ''').replace(/\//g,'/'),'\n
\n
\n ',(''+ t('dialog.tabs.file.nodrop') ).replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"').replace(/'/g, ''').replace(/\//g,'/'),'\n
\n
\n ',(''+ t('dialog.tabs.file.or') ).replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"').replace(/'/g, ''').replace(/\//g,'/'),'\n
\n
\n ',(''+ t('dialog.tabs.file.button') ).replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"').replace(/'/g, ''').replace(/\//g,'/'),'\n
\n '); if (tabs.length > 1) { ; __p.push('\n
\n ',(''+ t('dialog.tabs.file.also') ).replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"').replace(/'/g, ''').replace(/\//g,'/'),'\n
\n
\n '); for (var i = 0; i < tabs.length; i++) {
var tab = tabs[i];
if (tab == 'file') continue; ; __p.push('\n
',(''+ t('dialog.tabs.file.tabNames.' + tab) ).replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"').replace(/'/g, ''').replace(/\//g,'/'),'
\n '); } ; __p.push('\n
\n '); } ; __p.push('\n
\n');}return __p.join('');};
}).call(this);
(function() {
this.JST || (this.JST = {});
this.JST["uploadcare/templates/tab-preview-error"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('\n
\n\n
\n\n
',(''+
t('dialog.tabs.preview.error.'+error+'.title') || t('dialog.tabs.preview.error.default.title')
).replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"').replace(/'/g, ''').replace(/\//g,'/'),'
\n\n
',(''+
t('dialog.tabs.preview.error.'+error+'.text') || t('dialog.tabs.preview.error.default.text')
).replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"').replace(/'/g, ''').replace(/\//g,'/'),'
\n\n
',(''+
t('dialog.tabs.preview.error.'+error+'.back') || t('dialog.tabs.preview.error.default.back')
).replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"').replace(/'/g, ''').replace(/\//g,'/'),'
\n\n
\n
\n');}return __p.join('');};
}).call(this);
(function() {
this.JST || (this.JST = {});
this.JST["uploadcare/templates/tab-preview-image"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('',(''+ t('dialog.tabs.preview.image.title') ).replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"').replace(/'/g, ''').replace(/\//g,'/'),'
\n\n\n
\n \n
\n
\n
\n\n\n');}return __p.join('');};
}).call(this);
(function() {
this.JST || (this.JST = {});
this.JST["uploadcare/templates/tab-preview-multiple-file"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('\n
\n
\n ',(''+ t('dialog.tabs.preview.unknownName') ).replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"').replace(/'/g, ''').replace(/\//g,'/'),'\n
\n
\n');}return __p.join('');};
}).call(this);
(function() {
this.JST || (this.JST = {});
this.JST["uploadcare/templates/tab-preview-multiple"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('
\n\n
\n\n\n');}return __p.join('');};
}).call(this);
(function() {
this.JST || (this.JST = {});
this.JST["uploadcare/templates/tab-preview-regular"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('',(''+ t('dialog.tabs.preview.regular.title') ).replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"').replace(/'/g, ''').replace(/\//g,'/'),'
\n\n\n ',(''+ (file.name || t('dialog.tabs.preview.unknownName')) ).replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"').replace(/'/g, ''').replace(/\//g,'/'),'',(''+
utils.readableFileSize(file.size, '', ', ') ).replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"').replace(/'/g, ''').replace(/\//g,'/'),'\n
\n\n\n ',(''+ t('dialog.tabs.preview.regular.line1') ).replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"').replace(/'/g, ''').replace(/\//g,'/'),' \n ',(''+ t('dialog.tabs.preview.regular.line2') ).replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"').replace(/'/g, ''').replace(/\//g,'/'),'\n
\n\n',(''+ t('dialog.tabs.preview.done') ).replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"').replace(/'/g, ''').replace(/\//g,'/'),'
\n',(''+ t('dialog.tabs.preview.change') ).replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"').replace(/'/g, ''').replace(/\//g,'/'),'
\n');}return __p.join('');};
}).call(this);
(function() {
this.JST || (this.JST = {});
this.JST["uploadcare/templates/tab-preview-unknown"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('',(''+ t('dialog.tabs.preview.unknown.title') ).replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"').replace(/'/g, ''').replace(/\//g,'/'),'
\n\n\n ',(''+ (file.name || t('dialog.tabs.preview.unknownName')) ).replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"').replace(/'/g, ''').replace(/\//g,'/'),'',(''+
utils.readableFileSize(file.size, '', ', ') ).replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"').replace(/'/g, ''').replace(/\//g,'/'),'\n
\n\n',(''+ t('dialog.tabs.preview.unknown.done') ).replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"').replace(/'/g, ''').replace(/\//g,'/'),'
\n');}return __p.join('');};
}).call(this);
(function() {
this.JST || (this.JST = {});
this.JST["uploadcare/templates/tab-url"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('',(''+ t('dialog.tabs.url.title') ).replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"').replace(/'/g, ''').replace(/\//g,'/'),'
\n\n
',(''+ t('dialog.tabs.url.line1') ).replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"').replace(/'/g, ''').replace(/\//g,'/'),'
\n
',(''+ t('dialog.tabs.url.line2') ).replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"').replace(/'/g, ''').replace(/\//g,'/'),'
\n
\n\n');}return __p.join('');};
}).call(this);
(function() {
this.JST || (this.JST = {});
this.JST["uploadcare/templates/tab-welcome"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('\n
Hello!
\n
\n
\n
Add this to the <head> tag to start uploading files:
\n
<script>\nUPLOADCARE_PUBLIC_KEY = \'your_public_key\';\n</script>
\n
\n
\n');}return __p.join('');};
}).call(this);
(function() {
this.JST || (this.JST = {});
this.JST["uploadcare/templates/widget-button"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('',(''+ caption ).replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"').replace(/'/g, ''').replace(/\//g,'/'),'
\n');}return __p.join('');};
}).call(this);
(function() {
this.JST || (this.JST = {});
this.JST["uploadcare/templates/widget-file-name"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('',(''+ utils.fitText(name, 16) ).replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"').replace(/'/g, ''').replace(/\//g,'/'),' ,\n',(''+ utils.readableFileSize(size) ).replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"').replace(/'/g, ''').replace(/\//g,'/'),'\n');}return __p.join('');};
}).call(this);
(function() {
this.JST || (this.JST = {});
this.JST["uploadcare/templates/widget"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('\n');}return __p.join('');};
}).call(this);
(function() {
var locale, namespace, utils;
namespace = uploadcare.namespace, locale = uploadcare.locale, utils = uploadcare.utils;
namespace('uploadcare.templates', function(ns) {
return ns.tpl = function(key, ctx) {
var fn;
if (ctx == null) {
ctx = {};
}
fn = JST["uploadcare/templates/" + key];
if (fn != null) {
ctx.t = locale.t;
ctx.utils = utils;
return fn(ctx);
} else {
return '';
}
};
});
}).call(this);
(function() {
var $, tpl;
$ = uploadcare.jQuery;
tpl = uploadcare.templates.tpl;
uploadcare.settings.waitForSettings(null, function() {
var css, style;
css = tpl('styles');
style = document.createElement('style');
style.setAttribute('type', 'text/css');
if (style.styleSheet != null) {
style.styleSheet.cssText = css;
} else {
style.appendChild(document.createTextNode(css));
}
return $('head').prepend(style);
});
}).call(this);
/**
* jquery.Jcrop.js v0.9.10
* jQuery Image Cropping Plugin - released under MIT License
* Author: Kelly Hallman
* http://github.com/tapmodo/Jcrop
* Copyright (c) 2008-2012 Tapmodo Interactive LLC {{{
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* }}}
*/
(function ($) {
$.Jcrop = function (obj, opt) {
var options = $.extend({}, $.Jcrop.defaults),
docOffset, lastcurs;
// Internal Methods {{{
function px(n) {
return Math.round(n) + 'px';
}
function cssClass(cl) {
return options.baseClass + '-' + cl;
}
function supportsColorFade() {
return $.fx.step.hasOwnProperty('backgroundColor');
}
function getPos(obj) //{{{
{
var pos = $(obj).offset();
return [pos.left, pos.top];
}
//}}}
function mouseAbs(e) //{{{
{
return [(e.pageX - docOffset[0]), (e.pageY - docOffset[1])];
}
//}}}
function setOptions(opt) //{{{
{
if (typeof(opt) !== 'object') opt = {};
options = $.extend(options, opt);
$.each(['onChange','onSelect','onRelease','onDblClick'],function(i,e) {
if (typeof(options[e]) !== 'function') options[e] = function () {};
});
}
//}}}
function startDragMode(mode, pos) //{{{
{
docOffset = getPos($img);
Tracker.setCursor(mode === 'move' ? mode : mode + '-resize');
if (mode === 'move') {
return Tracker.activateHandlers(createMover(pos), doneSelect);
}
var fc = Coords.getFixed();
var opp = oppLockCorner(mode);
var opc = Coords.getCorner(oppLockCorner(opp));
Coords.setPressed(Coords.getCorner(opp));
Coords.setCurrent(opc);
Tracker.activateHandlers(dragmodeHandler(mode, fc), doneSelect);
}
//}}}
function dragmodeHandler(mode, f) //{{{
{
return function (pos) {
if (!options.aspectRatio) {
switch (mode) {
case 'e':
pos[1] = f.y2;
break;
case 'w':
pos[1] = f.y2;
break;
case 'n':
pos[0] = f.x2;
break;
case 's':
pos[0] = f.x2;
break;
}
} else {
switch (mode) {
case 'e':
pos[1] = f.y + 1;
break;
case 'w':
pos[1] = f.y + 1;
break;
case 'n':
pos[0] = f.x + 1;
break;
case 's':
pos[0] = f.x + 1;
break;
}
}
Coords.setCurrent(pos);
Selection.update();
};
}
//}}}
function createMover(pos) //{{{
{
var lloc = pos;
KeyManager.watchKeys();
return function (pos) {
Coords.moveOffset([pos[0] - lloc[0], pos[1] - lloc[1]]);
lloc = pos;
Selection.update();
};
}
//}}}
function oppLockCorner(ord) //{{{
{
switch (ord) {
case 'n':
return 'sw';
case 's':
return 'nw';
case 'e':
return 'nw';
case 'w':
return 'ne';
case 'ne':
return 'sw';
case 'nw':
return 'se';
case 'se':
return 'nw';
case 'sw':
return 'ne';
}
}
//}}}
function createDragger(ord) //{{{
{
return function (e) {
if (options.disabled) {
return false;
}
if ((ord === 'move') && !options.allowMove) {
return false;
}
// Fix position of crop area when dragged the very first time.
// Necessary when crop image is in a hidden element when page is loaded.
docOffset = getPos($img);
btndown = true;
startDragMode(ord, mouseAbs(e));
e.stopPropagation();
e.preventDefault();
return false;
};
}
//}}}
function presize($obj, w, h) //{{{
{
var nw = $obj.width(),
nh = $obj.height();
if ((nw > w) && w > 0) {
nw = w;
nh = (w / $obj.width()) * $obj.height();
}
if ((nh > h) && h > 0) {
nh = h;
nw = (h / $obj.height()) * $obj.width();
}
xscale = $obj.width() / nw;
yscale = $obj.height() / nh;
$obj.width(nw).height(nh);
}
//}}}
function unscale(c) //{{{
{
return {
x: c.x * xscale,
y: c.y * yscale,
x2: c.x2 * xscale,
y2: c.y2 * yscale,
w: c.w * xscale,
h: c.h * yscale
};
}
//}}}
function doneSelect(pos) //{{{
{
var c = Coords.getFixed();
if ((c.w > options.minSelect[0]) && (c.h > options.minSelect[1])) {
Selection.enableHandles();
Selection.done();
} else {
Selection.release();
}
Tracker.setCursor(options.allowSelect ? 'crosshair' : 'default');
}
//}}}
function newSelection(e) //{{{
{
if (options.disabled) {
return false;
}
if (!options.allowSelect) {
return false;
}
btndown = true;
docOffset = getPos($img);
Selection.disableHandles();
Tracker.setCursor('crosshair');
var pos = mouseAbs(e);
Coords.setPressed(pos);
Selection.update();
Tracker.activateHandlers(selectDrag, doneSelect);
KeyManager.watchKeys();
e.stopPropagation();
e.preventDefault();
return false;
}
//}}}
function selectDrag(pos) //{{{
{
Coords.setCurrent(pos);
Selection.update();
}
//}}}
function newTracker() //{{{
{
var trk = $('
').addClass(cssClass('tracker'));
trk.css({
opacity: 0,
backgroundColor: 'white'
});
return trk;
}
//}}}
// }}}
// Initialization {{{
// Sanitize some options {{{
if (typeof(obj) !== 'object') {
obj = $(obj)[0];
}
if (typeof(opt) !== 'object') {
opt = {};
}
// }}}
setOptions(opt);
// Initialize some jQuery objects {{{
// The values are SET on the image(s) for the interface
// If the original image has any of these set, they will be reset
// However, if you destroy() the Jcrop instance the original image's
// character in the DOM will be as you left it.
var img_css = {
border: 'none',
visibility: 'visible',
margin: 0,
padding: 0,
position: 'absolute',
top: 0,
left: 0
};
var $origimg = $(obj),
img_mode = true;
if (obj.tagName == 'IMG') {
// Fix size of crop image.
// Necessary when crop image is within a hidden element when page is loaded.
if ($origimg[0].width != 0 && $origimg[0].height != 0) {
// Obtain dimensions from contained img element.
$origimg.width($origimg[0].width);
$origimg.height($origimg[0].height);
} else {
// Obtain dimensions from temporary image in case the original is not loaded yet (e.g. IE 7.0).
var tempImage = new Image();
tempImage.src = $origimg[0].src;
$origimg.width(tempImage.width);
$origimg.height(tempImage.height);
}
var $img = $origimg.clone().removeAttr('id').css(img_css).show();
$img.width($origimg.width());
$img.height($origimg.height());
$origimg.after($img).hide();
} else {
$img = $origimg.css(img_css).show();
img_mode = false;
if (options.shade === null) { options.shade = true; }
}
presize($img, options.boxWidth, options.boxHeight);
var boundx = $img.width(),
boundy = $img.height(),
$div = $('
').width(boundx).height(boundy).addClass(cssClass('holder')).css({
position: 'relative',
backgroundColor: options.bgColor
}).insertAfter($origimg).append($img);
if (options.addClass) {
$div.addClass(options.addClass);
}
var $img2 = $('
'),
$img_holder = $('
')
.width('100%').height('100%').css({
zIndex: 310,
position: 'absolute',
overflow: 'hidden'
}),
$hdl_holder = $('
')
.width('100%').height('100%').css('zIndex', 320),
$sel = $('
')
.css({
position: 'absolute',
zIndex: 600
}).dblclick(function(){
var c = Coords.getFixed();
options.onDblClick.call(api,c);
}).insertBefore($img).append($img_holder, $hdl_holder);
if (img_mode) {
$img2 = $(' ')
.attr('src', $img.attr('src')).css(img_css).width(boundx).height(boundy),
$img_holder.append($img2);
}
var bound = options.boundary;
var $trk = newTracker().width(boundx + (bound * 2)).height(boundy + (bound * 2)).css({
position: 'absolute',
top: px(-bound),
left: px(-bound),
zIndex: 290
}).mousedown(newSelection);
/* }}} */
// Set more variables {{{
var bgcolor = options.bgColor,
bgopacity = options.bgOpacity,
xlimit, ylimit, xmin, ymin, xscale, yscale, enabled = true,
btndown, animating, shift_down;
docOffset = getPos($img);
// }}}
// }}}
// Internal Modules {{{
// Touch Module {{{
var Touch = (function () {
// Touch support detection function adapted (under MIT License)
// from code by Jeffrey Sambells - http://github.com/iamamused/
function hasTouchSupport() {
var support = {},
events = ['touchstart', 'touchmove', 'touchend'],
el = document.createElement('div'), i;
try {
for(i=0; i x1 + ox) {
ox -= ox + x1;
}
if (0 > y1 + oy) {
oy -= oy + y1;
}
if (boundy < y2 + oy) {
oy += boundy - (y2 + oy);
}
if (boundx < x2 + ox) {
ox += boundx - (x2 + ox);
}
x1 += ox;
x2 += ox;
y1 += oy;
y2 += oy;
}
//}}}
function getCorner(ord) //{{{
{
var c = getFixed();
switch (ord) {
case 'ne':
return [c.x2, c.y];
case 'nw':
return [c.x, c.y];
case 'se':
return [c.x2, c.y2];
case 'sw':
return [c.x, c.y2];
}
}
//}}}
function getFixed() //{{{
{
if (!options.aspectRatio) {
return getRect();
}
// This function could use some optimization I think...
var aspect = options.aspectRatio,
min_x = options.minSize[0] / xscale,
//min_y = options.minSize[1]/yscale,
max_x = options.maxSize[0] / xscale,
max_y = options.maxSize[1] / yscale,
rw = x2 - x1,
rh = y2 - y1,
rwa = Math.abs(rw),
rha = Math.abs(rh),
real_ratio = rwa / rha,
xx, yy, w, h;
if (max_x === 0) {
max_x = boundx * 10;
}
if (max_y === 0) {
max_y = boundy * 10;
}
if (real_ratio < aspect) {
yy = y2;
w = rha * aspect;
xx = rw < 0 ? x1 - w : w + x1;
if (xx < 0) {
xx = 0;
h = Math.abs((xx - x1) / aspect);
yy = rh < 0 ? y1 - h : h + y1;
} else if (xx > boundx) {
xx = boundx;
h = Math.abs((xx - x1) / aspect);
yy = rh < 0 ? y1 - h : h + y1;
}
} else {
xx = x2;
h = rwa / aspect;
yy = rh < 0 ? y1 - h : y1 + h;
if (yy < 0) {
yy = 0;
w = Math.abs((yy - y1) * aspect);
xx = rw < 0 ? x1 - w : w + x1;
} else if (yy > boundy) {
yy = boundy;
w = Math.abs(yy - y1) * aspect;
xx = rw < 0 ? x1 - w : w + x1;
}
}
// Magic %-)
if (xx > x1) { // right side
if (xx - x1 < min_x) {
xx = x1 + min_x;
} else if (xx - x1 > max_x) {
xx = x1 + max_x;
}
if (yy > y1) {
yy = y1 + (xx - x1) / aspect;
} else {
yy = y1 - (xx - x1) / aspect;
}
} else if (xx < x1) { // left side
if (x1 - xx < min_x) {
xx = x1 - min_x;
} else if (x1 - xx > max_x) {
xx = x1 - max_x;
}
if (yy > y1) {
yy = y1 + (x1 - xx) / aspect;
} else {
yy = y1 - (x1 - xx) / aspect;
}
}
if (xx < 0) {
x1 -= xx;
xx = 0;
} else if (xx > boundx) {
x1 -= xx - boundx;
xx = boundx;
}
if (yy < 0) {
y1 -= yy;
yy = 0;
} else if (yy > boundy) {
y1 -= yy - boundy;
yy = boundy;
}
return makeObj(flipCoords(x1, y1, xx, yy));
}
//}}}
function rebound(p) //{{{
{
if (p[0] < 0) {
p[0] = 0;
}
if (p[1] < 0) {
p[1] = 0;
}
if (p[0] > boundx) {
p[0] = boundx;
}
if (p[1] > boundy) {
p[1] = boundy;
}
return [p[0], p[1]];
}
//}}}
function flipCoords(x1, y1, x2, y2) //{{{
{
var xa = x1,
xb = x2,
ya = y1,
yb = y2;
if (x2 < x1) {
xa = x2;
xb = x1;
}
if (y2 < y1) {
ya = y2;
yb = y1;
}
return [xa, ya, xb, yb];
}
//}}}
function getRect() //{{{
{
var xsize = x2 - x1,
ysize = y2 - y1,
delta;
if (xlimit && (Math.abs(xsize) > xlimit)) {
x2 = (xsize > 0) ? (x1 + xlimit) : (x1 - xlimit);
}
if (ylimit && (Math.abs(ysize) > ylimit)) {
y2 = (ysize > 0) ? (y1 + ylimit) : (y1 - ylimit);
}
if (ymin / yscale && (Math.abs(ysize) < ymin / yscale)) {
y2 = (ysize > 0) ? (y1 + ymin / yscale) : (y1 - ymin / yscale);
}
if (xmin / xscale && (Math.abs(xsize) < xmin / xscale)) {
x2 = (xsize > 0) ? (x1 + xmin / xscale) : (x1 - xmin / xscale);
}
if (x1 < 0) {
x2 -= x1;
x1 -= x1;
}
if (y1 < 0) {
y2 -= y1;
y1 -= y1;
}
if (x2 < 0) {
x1 -= x2;
x2 -= x2;
}
if (y2 < 0) {
y1 -= y2;
y2 -= y2;
}
if (x2 > boundx) {
delta = x2 - boundx;
x1 -= delta;
x2 -= delta;
}
if (y2 > boundy) {
delta = y2 - boundy;
y1 -= delta;
y2 -= delta;
}
if (x1 > boundx) {
delta = x1 - boundy;
y2 -= delta;
y1 -= delta;
}
if (y1 > boundy) {
delta = y1 - boundy;
y2 -= delta;
y1 -= delta;
}
return makeObj(flipCoords(x1, y1, x2, y2));
}
//}}}
function makeObj(a) //{{{
{
return {
x: a[0],
y: a[1],
x2: a[2],
y2: a[3],
w: a[2] - a[0],
h: a[3] - a[1]
};
}
//}}}
return {
flipCoords: flipCoords,
setPressed: setPressed,
setCurrent: setCurrent,
getOffset: getOffset,
moveOffset: moveOffset,
getCorner: getCorner,
getFixed: getFixed
};
}());
//}}}
// Shade Module {{{
var Shade = (function() {
var enabled = false,
holder = $('
').css({
position: 'absolute',
zIndex: 240,
opacity: 0
}),
shades = {
top: createShade(),
left: createShade().height(boundy),
right: createShade().height(boundy),
bottom: createShade()
};
function resizeShades(w,h) {
shades.left.css({ height: px(h) });
shades.right.css({ height: px(h) });
}
function updateAuto()
{
return updateShade(Coords.getFixed());
}
function updateShade(c)
{
shades.top.css({
left: px(c.x),
width: px(c.w),
height: px(c.y)
});
shades.bottom.css({
top: px(c.y2),
left: px(c.x),
width: px(c.w),
height: px(boundy-c.y2)
});
shades.right.css({
left: px(c.x2),
width: px(boundx-c.x2)
});
shades.left.css({
width: px(c.x)
});
}
function createShade() {
return $('
').css({
position: 'absolute',
backgroundColor: options.shadeColor||options.bgColor
}).appendTo(holder);
}
function enableShade() {
if (!enabled) {
enabled = true;
holder.insertBefore($img);
updateAuto();
Selection.setBgOpacity(1,0,1);
$img2.hide();
setBgColor(options.shadeColor||options.bgColor,1);
if (Selection.isAwake())
{
setOpacity(options.bgOpacity,1);
}
else setOpacity(1,1);
}
}
function setBgColor(color,now) {
colorChangeMacro(getShades(),color,now);
}
function disableShade() {
if (enabled) {
holder.remove();
$img2.show();
enabled = false;
if (Selection.isAwake()) {
Selection.setBgOpacity(options.bgOpacity,1,1);
} else {
Selection.setBgOpacity(1,1,1);
Selection.disableHandles();
}
colorChangeMacro($div,0,1);
}
}
function setOpacity(opacity,now) {
if (enabled) {
if (options.bgFade && !now) {
holder.animate({
opacity: 1-opacity
},{
queue: false,
duration: options.fadeTime
});
}
else holder.css({opacity:1-opacity});
}
}
function refreshAll() {
options.shade ? enableShade() : disableShade();
if (Selection.isAwake()) setOpacity(options.bgOpacity);
}
function getShades() {
return holder.children();
}
return {
update: updateAuto,
updateRaw: updateShade,
getShades: getShades,
setBgColor: setBgColor,
enable: enableShade,
disable: disableShade,
resize: resizeShades,
refresh: refreshAll,
opacity: setOpacity
};
}());
// }}}
// Selection Module {{{
var Selection = (function () {
var awake,
hdep = 370,
borders = {},
handle = {},
dragbar = {},
seehandles = false;
// Private Methods
function insertBorder(type) //{{{
{
var jq = $('
').css({
position: 'absolute',
opacity: options.borderOpacity
}).addClass(cssClass(type));
$img_holder.append(jq);
return jq;
}
//}}}
function dragDiv(ord, zi) //{{{
{
var jq = $('
').mousedown(createDragger(ord)).css({
cursor: ord + '-resize',
position: 'absolute',
zIndex: zi
}).addClass('ord-'+ord);
if (Touch.support) {
jq.bind('touchstart.jcrop', Touch.createDragger(ord));
}
$hdl_holder.append(jq);
return jq;
}
//}}}
function insertHandle(ord) //{{{
{
var hs = options.handleSize;
return dragDiv(ord, hdep++).css({
opacity: options.handleOpacity
}).width(hs).height(hs).addClass(cssClass('handle'));
}
//}}}
function insertDragbar(ord) //{{{
{
return dragDiv(ord, hdep++).addClass('jcrop-dragbar');
}
//}}}
function createDragbars(li) //{{{
{
var i;
for (i = 0; i < li.length; i++) {
dragbar[li[i]] = insertDragbar(li[i]);
}
}
//}}}
function createBorders(li) //{{{
{
var cl,i;
for (i = 0; i < li.length; i++) {
switch(li[i]){
case'n': cl='hline'; break;
case's': cl='hline bottom'; break;
case'e': cl='vline right'; break;
case'w': cl='vline'; break;
}
borders[li[i]] = insertBorder(cl);
}
}
//}}}
function createHandles(li) //{{{
{
var i;
for (i = 0; i < li.length; i++) {
handle[li[i]] = insertHandle(li[i]);
}
}
//}}}
function moveto(x, y) //{{{
{
if (!options.shade) {
$img2.css({
top: px(-y),
left: px(-x)
});
}
$sel.css({
top: px(y),
left: px(x)
});
}
//}}}
function resize(w, h) //{{{
{
$sel.width(Math.round(w)).height(Math.round(h));
}
//}}}
function refresh() //{{{
{
var c = Coords.getFixed();
Coords.setPressed([c.x, c.y]);
Coords.setCurrent([c.x2, c.y2]);
updateVisible();
}
//}}}
// Internal Methods
function updateVisible(select) //{{{
{
if (awake) {
return update(select);
}
}
//}}}
function update(select) //{{{
{
var c = Coords.getFixed();
resize(c.w, c.h);
moveto(c.x, c.y);
if (options.shade) Shade.updateRaw(c);
awake || show();
if (select) {
options.onSelect.call(api, unscale(c));
} else {
options.onChange.call(api, unscale(c));
}
}
//}}}
function setBgOpacity(opacity,force,now) //{{{
{
if (!awake && !force) return;
if (options.bgFade && !now) {
$img.animate({
opacity: opacity
},{
queue: false,
duration: options.fadeTime
});
} else {
$img.css('opacity', opacity);
}
}
//}}}
function show() //{{{
{
$sel.show();
if (options.shade) Shade.opacity(bgopacity);
else setBgOpacity(bgopacity,true);
awake = true;
}
//}}}
function release() //{{{
{
disableHandles();
$sel.hide();
if (options.shade) Shade.opacity(1);
else setBgOpacity(1);
awake = false;
options.onRelease.call(api);
}
//}}}
function showHandles() //{{{
{
if (seehandles) {
$hdl_holder.show();
}
}
//}}}
function enableHandles() //{{{
{
seehandles = true;
if (options.allowResize) {
$hdl_holder.show();
return true;
}
}
//}}}
function disableHandles() //{{{
{
seehandles = false;
$hdl_holder.hide();
}
//}}}
function animMode(v) //{{{
{
if (v) {
animating = true;
disableHandles();
} else {
animating = false;
enableHandles();
}
}
//}}}
function done() //{{{
{
animMode(false);
refresh();
}
//}}}
// Insert draggable elements {{{
// Insert border divs for outline
if (options.dragEdges && $.isArray(options.createDragbars))
createDragbars(options.createDragbars);
if ($.isArray(options.createHandles))
createHandles(options.createHandles);
if (options.drawBorders && $.isArray(options.createBorders))
createBorders(options.createBorders);
//}}}
// This is a hack for iOS5 to support drag/move touch functionality
$(document).bind('touchstart.jcrop-ios',function(e) {
if ($(e.currentTarget).hasClass('jcrop-tracker')) e.stopPropagation();
});
var $track = newTracker().mousedown(createDragger('move')).css({
cursor: 'move',
position: 'absolute',
zIndex: 360
});
if (Touch.support) {
$track.bind('touchstart.jcrop', Touch.createDragger('move'));
}
$img_holder.append($track);
disableHandles();
return {
updateVisible: updateVisible,
update: update,
release: release,
refresh: refresh,
isAwake: function () {
return awake;
},
setCursor: function (cursor) {
$track.css('cursor', cursor);
},
enableHandles: enableHandles,
enableOnly: function () {
seehandles = true;
},
showHandles: showHandles,
disableHandles: disableHandles,
animMode: animMode,
setBgOpacity: setBgOpacity,
done: done
};
}());
//}}}
// Tracker Module {{{
var Tracker = (function () {
var onMove = function () {},
onDone = function () {},
trackDoc = options.trackDocument;
function toFront() //{{{
{
$trk.css({
zIndex: 450
});
if (Touch.support) {
$(document)
.bind('touchmove.jcrop', trackTouchMove)
.bind('touchend.jcrop', trackTouchEnd);
}
if (trackDoc) {
$(document)
.bind('mousemove.jcrop',trackMove)
.bind('mouseup.jcrop',trackUp);
}
}
//}}}
function toBack() //{{{
{
$trk.css({
zIndex: 290
});
$(document).unbind('.jcrop');
}
//}}}
function trackMove(e) //{{{
{
onMove(mouseAbs(e));
return false;
}
//}}}
function trackUp(e) //{{{
{
e.preventDefault();
e.stopPropagation();
if (btndown) {
btndown = false;
onDone(mouseAbs(e));
if (Selection.isAwake()) {
options.onSelect.call(api, unscale(Coords.getFixed()));
}
toBack();
onMove = function () {};
onDone = function () {};
}
return false;
}
//}}}
function activateHandlers(move, done) //{{{
{
btndown = true;
onMove = move;
onDone = done;
toFront();
return false;
}
//}}}
function trackTouchMove(e) //{{{
{
e.pageX = e.originalEvent.changedTouches[0].pageX;
e.pageY = e.originalEvent.changedTouches[0].pageY;
return trackMove(e);
}
//}}}
function trackTouchEnd(e) //{{{
{
e.pageX = e.originalEvent.changedTouches[0].pageX;
e.pageY = e.originalEvent.changedTouches[0].pageY;
return trackUp(e);
}
//}}}
function setCursor(t) //{{{
{
$trk.css('cursor', t);
}
//}}}
if (!trackDoc) {
$trk.mousemove(trackMove).mouseup(trackUp).mouseout(trackUp);
}
$img.before($trk);
return {
activateHandlers: activateHandlers,
setCursor: setCursor
};
}());
//}}}
// KeyManager Module {{{
var KeyManager = (function () {
var $keymgr = $(' ').css({
position: 'fixed',
left: '-120px',
width: '12px'
}).addClass('jcrop-keymgr'),
$keywrap = $('
').css({
position: 'absolute',
overflow: 'hidden'
}).append($keymgr);
function watchKeys() //{{{
{
if (options.keySupport) {
$keymgr.show();
$keymgr.focus();
}
}
//}}}
function onBlur(e) //{{{
{
$keymgr.hide();
}
//}}}
function doNudge(e, x, y) //{{{
{
if (options.allowMove) {
Coords.moveOffset([x, y]);
Selection.updateVisible(true);
}
e.preventDefault();
e.stopPropagation();
}
//}}}
function parseKey(e) //{{{
{
if (e.ctrlKey || e.metaKey) {
return true;
}
shift_down = e.shiftKey ? true : false;
var nudge = shift_down ? 10 : 1;
switch (e.keyCode) {
case 37:
doNudge(e, -nudge, 0);
break;
case 39:
doNudge(e, nudge, 0);
break;
case 38:
doNudge(e, 0, -nudge);
break;
case 40:
doNudge(e, 0, nudge);
break;
case 27:
if (options.allowSelect) Selection.release();
break;
case 9:
return true;
}
return false;
}
//}}}
if (options.keySupport) {
$keymgr.keydown(parseKey).blur(onBlur);
$keymgr.css({
position: 'absolute',
left: '-20px'
});
$keywrap.append($keymgr).insertBefore($img);
}
return {
watchKeys: watchKeys
};
}());
//}}}
// }}}
// API methods {{{
function setClass(cname) //{{{
{
$div.removeClass().addClass(cssClass('holder')).addClass(cname);
}
//}}}
function setSelect(rect) //{{{
{
setSelectRaw([rect[0] / xscale, rect[1] / yscale, rect[2] / xscale, rect[3] / yscale]);
options.onSelect.call(api, unscale(Coords.getFixed()));
Selection.enableHandles();
}
//}}}
function setSelectRaw(l) //{{{
{
Coords.setPressed([l[0], l[1]]);
Coords.setCurrent([l[2], l[3]]);
Selection.update();
}
//}}}
function tellSelect() //{{{
{
return unscale(Coords.getFixed());
}
//}}}
function tellScaled() //{{{
{
return Coords.getFixed();
}
//}}}
function setOptionsNew(opt) //{{{
{
setOptions(opt);
interfaceUpdate();
}
//}}}
function disableCrop() //{{{
{
options.disabled = true;
Selection.disableHandles();
Selection.setCursor('default');
Tracker.setCursor('default');
}
//}}}
function enableCrop() //{{{
{
options.disabled = false;
interfaceUpdate();
}
//}}}
function cancelCrop() //{{{
{
Selection.done();
Tracker.activateHandlers(null, null);
}
//}}}
function destroy() //{{{
{
$div.remove();
$origimg.show();
$origimg.css('visibility','visible');
$(obj).removeData('Jcrop');
}
//}}}
function colorChangeMacro($obj,color,now) {
var mycolor = color || options.bgColor;
if (options.bgFade && supportsColorFade() && options.fadeTime && !now) {
$obj.animate({
backgroundColor: mycolor
}, {
queue: false,
duration: options.fadeTime
});
} else {
$obj.css('backgroundColor', mycolor);
}
}
function interfaceUpdate(alt) //{{{
// This method tweaks the interface based on options object.
// Called when options are changed and at end of initialization.
{
if (options.allowResize) {
if (alt) {
Selection.enableOnly();
} else {
Selection.enableHandles();
}
} else {
Selection.disableHandles();
}
Tracker.setCursor(options.allowSelect ? 'crosshair' : 'default');
Selection.setCursor(options.allowMove ? 'move' : 'default');
if (options.hasOwnProperty('trueSize')) {
xscale = options.trueSize[0] / boundx;
yscale = options.trueSize[1] / boundy;
}
if (options.hasOwnProperty('setSelect')) {
setSelect(options.setSelect);
Selection.done();
delete(options.setSelect);
}
Shade.refresh();
if (options.bgColor != bgcolor) {
colorChangeMacro(
options.shade? Shade.getShades(): $div,
options.shade?
(options.shadeColor || options.bgColor):
options.bgColor
);
bgcolor = options.bgColor;
}
if (bgopacity != options.bgOpacity) {
bgopacity = options.bgOpacity;
if (options.shade) Shade.refresh();
else Selection.setBgOpacity(bgopacity);
}
xlimit = options.maxSize[0] || 0;
ylimit = options.maxSize[1] || 0;
xmin = options.minSize[0] || 0;
ymin = options.minSize[1] || 0;
if (options.hasOwnProperty('outerImage')) {
$img.attr('src', options.outerImage);
delete(options.outerImage);
}
Selection.refresh();
}
//}}}
//}}}
if (Touch.support) $trk.bind('touchstart.jcrop', Touch.newSelection);
$hdl_holder.hide();
interfaceUpdate(true);
var api = {
setSelect: setSelect,
setOptions: setOptionsNew,
tellSelect: tellSelect,
tellScaled: tellScaled,
setClass: setClass,
disable: disableCrop,
enable: enableCrop,
cancel: cancelCrop,
release: Selection.release,
destroy: destroy,
focus: KeyManager.watchKeys,
getBounds: function () {
return [boundx * xscale, boundy * yscale];
},
getWidgetSize: function () {
return [boundx, boundy];
},
getScaleFactor: function () {
return [xscale, yscale];
},
getOptions: function() {
// careful: internal values are returned
return options;
},
ui: {
holder: $div,
selection: $sel
}
};
$origimg.data('Jcrop', api);
return api;
};
$.fn.Jcrop = function (options, callback) //{{{
{
var api;
// Iterate over each object, attach Jcrop
this.each(function () {
// If we've already attached to this object
if ($(this).data('Jcrop')) {
// The API can be requested this way (undocumented)
if (options === 'api') return $(this).data('Jcrop');
// Otherwise, we just reset the options...
else $(this).data('Jcrop').setOptions(options);
}
// If we haven't been attached, preload and attach
else {
if (this.tagName == 'IMG')
$.Jcrop.Loader(this,function(){
$(this).css({display:'block',visibility:'hidden'});
api = $.Jcrop(this, options);
if ($.isFunction(callback)) callback.call(api);
});
else {
$(this).css({display:'block',visibility:'hidden'});
api = $.Jcrop(this, options);
if ($.isFunction(callback)) callback.call(api);
}
}
});
// Return "this" so the object is chainable (jQuery-style)
return this;
};
//}}}
// $.Jcrop.Loader - basic image loader {{{
$.Jcrop.Loader = function(imgobj,success,error){
var $img = $(imgobj), img = $img[0];
function completeCheck(){
if (img.complete) {
$img.unbind('.jcloader');
if ($.isFunction(success)) success.call(img);
}
else window.setTimeout(completeCheck,50);
}
$img
.bind('load.jcloader',completeCheck)
.bind('error.jcloader',function(e){
$img.unbind('.jcloader');
if ($.isFunction(error)) error.call(img);
});
if (img.complete && $.isFunction(success)){
$img.unbind('.jcloader');
success.call(img);
}
};
//}}}
// Global Defaults {{{
$.Jcrop.defaults = {
// Basic Settings
allowSelect: true,
allowMove: true,
allowResize: true,
trackDocument: true,
// Styling Options
baseClass: 'jcrop',
addClass: null,
bgColor: 'black',
bgOpacity: 0.6,
bgFade: false,
borderOpacity: 0.4,
handleOpacity: 0.5,
handleSize: 7,
aspectRatio: 0,
keySupport: true,
createHandles: ['n','s','e','w','nw','ne','se','sw'],
createDragbars: ['n','s','e','w'],
createBorders: ['n','s','e','w'],
drawBorders: true,
dragEdges: true,
fixedSupport: true,
touchSupport: null,
shade: null,
boxWidth: 0,
boxHeight: 0,
boundary: 2,
fadeTime: 400,
animationDelay: 20,
swingSpeed: 3,
minSelect: [0, 0],
maxSize: [0, 0],
minSize: [0, 0],
// Callbacks / Event Handlers
onChange: function () {},
onSelect: function () {},
onDblClick: function () {},
onRelease: function () {}
};
// }}}
}(uploadcare.jQuery));
(function() {
var $, namespace, tpl, utils, _ref;
namespace = uploadcare.namespace, $ = uploadcare.jQuery, (_ref = uploadcare.templates, tpl = _ref.tpl), utils = uploadcare.utils;
namespace('uploadcare.crop', function(ns) {
return ns.CropWidget = (function() {
var IMAGE_CLEARED, LOADING_ERROR, cropModifierRegExp, defaultOptions, prepareOptions;
defaultOptions = {
container: null,
scale: false,
upscale: false,
notLess: false,
widgetSize: null,
preferedSize: null
};
LOADING_ERROR = 'loadingerror';
IMAGE_CLEARED = 'imagecleared';
prepareOptions = function(options) {
var fited, willBe;
if (!options.container) {
throw new Error("options.container must be specified");
}
if (!options.preferedSize) {
options.scale = false;
options.upscale = false;
options.notLess = false;
}
if (options.scale) {
fited = utils.fitSizeInCdnLimit(options.preferedSize);
if (fited[0] !== options.preferedSize[0]) {
willBe = "" + (fited.join('x')) + (options.upscale ? '' : ' or smaller');
utils.warnOnce("Specified preferred crop size is bigger than our CDN allows.\nResulting image size will be " + willBe + ".");
return options.preferedSize = fited;
}
}
};
function CropWidget(options) {
this.__options = $.extend({}, defaultOptions, options);
prepareOptions(this.__options);
this.onStateChange = $.Callbacks();
this.__buildWidget();
}
CropWidget.prototype.croppedImageUrl = function(previewUrl, size) {
var _this = this;
return this.croppedImageModifiers(previewUrl, size).then(function(opts) {
return _this.__url + opts.modifiers;
});
};
cropModifierRegExp = /-\/crop\/([0-9]+)x([0-9]+)(\/(center|([0-9]+),([0-9]+)))?\//i;
CropWidget.prototype.__parseModifiers = function(modifiers) {
var raw;
if (raw = modifiers != null ? modifiers.match(cropModifierRegExp) : void 0) {
return {
width: parseInt(raw[1], 10),
height: parseInt(raw[2], 10),
center: raw[4] === 'center',
left: parseInt(raw[5], 10) || void 0,
top: parseInt(raw[6], 10) || void 0
};
}
};
CropWidget.prototype.croppedImageModifiers = function(previewUrl, size, modifiers) {
var _this = this;
return this.croppedImageCoords(previewUrl, size, this.__parseModifiers(modifiers)).then(function(coords) {
var downscale, notTouched, opts, resized, topLeft, upscale;
size = "" + coords.width + "x" + coords.height;
topLeft = "" + coords.left + "," + coords.top;
opts = {
crop: $.extend({}, coords),
modifiers: "-/crop/" + size + "/" + topLeft + "/"
};
notTouched = coords.width === _this.__originalSize[0] && coords.height === _this.__originalSize[1];
if (notTouched && !_this.__options.scale) {
opts.modifiers = '';
} else {
downscale = _this.__options.scale && coords.width > _this.__options.preferedSize[0];
upscale = _this.__options.upscale && coords.width < _this.__options.preferedSize[0];
if (downscale || upscale) {
resized = _this.__options.preferedSize.slice();
} else {
resized = utils.fitSizeInCdnLimit([coords.width, coords.height]);
}
if (resized[0] !== coords.width || resized[1] !== coords.height) {
opts.crop.sw = resized[0], opts.crop.sh = resized[1];
resized[0 + (resized[0] > resized[1])] = '';
opts.modifiers += "-/resize/" + (resized.join('x')) + "/";
}
}
return opts;
});
};
CropWidget.prototype.croppedImageCoords = function(previewUrl, size, coords) {
this.__clearImage();
this.__calcSizes(size);
this.__setImage(previewUrl);
this.__initJcrop(coords);
return this.__deferred.promise();
};
CropWidget.prototype.forceDone = function() {
if (this.__state === 'loaded') {
return this.__deferred.resolve(this.getCurrentCoords());
} else {
throw new Error("not ready");
}
};
CropWidget.prototype.getCurrentCoords = function() {
var scaleX, scaleY, _ref1;
_ref1 = this.__resizedScale, scaleX = _ref1[0], scaleY = _ref1[1];
return {
left: Math.round(this.__currentCoords.left / scaleX),
top: Math.round(this.__currentCoords.top / scaleY),
width: Math.round(this.__currentCoords.width / scaleX),
height: Math.round(this.__currentCoords.height / scaleY)
};
};
CropWidget.prototype.destroy = function() {
this.__clearImage();
this.__widgetElement.remove();
return this.__widgetElement = null;
};
CropWidget.prototype.__buildWidget = function() {
this.container = $(this.__options.container);
this.__widgetElement = $(tpl('crop-widget')).appendTo(this.container);
return this.__setState('waiting');
};
CropWidget.prototype.__clearImage = function() {
var _ref1, _ref2, _ref3;
if ((_ref1 = this.__jCropApi) != null) {
_ref1.destroy();
}
if ((_ref2 = this.__img) != null) {
_ref2.off().remove();
}
if ((_ref3 = this.__deferred) != null) {
_ref3.reject(IMAGE_CLEARED);
}
this.__deferred = $.Deferred();
return this.__setState('waiting');
};
CropWidget.prototype.__setImage = function(__url) {
var _this = this;
this.__url = __url;
return this.__img = $(' ').css({
margin: '0 auto'
}).on('error', function() {
_this.__setState('error');
_this.__deferred.reject(LOADING_ERROR);
return _this.__img.remove();
}).attr({
src: this.__url,
width: this.__resizedSize[0],
height: this.__resizedSize[1]
}).appendTo(this.__widgetElement);
};
CropWidget.prototype.__calcSizes = function(originalSize) {
var resizedSize, widgetSize;
widgetSize = this.__options.widgetSize || [this.container.width(), this.container.height()];
resizedSize = utils.fitSize(originalSize, widgetSize);
this.__originalSize = originalSize;
this.__resizedSize = resizedSize;
return this.__resizedScale = [resizedSize[0] / originalSize[0], resizedSize[1] / originalSize[1]];
};
CropWidget.prototype.__setState = function(state) {
var prefix, s;
if (this.__state === state) {
return;
}
this.__state = state;
prefix = 'uploadcare-crop-widget--';
this.__widgetElement.removeClass(((function() {
var _i, _len, _ref1, _results;
_ref1 = ['error', 'loading', 'loaded', 'waiting'];
_results = [];
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
s = _ref1[_i];
_results.push(prefix + s);
}
return _results;
})()).join(' ')).addClass(prefix + state);
return this.onStateChange.fire(state);
};
CropWidget.prototype.__initJcrop = function(previousCoords) {
var done, jCropOptions, left, preferedSize, scaleX, scaleY, top, _ref1, _ref2, _ref3,
_this = this;
jCropOptions = {
onSelect: function(coords) {
return _this.__currentCoords = {
height: coords.h,
width: coords.w,
left: coords.x,
top: coords.y
};
}
};
if (this.__options.preferedSize) {
jCropOptions.aspectRatio = this.__options.preferedSize[0] / this.__options.preferedSize[1];
}
if (!previousCoords) {
previousCoords = {
center: true
};
if (this.__options.preferedSize) {
_ref1 = utils.fitSize(this.__options.preferedSize, this.__originalSize, true), previousCoords.width = _ref1[0], previousCoords.height = _ref1[1];
} else {
_ref2 = this.__originalSize, previousCoords.width = _ref2[0], previousCoords.height = _ref2[1];
}
}
if (previousCoords.center) {
left = (this.__originalSize[0] - previousCoords.width) / 2;
top = (this.__originalSize[1] - previousCoords.height) / 2;
} else {
left = previousCoords.left || 0;
top = previousCoords.top || 0;
}
_ref3 = this.__resizedScale, scaleX = _ref3[0], scaleY = _ref3[1];
if (this.__options.notLess) {
preferedSize = utils.fitSize(this.__options.preferedSize, this.__originalSize);
jCropOptions.minSize = [Math.ceil(preferedSize[0] * scaleX, Math.ceil(preferedSize[1] * scaleY))];
}
jCropOptions.setSelect = [left * scaleX, top * scaleY, (previousCoords.width + left) * scaleX, (previousCoords.height + top) * scaleY];
this.__setState('loading');
done = function(api) {
_this.__jCropApi = api;
return _this.__setState('loaded');
};
return this.__img.Jcrop(jCropOptions, function() {
return done(this);
});
};
return CropWidget;
})();
});
}).call(this);
(function() {
var $, namespace, s, utils,
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
namespace = uploadcare.namespace, s = uploadcare.settings, $ = uploadcare.jQuery, utils = uploadcare.utils;
namespace('uploadcare.files', function(ns) {
return ns.BaseFile = (function() {
function BaseFile(settings) {
this.settings = settings;
this.__resolveApi = __bind(this.__resolveApi, this);
this.__rejectApi = __bind(this.__rejectApi, this);
this.__extendApi = __bind(this.__extendApi, this);
this.__runValidators = __bind(this.__runValidators, this);
this.__preview = __bind(this.__preview, this);
this.__cancel = __bind(this.__cancel, this);
this.__fileInfo = __bind(this.__fileInfo, this);
this.__updateInfo = __bind(this.__updateInfo, this);
this.__handleFileData = __bind(this.__handleFileData, this);
this.__completeUpload = __bind(this.__completeUpload, this);
this.fileId = null;
this.fileName = null;
this.fileSize = null;
this.isStored = null;
this.cdnUrlModifiers = null;
this.isImage = null;
this.imageInfo = null;
this.onInfoReady = $.Callbacks('once memory');
this.__setupValidation();
this.__initApi();
}
BaseFile.prototype.__startUpload = function() {
throw new Error('not implemented');
};
BaseFile.prototype.__completeUpload = function() {
var check, timeout,
_this = this;
timeout = 100;
return (check = function() {
if (_this.apiPromise.state() === 'pending') {
return _this.__updateInfo().done(function() {
setTimeout(check, timeout);
return timeout += 50;
});
}
})();
};
BaseFile.prototype.__handleFileData = function(data) {
this.fileName = data.original_filename;
this.fileSize = data.size;
this.isImage = data.is_image;
this.imageInfo = data.image_info;
this.isStored = data.is_stored;
if (!this.onInfoReady.fired()) {
this.onInfoReady.fire(this.__fileInfo());
}
if (data.is_ready) {
return this.__resolveApi();
}
};
BaseFile.prototype.__updateInfo = function() {
var _this = this;
return utils.jsonp("" + this.settings.urlBase + "/info/", {
file_id: this.fileId,
pub_key: this.settings.publicKey
}).fail(function() {
return _this.__rejectApi('info');
}).done(this.__handleFileData);
};
BaseFile.prototype.__progressInfo = function() {
var _ref;
return {
state: this.__progressState,
uploadProgress: this.__progress,
progress: (_ref = this.__progressState) === 'ready' || _ref === 'error' ? 1 : this.__progress * 0.9,
incompleteFileInfo: this.__fileInfo()
};
};
BaseFile.prototype.__fileInfo = function() {
return {
uuid: this.fileId,
name: this.fileName,
size: this.fileSize,
isStored: this.isStored,
isImage: this.isImage,
originalImageInfo: this.imageInfo,
originalUrl: "" + this.settings.cdnBase + "/" + this.fileId + "/",
cdnUrl: "" + this.settings.cdnBase + "/" + this.fileId + "/" + (this.cdnUrlModifiers || ''),
cdnUrlModifiers: this.cdnUrlModifiers,
previewUrl: "" + this.settings.cdnBase + "/" + this.fileId + "/",
preview: this.apiPromise.preview
};
};
BaseFile.prototype.__cancel = function() {
this.__rejectApi('user');
return this.__uploadDf.reject();
};
BaseFile.prototype.__preview = function(selector) {
var _this = this;
utils.warnOnce("'preview' method is deprecated. " + "Use fileInfo.cdnUrl as image source.");
return this.apiPromise.done(function(info) {
var img;
img = new Image();
img.onload = function() {
return $(selector).html($('').css({
position: 'relative',
overflow: 'hidden',
width: this.width,
height: this.height
}).append(img));
};
return img.src = "" + info.cdnUrl + "-/preview/1600x1600/";
});
};
BaseFile.prototype.__setupValidation = function() {
this.validators = (this.settings.__validators || []).slice();
if (this.settings.imagesOnly) {
this.validators.push(function(info) {
if (!info.isImage) {
throw new Error('image');
}
});
}
return this.onInfoReady.add(this.__runValidators);
};
BaseFile.prototype.__runValidators = function(info) {
var v, _i, _len, _ref, _results;
try {
_ref = this.validators;
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
v = _ref[_i];
_results.push(v(info));
}
return _results;
} catch (err) {
return this.__rejectApi(err.message);
}
};
BaseFile.prototype.__extendApi = function(api) {
var __then,
_this = this;
api.cancel = this.__cancel;
api.preview = this.__preview;
__then = api.then;
api.pipe = api.then = function() {
return _this.__extendApi(__then.apply(api, arguments));
};
return api;
};
BaseFile.prototype.__notifyApi = function() {
return this.apiDeferred.notify(this.__progressInfo());
};
BaseFile.prototype.__rejectApi = function(err) {
this.__progressState = 'error';
this.__notifyApi();
return this.apiDeferred.reject(err, this.__fileInfo());
};
BaseFile.prototype.__resolveApi = function() {
this.__progressState = 'ready';
this.__notifyApi();
return this.apiDeferred.resolve(this.__fileInfo());
};
BaseFile.prototype.__initApi = function() {
var _this = this;
this.apiDeferred = $.Deferred();
this.apiPromise = this.__extendApi(this.apiDeferred.promise());
this.__progressState = 'uploading';
this.__progress = 0;
this.__notifyApi();
return this.__uploadDf = $.Deferred().done(this.__completeUpload).done(function() {
_this.__progressState = 'uploaded';
_this.__progress = 1;
return _this.__notifyApi();
}).progress(function(progress) {
if (progress > _this.__progress) {
_this.__progress = progress;
return _this.__notifyApi();
}
}).fail(function() {
return _this.__rejectApi('upload');
});
};
BaseFile.prototype.promise = function() {
if (!this.__uploadStarted) {
this.__uploadStarted = true;
this.__startUpload();
}
return this.apiPromise;
};
return BaseFile;
})();
});
namespace('uploadcare.utils', function(utils) {
utils.isFile = function(obj) {
return obj && obj.done && obj.fail && obj.cancel;
};
return utils.valueToFile = function(value, settings) {
if (value && !utils.isFile(value)) {
value = uploadcare.fileFrom('uploaded', value, settings);
}
return value;
};
});
}).call(this);
(function() {
var $, namespace, utils,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
namespace = uploadcare.namespace, $ = uploadcare.jQuery, utils = uploadcare.utils;
namespace('uploadcare.files', function(ns) {
return ns.ObjectFile = (function(_super) {
__extends(ObjectFile, _super);
ObjectFile.prototype.MP_MIN_SIZE = 25 * 1024 * 1024;
ObjectFile.prototype.MP_PART_SIZE = 5 * 1024 * 1024;
ObjectFile.prototype.MP_CONCURRENCY = 4;
function ObjectFile(settings, __file) {
this.__file = __file;
ObjectFile.__super__.constructor.apply(this, arguments);
this.fileSize = this.__file.size;
this.fileName = this.__file.name || 'original';
this.fileType = this.__file.type || 'application/octet-stream';
this.__notifyApi();
}
ObjectFile.prototype.__startUpload = function() {
if (this.fileSize < this.MP_MIN_SIZE) {
return this.directUpload();
} else {
return this.multipartUpload();
}
};
ObjectFile.prototype.directUpload = function() {
var formData,
_this = this;
formData = new FormData();
formData.append('UPLOADCARE_PUB_KEY', this.settings.publicKey);
if (this.settings.autostore) {
formData.append('UPLOADCARE_STORE', '1');
}
formData.append('file', this.__file);
return $.ajax({
xhr: function() {
var xhr;
xhr = $.ajaxSettings.xhr();
if (xhr.upload) {
xhr.upload.addEventListener('progress', function(e) {
return _this.__uploadDf.notify(e.loaded / _this.fileSize);
});
}
return xhr;
},
crossDomain: true,
type: 'POST',
url: "" + this.settings.urlBase + "/base/?jsonerrors=1",
xhrFields: {
withCredentials: true
},
headers: {
'X-PINGOTHER': 'pingpong'
},
contentType: false,
processData: false,
data: formData,
dataType: 'json',
error: this.__uploadDf.reject,
success: function(data) {
if (data != null ? data.file : void 0) {
_this.fileId = data.file;
return _this.__uploadDf.resolve();
} else {
if (_this.settings.autostore && /autostore/i.test(data.error.content)) {
utils.commonWarning('autostore');
}
return _this.__uploadDf.reject();
}
}
});
};
ObjectFile.prototype.multipartUpload = function() {
var _this = this;
return this.multipartStart().done(function(data) {
return _this.uploadParts(data.parts).done(function() {
return _this.multipartComplete(data.uuid).done(function(data) {
_this.fileId = data.uuid;
_this.__handleFileData(data);
return _this.__completeUpload();
}).fail(_this.__uploadDf.reject);
}).fail(_this.__uploadDf.reject);
}).fail(this.__uploadDf.reject);
};
ObjectFile.prototype.multipartStart = function() {
var data;
data = {
UPLOADCARE_PUB_KEY: this.settings.publicKey,
filename: this.fileName,
size: this.fileSize,
content_type: this.fileType
};
if (this.settings.autostore) {
data.UPLOADCARE_STORE = '1';
}
return utils.jsonp("" + this.settings.urlBase + "/multipart/start/?jsonerrors=1", 'POST', data);
};
ObjectFile.prototype.uploadParts = function(parts) {
var blob, blobCount, blobOffset, blobSize, i, progress, requests, updateProgress,
_this = this;
blobCount = Math.min(parts.length, this.MP_CONCURRENCY);
blobSize = Math.max(Math.ceil(this.__file.size / blobCount), this.MP_PART_SIZE);
blobOffset = 0;
progress = [];
updateProgress = function(i, loaded) {
var total, _i, _len;
progress[i] = loaded;
total = 0;
for (_i = 0, _len = progress.length; _i < _len; _i++) {
loaded = progress[_i];
total += loaded;
}
return _this.__uploadDf.notify(total / _this.fileSize);
};
requests = (function() {
var _i, _results,
_this = this;
_results = [];
for (i = _i = 0; 0 <= blobCount ? _i < blobCount : _i > blobCount; i = 0 <= blobCount ? ++_i : --_i) {
progress.push(0);
blob = this.__file.slice(blobOffset, blobOffset + blobSize);
blobOffset += blobSize;
_results.push($.ajax({
xhr: function() {
var xhr;
xhr = $.ajaxSettings.xhr();
if (xhr.upload) {
xhr.upload._part = i;
xhr.upload.addEventListener('progress', function(e) {
return updateProgress(e.target._part, e.loaded);
});
}
return xhr;
},
url: parts[i],
crossDomain: true,
type: 'PUT',
processData: false,
contentType: this.fileType,
data: blob
}));
}
return _results;
}).call(this);
return $.when.apply(null, requests);
};
ObjectFile.prototype.multipartComplete = function(uuid) {
var data;
data = {
UPLOADCARE_PUB_KEY: this.settings.publicKey,
uuid: uuid
};
return utils.jsonp("" + this.settings.urlBase + "/multipart/complete/?jsonerrors=1", "POST", data);
};
return ObjectFile;
})(ns.BaseFile);
});
}).call(this);
(function() {
var $, namespace, utils,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
namespace = uploadcare.namespace, $ = uploadcare.jQuery, utils = uploadcare.utils;
namespace('uploadcare.files', function(ns) {
return ns.InputFile = (function(_super) {
__extends(InputFile, _super);
function InputFile(settings, __input) {
this.__input = __input;
InputFile.__super__.constructor.apply(this, arguments);
this.fileId = utils.uuid();
this.fileName = $(this.__input).val().split('\\').pop();
this.__notifyApi();
}
InputFile.prototype.__startUpload = function() {
var formParam, iframeId, targetUrl,
_this = this;
targetUrl = "" + this.settings.urlBase + "/iframe/";
this.__uploadDf.always(function() {
return _this.__cleanUp();
});
iframeId = "uploadcare-iframe-" + this.fileId;
this.__iframe = $('