<?php

// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
    exit;
}
/**
 * Customize Slider control class.
 *
 * @package pawfect
 *
 * @see     WP_Customize_Control
 * @access  public
 */

if (!class_exists('pawfect_Customize_Slider_Control')) {
    /**
     * Class pawfect_Customize_Slider_Control
     */
    class pawfect_Customize_Slider_Control extends pawfect_Customize_Base_Control {
        
        /**
         * Customize control type.
         *
         * @access public
         * @var    string
         */
        public $type = 'pawfect-slider';

        /**
         * Renders the Underscore template for this control.
         *
         * @see    WP_Customize_Control::print_template()
         * @access protected
         * @return void
         */
        protected function content_template() {
            ?>
            <label>
                <# if ( data.label ) { #>
                    <span class="customize-control-title">{{{ data.label }}}</span>
                <# } #>
                <# if ( data.description ) { #>
                    <span class="description customize-control-description">{{{ data.description }}}</span>
                <# } #>
                <div class="customize-control-content">
                    <div class="pawfect-slider"
                         data-min="{{ data.inputAttrs.min || 0 }}"
                         data-max="{{ data.inputAttrs.max || 100 }}"
                         data-step="{{ data.inputAttrs.step || 1 }}"></div>
                    <div class="pawfect-slider-input">
                        <input type="number"
                               class="slider-input"
                               value="{{ data.value.slider || data.default.slider }}"
                               min="{{ data.inputAttrs.min || 0 }}"
                               max="{{ data.inputAttrs.max || 100 }}"
                               step="{{ data.inputAttrs.step || 1 }}"
                               {{{ data.link }}} />
                        <span class="slider-reset dashicons dashicons-image-rotate" title="<?php esc_attr_e( 'Reset', 'pawfect' ); ?>"></span>
                    </div>
                </div>
            </label>
            <?php
        }

        /**
         * Render content is still called, so be sure to override it with an empty function in your subclass as well.
         */
        protected function render_content() {
            // Empty - using content_template instead
        }
    }
}
