"use strict";!function(t){t.fn.famultibutton=function(o){function e(){m=!0,h.bg.css("color",P.onBackgroundColor),h.fg.css("color",P.onColor),c.addClass("active"),h.trigger("setOn")}function n(){m=!1,h.bg.css("color",P.offBackgroundColor),h.fg.css("color",P.offColor),c.removeClass("active"),h.trigger("setOff")}function i(){t("
").animate({width:100},{duration:700,easing:"swing",step:function(t,o){var e=(t-o.start)/(o.end-o.start);h.bg.css("color",s(P.onBackgroundColor,P.offBackgroundColor,e)),h.fg.css("color",s(P.onColor,P.offColor,e))},complete:function(){!0===m?e():n()}})}function a(t){var o=t.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i);return o&&4===o.length?"#"+("0"+parseInt(o[1],10).toString(16)).slice(-2)+("0"+parseInt(o[2],10).toString(16)).slice(-2)+("0"+parseInt(o[3],10).toString(16)).slice(-2):t}function s(t,o,e){t=a(t).replace(/^\s*#|\s*$/g,""),o=a(o).replace(/^\s*#|\s*$/g,""),3==t.length&&(t=t.replace(/(.)/g,"$1$1")),3==o.length&&(o=o.replace(/(.)/g,"$1$1"));var n=parseInt(t.substr(0,2),16),i=parseInt(t.substr(2,2),16),s=parseInt(t.substr(4,2),16),r=parseInt(o.substr(0,2),16)-n,f=parseInt(o.substr(2,2),16)-i,l=parseInt(o.substr(4,2),16)-s;return r=(r*e+n).toString(16).split(".")[0],f=(f*e+i).toString(16).split(".")[0],l=(l*e+s).toString(16).split(".")[0],1==r.length&&(r="0"+r),1==f.length&&(f="0"+f),1==l.length&&(l="0"+l),"#"+r+f+l}function r(){clearTimeout(d),(w=k>0?w-=P.step:w+=P.step)>P.max&&(w=P.max),w3||Math.abs(o-t(window).scrollLeft())>3))return s=m,e(),"function"==typeof P.toggleOn&&P.toggleOn.call(this),m=!1,setTimeout(function(){i()},200),!0===s&&setTimeout(function(){e()},1e3),h.trigger("clicked"),!1})):"updown"==P.mode?(c.on(y,function(t){t.preventDefault(),t.stopImmediatePropagation(),s=m,e(),"function"==typeof P.toggleOn&&P.toggleOn.call(this)}),c.on(B,function(t){return t.preventDefault(),t.stopImmediatePropagation(),"function"==typeof P.toggleOff&&P.toggleOff.call(this),m=!1,setTimeout(function(){i()},200),!0===s&&setTimeout(function(){e()},1e3),h.trigger("clicked"),!1})):"toggle"==P.mode?(c.on(y,function(e){e.stopImmediatePropagation(),a=t(window).scrollTop(),o=t(window).scrollLeft()}),c.on(B,function(i){if(i.preventDefault(),i.stopImmediatePropagation(),!(Math.abs(a-t(window).scrollTop())>3||Math.abs(o-t(window).scrollLeft())>3))return m?(n(),"function"==typeof P.toggleOff&&P.toggleOff.call(this),P.timeout>0&&(p=setTimeout(function(){e()},P.timeout))):(e(),"function"==typeof P.toggleOn&&P.toggleOn.call(this),P.timeout>0&&(p=setTimeout(function(){n()},P.timeout))),h.trigger("clicked"),!1})):"dimmer"==P.mode&&(c.on(y,function(t){t.preventDefault(),t.stopImmediatePropagation();var o=t.originalEvent;b=o.touches?o.touches[0].clientY:t.pageY,k=0,O=!0}),c.on(D,function(t){t.preventDefault(),t.stopImmediatePropagation(),x&&(x=!1,c.animate({top:0}),clearInterval(d),v=!1,l()),O=!1}),c.on(B,function(t){return t.preventDefault(),t.stopImmediatePropagation(),x?(x=!1,c.animate({top:0}),clearTimeout(d),v=!1,"function"==typeof P.valueChanged&&P.valueChanged.call(this,w)):m?(n(),"function"==typeof P.toggleOff&&P.toggleOff.call(this),P.timeout>0&&(p=setTimeout(function(){e()},P.timeout))):(e(),"function"==typeof P.toggleOn&&P.toggleOn.call(this),P.timeout>0&&(p=setTimeout(function(){n()},P.timeout))),x=!1,O=!1,l(),f(),h.trigger("clicked"),!1}),c.on(S,function(t){t.preventDefault(),t.stopImmediatePropagation(),O&&(x=!0);var o=t.originalEvent;if(T=o.touches?o.touches[0].clientY:t.pageY,(k=T-b)>20&&(k=20),k<-20&&(k=-20),x){this.style.top=k+"px";g[0].style.top=-k+"px",v||(l(),r(),v=!0)}}))}if(this.length>1)return this.each(function(){t(this).famultibutton(o)}),this;var c,g,d,p,h=this,m=!1,v=!1,C=[0,10,40,80,120,140,150,160,180,200,240,260,280,300,320,420,430,440,450,460,470],b=0,w=0,k=0,I=0,T=0,x=!1,O=!1,P=t.extend({},{backgroundIcon:"fa-circle",icon:"fa-power-off",offColor:"#2A2A2A",offBackgroundColor:"#505050",onColor:"#2A2A2A",onBackgroundColor:"#aa6900",mode:"toggle",toggleOn:null,toggleOff:null,valueChanged:null,progressWidth:15,timeout:0,max:100,min:0,step:1},o);return this.setOn=function(){clearTimeout(p),e()},this.setOff=function(){clearTimeout(p),n()},this.getState=function(){return m},this.getValue=function(){return w},this.setDimValue=function(t){w=t,f()},this.setProgressValue=function(o){!function(o){var e=h.find("canvas#progress");if(o>0){0===e.length&&(e=t("").attr({id:"progress"}).appendTo(c));var n=e[0];if(n){n.height=h.h,n.width=h.w;var i=n.width/2,a=n.height/2;if(n.getContext){var s=n.getContext("2d");s.beginPath(),s.strokeStyle=P.onColor,s.arc(i,a,i*(-.4/90*Number(P.progressWidth)+.8),-.5*Math.PI,(2*o-.5)*Math.PI,!1),s.lineWidth=.8*i*P.progressWidth/100,s.stroke()}}}else h.find("canvas#progress").remove()}(o)},this.setForegroundColor=function(t){!function(t){h.fg.css("color",t)}(t)},this.setBackgroundColor=function(t){!function(t){h.bg.css("color",t)}(t)},this.setForegroundIcon=function(t){!function(t){h.fg.removeClass(h.fi),h.fi=t,h.fg.addClass(h.fi)}(t)},this.setBackgroundIcon=function(t){!function(t){h.bg.removeClass(h.bi),h.bi=t,h.bg.addClass(h.bi)}(t)},function(){P=t.extend({},P,h.data());var o=h.html()!==h.text()?h.children().detach():jQuery("
",{}).text(h.text());return"none"!==P.onColor&&"none"!==P.offColor&&o.attr("id","fg"),o.addClass("fa-stack-1x"),h.html(""),h.bi=P.backgroundIcon,h.fi=P.icon,(c=t("
",{class:"famultibutton"})).addClass("fa-stack"),h.bg=jQuery("",{id:"bg",class:"fa fa-stack-2x"}).addClass(h.bi),h.fg=jQuery("",{id:"fg",class:"fa fa-stack-1x"}).addClass(h.fi),c.addClass("fa-2x"),h.bg.appendTo(c),h.fg.appendTo(c),o.appendTo(c),c.appendTo(h),h.o=P,h.w=c.width(),h.h=c.height(),n(),"dimmer"==P.mode&&(g=t("").attr({id:"scale",height:h.h+"px",width:h.w+"px"}).appendTo(c),I=parseInt(g.offset().top)-parseInt(c.offset().top),f(),l()),h.data("famultibutton",h),u(),h}()}}(jQuery);