<?php

// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
    exit;
}
/**
	pawfect Range
 */
  if ( ! class_exists( 'WP_Customize_Control' ) ) {
	return;
}
	class pawfect_Customize_Range_Control extends WP_Customize_Control {

		public $type = 'pawfect-range-slider';

		public function to_json() {
			if ( ! empty( $this->setting->default ) ) {
				$this->json['default'] = $this->setting->default;
			} else {
				$this->json['default'] = false;
			}
			parent::to_json();
		}

		public function enqueue() {
			wp_enqueue_script( 'pawfect-range-slider', PAWFECT_THEME_URL . '/inc/customizer/assets/js/range-control.js', array( 'jquery' ), time(), true );
			wp_enqueue_style( 'pawfect-range-slider', PAWFECT_THEME_URL . '/inc/customizer/assets/css/range-control.css', array(), time() );
		}

		public function render_content() {
		?>
			<label>
				<?php if ( ! empty( $this->label ) ) : ?>
					<span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
				<?php endif;
				if ( ! empty( $this->description ) ) : ?>
					<span class="description customize-control-description"><?php echo esc_html( $this->description ); ?></span>
				<?php endif; ?>
				<div id="<?php echo esc_attr( $this->id ); ?>">
					<div class="pawfect-range-slider">
						<input class="pawfect-range-slider-range" type="range" data-default="<?php echo esc_attr( $this->setting->default ); ?>" value="<?php echo esc_attr( $this->value() ); ?>" <?php $this->input_attrs(); $this->link(); ?> />
						<input class="pawfect-range-slider-value" type="number" data-default="<?php echo esc_attr( $this->setting->default ); ?>" value="<?php echo esc_attr( $this->value() ); ?>" <?php $this->input_attrs(); $this->link(); ?> />
						<?php if ( ! empty( $this->setting->default ) ) : ?>
							<span class="pawfect-range-reset-slider" title="<?php esc_attr_e( 'Reset', 'pawfect' ); ?>"><span class="dashicons dashicons-image-rotate"></span></span>
						<?php endif;?>
					</div>
				</div>
			</label>
		<?php }

	}
