mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
17 lines
514 KiB
JavaScript
17 lines
514 KiB
JavaScript
|
!function(a,b){function c(a){var b=oa[a]={};return $.each(a.split(ba),function(a,c){b[c]=!0}),b}function d(a,c,d){if(d===b&&1===a.nodeType){var e="data-"+c.replace(qa,"-$1").toLowerCase();if(d=a.getAttribute(e),"string"==typeof d){try{d="true"===d||"false"!==d&&("null"===d?null:+d+""===d?+d:pa.test(d)?$.parseJSON(d):d)}catch(f){}$.data(a,c,d)}else d=b}return d}function e(a){var b;for(b in a)if(("data"!==b||!$.isEmptyObject(a[b]))&&"toJSON"!==b)return!1;return!0}function f(){return!1}function g(){return!0}function h(a){return!a||!a.parentNode||11===a.parentNode.nodeType}function i(a,b){do a=a[b];while(a&&1!==a.nodeType);return a}function j(a,b,c){if(b=b||0,$.isFunction(b))return $.grep(a,function(a,d){var e=!!b.call(a,d,a);return e===c});if(b.nodeType)return $.grep(a,function(a,d){return a===b===c});if("string"==typeof b){var d=$.grep(a,function(a){return 1===a.nodeType});if(Ka.test(b))return $.filter(b,d,!c);b=$.filter(b,d)}return $.grep(a,function(a,d){return $.inArray(a,b)>=0===c})}function k(a){var b=Na.split("|"),c=a.createDocumentFragment();if(c.createElement)for(;b.length;)c.createElement(b.pop());return c}function l(a,b){return a.getElementsByTagName(b)[0]||a.appendChild(a.ownerDocument.createElement(b))}function m(a,b){if(1===b.nodeType&&$.hasData(a)){var c,d,e,f=$._data(a),g=$._data(b,f),h=f.events;if(h){delete g.handle,g.events={};for(c in h)for(d=0,e=h[c].length;d<e;d++)$.event.add(b,c,h[c][d])}g.data&&(g.data=$.extend({},g.data))}}function n(a,b){var c;1===b.nodeType&&(b.clearAttributes&&b.clearAttributes(),b.mergeAttributes&&b.mergeAttributes(a),c=b.nodeName.toLowerCase(),"object"===c?(b.parentNode&&(b.outerHTML=a.outerHTML),$.support.html5Clone&&a.innerHTML&&!$.trim(b.innerHTML)&&(b.innerHTML=a.innerHTML)):"input"===c&&Xa.test(a.type)?(b.defaultChecked=b.checked=a.checked,b.value!==a.value&&(b.value=a.value)):"option"===c?b.selected=a.defaultSelected:"input"===c||"textarea"===c?b.defaultValue=a.defaultValue:"script"===c&&b.text!==a.text&&(b.text=a.text),b.removeAttribute($.expando))}function o(a){return"undefined"!=typeof a.getElementsByTagName?a.getElementsByTagName("*"):"undefined"!=typeof a.querySelectorAll?a.querySelectorAll("*"):[]}function p(a){Xa.test(a.type)&&(a.defaultChecked=a.checked)}function q(a,b){if(b in a)return b;for(var c=b.charAt(0).toUpperCase()+b.slice(1),d=b,e=qb.length;e--;)if(b=qb[e]+c,b in a)return b;return d}function r(a,b){return a=b||a,"none"===$.css(a,"display")||!$.contains(a.ownerDocument,a)}function s(a,b){for(var c,d,e=[],f=0,g=a.length;f<g;f++)c=a[f],c.style&&(e[f]=$._data(c,"olddisplay"),b?(e[f]||"none"!==c.style.display||(c.style.display=""),""===c.style.display&&r(c)&&(e[f]=$._data(c,"olddisplay",w(c.nodeName)))):(d=cb(c,"display"),e[f]||"none"===d||$._data(c,"olddisplay",d)));for(f=0;f<g;f++)c=a[f],c.style&&(b&&"none"!==c.style.display&&""!==c.style.display||(c.style.display=b?e[f]||"":"none"));return a}function t(a,b,c){var d=jb.exec(b);return d?Math.max(0,d[1]-(c||0))+(d[2]||"px"):b}function u(a,b,c,d){for(var e=c===(d?"border":"content")?4:"width"===b?1:0,f=0;e<4;e+=2)"margin"===c&&(f+=$.css(a,c+pb[e],!0)),d?("content"===c&&(f-=parseFloat(cb(a,"padding"+pb[e]))||0),"margin"!==c&&(f-=parseFloat(cb(a,"border"+pb[e]+"Width"))||0)):(f+=parseFloat(cb(a,"padding"+pb[e]))||0,"padding"!==c&&(f+=parseFloat(cb(a,"border"+pb[e]+"Width"))||0));return f}function v(a,b,c){var d="width"===b?a.offsetWidth:a.offsetHeight,e=!0,f=$.support.boxSizing&&"border-box"===$.css(a,"boxSizing");if(d<=0){if(d=cb(a,b),(d<0||null==d)&&(d=a.style[b]),kb.test(d))return d;e=f&&($.support.boxSizingReliable||d===a.style[b]),d=parseFloat(d)||0}return d+u(a,b,c||(f?"border":"content"),e)+"px"}function w(a){if(mb[a])return mb[a];var b=$("<"+a+">").appendTo(P.body),c=b.css("display");return b.remove(),"none"!==c&&""!==c||(db=P.body.appendChild(db||$.extend(P.createElement("iframe"),{frameBorder:0,width:0,height:0})),eb&&db.createElement||(eb=(db.contentWindow||db.contentDocument).document,eb.write("<!doctype html><html><body>"),eb.close()),b=eb.body.appendChild(eb.createElement(a)),c=cb(b,"display"),P.bod
|
||
|
c}})}),$.attrHooks.contenteditable={get:ra.get,set:function(a,b,c){""===b&&(b="false"),ra.set(a,b,c)}}),$.support.hrefNormalized||$.each(["href","src","width","height"],function(a,c){$.attrHooks[c]=$.extend($.attrHooks[c],{get:function(a){var d=a.getAttribute(c,2);return null===d?b:d}})}),$.support.style||($.attrHooks.style={get:function(a){return a.style.cssText.toLowerCase()||b},set:function(a,b){return a.style.cssText=""+b}}),$.support.optSelected||($.propHooks.selected=$.extend($.propHooks.selected,{get:function(a){var b=a.parentNode;return b&&(b.selectedIndex,b.parentNode&&b.parentNode.selectedIndex),null}})),$.support.enctype||($.propFix.enctype="encoding"),$.support.checkOn||$.each(["radio","checkbox"],function(){$.valHooks[this]={get:function(a){return null===a.getAttribute("value")?"on":a.value}}}),$.each(["radio","checkbox"],function(){$.valHooks[this]=$.extend($.valHooks[this],{set:function(a,b){if($.isArray(b))return a.checked=$.inArray($(a).val(),b)>=0}})});var Ba=/^(?:textarea|input|select)$/i,Ca=/^([^\.]*|)(?:\.(.+)|)$/,Da=/(?:^|\s)hover(\.\S+|)\b/,Ea=/^key/,Fa=/^(?:mouse|contextmenu)|click/,Ga=/^(?:focusinfocus|focusoutblur)$/,Ha=function(a){return $.event.special.hover?a:a.replace(Da,"mouseenter$1 mouseleave$1")};$.event={add:function(a,c,d,e,f){var g,h,i,j,k,l,m,n,o,p,q;if(3!==a.nodeType&&8!==a.nodeType&&c&&d&&(g=$._data(a))){for(d.handler&&(o=d,d=o.handler,f=o.selector),d.guid||(d.guid=$.guid++),i=g.events,i||(g.events=i={}),h=g.handle,h||(g.handle=h=function(a){return"undefined"==typeof $||a&&$.event.triggered===a.type?b:$.event.dispatch.apply(h.elem,arguments)},h.elem=a),c=$.trim(Ha(c)).split(" "),j=0;j<c.length;j++)k=Ca.exec(c[j])||[],l=k[1],m=(k[2]||"").split(".").sort(),q=$.event.special[l]||{},l=(f?q.delegateType:q.bindType)||l,q=$.event.special[l]||{},n=$.extend({type:l,origType:k[1],data:e,handler:d,guid:d.guid,selector:f,namespace:m.join(".")},o),p=i[l],p||(p=i[l]=[],p.delegateCount=0,q.setup&&q.setup.call(a,e,m,h)!==!1||(a.addEventListener?a.addEventListener(l,h,!1):a.attachEvent&&a.attachEvent("on"+l,h))),q.add&&(q.add.call(a,n),n.handler.guid||(n.handler.guid=d.guid)),f?p.splice(p.delegateCount++,0,n):p.push(n),$.event.global[l]=!0;a=null}},global:{},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,n,o,p,q=$.hasData(a)&&$._data(a);if(q&&(m=q.events)){for(b=$.trim(Ha(b||"")).split(" "),f=0;f<b.length;f++)if(g=Ca.exec(b[f])||[],h=i=g[1],j=g[2],h){for(n=$.event.special[h]||{},h=(d?n.delegateType:n.bindType)||h,o=m[h]||[],k=o.length,j=j?new RegExp("(^|\\.)"+j.split(".").sort().join("\\.(?:.*\\.|)")+"(\\.|$)"):null,l=0;l<o.length;l++)p=o[l],!e&&i!==p.origType||c&&c.guid!==p.guid||j&&!j.test(p.namespace)||d&&d!==p.selector&&("**"!==d||!p.selector)||(o.splice(l--,1),p.selector&&o.delegateCount--,n.remove&&n.remove.call(a,p));0===o.length&&k!==o.length&&(n.teardown&&n.teardown.call(a,j,q.handle)!==!1||$.removeEvent(a,h,q.handle),delete m[h])}else for(h in m)$.event.remove(a,h+b[f],c,d,!0);$.isEmptyObject(m)&&(delete q.handle,$.removeData(a,"events",!0))}},customEvent:{getData:!0,setData:!0,changeData:!0},trigger:function(c,d,e,f){if(!e||3!==e.nodeType&&8!==e.nodeType){var g,h,i,j,k,l,m,n,o,p,q=c.type||c,r=[];if(!Ga.test(q+$.event.triggered)&&(q.indexOf("!")>=0&&(q=q.slice(0,-1),h=!0),q.indexOf(".")>=0&&(r=q.split("."),q=r.shift(),r.sort()),e&&!$.event.customEvent[q]||$.event.global[q]))if(c="object"==typeof c?c[$.expando]?c:new $.Event(q,c):new $.Event(q),c.type=q,c.isTrigger=!0,c.exclusive=h,c.namespace=r.join("."),c.namespace_re=c.namespace?new RegExp("(^|\\.)"+r.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,l=q.indexOf(":")<0?"on"+q:"",e){if(c.result=b,c.target||(c.target=e),d=null!=d?$.makeArray(d):[],d.unshift(c),m=$.event.special[q]||{},!m.trigger||m.trigger.apply(e,d)!==!1){if(o=[[e,m.bindType||q]],!f&&!m.noBubble&&!$.isWindow(e)){for(p=m.delegateType||q,j=Ga.test(p+q)?e:e.parentNode,k=e;j;j=j.parentNode)o.push([j,p]),k=j;k===(e.ownerDocument||P)&&o.push([k.defaultView||k.parentWindow||a,p])}for(i=0;i<o.length&&!c.isPropagationStopped();i++)j=o[i][0],c.type=o[i][1],n=($._data(j,"events")||{})[c.type]
|
||
|
_a.th=_a.td,$.support.htmlSerialize||(_a._default=[1,"X<div>","</div>"]),$.fn.extend({text:function(a){return $.access(this,function(a){return a===b?$.text(this):this.empty().append((this[0]&&this[0].ownerDocument||P).createTextNode(a))},null,a,arguments.length)},wrapAll:function(a){if($.isFunction(a))return this.each(function(b){$(this).wrapAll(a.call(this,b))});if(this[0]){var b=$(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){for(var a=this;a.firstChild&&1===a.firstChild.nodeType;)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){return $.isFunction(a)?this.each(function(b){$(this).wrapInner(a.call(this,b))}):this.each(function(){var b=$(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=$.isFunction(a);return this.each(function(c){$(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(){return this.parent().each(function(){$.nodeName(this,"body")||$(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(a){1!==this.nodeType&&11!==this.nodeType||this.appendChild(a)})},prepend:function(){return this.domManip(arguments,!0,function(a){1!==this.nodeType&&11!==this.nodeType||this.insertBefore(a,this.firstChild)})},before:function(){if(!h(this[0]))return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this)});if(arguments.length){var a=$.clean(arguments);return this.pushStack($.merge(a,this),"before",this.selector)}},after:function(){if(!h(this[0]))return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this.nextSibling)});if(arguments.length){var a=$.clean(arguments);return this.pushStack($.merge(this,a),"after",this.selector)}},remove:function(a,b){for(var c,d=0;null!=(c=this[d]);d++)a&&!$.filter(a,[c]).length||(b||1!==c.nodeType||($.cleanData(c.getElementsByTagName("*")),$.cleanData([c])),c.parentNode&&c.parentNode.removeChild(c));return this},empty:function(){for(var a,b=0;null!=(a=this[b]);b++)for(1===a.nodeType&&$.cleanData(a.getElementsByTagName("*"));a.firstChild;)a.removeChild(a.firstChild);return this},clone:function(a,b){return a=null!=a&&a,b=null==b?a:b,this.map(function(){return $.clone(this,a,b)})},html:function(a){return $.access(this,function(a){var c=this[0]||{},d=0,e=this.length;if(a===b)return 1===c.nodeType?c.innerHTML.replace(Oa,""):b;if("string"==typeof a&&!Ua.test(a)&&($.support.htmlSerialize||!Wa.test(a))&&($.support.leadingWhitespace||!Pa.test(a))&&!_a[(Ra.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Qa,"<$1></$2>");try{for(;d<e;d++)c=this[d]||{},1===c.nodeType&&($.cleanData(c.getElementsByTagName("*")),c.innerHTML=a);c=0}catch(f){}}c&&this.empty().append(a)},null,a,arguments.length)},replaceWith:function(a){return h(this[0])?this.length?this.pushStack($($.isFunction(a)?a():a),"replaceWith",a):this:$.isFunction(a)?this.each(function(b){var c=$(this),d=c.html();c.replaceWith(a.call(this,b,d))}):("string"!=typeof a&&(a=$(a).detach()),this.each(function(){var b=this.nextSibling,c=this.parentNode;$(this).remove(),b?$(b).before(a):$(c).append(a)}))},detach:function(a){return this.remove(a,!0)},domManip:function(a,c,d){a=[].concat.apply([],a);var e,f,g,h,i=0,j=a[0],k=[],m=this.length;if(!$.support.checkClone&&m>1&&"string"==typeof j&&Ya.test(j))return this.each(function(){$(this).domManip(a,c,d)});if($.isFunction(j))return this.each(function(e){var f=$(this);a[0]=j.call(this,e,c?f.html():b),f.domManip(a,c,d)});if(this[0]){if(e=$.buildFragment(a,this,k),g=e.fragment,f=g.firstChild,1===g.childNodes.length&&(g=f),f)for(c=c&&$.nodeName(f,"tr"),h=e.cacheable||m-1;i<m;i++)d.call(c&&$.nodeName(this[i],"table")?l(this[i],"tbody"):this[i],i===h?g:$.clone(g,!0,!0));g=f=null,k.length&&$.each(k,function(a,b){b.src?$.ajax?$.ajax({url:b.src,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0}):$.error("no ajax"):$.globalEval((b.text||b.textContent||b.innerHTML||"").replace($a,"")),b.parentNode&&b.parentNode.removeChild(b)})}return this}}),$.buildFragment=function(a,c,d){var e,f,g,h=a[0];return c=c||P,c=(c[0]
|
||
|
e=b[d]>0,b[d]=0,e)}})}(jQuery),function(a,b){var c=0,d=Array.prototype.slice,e=a.cleanData;a.cleanData=function(b){for(var c,d=0;null!=(c=b[d]);d++)try{a(c).triggerHandler("remove")}catch(f){}e(b)},a.widget=function(b,c,d){var e,f,g,h,i={},j=b.split(".")[0];b=b.split(".")[1],e=j+"-"+b,d||(d=c,c=a.Widget),a.expr[":"][e.toLowerCase()]=function(b){return!!a.data(b,e)},a[j]=a[j]||{},f=a[j][b],g=a[j][b]=function(a,b){return this._createWidget?void(arguments.length&&this._createWidget(a,b)):new g(a,b)},a.extend(g,f,{version:d.version,_proto:a.extend({},d),_childConstructors:[]}),h=new c,h.options=a.widget.extend({},h.options),a.each(d,function(b,d){return a.isFunction(d)?void(i[b]=function(){var a=function(){return c.prototype[b].apply(this,arguments)},e=function(a){return c.prototype[b].apply(this,a)};return function(){var b,c=this._super,f=this._superApply;return this._super=a,this._superApply=e,b=d.apply(this,arguments),this._super=c,this._superApply=f,b}}()):void(i[b]=d)}),g.prototype=a.widget.extend(h,{widgetEventPrefix:f?h.widgetEventPrefix:b},i,{constructor:g,namespace:j,widgetName:b,widgetFullName:e}),f?(a.each(f._childConstructors,function(b,c){var d=c.prototype;a.widget(d.namespace+"."+d.widgetName,g,c._proto)}),delete f._childConstructors):c._childConstructors.push(g),a.widget.bridge(b,g)},a.widget.extend=function(c){for(var e,f,g=d.call(arguments,1),h=0,i=g.length;h<i;h++)for(e in g[h])f=g[h][e],g[h].hasOwnProperty(e)&&f!==b&&(a.isPlainObject(f)?c[e]=a.isPlainObject(c[e])?a.widget.extend({},c[e],f):a.widget.extend({},f):c[e]=f);return c},a.widget.bridge=function(c,e){var f=e.prototype.widgetFullName||c;a.fn[c]=function(g){var h="string"==typeof g,i=d.call(arguments,1),j=this;return g=!h&&i.length?a.widget.extend.apply(null,[g].concat(i)):g,h?this.each(function(){var d,e=a.data(this,f);return e?a.isFunction(e[g])&&"_"!==g.charAt(0)?(d=e[g].apply(e,i),d!==e&&d!==b?(j=d&&d.jquery?j.pushStack(d.get()):d,!1):void 0):a.error("no such method '"+g+"' for "+c+" widget instance"):a.error("cannot call methods on "+c+" prior to initialization; attempted to call method '"+g+"'")}):this.each(function(){var b=a.data(this,f);b?b.option(g||{})._init():a.data(this,f,new e(g,this))}),j}},a.Widget=function(){},a.Widget._childConstructors=[],a.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",defaultElement:"<div>",options:{disabled:!1,create:null},_createWidget:function(b,d){d=a(d||this.defaultElement||this)[0],this.element=a(d),this.uuid=c++,this.eventNamespace="."+this.widgetName+this.uuid,this.options=a.widget.extend({},this.options,this._getCreateOptions(),b),this.bindings=a(),this.hoverable=a(),this.focusable=a(),d!==this&&(a.data(d,this.widgetFullName,this),this._on(!0,this.element,{remove:function(a){a.target===d&&this.destroy()}}),this.document=a(d.style?d.ownerDocument:d.document||d),this.window=a(this.document[0].defaultView||this.document[0].parentWindow)),this._create(),this._trigger("create",null,this._getCreateEventData()),this._init()},_getCreateOptions:a.noop,_getCreateEventData:a.noop,_create:a.noop,_init:a.noop,destroy:function(){this._destroy(),this.element.unbind(this.eventNamespace).removeData(this.widgetName).removeData(this.widgetFullName).removeData(a.camelCase(this.widgetFullName)),this.widget().unbind(this.eventNamespace).removeAttr("aria-disabled").removeClass(this.widgetFullName+"-disabled ui-state-disabled"),this.bindings.unbind(this.eventNamespace),this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus")},_destroy:a.noop,widget:function(){return this.element},option:function(c,d){var e,f,g,h=c;if(0===arguments.length)return a.widget.extend({},this.options);if("string"==typeof c)if(h={},e=c.split("."),c=e.shift(),e.length){for(f=h[c]=a.widget.extend({},this.options[c]),g=0;g<e.length-1;g++)f[e[g]]=f[e[g]]||{},f=f[e[g]];if(c=e.pop(),d===b)return f[c]===b?null:f[c];f[c]=d}else{if(d===b)return this.options[c]===b?null:this.options[c];h[c]=d}return this._setOptions(h),this},_setOptions:function(a){var b;for(b in a)this._setOption(b,a[b]);return this},_setOption:functi
|
||
|
if(this.storedCursor&&(this.document.find("body").css("cursor",this.storedCursor),this.storedStylesheet.remove()),this._storedOpacity&&this.helper.css("opacity",this._storedOpacity),this._storedZIndex&&this.helper.css("zIndex","auto"===this._storedZIndex?"":this._storedZIndex),this.dragging=!1,this.cancelHelperRemoval){if(!b){for(this._trigger("beforeStop",a,this._uiHash()),c=0;c<d.length;c++)d[c].call(this,a);this._trigger("stop",a,this._uiHash())}return this.fromOutside=!1,!1}if(b||this._trigger("beforeStop",a,this._uiHash()),this.placeholder[0].parentNode.removeChild(this.placeholder[0]),this.helper[0]!==this.currentItem[0]&&this.helper.remove(),this.helper=null,!b){for(c=0;c<d.length;c++)d[c].call(this,a);this._trigger("stop",a,this._uiHash())}return this.fromOutside=!1,!0},_trigger:function(){a.Widget.prototype._trigger.apply(this,arguments)===!1&&this.cancel()},_uiHash:function(b){var c=b||this;return{helper:c.helper,placeholder:c.placeholder||a([]),position:c.position,originalPosition:c.originalPosition,offset:c.positionAbs,item:c.currentItem,sender:b?b.element:null}}})}(jQuery),function(a){var b=a({});a.subscribe=function(){b.on.apply(b,arguments)},a.unsubscribe=function(){b.off.apply(b,arguments)},a.publish=function(){b.trigger.apply(b,arguments)}}(jQuery),!function(a){"use strict";var b=function(a,b){this.init("tooltip",a,b)};b.prototype={constructor:b,init:function(b,c,d){var e,f;this.type=b,this.$element=a(c),this.options=this.getOptions(d),this.enabled=!0,"click"==this.options.trigger?this.$element.on("click."+this.type,this.options.selector,a.proxy(this.toggle,this)):"manual"!=this.options.trigger&&(e="hover"==this.options.trigger?"mouseenter":"focus",f="hover"==this.options.trigger?"mouseleave":"blur",this.$element.on(e+"."+this.type,this.options.selector,a.proxy(this.enter,this)),this.$element.on(f+"."+this.type,this.options.selector,a.proxy(this.leave,this))),this.options.selector?this._options=a.extend({},this.options,{trigger:"manual",selector:""}):this.fixTitle()},getOptions:function(b){return b=a.extend({},a.fn[this.type].defaults,b,this.$element.data()),b.delay&&"number"==typeof b.delay&&(b.delay={show:b.delay,hide:b.delay}),b},enter:function(b){var c=a(b.currentTarget)[this.type](this._options).data(this.type);return c.options.delay&&c.options.delay.show?(clearTimeout(this.timeout),c.hoverState="in",void(this.timeout=setTimeout(function(){"in"==c.hoverState&&c.show()},c.options.delay.show))):c.show()},leave:function(b){var c=a(b.currentTarget)[this.type](this._options).data(this.type);return this.timeout&&clearTimeout(this.timeout),c.options.delay&&c.options.delay.hide?(c.hoverState="out",void(this.timeout=setTimeout(function(){"out"==c.hoverState&&c.hide()},c.options.delay.hide))):c.hide()},show:function(){var a,b,c,d,e,f,g;if(this.hasContent()&&this.enabled){switch(a=this.tip(),this.setContent(),this.options.animation&&a.addClass("fade"),f="function"==typeof this.options.placement?this.options.placement.call(this,a[0],this.$element[0]):this.options.placement,b=/in/.test(f),a.remove().css({top:0,left:0,display:"block"}).appendTo(b?this.$element:document.body),c=this.getPosition(b),d=a[0].offsetWidth,e=a[0].offsetHeight,b?f.split(" ")[1]:f){case"bottom":g={top:c.top+c.height,left:c.left+c.width/2-d/2};break;case"top":g={top:c.top-e,left:c.left+c.width/2-d/2};break;case"left":g={top:c.top+c.height/2-e/2,left:c.left-d};break;case"right":g={top:c.top+c.height/2-e/2,left:c.left+c.width}}a.css(g).addClass(f).addClass("in")}},setContent:function(){var a=this.tip(),b=this.getTitle();a.find(".tooltip-inner")[this.options.html?"html":"text"](b),a.removeClass("fade in top bottom left right")},hide:function(){function b(){var b=setTimeout(function(){c.off(a.support.transition.end).remove()},500);c.one(a.support.transition.end,function(){clearTimeout(b),c.remove()})}var c=this.tip();return c.removeClass("in"),a.support.transition&&this.$tip.hasClass("fade")?b():c.remove(),this},fixTitle:function(){var a=this.$element;(a.attr("title")||"string"!=typeof a.attr("data-original-title"))&&a.attr("data-original-titl
|
||
|
return Math.floor(65536*(1+Math.random())).toString(16).substring(1)};a.Uuid={generate:function(){return"ss-s-s-s-sss".replace(/s/g,function(){return b()})}}}(),function(){var a=$.namespace("pskl.utils"),b={};a.WorkerUtils={createWorker:function(c,d){return b[d]||(b[d]=a.WorkerUtils.createWorkerURL(c)),new Worker(b[d])},createWorkerURL:function(a){var b=[(a+"").replace(/function\s*\(\)\s*\{/,"").replace(/\}[^}]*$/,"")],c=new Blob(b,{type:"application/javascript"});return window.URL.createObjectURL(c)}}}(),function(){var a=$.namespace("pskl.utils");a.Xhr={get:function(b,c,d){var e=a.Xhr.xhr_(b,"GET",c,d);e.send()},post:function(b,c,d,e){var f=a.Xhr.xhr_(b,"POST",d,e),g=new FormData;if("object"==typeof c)for(var h in c)c.hasOwnProperty(h)&&g.append(h,c[h]);f.send(g)},xhr_:function(a,b,c,d){c=c||function(){},d=d||function(){};var e=new XMLHttpRequest;return e.open(b,a,!0),e.onload=function(a){200==this.status?c(this):this.onerror(this,a)},e.onerror=function(a){d(a,this)},e}}}(),function(){var a=$.namespace("pskl.utils.serialization"),b=function(a){return a.length&&a.every(function(a){return a.base64PNG&&"data:,"!==a.base64PNG})},c=function(a,b){for(var c=[],d=0;d<a;d++)c.push([d+b]);return c};a.Serializer={serialize:function(a){var b=a.getLayers().map(function(a){return pskl.utils.serialization.Serializer.serializeLayer(a)});return JSON.stringify({modelVersion:Constants.MODEL_VERSION,piskel:{name:a.getDescriptor().name,description:a.getDescriptor().description,fps:pskl.app.piskelController.getFPS(),height:a.getHeight(),width:a.getWidth(),layers:b}})},serializeLayer:function(d){for(var e=d.getFrames(),f={name:d.getName(),opacity:d.getOpacity(),frameCount:e.length},g=[];!b(g);){if(g.length>=e.length){g=[];break}var h=pskl.utils.Array.chunk(e,g.length+1);g=[];for(var i=0,j=0;j<h.length;j++){var k=h[j];g.push({layout:c(k.length,i),base64PNG:a.Serializer.serializeFramesToBase64(k)}),i+=k.length}}return f.chunks=g,JSON.stringify(f)},serializeFramesToBase64:function(a){try{var b=new pskl.rendering.FramesheetRenderer(a);return b.renderAsCanvas().toDataURL()}catch(c){return""}}}}(),function(){var a=$.namespace("pskl.utils.serialization");a.Deserializer=function(a,b){this.layersToLoad_=0,this.data_=a,this.callback_=b,this.piskel_=null,this.layers_=[]},a.Deserializer.deserialize=function(b,c,d){try{var e;e=b.modelVersion==Constants.MODEL_VERSION?new a.Deserializer(b,c):1==b.modelVersion?new a.backward.Deserializer_v1(b,c):new a.backward.Deserializer_v0(b,c),e.deserialize()}catch(f){console.error(f),"function"==typeof d&&d(f)}},a.Deserializer.prototype.deserialize=function(){var a=this.data_,b=a.piskel,c=b.name||"Deserialized piskel",d=b.description||"",e=new pskl.model.piskel.Descriptor(c,d);this.piskel_=new pskl.model.Piskel(b.width,b.height,b.fps,e),this.layersToLoad_=b.layers.length,b.layers.forEach(this.deserializeLayer.bind(this))},a.Deserializer.prototype.deserializeLayer=function(a,b){var c=JSON.parse(a),d=new pskl.model.Layer(c.name);d.setOpacity(c.opacity),"undefined"==typeof c.chunks&&c.base64PNG&&this.normalizeLayerData_(c);var e=c.chunks,f=[];return Q.all(e.map(function(a){var b=Q.defer(),c=new Image;return c.onload=function(){var d=pskl.utils.FrameUtils.createFramesFromChunk(c,a.layout);d.forEach(function(a){f[a.index]=a.frame}),b.resolve()},c.src=a.base64PNG,b.promise})).then(function(){f.forEach(d.addFrame.bind(d)),this.layers_[b]=d,this.onLayerLoaded_()}.bind(this))["catch"](function(a){console.error("Failed to deserialize layer"),console.error(a)}),d},a.Deserializer.prototype.onLayerLoaded_=function(){this.layersToLoad_=this.layersToLoad_-1,0===this.layersToLoad_&&(this.layers_.forEach(function(a){this.piskel_.addLayer(a)}.bind(this)),this.callback_(this.piskel_))},a.Deserializer.prototype.normalizeLayerData_=function(a){for(var b=[],c=0;c<a.frameCount;c++)b.push([c]);a.chunks=[{base64PNG:a.base64PNG,layout:b}]}}(),function(){var a=$.namespace("pskl.utils.serialization.arraybuffer");a.ArrayBufferDeserializer={deserialize:function(a,b){var c,d,e=a,f=new Uint8Array(e),g=new Uint16Array(f.buffer),h=(g[0],g[1]),i=g[2],j=
|
||
|
};l()},g=function(b){var c={vp_l:0,vp_t:0,vp_w:null,vp_h:null,c_w:null,c_h:null};for(var e in b)c[e]=b[e];c.vp_w&&c.vp_h&&(c.is_vp=!0);var g,h,i=null,j=!1,k=null,l=null,m=null,n=0,o=null,p=null,q=null,r=[],s=c.gif,t=function(){k=null,l=null,o=m,m=null,p=null},u=function(){try{f(g,B)}catch(a){w("parse")}},v=function(a,b){F.width=a,F.height=b,F.getContext("2d").setTransform(1,0,0,1,0,0)},w=function(a){i=a,h={width:s.width,height:s.height},r=[]},x=function(a){h=a,v(h.width,h.height)},y=function(a){z(),t(),k=a.transparencyGiven?a.transparencyIndex:null,l=a.delayTime,m=a.disposalMethod},z=function(){p&&r.push({data:p.getImageData(0,0,h.width,h.height),delay:l})},A=function(a){p||(p=F.getContext("2d"));var b=r.length,c=a.lctFlag?a.lct:h.gct;b>0&&(3===o?p.putImageData(r[n].data,0,0):n=b-1,2===o&&p.clearRect(q.leftPos,q.topPos,q.width,q.height));var d=p.getImageData(a.leftPos,a.topPos,a.width,a.height),e=d.data;a.pixels.forEach(function(a,b){a!==k&&(e[4*b+0]=c[a][0],e[4*b+1]=c[a][1],e[4*b+2]=c[a][2],e[4*b+3]=255)}),p.putImageData(d,a.leftPos,a.topPos),q=a},B={hdr:x,gce:y,img:A,eof:function(a){z(),j=!1,C&&C()},onError:function(a){E&&E()}},C=!1,D=!1,E=!1,F=document.createElement("canvas");return{load:function(b){if(C=b.success,D=b.step,E=b.error,j=!0,s.src.indexOf("data:")!==-1){var c=s.src.substring(s.src.indexOf(",")+1);g=new d(a.atob(c)),u()}else{var e=new XMLHttpRequest;e.overrideMimeType("text/plain; charset=x-user-defined"),e.onload=function(a){g=new d(e.responseText),setTimeout(u,0)},e.onerror=function(){w("xhr")},e.open("GET",s.getAttribute("data-animated-src")||s.src,!0),e.send()}},getFrames:function(){return r}}};a.SuperGif=g}(window),!function(a){"object"==typeof exports?module.exports=a():"function"==typeof define&&define.amd?define(a):"undefined"!=typeof window?window.JSZip=a():"undefined"!=typeof global?global.JSZip=a():"undefined"!=typeof self&&(self.JSZip=a())}(function(){return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){var c=b[g][1][a];return e(c?c:a)},j,j.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b,c){"use strict";var d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";c.encode=function(a){for(var b,c,e,f,g,h,i,j="",k=0;k<a.length;)b=a.charCodeAt(k++),c=a.charCodeAt(k++),e=a.charCodeAt(k++),f=b>>2,g=(3&b)<<4|c>>4,h=(15&c)<<2|e>>6,i=63&e,isNaN(c)?h=i=64:isNaN(e)&&(i=64),j=j+d.charAt(f)+d.charAt(g)+d.charAt(h)+d.charAt(i);return j},c.decode=function(a){var b,c,e,f,g,h,i,j="",k=0;for(a=a.replace(/[^A-Za-z0-9\+\/\=]/g,"");k<a.length;)f=d.indexOf(a.charAt(k++)),g=d.indexOf(a.charAt(k++)),h=d.indexOf(a.charAt(k++)),i=d.indexOf(a.charAt(k++)),b=f<<2|g>>4,c=(15&g)<<4|h>>2,e=(3&h)<<6|i,j+=String.fromCharCode(b),64!=h&&(j+=String.fromCharCode(c)),64!=i&&(j+=String.fromCharCode(e));return j}},{}],2:[function(a,b){"use strict";function c(){this.compressedSize=0,this.uncompressedSize=0,this.crc32=0,this.compressionMethod=null,this.compressedContent=null}c.prototype={getContent:function(){return null},getCompressedContent:function(){return null}},b.exports=c},{}],3:[function(a,b,c){"use strict";c.STORE={magic:"\0\0",compress:function(a){return a},uncompress:function(a){return a},compressInputType:null,uncompressInputType:null},c.DEFLATE=a("./flate")},{"./flate":6}],4:[function(a,b){"use strict";function c(){this.data=null,this.length=0,this.index=0}var d=a("./utils");c.prototype={checkOffset:function(a){this.checkIndex(this.index+a)},checkIndex:function(a){if(this.length<a||0>a)throw new Error("End of data reached (data length = "+this.length+", asked index = "+a+"). Corrupted zip ?")},setIndex:function(a){this.checkIndex(a),this.index=a},skip:function(a){this.setIndex(this.index+a)},byteAt:function(){},readInt:function(a){var b,c=0;for(this.checkOffset(a),b=this.index+a-1;b>=this.index;b--)c=(c<<8)+this.byteAt(b);ret
|
||
|
g=[23,d-3073,10];break;case 6144>=d:g=[24,d-4097,11];break;case 8192>=d:g=[25,d-6145,11];break;case 12288>=d:g=[26,d-8193,12];break;case 16384>=d:g=[27,d-12289,12];break;case 24576>=d:g=[28,d-16385,13];break;case 32768>=d:g=[29,d-24577,13];break;default:throw"invalid distance"}c=g,e[f++]=c[0],e[f++]=c[1],e[f++]=c[2];var h,i;for(h=0,i=e.length;i>h;++h)r[s++]=e[h];u[e[0]]++,v[e[3]]++,t=a.length+b-1,n=null}var d,e,f,g,i,j,k,n,p,q={},r=o?new Uint16Array(2*b.length):[],s=0,t=0,u=new(o?Uint32Array:Array)(286),v=new(o?Uint32Array:Array)(30),w=a.f;if(!o){for(f=0;285>=f;)u[f++]=0;for(f=0;29>=f;)v[f++]=0}for(u[256]=1,d=0,e=b.length;e>d;++d){for(f=i=0,g=3;g>f&&d+f!==e;++f)i=i<<8|b[d+f];if(q[i]===l&&(q[i]=[]),j=q[i],!(0<t--)){for(;0<j.length&&32768<d-j[0];)j.shift();if(d+3>=e){for(n&&c(n,-1),f=0,g=e-d;g>f;++f)p=b[d+f],r[s++]=p,++u[p];break}0<j.length?(k=h(b,d,j),n?n.length<k.length?(p=b[d-1],r[s++]=p,++u[p],c(k,0)):c(n,-1):k.length<w?n=k:c(k,0)):n?c(n,-1):(p=b[d],r[s++]=p,++u[p])}j.push(d)}return r[s++]=256,u[256]++,a.j=u,a.i=v,o?r.subarray(0,s):r}function h(a,b,c){var d,e,g,h,i,j,k=0,l=a.length;h=0,j=c.length;a:for(;j>h;h++){if(d=c[j-h-1],g=3,k>3){for(i=k;i>3;i--)if(a[d+i-1]!==a[b+i-1])continue a;g=k}for(;258>g&&l>b+g&&a[d+g]===a[b+g];)++g;if(g>k&&(e=d,k=g),258===g)break}return new f(k,b-e)}function i(a,b){var c,e,f,g,h,i=a.length,k=new d(572),l=new(o?Uint8Array:Array)(i);if(!o)for(g=0;i>g;g++)l[g]=0;for(g=0;i>g;++g)0<a[g]&&k.push(g,a[g]);if(c=Array(k.length/2),e=new(o?Uint32Array:Array)(k.length/2),1===c.length)return l[k.pop().index]=1,l;for(g=0,h=k.length/2;h>g;++g)c[g]=k.pop(),e[g]=c[g].value;for(f=j(e,e.length,b),g=0,h=c.length;h>g;++g)l[c[g].index]=f[g];return l}function j(a,b,c){function d(a){var c=n[a][p[a]];c===b?(d(a+1),d(a+1)):--l[c],++p[a]}var e,f,g,h,i,j=new(o?Uint16Array:Array)(c),k=new(o?Uint8Array:Array)(c),l=new(o?Uint8Array:Array)(b),m=Array(c),n=Array(c),p=Array(c),q=(1<<c)-b,r=1<<c-1;for(j[c-1]=b,f=0;c>f;++f)r>q?k[f]=0:(k[f]=1,q-=r),q<<=1,j[c-2-f]=(j[c-1-f]/2|0)+b;for(j[0]=k[0],m[0]=Array(j[0]),n[0]=Array(j[0]),f=1;c>f;++f)j[f]>2*j[f-1]+k[f]&&(j[f]=2*j[f-1]+k[f]),m[f]=Array(j[f]),n[f]=Array(j[f]);for(e=0;b>e;++e)l[e]=c;for(g=0;g<j[c-1];++g)m[c-1][g]=a[g],n[c-1][g]=g;for(e=0;c>e;++e)p[e]=0;for(1===k[c-1]&&(--l[0],++p[c-1]),f=c-2;f>=0;--f){for(h=e=0,i=p[f+1],g=0;g<j[f];g++)h=m[f+1][i]+m[f+1][i+1],h>a[e]?(m[f][g]=h,n[f][g]=b,i+=2):(m[f][g]=a[e],n[f][g]=e,++e);p[f]=0,1===k[f]&&d(f)}return l}function k(a){var b,c,d,e,f=new(o?Uint16Array:Array)(a.length),g=[],h=[],i=0;for(b=0,c=a.length;c>b;b++)g[a[b]]=(0|g[a[b]])+1;for(b=1,c=16;c>=b;b++)h[b]=i,i+=0|g[b],i<<=1;for(b=0,c=a.length;c>b;b++)for(i=h[a[b]],h[a[b]]+=1,d=f[b]=0,e=a[b];e>d;d++)f[b]=f[b]<<1|1&i,i>>>=1;return f}var l=void 0,m=!0,n=this,o="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array&&"undefined"!=typeof DataView;b.prototype.a=function(a,b,d){var e,f=this.buffer,g=this.index,h=this.d,i=f[g];if(d&&b>1&&(a=b>8?(u[255&a]<<24|u[a>>>8&255]<<16|u[a>>>16&255]<<8|u[a>>>24&255])>>32-b:u[a]>>8-b),8>b+h)i=i<<b|a,h+=b;else for(e=0;b>e;++e)i=i<<1|a>>b-e-1&1,8===++h&&(h=0,f[g++]=u[i],i=0,g===f.length&&(f=c(this)));f[g]=i,this.buffer=f,this.d=h,this.index=g},b.prototype.finish=function(){var a,b=this.buffer,c=this.index;return 0<this.d&&(b[c]<<=8-this.d,b[c]=u[b[c]],c++),o?a=b.subarray(0,c):(b.length=c,a=b),a};var p,q=new(o?Uint8Array:Array)(256);for(p=0;256>p;++p){for(var r=p,s=r,t=7,r=r>>>1;r;r>>>=1)s<<=1,s|=1&r,--t;q[p]=(s<<t&255)>>>0}var u=q;d.prototype.getParent=function(a){return 2*((a-2)/4|0)},d.prototype.push=function(a,b){var c,d,e,f=this.buffer;for(c=this.length,f[this.length++]=b,f[this.length++]=a;c>0&&(d=this.getParent(c),f[c]>f[d]);)e=f[c],f[c]=f[d],f[d]=e,e=f[c+1],f[c+1]=f[d+1],f[d+1]=e,c=d;return this.length},d.prototype.pop=function(){var a,b,c,d,e,f=this.buffer;for(b=f[0],a=f[1],this.length-=2,f[0]=f[this.length],f[1]=f[this.length+1],e=0;d=2*e+2,!(d>=this.length)&&(d+2<this.length&&f[d+2]>f[d]&&(d+=2),f[d]>f[e]);)c=f[e],f[e]=f[d],f[d]=c,c=f[e+1],f[e+1]=f[d+1],f[d+1]=c,e=d;return{index:a,value:b,length:this.l
|
||
|
function d(a,b,c){return c<0&&(c+=1),c>1&&(c-=1),c<1/6?a+6*(b-a)*c:c<.5?b:c<2/3?a+(b-a)*(2/3-c)*6:a}var e,f,g;if(a=l(a,360),b=l(b,100),c=l(c,100),0===b)e=f=g=c;else{var h=c<.5?c*(1+b):c+b-c*b,i=2*c-h;e=d(i,h,a+1/3),f=d(i,h,a),g=d(i,h,a-1/3)}return{r:255*e,g:255*f,b:255*g}}function g(a,b,c){a=l(a,255),b=l(b,255),c=l(c,255);var d,e,f=z(a,b,c),g=y(a,b,c),h=f,i=f-g;if(e=0===f?0:i/f,f==g)d=0;else{switch(f){case a:d=(b-c)/i+(b<c?6:0);break;case b:d=(c-a)/i+2;break;case c:d=(a-b)/i+4}d/=6}return{h:d,s:e,v:h}}function h(a,b,c){a=6*l(a,360),b=l(b,100),c=l(c,100);var d=w.floor(a),e=a-d,f=c*(1-b),g=c*(1-e*b),h=c*(1-(1-e)*b),i=d%6,j=[c,g,f,f,h,c][i],k=[h,c,c,g,f,f][i],m=[f,f,h,c,c,g][i];return{r:255*j,g:255*k,b:255*m}}function i(a,b,c,d){var e=[q(x(a).toString(16)),q(x(b).toString(16)),q(x(c).toString(16))];return d&&e[0].charAt(0)==e[0].charAt(1)&&e[1].charAt(0)==e[1].charAt(1)&&e[2].charAt(0)==e[2].charAt(1)?e[0].charAt(0)+e[1].charAt(0)+e[2].charAt(0):e.join("")}function j(a){var b={};for(var c in a)a.hasOwnProperty(c)&&(b[a[c]]=c);return b}function k(a){return a=parseFloat(a),(isNaN(a)||a<0||a>1)&&(a=1),a}function l(a,b){o(a)&&(a="100%");var c=p(a);return a=y(b,z(0,parseFloat(a))),c&&(a=parseInt(a*b,10)/100),w.abs(a-b)<1e-6?1:a%b/parseFloat(b)}function m(a){return y(1,z(0,a))}function n(a){return parseInt(a,16)}function o(a){return"string"==typeof a&&a.indexOf(".")!=-1&&1===parseFloat(a)}function p(a){return"string"==typeof a&&a.indexOf("%")!=-1}function q(a){return 1==a.length?"0"+a:""+a}function r(a){return a<=1&&(a=100*a+"%"),a}function s(a){a=a.replace(t,"").replace(u,"").toLowerCase();var b=!1;if(B[a])a=B[a],b=!0;else if("transparent"==a)return{r:0,g:0,b:0,a:0,format:"name"};var c;return(c=D.rgb.exec(a))?{r:c[1],g:c[2],b:c[3]}:(c=D.rgba.exec(a))?{r:c[1],g:c[2],b:c[3],a:c[4]}:(c=D.hsl.exec(a))?{h:c[1],s:c[2],l:c[3]}:(c=D.hsla.exec(a))?{h:c[1],s:c[2],l:c[3],a:c[4]}:(c=D.hsv.exec(a))?{h:c[1],s:c[2],v:c[3]}:(c=D.hex6.exec(a))?{r:n(c[1]),g:n(c[2]),b:n(c[3]),format:b?"name":"hex"}:!!(c=D.hex3.exec(a))&&{r:n(c[1]+""+c[1]),g:n(c[2]+""+c[2]),b:n(c[3]+""+c[3]),format:b?"name":"hex"}}var t=/^[\s,#]+/,u=/\s+$/,v=0,w=Math,x=w.round,y=w.min,z=w.max,A=w.random;b.fromRatio=function(a,c){if("object"==typeof a){var d={};for(var e in a)a.hasOwnProperty(e)&&("a"===e?d[e]=a[e]:d[e]=r(a[e]));a=d}return b(a,c)},b.equals=function(a,c){return!(!a||!c)&&b(a).toRgbString()==b(c).toRgbString()},b.random=function(){return b.fromRatio({r:A(),g:A(),b:A()})},b.desaturate=function(a,c){c=0===c?0:c||10;var d=b(a).toHsl();return d.s-=c/100,d.s=m(d.s),b(d)},b.saturate=function(a,c){c=0===c?0:c||10;var d=b(a).toHsl();return d.s+=c/100,d.s=m(d.s),b(d)},b.greyscale=function(a){return b.desaturate(a,100)},b.lighten=function(a,c){c=0===c?0:c||10;var d=b(a).toHsl();return d.l+=c/100,d.l=m(d.l),b(d)},b.darken=function(a,c){c=0===c?0:c||10;var d=b(a).toHsl();return d.l-=c/100,d.l=m(d.l),b(d)},b.complement=function(a){var c=b(a).toHsl();return c.h=(c.h+180)%360,b(c)},b.triad=function(a){var c=b(a).toHsl(),d=c.h;return[b(a),b({h:(d+120)%360,s:c.s,l:c.l}),b({h:(d+240)%360,s:c.s,l:c.l})]},b.tetrad=function(a){var c=b(a).toHsl(),d=c.h;return[b(a),b({h:(d+90)%360,s:c.s,l:c.l}),b({h:(d+180)%360,s:c.s,l:c.l}),b({h:(d+270)%360,s:c.s,l:c.l})]},b.splitcomplement=function(a){var c=b(a).toHsl(),d=c.h;return[b(a),b({h:(d+72)%360,s:c.s,l:c.l}),b({h:(d+216)%360,s:c.s,l:c.l})]},b.analogous=function(a,c,d){c=c||6,d=d||30;var e=b(a).toHsl(),f=360/d,g=[b(a)];for(e.h=(e.h-(f*c>>1)+720)%360;--c;)e.h=(e.h+f)%360,g.push(b(e));return g},b.monochromatic=function(a,c){c=c||6;for(var d=b(a).toHsv(),e=d.h,f=d.s,g=d.v,h=[],i=1/c;c--;)h.push(b({h:e,s:f,v:g})),g=(g+i)%1;return h},b.readability=function(a,c){var d=b(a).toRgb(),e=b(c).toRgb(),f=(299*d.r+587*d.g+114*d.b)/1e3,g=(299*e.r+587*e.g+114*e.b)/1e3,h=Math.max(d.r,e.r)-Math.min(d.r,e.r)+Math.max(d.g,e.g)-Math.min(d.g,e.g)+Math.max(d.b,e.b)-Math.min(d.b,e.b);return{brightness:Math.abs(f-g),color:h}},b.readable=function(a,c){var d=b.readability(a,c);return d.brightness>125&&d.color>500},b.mostReadable=function(a,c){for(var d=null,e=0,f=!1,g=0;g<
|
||
|
a.forEach(d.addLayer.bind(d)),d},a.Piskel.prototype.getLayers=function(){return this.layers},a.Piskel.prototype.getHeight=function(){return this.height},a.Piskel.prototype.getWidth=function(){return this.width},a.Piskel.prototype.getFPS=function(){return this.fps},a.Piskel.prototype.getLayers=function(){return this.layers},a.Piskel.prototype.getLayerAt=function(a){return this.layers[a]},a.Piskel.prototype.getLayersByName=function(a){return this.layers.filter(function(b){return b.getName()==a})},a.Piskel.prototype.addLayer=function(a){this.layers.push(a)},a.Piskel.prototype.addLayerAt=function(a,b){this.layers.splice(b,0,a)},a.Piskel.prototype.moveLayerUp=function(a){var b=this.layers.indexOf(a);b>-1&&b<this.layers.length-1&&(this.layers[b]=this.layers[b+1],this.layers[b+1]=a)},a.Piskel.prototype.moveLayerDown=function(a){var b=this.layers.indexOf(a);b>0&&(this.layers[b]=this.layers[b-1],this.layers[b-1]=a)},a.Piskel.prototype.removeLayer=function(a){var b=this.layers.indexOf(a);b!=-1&&this.layers.splice(b,1)},a.Piskel.prototype.removeLayerAt=function(a){this.layers.splice(a,1)},a.Piskel.prototype.getDescriptor=function(){return this.descriptor},a.Piskel.prototype.setDescriptor=function(a){this.descriptor=a,$.publish(Events.PISKEL_DESCRIPTOR_UPDATED)},a.Piskel.prototype.setName=function(a){this.descriptor.name=a,$.publish(Events.PISKEL_DESCRIPTOR_UPDATED)},a.Piskel.prototype.getHash=function(){return this.layers.map(function(a){return a.getHash()}).join("-")}}(),function(){var a=$.namespace("pskl.selection"),b={PASTE:"REPLAY_PASTE",ERASE:"REPLAY_ERASE"};a.SelectionManager=function(a){this.piskelController=a,this.currentSelection=null},a.SelectionManager.prototype.init=function(){$.subscribe(Events.SELECTION_CREATED,$.proxy(this.onSelectionCreated_,this)),$.subscribe(Events.SELECTION_DISMISSED,$.proxy(this.onSelectionDismissed_,this)),$.subscribe(Events.SELECTION_MOVE_REQUEST,$.proxy(this.onSelectionMoved_,this)),$.subscribe(Events.SELECTION_COPY,this.copy.bind(this)),$.subscribe(Events.SELECTION_CUT,this.cut.bind(this)),$.subscribe(Events.SELECTION_PASTE,this.paste.bind(this));var a=pskl.service.keyboard.Shortcuts;pskl.app.shortcutService.registerShortcut(a.SELECTION.PASTE,this.paste.bind(this)),pskl.app.shortcutService.registerShortcut(a.SELECTION.CUT,this.cut.bind(this)),pskl.app.shortcutService.registerShortcut(a.SELECTION.COPY,this.copy.bind(this)),pskl.app.shortcutService.registerShortcut(a.SELECTION.DELETE,this.onDeleteShortcut_.bind(this)),pskl.app.shortcutService.registerShortcut(a.SELECTION.COMMIT,this.commit.bind(this)),$.subscribe(Events.TOOL_SELECTED,$.proxy(this.onToolSelected_,this))},a.SelectionManager.prototype.cleanSelection_=function(){this.currentSelection&&(this.currentSelection.reset(),this.currentSelection=null)},a.SelectionManager.prototype.onToolSelected_=function(a,b){var c=b instanceof pskl.tools.drawing.selection.BaseSelect;c||this.cleanSelection_()},a.SelectionManager.prototype.onSelectionDismissed_=function(a){this.cleanSelection_()},a.SelectionManager.prototype.onDeleteShortcut_=function(a){return!this.currentSelection||void this.erase()},a.SelectionManager.prototype.erase=function(){for(var a=this.currentSelection.pixels,c=this.piskelController.getCurrentFrame(),d=0,e=a.length;d<e;d++)c.setPixel(a[d].col,a[d].row,Constants.TRANSPARENT_COLOR);$.publish(Events.PISKEL_SAVE_STATE,{type:pskl.service.HistoryService.REPLAY,scope:this,replay:{type:b.ERASE,pixels:JSON.parse(JSON.stringify(a.slice(0)))}})},a.SelectionManager.prototype.cut=function(){this.currentSelection&&(this.currentSelection.fillSelectionFromFrame(this.piskelController.getCurrentFrame()),this.erase())},a.SelectionManager.prototype.paste=function(){if(!this.currentSelection||!this.currentSelection.hasPastedContent){if(!window.localStorage.getItem("piskel.clipboard"))return;this.currentSelection=JSON.parse(window.localStorage.getItem("piskel.clipboard"))}var a=this.currentSelection.pixels,c=this.piskelController.getCurrentFrame();this.pastePixels_(c,a),$.publish(Events.PISKEL_SAVE_STATE,{type:pskl.service.HistoryService.REPLAY,scope
|
||
|
var a=this.piskelController.getWidth(),b=this.piskelController.getHeight();return"["+a+"x"+b+"] "},a.CursorCoordinatesController.prototype.onCursorMoved_=function(a,b,c){this.coordinates={x:b,y:c},this.redraw()},a.CursorCoordinatesController.prototype.onDragStart_=function(a,b,c){this.origin={x:b,y:c},this.redraw()},a.CursorCoordinatesController.prototype.onDragEnd_=function(a){this.origin=null,this.redraw()}}(),function(){var a=$.namespace("pskl.controller");a.DrawingController=function(b,c){this.piskelController=b,this.dragHandler=new a.drawing.DragHandler(this),this.overlayFrame=pskl.model.Frame.createEmptyFromFrame(b.getCurrentFrame()),this.container=c;var d={zoom:this.calculateZoom_(),supportGridRendering:!0,height:this.getContainerHeight_(),width:this.getContainerWidth_(),xOffset:0,yOffset:0};this.overlayRenderer=new pskl.rendering.frame.CachedFrameRenderer(this.container,d,["canvas-overlay"]),this.renderer=new pskl.rendering.frame.CachedFrameRenderer(this.container,d,["drawing-canvas"]),this.onionSkinRenderer=pskl.rendering.OnionSkinRenderer.createInContainer(this.container,d,b),this.layersRenderer=new pskl.rendering.layer.LayersRenderer(this.container,d,b),this.compositeRenderer=new pskl.rendering.CompositeRenderer,this.compositeRenderer.add(this.overlayRenderer).add(this.renderer).add(this.layersRenderer).add(this.onionSkinRenderer),this.isClicked=!1,this.previousMousemoveTime=0,this.currentToolBehavior=null},a.DrawingController.prototype.init=function(){this.initMouseBehavior(),$.subscribe(Events.TOOL_SELECTED,$.proxy(function(a,b){this.currentToolBehavior=b,this.overlayFrame.clear()},this)),$(window).resize($.proxy(this.startResizeTimer_,this)),$.subscribe(Events.USER_SETTINGS_CHANGED,this.onUserSettingsChange_.bind(this)),$.subscribe(Events.FRAME_SIZE_CHANGED,this.onFrameSizeChange_.bind(this));var a=pskl.service.keyboard.Shortcuts;pskl.app.shortcutService.registerShortcut(a.MISC.RESET_ZOOM,this.resetZoom_.bind(this)),pskl.app.shortcutService.registerShortcut(a.MISC.INCREASE_ZOOM,this.updateZoom_.bind(this,1)),pskl.app.shortcutService.registerShortcut(a.MISC.DECREASE_ZOOM,this.updateZoom_.bind(this,-1)),window.setTimeout(function(){this.afterWindowResize_(),this.resetZoom_()}.bind(this),100)},a.DrawingController.prototype.initMouseBehavior=function(){var a=$("body");this.container.mousedown($.proxy(this.onMousedown_,this)),pskl.utils.UserAgent.isChrome||pskl.utils.UserAgent.isIE11?this.container.on("mousewheel",$.proxy(this.onMousewheel_,this)):this.container.on("wheel",$.proxy(this.onMousewheel_,this)),window.addEventListener("mouseup",this.onMouseup_.bind(this)),window.addEventListener("mousemove",this.onMousemove_.bind(this)),window.addEventListener("keyup",this.onKeyup_.bind(this)),window.addEventListener("touchstart",this.onTouchstart_.bind(this)),window.addEventListener("touchmove",this.onTouchmove_.bind(this)),window.addEventListener("touchend",this.onTouchend_.bind(this)),a.contextmenu(this.onCanvasContextMenu_)},a.DrawingController.prototype.startResizeTimer_=function(){this.resizeTimer&&window.clearInterval(this.resizeTimer),this.resizeTimer=window.setTimeout($.proxy(this.afterWindowResize_,this),200)},a.DrawingController.prototype.afterWindowResize_=function(){var a=this.compositeRenderer.getDisplaySize().width;this.compositeRenderer.setDisplaySize(this.getContainerWidth_(),this.getContainerHeight_()),this.centerColumnWrapperHorizontally_();var b=this.compositeRenderer.getDisplaySize().width/a,c=b*this.compositeRenderer.getZoom();this.compositeRenderer.setZoom(c),$.publish(Events.ZOOM_CHANGED)},a.DrawingController.prototype.onUserSettingsChange_=function(a,b,c){b==pskl.UserSettings.SHOW_GRID?console.warn("DrawingController:onUserSettingsChange_ not implemented !"):b!=pskl.UserSettings.ONION_SKIN&&b!=pskl.UserSettings.LAYER_PREVIEW||(this.onionSkinRenderer.clear(),this.onionSkinRenderer.flush(),this.layersRenderer.clear(),this.layersRenderer.flush(),this.render())},a.DrawingController.prototype.onFrameSizeChange_=function(){this.compositeRenderer.setDisplaySize(this.getContainerWidth_(),this.getCon
|
||
|
c&&pskl.UserSettings.set(pskl.UserSettings.PREVIEW_SIZE,a)},a.PreviewController.prototype.onUserSettingsChange_=function(a,b,c){b==pskl.UserSettings.ONION_SKIN?this.updateOnionSkinPreview_():b==pskl.UserSettings.MAX_FPS?this.updateMaxFPS_():b===pskl.UserSettings.SEAMLESS_MODE?this.onFrameSizeChange_():(this.updateZoom_(),this.selectPreviewSizeButton_(),this.updateContainerDimensions_())},a.PreviewController.prototype.updateOnionSkinPreview_=function(){var a="preview-toggle-onion-skin-enabled",b=pskl.UserSettings.get(pskl.UserSettings.ONION_SKIN);b?this.toggleOnionSkinButton.classList.add(a):this.toggleOnionSkinButton.classList.remove(a)},a.PreviewController.prototype.selectPreviewSizeButton_=function(){var a=document.querySelector(".size-button-selected");a&&a.classList.remove("size-button-selected");var b=pskl.UserSettings.get(pskl.UserSettings.PREVIEW_SIZE),c=this.previewSizes[b];c.button.classList.add("size-button-selected")},a.PreviewController.prototype.updateMaxFPS_=function(){var a=pskl.UserSettings.get(pskl.UserSettings.MAX_FPS);this.fpsRangeInput.setAttribute("max",a),this.piskelController.setFPS(Math.min(a,this.piskelController.getFPS()))},a.PreviewController.prototype.updateZoom_=function(){var a,b=pskl.UserSettings.get(pskl.UserSettings.PREVIEW_SIZE);"original"===b?a=1:"best"===b?a=Math.floor(this.calculateZoom_()):"full"===b&&(a=this.calculateZoom_()),this.renderer.setZoom(a),this.setRenderFlag_(!0)},a.PreviewController.prototype.getZoom=function(){return this.calculateZoom_()},a.PreviewController.prototype.getCoordinates=function(a,b){var c=this.container.offset();a-=c.left,b-=c.top;var d=this.getZoom();return{x:Math.floor(a/d),y:Math.floor(b/d)}},a.PreviewController.prototype.onFpsRangeInputUpdate_=function(a){var b=parseInt(this.fpsRangeInput.value,10);this.piskelController.setFPS(b),"change"===a.type&&this.fpsRangeInput.blur()},a.PreviewController.prototype.updateFPS_=function(){var a=this.piskelController.getFPS();a!==this.fps&&(this.fps=a,this.fpsRangeInput.value=0,this.fpsRangeInput.value=this.fps,this.fpsCounterDisplay.innerHTML=this.fps+" FPS")},a.PreviewController.prototype.render=function(a){this.elapsedTime+=a;var b=this.getNextIndex_(a);if(this.shouldRender_()||this.currentIndex!=b){this.currentIndex=b;var c=pskl.utils.LayerUtils.mergeFrameAt(this.piskelController.getLayers(),b);this.renderer.render(c),this.renderFlag=!1,this.lastRenderTime=Date.now(),this.popupPreviewController.render(c)}},a.PreviewController.prototype.getNextIndex_=function(a){if(0===this.fps)return this.piskelController.getCurrentFrameIndex();var b=Math.floor(this.elapsedTime/(1e3/this.fps));return this.piskelController.hasFrameAt(b)||(this.elapsedTime=0,b=0),b},a.PreviewController.prototype.calculateZoom_=function(){var a=this.piskelController.getCurrentFrame(),c=b/a.getHeight(),d=b/a.getWidth();return Math.min(c,d)},a.PreviewController.prototype.onFrameSizeChange_=function(){this.updateZoom_(),this.updateContainerDimensions_(),this.updatePreviewSizeButtons_()},a.PreviewController.prototype.updateContainerDimensions_=function(){var a=pskl.UserSettings.get(pskl.UserSettings.SEAMLESS_MODE);this.renderer.setRepeated(a);var c,d;if(a)c=b,d=b;else{var e=this.getZoom(),f=this.piskelController.getCurrentFrame();c=f.getHeight()*e,d=f.getWidth()*e}var g=this.container.get(0);g.style.height=c+"px",g.style.width=d+"px";var h=(b-c)/2;g.style.marginTop=h+"px",g.style.marginBottom=h+"px";var i=(b-d)/2;g.style.marginLeft=i+"px",g.style.marginRight=i+"px"},a.PreviewController.prototype.setRenderFlag_=function(a){this.renderFlag=a},a.PreviewController.prototype.shouldRender_=function(){return(this.renderFlag||this.popupPreviewController.renderFlag)&&Date.now()-this.lastRenderTime>c},a.PreviewController.prototype.toggleOnionSkin_=function(){var a=pskl.UserSettings.get(pskl.UserSettings.ONION_SKIN);pskl.UserSettings.set(pskl.UserSettings.ONION_SKIN,!a)}}(),function(){var a=$.namespace("pskl.controller");a.MinimapController=function(a,b,c,d){this.piskelController=a,this.previewController=b,this.drawingController=c,this.container=d,this.isClicke
|
||
|
p.fillRect(0,0,l,m),p.drawImage(r,0,0,l,m);var s=pskl.utils.ImageResizer.scale(o,a);n.addFrame(s.getContext("2d"),{delay:1e3/b})}$.publish(Events.SHOW_PROGRESS,[{name:"Building animated GIF ..."}]),n.on("progress",function(a){$.publish(Events.UPDATE_PROGRESS,[{progress:(100*a).toFixed(1)}])}.bind(this)),n.on("finished",function(a){$.publish(Events.HIDE_PROGRESS),pskl.utils.FileUtils.readFile(a,d)}.bind(this)),n.render()},a.GifExportController.prototype.getTransparentColor=function(a){var b=pskl.utils.ColorUtils.getUnusedColor(a);return b||(console.error("Unable to find unused color to use as transparent color in the current sprite"),b=d),b},a.GifExportController.prototype.updateStatus_=function(a,c){if(a){var d='<a class="highlight" href="{{link}}" target="_blank">{{shortLink}}</a>',e=pskl.utils.Template.replace(d,{link:a,shortLink:this.shorten_(a,b,"...")});this.uploadStatusContainerEl.innerHTML="Your image is now available at : "+e}},a.GifExportController.prototype.shorten_=function(a,b,c){if(a.length>b){var d=Math.round((b-c.length)/2),e=a.substring(0,d),f=a.substring(a.length-d,a.length);a=e+c+f}return a}}(),function(){var a=$.namespace("pskl.controller.settings.exportimage"),b="{{width}} x {{height}} px, {{frames}}<br/>{{columns}}, {{rows}}.",c=pskl.utils.Template.replace,d=function(a,b){return 1===b?"1 "+a:b+" "+a+"s"};a.PngExportController=function(a,b){this.piskelController=a,this.exportController=b,this.onScaleChanged_=this.onScaleChanged_.bind(this)},pskl.utils.inherit(a.PngExportController,pskl.controller.settings.AbstractSettingController),a.PngExportController.prototype.init=function(){this.layoutContainer=document.querySelector(".png-export-layout-section"),this.dimensionInfo=document.querySelector(".png-export-dimension-info"),this.rowsInput=document.querySelector("#png-export-rows"),this.columnsInput=document.querySelector("#png-export-columns");var a=document.querySelector(".png-download-button"),b=document.querySelector(".png-pixi-download-button"),c=document.querySelector(".datauri-open-button");this.initLayoutSection_(),this.updateDimensionLabel_(),this.addEventListener(this.columnsInput,"input",this.onColumnsInput_),this.addEventListener(a,"click",this.onDownloadClick_),this.addEventListener(b,"click",this.onPixiDownloadClick_),this.addEventListener(c,"click",this.onDataUriClick_),$.subscribe(Events.EXPORT_SCALE_CHANGED,this.onScaleChanged_)},a.PngExportController.prototype.destroy=function(){$.unsubscribe(Events.EXPORT_SCALE_CHANGED,this.onScaleChanged_),this.superclass.destroy.call(this)},a.PngExportController.prototype.initLayoutSection_=function(){var a=this.piskelController.getFrameCount();1===a?this.layoutContainer.style.display="none":(this.columnsInput.setAttribute("max",a),this.columnsInput.value=this.getBestFit_(),this.onColumnsInput_())},a.PngExportController.prototype.updateDimensionLabel_=function(){var a=this.exportController.getExportZoom(),e=this.piskelController.getFrameCount(),f=this.piskelController.getWidth()*a,g=this.piskelController.getHeight()*a,h=this.getColumns_(),i=this.getRows_();f=h*f,g=i*g,this.dimensionInfo.innerHTML=c(b,{width:f,height:g,rows:d("row",i),columns:d("column",h),frames:d("frame",e)})},a.PngExportController.prototype.getColumns_=function(){return parseInt(this.columnsInput.value||1,10)},a.PngExportController.prototype.getRows_=function(){return parseInt(this.rowsInput.value||1,10)},a.PngExportController.prototype.getBestFit_=function(){var a=this.piskelController.getWidth()/this.piskelController.getHeight(),b=this.piskelController.getFrameCount(),c=Math.round(Math.sqrt(b/a));return pskl.utils.Math.minmax(c,1,b)},a.PngExportController.prototype.onScaleChanged_=function(){this.updateDimensionLabel_()},a.PngExportController.prototype.onColumnsInput_=function(){var a=this.columnsInput.value;""!==a&&(a=parseInt(a,10),isNaN(a)&&(a=1),a=pskl.utils.Math.minmax(a,1,this.piskelController.getFrameCount()),this.columnsInput.value=a,this.rowsInput.value=Math.ceil(this.piskelController.getFrameCount()/a),this.updateDimensionLabel_())},a.PngExportController.prototype.crea
|
||
|
var b=document.querySelector(".create-palette-actions"),c=document.querySelector(".create-palette-delete"),d=document.querySelector(".create-palette-download-button"),e=document.querySelector(".create-palette-import-button");this.nameInput.addEventListener("input",this.onNameInputChange_.bind(this)),this.hiddenFileInput.addEventListener("change",this.onFileInputChange_.bind(this)),b.addEventListener("click",this.onButtonClick_.bind(this)),d.addEventListener("click",this.onDownloadButtonClick_.bind(this)),e.addEventListener("click",this.onImportFileButtonClick_.bind(this));var f=document.querySelector(".colors-container");this.colorsListWidget=new pskl.widgets.ColorsList(f);var g,h=a==Constants.CURRENT_COLORS_PALETTE_ID;if(a&&!h){e.style.display="none",this.setTitle("Edit Palette");var i=this.paletteService.getPaletteById(a);g=pskl.model.Palette.fromObject(i)}else{d.style.display="none",c.style.display="none",this.setTitle("Create Palette");var j=pskl.utils.Uuid.generate();g=h?new pskl.model.Palette(j,"Current colors clone",this.getCurrentColors_()):new pskl.model.Palette(j,"New palette",[])}this.setPalette_(g)},a.CreatePaletteController.prototype.getCurrentColors_=function(){var a=this.paletteService.getPaletteById(Constants.CURRENT_COLORS_PALETTE_ID);return a.getColors()},a.CreatePaletteController.prototype.setPalette_=function(a){this.palette=a,this.nameInput.value=pskl.utils.unescapeHtml(a.name),this.colorsListWidget.setColors(a.getColors())},a.CreatePaletteController.prototype.destroy=function(){this.colorsListWidget.destroy(),this.nameInput=null},a.CreatePaletteController.prototype.onButtonClick_=function(a){var b=a.target;"submit"===b.dataset.action?this.saveAndSelectPalette_():"cancel"===b.dataset.action?this.closeDialog():"delete"===b.dataset.action&&this.deletePalette_()},a.CreatePaletteController.prototype.saveAndSelectPalette_=function(){this.palette.setColors(this.colorsListWidget.getColors()),this.paletteService.savePalette(this.palette),pskl.UserSettings.set(pskl.UserSettings.SELECTED_PALETTE,this.palette.id),this.closeDialog()},a.CreatePaletteController.prototype.deletePalette_=function(){window.confirm("Are you sure you want to delete palette "+this.palette.name)&&(this.paletteService.deletePaletteById(this.palette.id),pskl.UserSettings.set(pskl.UserSettings.SELECTED_PALETTE,Constants.CURRENT_COLORS_PALETTE_ID),this.closeDialog())},a.CreatePaletteController.prototype.onDownloadButtonClick_=function(){var a=new pskl.service.palette.PaletteGplWriter(this.palette),b=a.write();pskl.utils.BlobUtils.stringToBlob(b,function(a){pskl.utils.FileUtils.downloadAsFile(a,this.palette.name+".gpl")}.bind(this),"application/json")},a.CreatePaletteController.prototype.onImportFileButtonClick_=function(){this.hiddenFileInput.click()},a.CreatePaletteController.prototype.onFileInputChange_=function(a){var b=this.hiddenFileInput.files;1==b.length&&this.paletteImportService.read(b[0],this.setPalette_.bind(this),this.displayErrorMessage_.bind(this))},a.CreatePaletteController.prototype.displayErrorMessage_=function(a){a="Could not import palette : "+a,$.publish(Events.SHOW_NOTIFICATION,[{content:a}]),window.setTimeout($.publish.bind($,Events.HIDE_NOTIFICATION),2e3)},a.CreatePaletteController.prototype.onNameInputChange_=function(a){this.palette.name=pskl.utils.escapeHtml(this.nameInput.value)}}(),function(){var a=$.namespace("pskl.controller.dialogs");a.ImportImageController=function(a){this.importedImage_=null,this.file_=null},pskl.utils.inherit(a.ImportImageController,a.AbstractDialogController),a.ImportImageController.prototype.init=function(a){this.superclass.init.call(this),this.file_=a,this.importPreview=$(".import-section-preview"),this.fileNameContainer=$(".import-image-file-name"),this.importType=$("[name=import-type]"),this.resizeWidth=$("[name=resize-width]"),this.resizeHeight=$("[name=resize-height]"),this.smoothResize=$("[name=smooth-resize-checkbox]"),this.frameSizeX=$("[name=frame-size-x]"),this.frameSizeY=$("[name=frame-size-y]"),this.frameOffsetX=$("[name=frame-offset-x]"),this.frameOffsetY=$("[name=frame-offse
|
||
|
c.reject(g.message)}}.bind(this),"application/piskel+json"),c.promise}}(),function(){var a=$.namespace("pskl.service.storage");a.LocalStorageService=function(a){if(void 0===a)throw"Bad LocalStorageService initialization: <undefined piskelController>";this.piskelController=a},a.LocalStorageService.prototype.init=function(){},a.LocalStorageService.prototype.save=function(a){var b=a.getDescriptor().name,c=a.getDescriptor().description,d=pskl.utils.serialization.Serializer.serialize(a);if(pskl.app.localStorageService.getPiskel(b)){var e=window.confirm("There is already a piskel saved as "+b+". Overwrite ?");if(!e)return Q.reject('Cancelled by user, "'+b+'" already exists')}try{return this.removeFromKeys_(b),this.addToKeys_(b,c,Date.now()),window.localStorage.setItem("piskel."+b,d),Q.resolve()}catch(f){return Q.reject(f.message)}},a.LocalStorageService.prototype.load=function(a){var b=this.getPiskel(a);this.getKey_(a);pskl.utils.serialization.Deserializer.deserialize(JSON.parse(b),function(a){pskl.app.piskelController.setPiskel(a)})},a.LocalStorageService.prototype.remove=function(a){this.removeFromKeys_(a),window.localStorage.removeItem("piskel."+a)},a.LocalStorageService.prototype.saveKeys_=function(a){window.localStorage.setItem("piskel.keys",JSON.stringify(a))},a.LocalStorageService.prototype.removeFromKeys_=function(a){var b=this.getKeys(),c=b.filter(function(b){return b.name!==a});this.saveKeys_(c)},a.LocalStorageService.prototype.getKey_=function(a){var b=this.getKeys().filter(function(b){return b.name===a});return b.length>0?b[0]:null},a.LocalStorageService.prototype.addToKeys_=function(a,b,c){var d=this.getKeys();d.push({name:a,description:b,date:c}),this.saveKeys_(d)},a.LocalStorageService.prototype.getPiskel=function(a){return window.localStorage.getItem("piskel."+a)},a.LocalStorageService.prototype.getKeys=function(a){var b=window.localStorage.getItem("piskel.keys");return JSON.parse(b)||[]}}(),function(){var a=$.namespace("pskl.service.storage");a.GalleryStorageService=function(a){this.piskelController=a},a.GalleryStorageService.prototype.init=function(){},a.GalleryStorageService.prototype.save=function(a){var b=a.getDescriptor(),c=Q.defer(),d=pskl.utils.serialization.Serializer.serialize(a),e={framesheet:d,fps:this.piskelController.getFPS(),name:b.name,description:b.description,frames:this.piskelController.getFrameCount(),first_frame_as_png:pskl.app.getFirstFrameAsPng(),framesheet_as_png:pskl.app.getFramesheetAsPng()};d.length>Constants.APPENGINE_SAVE_LIMIT&&c.reject("This sprite is too big to be saved on the gallery. Try saving it as a .piskel file."),b.isPublic&&(e["public"]=!0);var f=function(a){c.resolve()},g=function(a){c.reject(this.getErrorMessage_(a))};return pskl.utils.Xhr.post(Constants.APPENGINE_SAVE_URL,e,f,g.bind(this)),c.promise},a.GalleryStorageService.prototype.getErrorMessage_=function(a){var b="";return b=401===a.status?"Session expired, please log in again.":403===a.status?"Unauthorized action, this sprite belongs to another account.":500===a.status?"Unexpected server error, please contact us on Github (piskel) or Twitter (@piskelapp)":"Unknown error"}}(),function(){var a=$.namespace("pskl.service.storage"),b=".piskel";a.DesktopStorageService=function(a){this.piskelController=a||pskl.app.piskelController,this.hideNotificationTimeoutID=0},a.DesktopStorageService.prototype.init=function(){},a.DesktopStorageService.prototype.save=function(a,c){if(a.savePath&&!c)return this.saveAtPath_(a,a.savePath);var d=a.getDescriptor().name,e=pskl.utils.FileUtilsDesktop.chooseFilenameDialog(d,b);return e.then(this.saveAtPath_.bind(this,a))},a.DesktopStorageService.prototype.saveAtPath_=function(a,b){if(!b)return Q.reject("Invalid file name");var c=pskl.utils.serialization.Serializer.serialize(a);return b=this.addExtensionIfNeeded_(b),a.savePath=b,a.setName(this.extractFilename_(b)),pskl.utils.FileUtilsDesktop.saveToFile(c,b)},a.DesktopStorageService.prototype.openPiskel=function(){return pskl.utils.FileUtilsDesktop.chooseFilenameDialog().then(this.load)},a.DesktopStorageService.prototype.load=function(a){pskl
|
||
|
},a.CurrentColorsService.prototype.getCurrentColors=function(){return this.currentColors},a.CurrentColorsService.prototype.setCurrentColors=function(a){var b=pskl.app.historyService.currentIndex;this.cache[b]=a,a.join("")!==this.currentColors.join("")&&(this.currentColors=a,$.publish(Events.CURRENT_COLORS_UPDATED))},a.CurrentColorsService.prototype.isCurrentColorsPaletteSelected_=function(){var a=pskl.UserSettings.get(pskl.UserSettings.SELECTED_PALETTE),b=this.paletteService.getPaletteById(a);return b.id===Constants.CURRENT_COLORS_PALETTE_ID},a.CurrentColorsService.prototype.loadColorsFromCache_=function(){var a=pskl.app.historyService.currentIndex,b=this.cache[a];b?this.setCurrentColors(b):this.updateCurrentColors_()};var b=function(a,b){var c=[];for(a=a.slice(0);a.length;)c.push(a.splice(0,10));var d=Q([]);return c.forEach(function(a){d=d.then(function(c){return Q.all(a.map(b)).then(function(a){return c.concat(a)})})}),d};a.CurrentColorsService.prototype.updateCurrentColors_=function(){var a=this.piskelController.getLayers(),c=a.map(function(a){return a.getFrames()}).reduce(function(a,b){return a.concat(b)});b(c,function(a){return this.cachedFrameProcessor.get(a)}.bind(this)).then(function(a){var b={};a.forEach(function(a){Object.keys(a).forEach(function(a){b[a]=!0})}),delete b[pskl.utils.colorToInt(Constants.TRANSPARENT_COLOR)];var c=Object.keys(b).map(function(a){return pskl.utils.intToHex(a)});this.setCurrentColors(c)}.bind(this))},a.CurrentColorsService.prototype.isCurrentColorsPaletteSelected_=function(){var a=pskl.UserSettings.get(pskl.UserSettings.SELECTED_PALETTE),b=this.paletteService.getPaletteById(a);return b&&b.id===Constants.CURRENT_COLORS_PALETTE_ID},a.CurrentColorsService.prototype.loadColorsFromCache_=function(){var a=pskl.app.historyService.currentIndex,b=this.cache[a];b&&this.setCurrentColors(b)},a.CurrentColorsService.prototype.getFrameColors_=function(a,b){var c=new pskl.worker.framecolors.FrameColors(a,function(a){b(a.data.colors)},function(){},function(a){b({})});c.process()}}(),function(){var a=$.namespace("pskl.service");a.FileDropperService=function(a){this.piskelController=a,this.dropPosition_=null},a.FileDropperService.prototype.init=function(){document.body.addEventListener("drop",this.onFileDrop.bind(this),!1),document.body.addEventListener("dragover",this.onFileDragOver.bind(this),!1)},a.FileDropperService.prototype.onFileDragOver=function(a){a.stopPropagation(),a.preventDefault(),a.dataTransfer.dropEffect="copy"},a.FileDropperService.prototype.onFileDrop=function(a){a.preventDefault(),a.stopPropagation(),this.dropPosition_={x:a.clientX,y:a.clientY};var b=a.dataTransfer.files;this.isMultipleFiles_=b.length>1;for(var c=0;c<b.length;c++){var d=b[c],e=0===d.type.indexOf("image"),f=/\.piskel$/i.test(d.name),g=/\.(gpl|txt|pal)$/i.test(d.name);e?this.readImageFile_(d):f?pskl.utils.PiskelFileUtils.loadFromFile(d,this.onPiskelFileLoaded_,this.onPiskelFileError_):g&&pskl.app.paletteImportService.read(d,this.onPaletteLoaded_.bind(this))}},a.FileDropperService.prototype.readImageFile_=function(a){pskl.utils.FileUtils.readFile(a,this.processImageSource_.bind(this))},a.FileDropperService.prototype.onPaletteLoaded_=function(a){pskl.app.paletteService.savePalette(a),pskl.UserSettings.set(pskl.UserSettings.SELECTED_PALETTE,a.id)},a.FileDropperService.prototype.onPiskelFileLoaded_=function(a){window.confirm("This will replace your current animation")&&pskl.app.piskelController.setPiskel(a)},a.FileDropperService.prototype.onPiskelFileError_=function(a){$.publish(Events.PISKEL_FILE_IMPORT_FAILED,[a])},a.FileDropperService.prototype.processImageSource_=function(a){var b=new Image;b.onload=this.onImageLoaded_.bind(this,b),b.src=a},a.FileDropperService.prototype.onImageLoaded_=function(a){this.isMultipleFiles_&&(this.piskelController.addFrameAtCurrentIndex(),this.piskelController.selectNextFrame());var b=this.piskelController.getCurrentFrame(),c=pskl.app.drawingController.getSpriteCoordinates(this.dropPosition_.x,this.dropPosition_.y),d=c.x,e=c.y;pskl.utils.FrameUtils.addImageToFrame(b,a,d,e),$.publish(Events.
|
||
|
e.forEach(function(c){var e=b?c.getFrames():[c.getFrameAt(d)];e.forEach(function(b){this.applyToolOnFrame_(b,a)}.bind(this))}.bind(this))},a.AbstractTransformTool.prototype.replay=function(a,b){this.applyTool_(b.altKey,b.allFrames,b.allLayers)}}(),function(){var a=$.namespace("pskl.tools.transform");a.Center=function(){this.toolId="tool-center",this.helpText="Align image to the center",this.tooltipDescriptors=[{key:"ctrl",description:"Apply to all layers"},{key:"shift",description:"Apply to all frames"}]},pskl.utils.inherit(a.Center,a.AbstractTransformTool),a.Center.prototype.applyToolOnFrame_=function(b){a.TransformUtils.center(b)}}(),function(){var a=$.namespace("pskl.tools.transform");a.Clone=function(){this.toolId="tool-clone",this.helpText="Clone current layer to all frames",this.tooltipDescriptors=[]},pskl.utils.inherit(a.Clone,a.AbstractTransformTool),a.Clone.prototype.applyTool_=function(a,b,c){var d=pskl.app.piskelController.getCurrentFrame(),e=pskl.app.piskelController.getCurrentLayer();e.getFrames().forEach(function(a){a!==d&&a.setPixels(d.getPixels())})}}(),function(){var a=$.namespace("pskl.tools.transform");a.Flip=function(){this.toolId="tool-flip",this.helpText="Flip vertically",this.tooltipDescriptors=[{key:"alt",description:"Flip horizontally"},{key:"ctrl",description:"Apply to all layers"},{key:"shift",description:"Apply to all frames"}]},pskl.utils.inherit(a.Flip,a.AbstractTransformTool),a.Flip.prototype.applyToolOnFrame_=function(b,c){var d;d=c?a.TransformUtils.HORIZONTAL:a.TransformUtils.VERTICAL,a.TransformUtils.flip(b,d)}}(),function(){var a=$.namespace("pskl.tools.transform");a.Rotate=function(){this.toolId="tool-rotate",this.helpText="Counter-clockwise rotation",this.tooltipDescriptors=[{key:"alt",description:"Clockwise rotation"},{key:"ctrl",description:"Apply to all layers"},{key:"shift",description:"Apply to all frames"}]},pskl.utils.inherit(a.Rotate,a.AbstractTransformTool),a.Rotate.prototype.applyToolOnFrame_=function(b,c){var d;d=c?a.TransformUtils.CLOCKWISE:a.TransformUtils.COUNTERCLOCKWISE,a.TransformUtils.rotate(b,d)}}(),function(){var a=$.namespace("pskl.tools.transform");a.TransformUtils={VERTICAL:"VERTICAL",HORIZONTAL:"HORIZONTAL",flip:function(b,c){var d=b.clone(),e=b.getWidth(),f=b.getHeight();return d.forEachPixel(function(d,g,h){c===a.TransformUtils.VERTICAL?g=e-g-1:c===a.TransformUtils.HORIZONTAL&&(h=f-h-1),b.setPixel(g,h,d)}),b},CLOCKWISE:"clockwise",COUNTERCLOCKWISE:"counterclockwise",rotate:function(b,c){var d=b.clone(),e=b.getWidth(),f=b.getHeight(),g=Math.max(e,f),h=Math.ceil((g-e)/2),i=Math.ceil((g-f)/2);return b.forEachPixel(function(e,f,j){var k=f,l=j;f+=h,j+=i;var m=f,n=j;c===a.TransformUtils.CLOCKWISE?(f=n,j=g-1-m):c===a.TransformUtils.COUNTERCLOCKWISE&&(j=m,f=g-1-n),f-=h,j-=i,d.containsPixel(f,j)?b.setPixel(k,l,d.getPixel(f,j)):b.setPixel(k,l,Constants.TRANSPARENT_COLOR)}),b},center:function(a){var b=a.width,c=a.height,d=0,e=0,f=pskl.utils.colorToInt(Constants.TRANSPARENT_COLOR);a.forEachPixel(function(a,g,h){a!==f&&(b=Math.min(b,g),d=Math.max(d,g),c=Math.min(c,h),e=Math.max(e,h))});var g=(d-b+1)/2,h=(e-c+1)/2,i=a.width/2,j=a.height/2,k=Math.floor(i-g-b),l=Math.floor(j-h-c),m=a.clone();return a.forEachPixel(function(b,c,d){var e=c,f=d;c-=k,d-=l,m.containsPixel(c,d)?a.setPixel(e,f,m.getPixel(c,d)):a.setPixel(e,f,Constants.TRANSPARENT_COLOR)}),a}}}(),function(){var a=$.namespace("pskl.worker.framecolors");if("rgba(0, 0, 0, 0)"!==Constants.TRANSPARENT_COLOR)throw"Constants.TRANSPARENT_COLOR, please update FrameColorsWorker";a.FrameColorsWorker=function(){var a=function(a){for(var b={},c=this.TRANSPARENT_COLOR,d=0,e=0,f=a.length;e<f&&d<this.MAX_WORKER_COLORS;e++){var g=a[e];g!==c&&(b[g]||(b[g]=!0,d++))}return b};this.onmessage=function(b){try{this.TRANSPARENT_COLOR=b.data[0],this.MAX_WORKER_COLORS=b.data[1];var c=b.data[2],d=a(c);this.postMessage({type:"SUCCESS",colors:d})}catch(e){this.postMessage({type:"ERROR",message:e.message})}}}}(),function(){var a=$.namespace("pskl.worker.framecolors");a.FrameColors=function(b,c,d,e){this.pixels=b.pixels,this.onStep=d,this.onSucces
|