File Editor
Directories:
.. (Back)
Files:
class-sinatra-customizer-control-color.php
color.css
color.js
color.min.css
color.min.js
Create New File
Create
Edit File: color.min.js
!function($){function sinatra_get_alpha_value_from_color(value){var alphaVal;return(value=value.replace(/ /g,"")).match(/rgba\(\d+\,\d+\,\d+\,([^\)]+)\)/)?(alphaVal=100*parseFloat(value.match(/rgba\(\d+\,\d+\,\d+\,([^\)]+)\)/)[1]).toFixed(2),alphaVal=parseInt(alphaVal)):alphaVal=100,alphaVal}function sinatra_update_alpha_value_on_color_control(alpha,$control,$alphaSlider,update_slider){var iris,colorPicker,color;iris=$control.data("a8cIris"),colorPicker=$control.data("wpWpColorPicker"),iris._color._alpha=alpha,color=iris._color.toString(),$control.val(color),colorPicker.toggler.css({"background-color":color}),update_slider&&sinatraupdate_alpha_value_on_alpha_slider(alpha,$alphaSlider),$control.trigger("color-updated")}function sinatra_update_alpha_value_on_alpha_slider(alpha,$alphaSlider){$alphaSlider.slider("value",alpha),$alphaSlider.find(".ui-slider-handle").text(alpha.toString())}wp.customize.controlConstructor["sinatra-color"]=wp.customize.Control.extend({ready:function(){"use strict";var control=this,color=control.setting.get();control.container.on("color-updated",".sinatra-color-control",(function(){value=$(this).val(),value!==color&&(control.setting.set(value),color=value)}))}}),Color.prototype.toString=function(flag){if("no-alpha"==flag)return this.toCSS("rgba","1").replace(/\s+/g,"");if(1>this._alpha)return this.toCSS("rgba",this._alpha).replace(/\s+/g,"");var hex=parseInt(this._color,10).toString(16);if(this.error)return"";if(hex.length<6)for(var i=6-hex.length-1;i>=0;i--)hex="0"+hex;return"#"+hex},$(document).ready((function($){$(".sinatra-color-control").each((function(){var $control,startingColor,showOpacity,defaultColor,colorPickerOptions,$container,$alphaSlider,sliderOptions;$control=$(this),startingColor=$control.val().replace(/\s+/g,""),showOpacity=$control.attr("data-show-opacity"),defaultColor=$control.attr("data-default-color"),colorPickerOptions={change:function(event,ui){var value,alpha;value=ui.color.toString(),$control.val(value),defaultColor==value&&(alpha=sinatra_get_alpha_value_from_color(value),$alphaSlider.find(".ui-slider-handle").text(alpha)),$container.find(".transparency").css("background-color",ui.color.toString("no-alpha")),$control.trigger("color-updated")},palettes:sinatra_customizer_localized.color_palette},$control.wpColorPicker(colorPickerOptions),$container=$control.parents(".wp-picker-container:first"),"true"==showOpacity&&$('<div class="alpha-color-picker-container"><div class="min-click-zone click-zone"></div><div class="max-click-zone click-zone"></div><div class="alpha-slider"></div><div class="transparency"></div></div>').appendTo($container.find(".wp-picker-holder")),$alphaSlider=$container.find(".alpha-slider"),sliderOptions={create:function(event,ui){var value=$(this).slider("value");$(this).find(".ui-slider-handle").text(value),$(this).siblings(".transparency ").css("background-color",startingColor)},value:sinatra_get_alpha_value_from_color(startingColor),range:"max",step:1,min:0,max:100,animate:300},$alphaSlider.slider(sliderOptions),"true"==showOpacity&&$alphaSlider.find(".ui-slider-handle").addClass("show-opacity"),$container.find(".min-click-zone").on("click",(function(){sinatra_update_alpha_value_on_color_control(0,$control,$alphaSlider,!0)})),$container.find(".max-click-zone").on("click",(function(){sinatra_update_alpha_value_on_color_control(100,$control,$alphaSlider,!0)})),$container.find(".iris-palette").on("click",(function(e){var color,alpha;e.preventDefault(),sinatra_update_alpha_value_on_alpha_slider(alpha=sinatra_get_alpha_value_from_color(color=$(this).css("background-color")),$alphaSlider),100!=alpha&&(color=color.replace(/[^,]+(?=\))/,(alpha/100).toFixed(2))),$control.val(color),$control.wpColorPicker("color",color)})),$container.find(".button.wp-picker-clear").on("click",(function(e){e.preventDefault(),$control.val(""),sinatra_update_alpha_value_on_alpha_slider(100,$alphaSlider),$control.trigger("color-updated")})),$container.find(".button.wp-picker-default").on("click",(function(e){e.preventDefault(),sinatra_update_alpha_value_on_alpha_slider(sinatra_get_alpha_value_from_color(defaultColor),$alphaSlider)})),$control.on("input",(function(e){e.preventDefault(),sinatra_update_alpha_value_on_alpha_slider(sinatra_get_alpha_value_from_color($(this).val()),$alphaSlider),$control.trigger("color-updated")})),$alphaSlider.slider().on("slide",(function(event,ui){sinatra_update_alpha_value_on_color_control(parseFloat(ui.value)/100,$control,$alphaSlider,!1),$(this).find(".ui-slider-handle").text(ui.value)})),$(".iris-picker, .sinatra-color-control").on("click",(function(e){e.preventDefault()}))}))}))}(jQuery);
Save Changes
Rename File
Rename