/*! wp-color-picker-alpha - v1.1 * https://github.com/23r9i0/wp-color-picker-alpha * Copyright (c) 2015 Sergio P.A. (23r9i0); Licensed GPLv2 */ !function(t){var i="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAAHnlligAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAHJJREFUeNpi+P///4EDBxiAGMgCCCAGFB5AADGCRBgYDh48CCRZIJS9vT2QBAggFBkmBiSAogxFBiCAoHogAKIKAlBUYTELAiAmEtABEECk20G6BOmuIl0CIMBQ/IEMkO0myiSSraaaBhZcbkUOs0HuBwDplz5uFJ3Z4gAAAABJRU5ErkJggg==",o='',r='
',e='',a='';Color.fn.toString=function(){if(this._alpha<1)return this.toCSS("rgba",this._alpha).replace(/\s+/g,"");var t=parseInt(this._color,10).toString(16);if(this.error)return"";if(t.length<6)for(var i=6-t.length-1;i>=0;i--)t="0"+t;return"#"+t},t.widget("wp.wpColorPicker",t.wp.wpColorPicker,{_create:function(){if(t.support.iris){var n=this,s=n.element;t.extend(n.options,s.data()),n.close=t.proxy(n.close,n),n.initialValue=s.val(),s.addClass("wp-color-picker").hide().wrap(e),n.wrap=s.parent(),n.toggler=t(o).insertBefore(s).css({backgroundColor:n.initialValue}).attr("title",wpColorPickerL10n.pick).attr("data-current",wpColorPickerL10n.current),n.pickerContainer=t(r).insertAfter(s),n.button=t(a),n.options.defaultColor?n.button.addClass("wp-picker-default").val(wpColorPickerL10n.defaultString):n.button.addClass("wp-picker-clear").val(wpColorPickerL10n.clear),s.wrap('').after(n.button),s.iris({target:n.pickerContainer,hide:n.options.hide,width:n.options.width,mode:n.options.mode,palettes:n.options.palettes,change:function(o,r){n.options.alpha?(n.toggler.css({"background-image":"url("+i+")"}).html(""),n.toggler.find("span").css({width:"100%",height:"100%",position:"absolute",top:0,left:0,"border-top-left-radius":"3px","border-bottom-left-radius":"3px",background:r.color.toString()})):n.toggler.css({backgroundColor:r.color.toString()}),t.isFunction(n.options.change)&&n.options.change.call(this,o,r)}}),s.val(n.initialValue),n._addListeners(),n.options.hide||n.toggler.click()}},_addListeners:function(){var i=this;i.wrap.on("click.wpcolorpicker",function(t){t.stopPropagation()}),i.toggler.click(function(){i.toggler.hasClass("wp-picker-open")?i.close():i.open()}),i.element.change(function(o){var r=t(this),e=r.val();(""===e||i.element.hasClass("iris-error"))&&(i.options.alpha?(i.toggler.removeAttr("style"),i.toggler.find("span").css("backgroundColor","")):i.toggler.css("backgroundColor",""),t.isFunction(i.options.clear)&&i.options.clear.call(this,o))}),i.toggler.on("keyup",function(t){(13===t.keyCode||32===t.keyCode)&&(t.preventDefault(),i.toggler.trigger("click").next().focus())}),i.button.click(function(o){var r=t(this);r.hasClass("wp-picker-clear")?(i.element.val(""),i.options.alpha?(i.toggler.removeAttr("style"),i.toggler.find("span").css("backgroundColor","")):i.toggler.css("backgroundColor",""),t.isFunction(i.options.clear)&&i.options.clear.call(this,o)):r.hasClass("wp-picker-default")&&i.element.val(i.options.defaultColor).change()})}}),t.widget("a8c.iris",t.a8c.iris,{_create:function(){if(this._super(),this.options.alpha=this.element.data("alpha")||!1,this.element.is(":input")||(this.options.alpha=!1),"undefined"!=typeof this.options.alpha&&this.options.alpha){var i=this,o=i.element,r=' ',e=t(r).appendTo(i.picker.find(".iris-picker-inner")),a=e.find(".iris-slider-offset-alpha"),n={aContainer:e,aSlider:a};i.options.defaultWidth=o.width(),(i._color._alpha<1||1!=i._color.toString().indexOf("rgb"))&&o.width(parseInt(i.options.defaultWidth+100)),t.each(n,function(t,o){i.controls[t]=o}),i.controls.square.css({"margin-right":"0"});var s=i.picker.width()-i.controls.square.width()-20,l=s/6,c=s/2-l;t.each(["aContainer","strip"],function(t,o){i.controls[o].width(c).css({"margin-left":l+"px"})}),i._initControls(),i._change()}},_initControls:function(){if(this._super(),this.options.alpha){var t=this,i=t.controls;i.aSlider.slider({orientation:"vertical",min:0,max:100,step:1,value:parseInt(100*t._color._alpha),slide:function(i,o){t._color._alpha=parseFloat(o.value/100),t._change.apply(t,arguments)}})}},_change:function(){this._super();var t=this,o=t.element;if(this.options.alpha){var r=t.controls,e=parseInt(100*t._color._alpha),a=t._color.toRgb(),n=["rgb("+a.r+","+a.g+","+a.b+") 0%","rgba("+a.r+","+a.g+","+a.b+", 0) 100%"],s=t.options.defaultWidth,l=t.picker.closest(".wp-picker-container").find(".wp-color-result");if(r.aContainer.css({background:"linear-gradient(to bottom, "+n.join(", ")+"), url("+i+")"}),l.hasClass("wp-picker-open"))if(r.aSlider.slider("value",e),t._color._alpha<1){var c=r.strip.attr("style").replace(/rgba\(([0-9]+,)(\s+)?([0-9]+,)(\s+)?([0-9]+)(,(\s+)?[0-9\.]+)\)/g,"rgb($1$3$5)");r.strip.attr("style",c),o.width(parseInt(s+100))}else o.width(s)}var p=o.data("reset-alpha")||!1;p&&t.picker.find(".iris-palette-container").on("click.palette",".iris-palette",function(){t._color._alpha=1,t.active="external",t._change()})},_addInputListeners:function(t){var i=this,o=700,r=function(o){var r=new Color(t.val()),e=t.val();t.removeClass("iris-error"),r.error?""!==e&&t.addClass("iris-error"):r.toString()!==i._color.toString()&&("keyup"===o.type&&e.match(/^[0-9a-fA-F]{3}$/)||i._setOption("color",r.toString()))};t.on("change",r).on("keyup",i._debounce(r,o)),i.options.hide&&t.one("focus",function(){i.show()})}})}(jQuery),jQuery(document).ready(function(t){t(".color-picker").wpColorPicker()});