min = (isset($args['min']) && $args['min']) ? absint($args['min']) : 0; $this->max = (isset($args['max']) && $args['max']) ? absint($args['max']) : 0; } /** * Refresh the parameters passed to the JavaScript via JSON. * * @since 3.4.0 * @uses WP_Customize_Control::to_json() */ public function to_json() { parent::to_json(); $this->json['inputId'] = '_customize-' . $this->type . '-' . $this->id; $this->json['min'] = $this->min; $this->json['max'] = $this->max; $this->json['value'] = $this->value(); $this->json['link'] = $this->get_link(); } /** * Enqueue control related scripts/styles. * * Enqueue jQuery ui slider * * @access public */ public function enqueue() { wp_enqueue_script('jquery-ui-slider'); wp_register_style('bizflow-theme-customizer-slider-css', BIZFLOW_URL . '/assets/js/jquery-ui/jquery-ui.min.css'); wp_enqueue_style('bizflow-theme-customizer-slider-css'); } /** * Render a JS template for the content of the color picker control. * * @since 4.1.0 */ public function content_template() { ?> <# var sliderId = data.inputId + '_slider'; #> <# if(data.label){ #> {{{ data.label }}} <# } #> <# if(data.description){ #> {{{ data.description }}} <# } #>
<# (function($){ $(document).ready(function(){ $('#' + sliderId + ' .slider').slider({ max : data.max, min : data.min, value : data.value, change : function(e, ui){ $('#' + sliderId + '-values .range-value span').text(ui.value); $($('#' + sliderId).data('input')).val(ui.value); $($('#' + sliderId).data('input')).trigger('change'); } }); $('#' + sliderId + '-values .slider-minus').on( 'click', function(e){ e.preventDefault(); var val = $('#' + sliderId + ' .slider').slider( 'value' ); val--; if( $(this).data('min') !== undefined ){ var min = parseInt( $(this).data('min') ); if( val < min ){ val = min; } } $('#' + sliderId + ' .slider').slider( 'value', val ); }); $('#' + sliderId + '-values .slider-plus').on( 'click', function(e){ e.preventDefault(); var val = $('#' + sliderId + ' .slider').slider( 'value' ); val++; if( $(this).data('max') !== undefined ){ var max = parseInt( $(this).data('max') ); if( val > max ){ val = max; } } $('#' + sliderId + ' .slider').slider( 'value', val ); }); }) })(jQuery); #>