(function(e,t){var n='<a tabindex="0" class="wp-color-result" />',r='<div class="wp-picker-holder" />',i='<div class="wp-picker-container" />',s='<input type="button" class="button button-small hidden" />',o={options:{defaultColor:!1,change:!1,clear:!1,hide:!0,palettes:!0},_create:function(){if(e.browser.msie&&parseInt(e.browser.version,10)<8)return;var t=this,o=t.element;e.extend(t.options,o.data());t.initialValue=o.val();o.addClass("wp-color-picker").hide().wrap(i);t.wrap=o.parent();t.toggler=e(n).insertBefore(o).css({backgroundColor:t.initialValue}).attr("title",wpColorPickerL10n.pick).attr("data-current",wpColorPickerL10n.current);t.pickerContainer=e(r).insertAfter(o);t.button=e(s);t.options.defaultColor?t.button.addClass("wp-picker-default").val(wpColorPickerL10n.defaultString):t.button.addClass("wp-picker-clear").val(wpColorPickerL10n.clear);o.wrap('<span class="wp-picker-input-wrap" />').after(t.button);o.iris({target:t.pickerContainer,hide:!0,width:255,mode:"hsv",palettes:t.options.palettes,change:function(n,r){t.toggler.css({backgroundColor:r.color.toString()});e.isFunction(t.options.change)&&t.options.change.call(this,n,r)}});o.val(t.initialValue);t._addListeners();t.options.hide||t.toggler.click()},_addListeners:function(){var t=this;t.toggler.click(function(n){n.stopPropagation();t.element.toggle().iris("toggle");t.button.toggleClass("hidden");t.toggler.toggleClass("wp-picker-open");t.toggler.hasClass("wp-picker-open")?e("body").on("click",{wrap:t.wrap,toggler:t.toggler},t._bodyListener):e("body").off("click",t._bodyListener)});t.element.change(function(n){var r=e(this),i=r.val();if(i===""||i==="#"){t.toggler.css("backgroundColor","");e.isFunction(t.options.clear)&&t.options.clear.call(this,n)}});t.toggler.on("keyup",function(e){if(e.keyCode===13||e.keyCode===32){e.preventDefault();t.toggler.trigger("click").next().focus()}});t.button.click(function(n){var r=e(this);if(r.hasClass("wp-picker-clear")){t.element.val("");t.toggler.css("backgroundColor","");e.isFunction(t.options.clear)&&t.options.clear.call(this,n)}else r.hasClass("wp-picker-default")&&t.element.val(t.options.defaultColor).change()})},_bodyListener:function(e){e.data.wrap.find(e.target).length||e.data.toggler.click()},color:function(e){if(e===t)return this.element.iris("option","color");this.element.iris("option","color",e)},defaultColor:function(e){if(e===t)return this.options.defaultColor;this.options.defaultColor=e}};e.widget("wp.wpColorPicker",o)})(jQuery);