laipower/wp-content/plugins/gp-premium/library/alpha-color-picker/wp-color-picker-alpha.min.js

1 line
6.9 KiB
JavaScript
Raw Normal View History

!function(s){var p,o,r,a,i,n,t,l,c,d,g,h,u;s.wp.wpColorPicker.prototype._hasAlpha||(p="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAAHnlligAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAHJJREFUeNpi+P///4EDBxiAGMgCCCAGFB5AADGCRBgYDh48CCRZIJS9vT2QBAggFBkmBiSAogxFBiCAoHogAKIKAlBUYTELAiAmEtABEECk20G6BOmuIl0CIMBQ/IEMkO0myiSSraaaBhZcbkUOs0HuBwDplz5uFJ3Z4gAAAABJRU5ErkJggg==",o='<div class="wp-picker-holder" />',r='<div class="wp-picker-container" />',a='<input type="button" class="button button-small" />',i='<button type="button" class="button wp-color-result" aria-expanded="false"><span class="wp-color-result-text"></span></button>',n=!'<span class="screen-reader-text"></span>',void 0!==wp.i18n?(t=wp.i18n.__,l=t("Color value"),c=t("Select Color"),d=t("Default"),g=t("Select default color"),h=t("Clear"),u=t("Clear color")):"undefined"!=typeof wpColorPickerL10n&&((n=void 0!==wpColorPickerL10n.current)&&(i='<a tabindex="0" class="wp-color-result" />'),l=wpColorPickerL10n.defaultLabel,c=wpColorPickerL10n.pick,d=wpColorPickerL10n.defaultString,g=wpColorPickerL10n.defaultAriaLabel,h=wpColorPickerL10n.clear,u=wpColorPickerL10n.clearAriaLabel),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);return this.error?"":(t.length<6&&(t=("00000"+t).substr(-6)),"#"+t)},s.widget("wp.wpColorPicker",s.wp.wpColorPicker,{_hasAlpha:!0,_create:function(){if(s.support.iris){var e=this,t=e.element;if(s.extend(e.options,t.data()),"hue"===e.options.type)return e._createHueOnly();e.close=s.proxy(e.close,e),e.initialValue=t.val(),t.addClass("wp-color-picker"),n?(t.hide().wrap(r),e.wrap=t.parent(),e.toggler=s(i).insertBefore(t).css({backgroundColor:e.initialValue}).attr("title",c).attr("data-current",wpColorPickerL10n.current),e.pickerContainer=s(o).insertAfter(t),e.button=s(a).addClass("hidden")):(t.parent("label").length||(t.wrap("<label></label>"),e.wrappingLabelText=s('<span class="screen-reader-text"></span>').insertBefore(t).text(l)),e.wrappingLabel=t.parent(),e.wrappingLabel.wrap(r),e.wrap=e.wrappingLabel.parent(),e.toggler=s(i).insertBefore(e.wrappingLabel).css({backgroundColor:e.initialValue}),e.toggler.find(".wp-color-result-text").text(c),e.pickerContainer=s(o).insertAfter(e.wrappingLabel),e.button=s(a)),e.options.defaultColor?(e.button.addClass("wp-picker-default").val(d),n||e.button.attr("aria-label",g)):(e.button.addClass("wp-picker-clear").val(h),n||e.button.attr("aria-label",u)),n?t.wrap('<span class="wp-picker-input-wrap" />').after(e.button):(e.wrappingLabel.wrap('<span class="wp-picker-input-wrap hidden" />').after(e.button),e.inputWrapper=t.closest(".wp-picker-input-wrap")),t.iris({target:e.pickerContainer,hide:e.options.hide,width:e.options.width,mode:e.options.mode,palettes:e.options.palettes,change:function(t,o){e.options.alpha?(e.toggler.css({"background-image":"url("+p+")"}),n?e.toggler.html('<span class="color-alpha" />'):(e.toggler.css({position:"relative"}),0==e.toggler.find("span.color-alpha").length&&e.toggler.append('<span class="color-alpha" />')),e.toggler.find("span.color-alpha").css({width:"30px",height:"100%",position:"absolute",top:0,left:0,"border-top-left-radius":"2px","border-bottom-left-radius":"2px",background:o.color.toString()})):e.toggler.css({backgroundColor:o.color.toString()}),s.isFunction(e.options.change)&&e.options.change.call(this,t,o)}}),t.val(e.initialValue),e._addListeners(),e.options.hide||e.toggler.click()}},_addListeners:function(){var o=this;o.wrap.on("click.wpcolorpicker",function(t){t.stopPropagation()}),o.toggler.click(function(){o.toggler.hasClass("wp-picker-open")?o.close():o.open()}),o.element.on("change",function(t){""!==s(this).val()&&!o.element.hasClass("iris-error")||(o.options.alpha?(n&&o.toggler.removeAttr("style"),o.toggler.find("span.color-alpha").css("backgroundColor","")):o.toggler.css("backgroundColor",""),s.isFunction(o.options.clear)&&o.options.clear.call(this,t))}),o.button.on("click",function(t){s(this).hasClass("wp-picker-clear")?(o.element.val(""),o.options.alph