'),c=a(e.parent()),l.showHexInput?c.prepend('
#').append(n()):c.append(n()),l.showHexInput||e.attr("type","hidden")},updatePreview:function(a){l.allowBlank?(o.typedColor=a.val().match(/^\s+$|^$/)?"":tinycolor(a.val()).toHex(),""===o.typedColor?a.siblings(".input-group-btn").find(".current-color").css("background","none"):a.siblings(".input-group-btn").find(".current-color").css("background-color","#"+o.typedColor)):(o.typedColor=tinycolor(a.val()).toHex(),a.siblings(".input-group-btn").find(".current-color").css("background-color","#"+o.typedColor))},pressPreviewButton:function(){var a=arguments[0].thisEvent;a.stopPropagation(),s.toggleDropdown(a.target)},openDropdown:function(b,d){a(".color-menu").each(function(){var b=a(this);if("block"===b.css("display")){var c=b.parents(".input-group-btn");s.closeDropdown(c,b)}}),l.fadeMenuToggle&&!c?a(d).fadeIn("fast"):a(d).show(),a(b).addClass("open")},closeDropdown:function(b,d){l.fadeMenuToggle&&!c?a(d).fadeOut("fast"):a(d).css("display","none"),a(b).removeClass("open")},closeDropdownIfOpen:function(){var a=arguments[0].button,b=arguments[0].menu;"block"===b.css("display")&&s.closeDropdown(a,b)},toggleDropdown:function(b){var c=a(b).parents(".pick-a-color-markup"),d=c.find("input"),e=c.find(".input-group-btn"),f=c.find(".color-menu");d.is(":disabled")||"none"!==f.css("display")?s.closeDropdown(e,f):s.openDropdown(e,f)},tabbable:function(){var b=a(this),c=b.parents(".pick-a-color-markup");b.click(function(){var b=a(this),d=b.attr("class").split(" ")[0].split("-")[0]+"-content",e=b.parents(".dropdown-menu").find("."+d);b.hasClass("tab-active")||(c.find(".tab-active").removeClass("tab-active"),c.find(".active-content").removeClass("active-content").addClass("inactive-content"),b.addClass("tab-active"),a(e).addClass("active-content").removeClass("inactive-content"))})},getColorMultiplier:function(b,d,e){var f="basic"===e?parseInt(a(".color-box").first().width(),10):parseInt(a(".advanced-list").find(".color-box").first().width(),10);0===f&&(f="basic"===e?c?160:200:c?160:300);var g=f/2,h=d/f;return"bidirectional"===b?.5>=h?(1-d/g)/2:-((d-g)/g)/2:"darkenRight"===b?-(h/2):h/2},modifyHSLLightness:function(a,b){var c=a;return c.l+=b,c.l=Math.min(Math.max(0,c.l),1),tinycolor(c).toHslString()},getMoveableArea:function(a){var b={},c=a.parent(),d=a.outerWidth(),e=c.width(),f=c.offset();return b.minX=f.left,b.maxX=e-d,b},moveHighlightBand:function(b,d,e){var f=a(".highlight-band").first().outerWidth(),g=.75*f,h=c?e.originalEvent.pageX:e.pageX,i=h-d.minX-g;i=Math.max(0,Math.min(i,d.maxX)),b.css("position","absolute"),b.css("left",i)},horizontallyDraggable:function(){a(this).on(f,function(b){b.preventDefault();var c=a(b.delegateTarget);c.css("cursor","-webkit-grabbing"),c.css("cursor","-moz-grabbing");var d=s.getMoveableArea(c);a(document).on(g,function(a){c.trigger(j),s.moveHighlightBand(c,d,a)}).on(h,function(){a(document).off(g),a(document).off(j),c.css("cursor","-webkit-grab"),c.css("cursor","-moz-grab"),c.trigger(k),a(document).off(h)})}).on(h,function(b){b.stopPropagation(),a(document).off(g),a(document).off(j)})},modifyHighlightBand:function(a,b,c){var d={h:0,s:0,l:.05},e={h:0,s:0,l:.5},f=-b,g=a.find(".highlight-band-stripe"),h="lightenRight"===c?s.modifyHSLLightness(e,f):s.modifyHSLLightness(d,f);a.css("border-color",h),g.css("background-color",h)},calculateHighlightedColor:function(){var b,c,d,e,f,g,h,i,j=a(this),k=j.parent(),m=a(".highlight-band").first().outerWidth(),n=m/2,o=arguments[0].type;if("basic"===o){var p=k.attr("class").split("-")[2],q=l.basicColors[p];switch(c=tinycolor(q).toHsl(),q){case"fff":b="darkenRight";break;case"000":b="lightenRight";break;default:b="bidirectional"}}else{var r=j.parents(".advanced-list");e=arguments[0].hsl.s,h=r.find(".spectrum-hue"),d=arguments[0].hsl.h,g=r.find(".spectrum-saturation"),i=r.find(".lightness-value"),f=r.find(".color-preview"),c={h:arguments[0].hsl.h,l:.5,s:arguments[0].hsl.s},b="bidirectional"}var t=parseInt(j.css("left"),10)+n,u=s.getColorMultiplier(b,t,o),v=s.modifyHSLLightness(c,u),w="#"+tinycolor(v).toHex(),x=v.split("(")[1].split(")")[0].split(",")[2],y=parseInt(x.split("%")[0],10)/100;return"basic"===o?(k.siblings(".color-preview").css("background-color",w),k.prev(".color-label").replaceWith('
'),"darkenRight"!==b&&s.modifyHighlightBand(j,u,b)):(f.css("background-color",w),i.text(x),s.updateSaturationStyles(g,d,y),s.updateHueStyles(h,e,y),s.modifyHighlightBand(a(".advanced-content .highlight-band"),u,b)),"basic"===o?tinycolor(v).toHex():y},updateSavedColorPreview:function(b){a.each(b,function(c){var d=a(b[c]),e=d.attr("class");d.find(".color-preview").css("background-color",e)})},updateSavedColorMarkup:function(b,c){if(c=c?c:q,l.showSavedColors&&c.length>0){l.saveColorsPerElement||(b=a(".savedColors-content"),c=q);var d=p.rowsInDropdown*p.maxColsInDropdown;c=c.slice(0,d);var e=a("
").addClass("saved-color-col 0"),f=a("").addClass("saved-color-col 1");a.each(c,function(b,c){var d=a("- ").addClass("color-item"),g=a("").addClass(c);g.append(a("").addClass("color-preview")),g.append(a("").addClass("color-label").text(c)),d.append(g),b%2===0?e.append(d):f.append(d)}),b.html(e),b.append(f);var g=a(b).find("a");s.updateSavedColorPreview(g)}},setSavedColorsCookie:function(a,b){var c=new Date,d=31536e7,e=new Date(c.getTime()+d);e=e.toGMTString(),document.cookie="undefined"==typeof b?"pickAColorSavedColors-allSavedColors="+a+";expires="+e:"pickAColorSavedColors-"+b+"="+a+"; expires="+e},saveColorsToLocalStorage:function(a,b){if(d)if("undefined"==typeof b)try{localStorage.allSavedColors=JSON.stringify(a)}catch(c){localStorage.clear()}else try{localStorage["pickAColorSavedColors-"+b]=JSON.stringify(a)}catch(c){localStorage.clear()}else s.setSavedColorsCookie(a,b)},removeFromArray:function(b,c){-1!==a.inArray(c,b)&&b.splice(a.inArray(c,b),1)},updateSavedColors:function(a,b,c){s.removeFromArray(b,a),b.unshift(a),s.saveColorsToLocalStorage(b,c)},addToSavedColors:function(a,b,c){if(l.showSavedColors&&void 0!==a)if("#"!=a[0]&&(a="#"+a),s.updateSavedColors(a,q),l.saveColorsPerElement){var d=b.colors,e=b.dataAttr;s.updateSavedColors(a,d,e),s.updateSavedColorMarkup(c,d)}else s.updateSavedColorMarkup(c,q)},selectFromBasicColors:function(){var b=a(this).find("span:first").css("background-color"),c=arguments[0].els,d=arguments[0].savedColorsInfo;b=tinycolor(b).toHex(),a(c.thisEl).val(b),a(c.thisEl).trigger("change"),s.updatePreview(c.thisEl),s.addToSavedColors(b,d,c.savedColorsContent),s.closeDropdown(c.colorPreviewButton,c.colorMenu)},tapSpectrum:function(){var b=arguments[0].thisEvent,d=arguments[0].savedColorsInfo,e=arguments[0].els,f=arguments[0].mostRecentClick;b.stopPropagation();var g=a(this).find(".highlight-band"),h=s.getMoveableArea(g);c?s.moveHighlightBand(g,h,f):s.moveHighlightBand(g,h,b);var i=s.calculateHighlightedColor.apply(g,[{type:"basic"}]);s.addToSavedColors(i,d,e.savedColorsContent),e.touchInstructions.html("Press 'select' to choose this color")},executeUnlessScrolled:function(){var b,d,e=arguments[0].thisFunction,g=arguments[0].theseArguments;a(this).on(f,function(c){b=a(window).scrollTop(),d=c}).on(i,function(f){var h=b-a(window).scrollTop();return c&&Math.abs(h)>0?!1:(g.thisEvent=f,g.mostRecentClick=d,e.apply(a(this),[g]),void 0)})},updateSaturationStyles:function(b,c,d){var f=(100*d).toString()+"%",g="#"+tinycolor("hsl("+c+",0%,"+f).toHex(),h="#"+tinycolor("hsl("+c+",50%,"+f).toHex(),i="#"+tinycolor("hsl("+c+",100%,"+f).toHex(),j="",k=(a.each(["-webkit-linear-gradient","-o-linear-gradient"],function(a,b){j+="background-image: "+b+"(left, "+g+" 0%, "+h+" 50%, "+i+" 100%);"}),"progid:DXImageTransform.Microsoft.gradient(startColorstr='"+g+"', endColorstr='"+h+"', GradientType=1)"),l="progid:DXImageTransform.Microsoft.gradient(startColorstr='"+h+"', endColorstr='"+i+"', GradientType=1)";if(j="background-image: -moz-linear-gradient(left center, "+g+" 0%, "+h+" 50%, "+i+" 100%);background-image: linear-gradient(to right, "+g+" 0%, "+h+" 50%, "+i+" 100%); background-image: -webkit-gradient(linear, left top, right top,color-stop(0, "+g+"),color-stop(0.5, "+h+"),color-stop(1, "+i+"));"+j,e){var m=a(b).find(".saturation-spectrum-0"),n=a(b).find(".saturation-spectrum-1");m.css("filter",k),n.css("filter",l)}else b.attr("style",j)},updateLightnessStyles:function(b,c,d){var f=(100*d).toString()+"%",g="#"+tinycolor("hsl("+c+","+f+",100%)").toHex(),h="#"+tinycolor("hsl("+c+","+f+",50%)").toHex(),i="#"+tinycolor("hsl("+c+","+f+",0%)").toHex(),j="",k=(a.each(["-webkit-linear-gradient","-o-linear-gradient"],function(a,b){j+="background-image: "+b+"(left, "+g+" 0%, "+h+" 50%, "+i+" 100%);"}),"progid:DXImageTransform.Microsoft.gradient(startColorstr='"+g+"', endColorstr='"+h+"', GradientType=1)"),l="progid:DXImageTransform.Microsoft.gradient(startColorstr='"+h+"', endColorstr='"+i+"', GradientType=1)";if(j="background-image: -moz-linear-gradient(left center, "+g+" 0%, "+h+" 50%, "+i+" 100%); background-image: linear-gradient(to right, "+g+" 0%, "+h+" 50%, "+i+" 100%); background-image: -webkit-gradient(linear, left top, right top, color-stop(0, "+g+"), color-stop(0.5, "+h+"), color-stop(1, "+i+")); "+j,e){var m=a(b).find(".lightness-spectrum-0"),n=a(b).find(".lightness-spectrum-1");m.css("filter",k),n.css("filter",l)}else b.attr("style",j)},updateHueStyles:function(b,c,d){{var f=(100*c).toString()+"%",g=(100*d).toString()+"%",h="#"+tinycolor("hsl(0,"+f+","+g+")").toHex(),i="#"+tinycolor("hsl(60,"+f+","+g+")").toHex(),j="#"+tinycolor("hsl(120,"+f+","+g+")").toHex(),k="#"+tinycolor("hsl(180,"+f+","+g+")").toHex(),l="#"+tinycolor("hsl(240,"+f+","+g+")").toHex(),m="#"+tinycolor("hsl(300,"+f+","+g+")").toHex(),n="#"+tinycolor("hsl(0,"+f+","+g+")").toHex(),o="progid:DXImageTransform.Microsoft.gradient(startColorstr='"+h+"', endColorstr='"+i+"', GradientType=1)",p="progid:DXImageTransform.Microsoft.gradient(startColorstr='"+i+"', endColorstr='"+j+"', GradientType=1)",q="progid:DXImageTransform.Microsoft.gradient(startColorstr='"+j+"', endColorstr='"+k+"', GradientType=1)",r="progid:DXImageTransform.Microsoft.gradient(startColorstr='"+k+"', endColorstr='"+l+"', GradientType=1)",s="progid:DXImageTransform.Microsoft.gradient(startColorstr='"+l+"', endColorstr='"+m+"', GradientType=1)",t="progid:DXImageTransform.Microsoft.gradient(startColorstr='"+m+"', endColorstr='"+n+"', GradientType=1)",u="";a.each(["-webkit-linear-gradient","-o-linear-gradient"],function(a,b){u+="background-image: "+b+"(left, "+h+" 0%, "+i+" 17%, "+j+" 24%, "+k+" 51%, "+l+" 68%, "+m+" 85%, "+n+" 100%);"})}if(u+="background-image: -webkit-gradient(linear, left top, right top,color-stop(0%, "+h+"),color-stop(17%, "+i+"),color-stop(34%, "+j+"),color-stop(51%, "+k+"),color-stop(68%, "+l+"),color-stop(85%, "+m+"),color-stop(100%, "+n+"));background-image: linear-gradient(to right, "+h+" 0%, "+i+" 17%, "+j+" 24%,"+k+" 51%,"+l+" 68%,"+m+" 85%,"+n+" 100%); background-image: -moz-linear-gradient(left center, "+h+" 0%, "+i+" 17%, "+j+" 24%, "+k+" 51%, "+l+" 68%, "+m+" 85%, "+n+" 100%);",e){var v=a(b).find(".hue-spectrum-0"),w=a(b).find(".hue-spectrum-1"),x=a(b).find(".hue-spectrum-2"),y=a(b).find(".hue-spectrum-3"),z=a(b).find(".hue-spectrum-4"),A=a(b).find(".hue-spectrum-5");v.css("filter",o),w.css("filter",p),x.css("filter",q),y.css("filter",r),z.css("filter",s),A.css("filter",t)}else b.attr("style",u)},getHighlightedHue:function(){var b=a(this),d=b.outerWidth(),e=d/2,f=parseInt(b.css("left"),10)+e,g=b.parents(".advanced-list"),h=g.find(".color-preview"),i=g.find(".spectrum-lightness"),j=g.find(".spectrum-saturation"),k=parseInt(g.find(".color-box").first().width(),10),l=g.find(".hue-value"),m=arguments[0].l,n=arguments[0].s,o=(100*n).toString()+"%",p=(100*m).toString()+"%";0===k&&(k=c?160:300);var q=Math.floor(f/k*360),r="hsl("+q+","+o+","+p+")";return r="#"+tinycolor(r).toHex(),h.css("background-color",r),l.text(q),s.updateLightnessStyles(i,q,n),s.updateSaturationStyles(j,q,m),q},getHighlightedSaturation:function(){var b=a(this),d=b.outerWidth(),e=d/2,f=parseInt(b.css("left"),10)+e,g=b.parents(".advanced-list"),h=g.find(".color-preview"),i=g.find(".spectrum-lightness"),j=g.find(".spectrum-hue"),k=g.find(".saturation-value"),l=parseInt(g.find(".color-box").first().width(),10),m=arguments[0].l,n=(100*m).toString()+"%",o=arguments[0].h;0===l&&(l=c?160:300);var p=f/l,q=Math.round(100*p).toString()+"%",r="hsl("+o+","+q+","+n+")";return r="#"+tinycolor(r).toHex(),h.css("background-color",r),k.text(q),s.updateLightnessStyles(i,o,p),s.updateHueStyles(j,p,m),p},updateAdvancedInstructions:function(a){a.html("Press the color preview to choose this color")}};return this.each(function(b){s.initialize.apply(this,[b]);var c,e,f={thisEl:a(this),thisWrapper:a(this).parent(),colorTextInput:a(this).find("input"),colorMenuLinks:a(this).parent().find(".color-menu li a"),colorPreviewButton:a(this).parent().find(".input-group-btn"),colorMenu:a(this).parent().find(".color-menu"),colorSpectrums:a(this).parent().find(".color-box"),basicSpectrums:a(this).parent().find(".basicColors-content .color-box"),touchInstructions:a(this).parent().find(".color-menu-instructions"),advancedInstructions:a(this).parent().find(".advanced-instructions"),highlightBands:a(this).parent().find(".highlight-band"),basicHighlightBands:a(this).parent().find(".basicColors-content .highlight-band")};if(m&&(f.tabs=f.thisWrapper.find(".tab")),l.showSavedColors&&(f.savedColorsContent=f.thisWrapper.find(".savedColors-content"),l.saveColorsPerElement))if(e={colors:[],dataObj:a(this).data()},a.each(e.dataObj,function(a){e.dataAttr=a}),d&&localStorage["pickAColorSavedColors-"+e.dataAttr])e.colors=JSON.parse(localStorage["pickAColorSavedColors-"+e.dataAttr]);else if(document.cookie.match("pickAColorSavedColors-"+e.dataAttr))for(var g=document.cookie.split(";"),n=0;n