diff --git a/dist/wp-color-picker-alpha.min.js b/dist/wp-color-picker-alpha.min.js old mode 100755 new mode 100644 index db88dc7..4f6df11 --- a/dist/wp-color-picker-alpha.min.js +++ b/dist/wp-color-picker-alpha.min.js @@ -8,4 +8,4 @@ * https://github.com/kallookoo/wp-color-picker-alpha * Licensed under the GPLv2 license or later. */ -!function(t){if(!t.wp.wpColorPicker.prototype._hasAlpha){var o="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAAHnlligAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAHJJREFUeNpi+P///4EDBxiAGMgCCCAGFB5AADGCRBgYDh48CCRZIJS9vT2QBAggFBkmBiSAogxFBiCAoHogAKIKAlBUYTELAiAmEtABEECk20G6BOmuIl0CIMBQ/IEMkO0myiSSraaaBhZcbkUOs0HuBwDplz5uFJ3Z4gAAAABJRU5ErkJggg==",r='
',e='
',a='',i=void 0!==wpColorPickerL10n.current;if(i)var n='';else{n='';var l="",s=''}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)},t.widget("wp.wpColorPicker",t.wp.wpColorPicker,{_hasAlpha:!0,_create:function(){if(t.support.iris){var p=this,c=p.element;if(t.extend(p.options,c.data()),"hue"===p.options.type)return p._createHueOnly();p.close=t.proxy(p.close,p),p.initialValue=c.val(),c.addClass("wp-color-picker"),i?(c.hide().wrap(e),p.wrap=c.parent(),p.toggler=t(n).insertBefore(c).css({backgroundColor:p.initialValue}).attr("title",wpColorPickerL10n.pick).attr("data-current",wpColorPickerL10n.current),p.pickerContainer=t(r).insertAfter(c),p.button=t(a).addClass("hidden")):(c.parent("label").length||(c.wrap(l),p.wrappingLabelText=t(s).insertBefore(c).text(wpColorPickerL10n.defaultLabel)),p.wrappingLabel=c.parent(),p.wrappingLabel.wrap(e),p.wrap=p.wrappingLabel.parent(),p.toggler=t(n).insertBefore(p.wrappingLabel).css({backgroundColor:p.initialValue}),p.toggler.find(".wp-color-result-text").text(wpColorPickerL10n.pick),p.pickerContainer=t(r).insertAfter(p.wrappingLabel),p.button=t(a)),p.options.defaultColor?(p.button.addClass("wp-picker-default").val(wpColorPickerL10n.defaultString),i||p.button.attr("aria-label",wpColorPickerL10n.defaultAriaLabel)):(p.button.addClass("wp-picker-clear").val(wpColorPickerL10n.clear),i||p.button.attr("aria-label",wpColorPickerL10n.clearAriaLabel)),i?c.wrap('').after(p.button):(p.wrappingLabel.wrap('
',e='
',a='',i='',l=!1;if("undefined"!=typeof wpColorPickerL10n){(l=void 0!==wpColorPickerL10n.current)&&(i='');var n=wpColorPickerL10n.defaultLabel,s=wpColorPickerL10n.pick,p=wpColorPickerL10n.defaultString,c=wpColorPickerL10n.defaultAriaLabel,d=wpColorPickerL10n.clear,g=wpColorPickerL10n.clearAriaLabel}else{var h=wp.i18n.__;n=h("Color value"),s=h("Select Color"),p=h("Default"),c=h("Select default color"),d=h("Clear"),g=h("Clear color")}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)},t.widget("wp.wpColorPicker",t.wp.wpColorPicker,{_hasAlpha:!0,_create:function(){if(t.support.iris){var h=this,u=h.element;if(t.extend(h.options,u.data()),"hue"===h.options.type)return h._createHueOnly();h.close=t.proxy(h.close,h),h.initialValue=u.val(),u.addClass("wp-color-picker"),l?(u.hide().wrap(e),h.wrap=u.parent(),h.toggler=t(i).insertBefore(u).css({backgroundColor:h.initialValue}).attr("title",s).attr("data-current",wpColorPickerL10n.current),h.pickerContainer=t(r).insertAfter(u),h.button=t(a).addClass("hidden")):(u.parent("label").length||(u.wrap(""),h.wrappingLabelText=t('').insertBefore(u).text(n)),h.wrappingLabel=u.parent(),h.wrappingLabel.wrap(e),h.wrap=h.wrappingLabel.parent(),h.toggler=t(i).insertBefore(h.wrappingLabel).css({backgroundColor:h.initialValue}),h.toggler.find(".wp-color-result-text").text(s),h.pickerContainer=t(r).insertAfter(h.wrappingLabel),h.button=t(a)),h.options.defaultColor?(h.button.addClass("wp-picker-default").val(p),l||h.button.attr("aria-label",c)):(h.button.addClass("wp-picker-clear").val(d),l||h.button.attr("aria-label",g)),l?u.wrap('').after(h.button):(h.wrappingLabel.wrap('
', _wrap = '
', _button = '', - // Prevent CSS issues in < WordPress 4.9 - _deprecated = ( wpColorPickerL10n.current !== undefined ); - // Declare some global variables when is deprecated or not - if ( _deprecated ) { - var _before = ''; + _before = '', + _wrappingLabel = '', + _wrappingLabelText = '', + _deprecated = false; + // Check if wpColorPickerL10n is defined + if ( typeof wpColorPickerL10n !== "undefined" ) { + // wpColorPickerL10n is defined in <= WordPress 5.4 + // Prevent CSS issues in < WordPress 4.9. current can only be checked if we know wpColorPickerL10n is defined + _deprecated = ( typeof wpColorPickerL10n.current !== "undefined" ); + if ( _deprecated ) { + // Update _before if wpColorPickerL10n.current is defined (< WP 4.9) + _before = ''; + } + + var _colorValue = wpColorPickerL10n.defaultLabel, + _selectColor = wpColorPickerL10n.pick, + _defaultString = wpColorPickerL10n.defaultString, + _defaultAriaLabel = wpColorPickerL10n.defaultAriaLabel, + _clearString = wpColorPickerL10n.clear, + _clearAriaLabel = wpColorPickerL10n.clearAriaLabel; } else { - var _before = '', - _wrappingLabel = '', - _wrappingLabelText = ''; + // wpColorPickerL10n is not defined in WordPress 5.5+ + var __ = wp.i18n.__, + _colorValue = __( 'Color value' ), + _selectColor = __( 'Select Color' ), + _defaultString = __( 'Default' ), + _defaultAriaLabel = __( 'Select default color' ), + _clearString = __( 'Clear' ), + _clearAriaLabel = __( 'Clear color' ); } /** * Overwrite Color @@ -96,7 +116,7 @@ self.toggler = $( _before ) .insertBefore( el ) .css( { backgroundColor : self.initialValue } ) - .attr( 'title', wpColorPickerL10n.pick ) + .attr( 'title', _selectColor ) .attr( 'data-current', wpColorPickerL10n.current ); self.pickerContainer = $( _after ).insertAfter( el ); self.button = $( _button ).addClass('hidden'); @@ -111,7 +131,7 @@ // Insert the default label text. self.wrappingLabelText = $( _wrappingLabelText ) .insertBefore( el ) - .text( wpColorPickerL10n.defaultLabel ); + .text( _colorValue ); } /* @@ -129,7 +149,7 @@ .insertBefore( self.wrappingLabel ) .css( { backgroundColor: self.initialValue } ); // Set the toggle button span element text. - self.toggler.find( '.wp-color-result-text' ).text( wpColorPickerL10n.pick ); + self.toggler.find( '.wp-color-result-text' ).text( _selectColor ); // Set up the Iris container and insert it after the wrapping label. self.pickerContainer = $( _after ).insertAfter( self.wrappingLabel ); // Store a reference to the Clear/Default button. @@ -138,14 +158,14 @@ // Set up the Clear/Default button. if ( self.options.defaultColor ) { - self.button.addClass( 'wp-picker-default' ).val( wpColorPickerL10n.defaultString ); + self.button.addClass( 'wp-picker-default' ).val( _defaultString ); if ( ! _deprecated ) { - self.button.attr( 'aria-label', wpColorPickerL10n.defaultAriaLabel ); + self.button.attr( 'aria-label', _defaultAriaLabel ); } } else { - self.button.addClass( 'wp-picker-clear' ).val( wpColorPickerL10n.clear ); + self.button.addClass( 'wp-picker-clear' ).val( _clearString ); if ( ! _deprecated ) { - self.button.attr( 'aria-label', wpColorPickerL10n.clearAriaLabel ); + self.button.attr( 'aria-label', _clearAriaLabel ); } }