(function(e,t){if(typeof define==="function"&&define.amd){define(["jquery"],function(e){return t(e)})}else if(typeof exports==="object"){module.exports=t(require("jquery"))}else if(jQuery&&!jQuery.fn.colorpicker){t(jQuery)}})(this,function(f){"use strict";var s=function(e,t,i,o,r){this.fallbackValue=i?typeof i==="string"?this.parse(i):i:null;this.fallbackFormat=o?o:"rgba";this.hexNumberSignPrefix=r===true;this.value=this.fallbackValue;this.origFormat=null;this.predefinedColors=t?t:{};this.colors=f.extend({},s.webColors,this.predefinedColors);if(e){if(typeof e.h!=="undefined"){this.value=e}else{this.setColor(String(e))}}if(!this.value){this.value={h:0,s:0,b:0,a:1}}};s.webColors={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"00ffff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgrey:"d3d3d3",lightgreen:"90ee90",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"778899",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"00ff00",limegreen:"32cd32",linen:"faf0e6",magenta:"ff00ff",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370d8",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"d87093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",red:"ff0000",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"ffffff",whitesmoke:"f5f5f5",yellow:"ffff00",yellowgreen:"9acd32",transparent:"transparent"};s.prototype={constructor:s,colors:{},predefinedColors:{},getValue:function(){return this.value},setValue:function(e){this.value=e},_sanitizeNumber:function(e){if(typeof e==="number"){return e}if(isNaN(e)||e===null||e===""||e===undefined){return 1}if(e===""){return 0}if(typeof e.toLowerCase!=="undefined"){if(e.match(/^\./)){e="0"+e}return Math.ceil(parseFloat(e)*100)/100}return 1},isTransparent:function(e){if(!e||!(typeof e==="string"||e instanceof String)){return false}e=e.toLowerCase().trim();return e==="transparent"||e.match(/#?00000000/)||e.match(/(rgba|hsla)\(0,0,0,0?\.?0\)/)},rgbaIsTransparent:function(e){return e.r===0&&e.g===0&&e.b===0&&e.a===0},setColor:function(e){e=e.toLowerCase().trim();if(e){if(this.isTransparent(e)){this.value={h:0,s:0,b:0,a:0};return true}else{var t=this.parse(e);if(t){this.value=this.value={h:t.h,s:t.s,b:t.b,a:t.a};if(!this.origFormat){this.origFormat=t.format}}else if(this.fallbackValue){this.value=this.fallbackValue}}}return false},setHue:function(e){this.value.h=1-e},setSaturation:function(e){this.value.s=e},setBrightness:function(e){this.value.b=1-e},setAlpha:function(e){this.value.a=Math.round(parseInt((1-e)*100,10)/100*100)/100},toRGB:function(e,t,i,o){if(arguments.length===0){e=this.value.h;t=this.value.s;i=this.value.b;o=this.value.a}e*=360;var r,s,a,n,l;e=e%360/60;l=i*t;n=l*(1-Math.abs(e%2-1));r=s=a=i-l;e=~~e;r+=[l,n,0,0,n,l][e];s+=[n,l,l,n,0,0][e];a+=[0,0,n,l,l,n][e];return{r:Math.round(r*255),g:Math.round(s*255),b:Math.round(a*255),a:o}},toHex:function(e,t,i,o,r){if(arguments.length<=1){t=this.value.h;i=this.value.s;o=this.value.b;r=this.value.a}var s="#";var a=this.toRGB(t,i,o,r);if(this.rgbaIsTransparent(a)){return"transparent"}if(!e){s=this.hexNumberSignPrefix?"#":""}var n=s+((1<<24)+(parseInt(a.r)<<16)+(parseInt(a.g)<<8)+parseInt(a.b)).toString(16).slice(1);return n},toHSL:function(e,t,i,o){if(arguments.length===0){e=this.value.h;t=this.value.s;i=this.value.b;o=this.value.a}var r=e,s=(2-t)*i,a=t*i;if(s>0&&s<=1){a/=s}else{a/=2-s}s/=2;if(a>1){a=1}return{h:isNaN(r)?0:r,s:isNaN(a)?0:a,l:isNaN(s)?0:s,a:isNaN(o)?0:o}},toAlias:function(e,t,i,o){var r,s=arguments.length===0?this.toHex(true):this.toHex(true,e,t,i,o);var a=this.origFormat==="alias"?s:this.toString(false,this.origFormat);for(var n in this.colors){r=this.colors[n].toLowerCase().trim();if(r===s||r===a){return n}}return false},RGBtoHSB:function(e,t,i,o){e/=255;t/=255;i/=255;var r,s,a,n;a=Math.max(e,t,i);n=a-Math.min(e,t,i);r=n===0?null:a===e?(t-i)/n:a===t?(i-e)/n+2:(e-t)/n+4;r=(r+360)%6*60/360;s=n===0?0:n/a;return{h:this._sanitizeNumber(r),s:s,b:a,a:this._sanitizeNumber(o)}},HueToRGB:function(e,t,i){if(i<0){i+=1}else if(i>1){i-=1}if(i*6<1){return e+(t-e)*i*6}else if(i*2<1){return t}else if(i*3<2){return e+(t-e)*(2/3-i)*6}else{return e}},HSLtoRGB:function(e,t,i,o){if(t<0){t=0}var r;if(i<=.5){r=i*(1+t)}else{r=i+t-i*t}var s=2*i-r;var a=e+1/3;var n=e;var l=e-1/3;var f=Math.round(this.HueToRGB(s,r,a)*255);var h=Math.round(this.HueToRGB(s,r,n)*255);var c=Math.round(this.HueToRGB(s,r,l)*255);return[f,h,c,this._sanitizeNumber(o)]},parse:function(o){if(typeof o!=="string"){return this.fallbackValue}if(arguments.length===0){return false}var r=this,s=false,a=typeof this.colors[o]!=="undefined",n,l;if(a){o=this.colors[o].toLowerCase().trim()}f.each(this.stringParsers,function(e,t){var i=t.re.exec(o);n=i&&t.parse.apply(r,[i]);if(n){s={};l=a?"alias":t.format?t.format:r.getValidFallbackFormat();if(l.match(/hsla?/)){s=r.RGBtoHSB.apply(r,r.HSLtoRGB.apply(r,n))}else{s=r.RGBtoHSB.apply(r,n)}if(s instanceof Object){s.format=l}return false}return true});return s},getValidFallbackFormat:function(){var e=["rgba","rgb","hex","hsla","hsl"];if(this.origFormat&&e.indexOf(this.origFormat)!==-1){return this.origFormat}if(this.fallbackFormat&&e.indexOf(this.fallbackFormat)!==-1){return this.fallbackFormat}return"rgba"},toString:function(e,t,i){t=t||this.origFormat||this.fallbackFormat;i=i||false;var o=false;switch(t){case"rgb":{o=this.toRGB();if(this.rgbaIsTransparent(o)){return"transparent"}return"rgb("+o.r+","+o.g+","+o.b+")"}break;case"rgba":{o=this.toRGB();return"rgba("+o.r+","+o.g+","+o.b+","+o.a+")"}break;case"hsl":{o=this.toHSL();return"hsl("+Math.round(o.h*360)+","+Math.round(o.s*100)+"%,"+Math.round(o.l*100)+"%)"}break;case"hsla":{o=this.toHSL();return"hsla("+Math.round(o.h*360)+","+Math.round(o.s*100)+"%,"+Math.round(o.l*100)+"%,"+o.a+")"}break;case"hex":{return this.toHex(e)}break;case"alias":{o=this.toAlias();if(o===false){return this.toString(e,this.getValidFallbackFormat())}if(i&&!(o in s.webColors)&&o in this.predefinedColors){return this.predefinedColors[o]}return o}default:{return o}break}},stringParsers:[{re:/rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*?\)/,format:"rgb",parse:function(e){return[e[1],e[2],e[3],1]}},{re:/rgb\(\s*(\d*(?:\.\d+)?)\%\s*,\s*(\d*(?:\.\d+)?)\%\s*,\s*(\d*(?:\.\d+)?)\%\s*?\)/,format:"rgb",parse:function(e){return[2.55*e[1],2.55*e[2],2.55*e[3],1]}},{re:/rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d*(?:\.\d+)?)\s*)?\)/,format:"rgba",parse:function(e){return[e[1],e[2],e[3],e[4]]}},{re:/rgba\(\s*(\d*(?:\.\d+)?)\%\s*,\s*(\d*(?:\.\d+)?)\%\s*,\s*(\d*(?:\.\d+)?)\%\s*(?:,\s*(\d*(?:\.\d+)?)\s*)?\)/,format:"rgba",parse:function(e){return[2.55*e[1],2.55*e[2],2.55*e[3],e[4]]}},{re:/hsl\(\s*(\d*(?:\.\d+)?)\s*,\s*(\d*(?:\.\d+)?)\%\s*,\s*(\d*(?:\.\d+)?)\%\s*?\)/,format:"hsl",parse:function(e){return[e[1]/360,e[2]/100,e[3]/100,e[4]]}},{re:/hsla\(\s*(\d*(?:\.\d+)?)\s*,\s*(\d*(?:\.\d+)?)\%\s*,\s*(\d*(?:\.\d+)?)\%\s*(?:,\s*(\d*(?:\.\d+)?)\s*)?\)/,format:"hsla",parse:function(e){return[e[1]/360,e[2]/100,e[3]/100,e[4]]}},{re:/#?([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/,format:"hex",parse:function(e){return[parseInt(e[1],16),parseInt(e[2],16),parseInt(e[3],16),1]}},{re:/#?([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/,format:"hex",parse:function(e){return[parseInt(e[1]+e[1],16),parseInt(e[2]+e[2],16),parseInt(e[3]+e[3],16),1]}}],colorNameToHex:function(e){if(typeof this.colors[e.toLowerCase()]!=="undefined"){return this.colors[e.toLowerCase()]}return false}};var a={horizontal:false,inline:false,color:false,format:false,input:"input",container:false,component:".add-on, .input-group-addon",fallbackColor:false,fallbackFormat:"hex",hexNumberSignPrefix:true,sliders:{saturation:{maxLeft:100,maxTop:100,callLeft:"setSaturation",callTop:"setBrightness"},hue:{maxLeft:0,maxTop:100,callLeft:false,callTop:"setHue"},alpha:{maxLeft:0,maxTop:100,callLeft:false,callTop:"setAlpha"}},slidersHorz:{saturation:{maxLeft:100,maxTop:100,callLeft:"setSaturation",callTop:"setBrightness"},hue:{maxLeft:100,maxTop:0,callLeft:"setHue",callTop:false},alpha:{maxLeft:100,maxTop:0,callLeft:"setAlpha",callTop:false}},template:'<div class="colorpicker dropdown-menu">'+'<div class="colorpicker-saturation"><i><b></b></i></div>'+'<div class="colorpicker-hue"><i></i></div>'+'<div class="colorpicker-alpha"><i></i></div>'+'<div class="colorpicker-color"><div /></div>'+'<div class="colorpicker-selectors"></div>'+"</div>",align:"right",customClass:null,colorSelectors:null};var n=function(e,t){this.element=f(e).addClass("colorpicker-element");this.options=f.extend(true,{},a,this.element.data(),t);this.component=this.options.component;this.component=this.component!==false?this.element.find(this.component):false;if(this.component&&this.component.length===0){this.component=false}this.container=this.options.container===true?this.element:this.options.container;this.container=this.container!==false?f(this.container):false;this.input=this.element.is("input")?this.element:this.options.input?this.element.find(this.options.input):false;if(this.input&&this.input.length===0){this.input=false}this.color=this.createColor(this.options.color!==false?this.options.color:this.getValue());this.format=this.options.format!==false?this.options.format:this.color.origFormat;if(this.options.color!==false){this.updateInput(this.color);this.updateData(this.color)}this.disabled=false;var i=this.picker=f(this.options.template);if(this.options.customClass){i.addClass(this.options.customClass)}if(this.options.inline){i.addClass("colorpicker-inline colorpicker-visible")}else{i.addClass("colorpicker-hidden")}if(this.options.horizontal){i.addClass("colorpicker-horizontal")}if(["rgba","hsla","alias"].indexOf(this.format)!==-1||this.options.format===false||this.getValue()==="transparent"){i.addClass("colorpicker-with-alpha")}if(this.options.align==="right"){i.addClass("colorpicker-right")}if(this.options.inline===true){i.addClass("colorpicker-no-arrow")}if(this.options.colorSelectors){var o=this,r=o.picker.find(".colorpicker-selectors");if(r.length>0){f.each(this.options.colorSelectors,function(e,t){var i=f("<i />").addClass("colorpicker-selectors-color").css("background-color",t).data("class",e).data("alias",e);i.on("mousedown.colorpicker touchstart.colorpicker",function(e){e.preventDefault();o.setValue(o.format==="alias"?f(this).data("alias"):f(this).css("background-color"))});r.append(i)});r.show().addClass("colorpicker-visible")}}i.on("mousedown.colorpicker touchstart.colorpicker",f.proxy(function(e){if(e.target===e.currentTarget){e.preventDefault()}},this));i.find(".colorpicker-saturation, .colorpicker-hue, .colorpicker-alpha").on("mousedown.colorpicker touchstart.colorpicker",f.proxy(this.mousedown,this));i.appendTo(this.container?this.container:f("body"));if(this.input!==false){this.input.on({"keyup.colorpicker":f.proxy(this.keyup,this)});this.input.on({"input.colorpicker":f.proxy(this.change,this)});if(this.component===false){this.element.on({"focus.colorpicker":f.proxy(this.show,this)})}if(this.options.inline===false){this.element.on({"focusout.colorpicker":f.proxy(this.hide,this)})}}if(this.component!==false){this.component.on({"click.colorpicker":f.proxy(this.show,this)})}if(this.input===false&&this.component===false){this.element.on({"click.colorpicker":f.proxy(this.show,this)})}if(this.input!==false&&this.component!==false&&this.input.attr("type")==="color"){this.input.on({"click.colorpicker":f.proxy(this.show,this),"focus.colorpicker":f.proxy(this.show,this)})}this.update();f(f.proxy(function(){this.element.trigger("create")},this))};n.Color=s;n.prototype={constructor:n,destroy:function(){this.picker.remove();this.element.removeData("colorpicker","color").off(".colorpicker");if(this.input!==false){this.input.off(".colorpicker")}if(this.component!==false){this.component.off(".colorpicker")}this.element.removeClass("colorpicker-element");this.element.trigger({type:"destroy"})},reposition:function(){if(this.options.inline!==false||this.options.container){return false}var e=this.container&&this.container[0]!==window.document.body?"position":"offset";var t=this.component||this.element;var i=t[e]();if(this.options.align==="right"){i.left-=this.picker.outerWidth()-t.outerWidth()}this.picker.css({top:i.top+t.outerHeight(),left:i.left})},show:function(e){if(this.isDisabled()){return}this.picker.addClass("colorpicker-visible").removeClass("colorpicker-hidden");this.reposition();f(window).on("resize.colorpicker",f.proxy(this.reposition,this));if(e&&(!this.hasInput()||this.input.attr("type")==="color")){if(e.stopPropagation&&e.preventDefault){e.stopPropagation();e.preventDefault()}}if((this.component||!this.input)&&this.options.inline===false){f(window.document).on({"mousedown.colorpicker":f.proxy(this.hide,this)})}this.element.trigger({type:"showPicker",color:this.color})},hide:function(e){if(typeof e!=="undefined"&&e.target){if(f(e.currentTarget).parents(".colorpicker").length>0||f(e.target).parents(".colorpicker").length>0){return false}}this.picker.addClass("colorpicker-hidden").removeClass("colorpicker-visible");f(window).off("resize.colorpicker",this.reposition);f(window.document).off({"mousedown.colorpicker":this.hide});this.update();this.element.trigger({type:"hidePicker",color:this.color})},updateData:function(e){e=e||this.color.toString(false,this.format);this.element.data("color",e);return e},updateInput:function(e){e=e||this.color.toString(false,this.format);if(this.input!==false){this.input.prop("value",e);this.input.trigger("change")}return e},updatePicker:function(e){if(typeof e!=="undefined"){this.color=this.createColor(e)}var t=this.options.horizontal===false?this.options.sliders:this.options.slidersHorz;var i=this.picker.find("i");if(i.length===0){return}if(this.options.horizontal===false){t=this.options.sliders;i.eq(1).css("top",t.hue.maxTop*(1-this.color.value.h)).end().eq(2).css("top",t.alpha.maxTop*(1-this.color.value.a))}else{t=this.options.slidersHorz;i.eq(1).css("left",t.hue.maxLeft*(1-this.color.value.h)).end().eq(2).css("left",t.alpha.maxLeft*(1-this.color.value.a))}i.eq(0).css({top:t.saturation.maxTop-this.color.value.b*t.saturation.maxTop,left:this.color.value.s*t.saturation.maxLeft});this.picker.find(".colorpicker-saturation").css("backgroundColor",this.color.toHex(true,this.color.value.h,1,1,1));this.picker.find(".colorpicker-alpha").css("backgroundColor",this.color.toHex(true));this.picker.find(".colorpicker-color, .colorpicker-color div").css("backgroundColor",this.color.toString(true,this.format));return e},updateComponent:function(e){var t;if(typeof e!=="undefined"){t=this.createColor(e)}else{t=this.color}if(this.component!==false){var i=this.component.find("i").eq(0);if(i.length>0){i.css({backgroundColor:t.toString(true,this.format)})}else{this.component.css({backgroundColor:t.toString(true,this.format)})}}return t.toString(false,this.format)},update:function(e){var t;if(this.getValue(false)!==false||e===true){t=this.updateComponent();this.updateInput(t);this.updateData(t);this.updatePicker()}return t},setValue:function(e){this.color=this.createColor(e);this.update(true);this.element.trigger({type:"changeColor",color:this.color,value:e})},createColor:function(e){return new s(e?e:null,this.options.colorSelectors,this.options.fallbackColor?this.options.fallbackColor:this.color,this.options.fallbackFormat,this.options.hexNumberSignPrefix)},getValue:function(e){e=typeof e==="undefined"?this.options.fallbackColor:e;var t;if(this.hasInput()){t=this.input.val()}else{t=this.element.data("color")}if(t===undefined||t===""||t===null){t=e}return t},hasInput:function(){return this.input!==false},isDisabled:function(){return this.disabled},disable:function(){if(this.hasInput()){this.input.prop("disabled",true)}this.disabled=true;this.element.trigger({type:"disable",color:this.color,value:this.getValue()});return true},enable:function(){if(this.hasInput()){this.input.prop("disabled",false)}this.disabled=false;this.element.trigger({type:"enable",color:this.color,value:this.getValue()});return true},currentSlider:null,mousePointer:{left:0,top:0},mousedown:function(e){if(!e.pageX&&!e.pageY&&e.originalEvent&&e.originalEvent.touches){e.pageX=e.originalEvent.touches[0].pageX;e.pageY=e.originalEvent.touches[0].pageY}e.stopPropagation();e.preventDefault();var t=f(e.target);var i=t.closest("div");var o=this.options.horizontal?this.options.slidersHorz:this.options.sliders;if(!i.is(".colorpicker")){if(i.is(".colorpicker-saturation")){this.currentSlider=f.extend({},o.saturation)}else if(i.is(".colorpicker-hue")){this.currentSlider=f.extend({},o.hue)}else if(i.is(".colorpicker-alpha")){this.currentSlider=f.extend({},o.alpha)}else{return false}var r=i.offset();this.currentSlider.guide=i.find("i")[0].style;this.currentSlider.left=e.pageX-r.left;this.currentSlider.top=e.pageY-r.top;this.mousePointer={left:e.pageX,top:e.pageY};f(window.document).on({"mousemove.colorpicker":f.proxy(this.mousemove,this),"touchmove.colorpicker":f.proxy(this.mousemove,this),"mouseup.colorpicker":f.proxy(this.mouseup,this),"touchend.colorpicker":f.proxy(this.mouseup,this)}).trigger("mousemove")}return false},mousemove:function(e){if(!e.pageX&&!e.pageY&&e.originalEvent&&e.originalEvent.touches){e.pageX=e.originalEvent.touches[0].pageX;e.pageY=e.originalEvent.touches[0].pageY}e.stopPropagation();e.preventDefault();var t=Math.max(0,Math.min(this.currentSlider.maxLeft,this.currentSlider.left+((e.pageX||this.mousePointer.left)-this.mousePointer.left)));var i=Math.max(0,Math.min(this.currentSlider.maxTop,this.currentSlider.top+((e.pageY||this.mousePointer.top)-this.mousePointer.top)));this.currentSlider.guide.left=t+"px";this.currentSlider.guide.top=i+"px";if(this.currentSlider.callLeft){this.color[this.currentSlider.callLeft].call(this.color,t/this.currentSlider.maxLeft)}if(this.currentSlider.callTop){this.color[this.currentSlider.callTop].call(this.color,i/this.currentSlider.maxTop)}if(this.options.format===false&&(this.currentSlider.callTop==="setAlpha"||this.currentSlider.callLeft==="setAlpha")){if(this.color.value.a!==1){this.format="rgba";this.color.origFormat="rgba"}else{this.format="hex";this.color.origFormat="hex"}}this.update(true);this.element.trigger({type:"changeColor",color:this.color});return false},mouseup:function(e){e.stopPropagation();e.preventDefault();f(window.document).off({"mousemove.colorpicker":this.mousemove,"touchmove.colorpicker":this.mousemove,"mouseup.colorpicker":this.mouseup,"touchend.colorpicker":this.mouseup});return false},change:function(e){this.color=this.createColor(this.input.val());if(this.color.origFormat&&this.options.format===false){this.format=this.color.origFormat}if(this.getValue(false)!==false){this.updateData();this.updateComponent();this.updatePicker()}this.element.trigger({type:"changeColor",color:this.color,value:this.input.val()})},keyup:function(e){if(e.keyCode===38){if(this.color.value.a<1){this.color.value.a=Math.round((this.color.value.a+.01)*100)/100}this.update(true)}else if(e.keyCode===40){if(this.color.value.a>0){this.color.value.a=Math.round((this.color.value.a-.01)*100)/100}this.update(true)}this.element.trigger({type:"changeColor",color:this.color,value:this.input.val()})}};f.colorpicker=n;f.fn.colorpicker=function(o){var r=Array.prototype.slice.call(arguments,1),e=this.length===1,s=null;var t=this.each(function(){var e=f(this),t=e.data("colorpicker"),i=typeof o==="object"?o:{};if(!t){t=new n(this,i);e.data("colorpicker",t)}if(typeof o==="string"){if(f.isFunction(t[o])){s=t[o].apply(t,r)}else{if(r.length){t[o]=r[0]}s=t[o]}}else{s=e}});return e?s:t};f.fn.colorpicker.constructor=n});