Initial commit: Atomaste website
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
/**
|
||||
* Customizer Control: slider.
|
||||
*/
|
||||
|
||||
// Exit if accessed directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'Rara_Business_Slider_Control' ) ) {
|
||||
|
||||
/**
|
||||
* Slider control (range).
|
||||
*/
|
||||
class Rara_Business_Slider_Control extends WP_Customize_Control {
|
||||
|
||||
public $type = 'slider';
|
||||
|
||||
public $tooltip = '';
|
||||
|
||||
public function to_json() {
|
||||
parent::to_json();
|
||||
|
||||
if ( isset( $this->default ) ) {
|
||||
$this->json['default'] = $this->default;
|
||||
} else {
|
||||
$this->json['default'] = $this->setting->default;
|
||||
}
|
||||
|
||||
$this->json['value'] = $this->value();
|
||||
$this->json['choices'] = $this->choices;
|
||||
$this->json['link'] = $this->get_link();
|
||||
$this->json['tooltip'] = $this->tooltip;
|
||||
|
||||
$this->json['inputAttrs'] = '';
|
||||
foreach ( $this->input_attrs as $attr => $value ) {
|
||||
$this->json['inputAttrs'] .= $attr . '="' . esc_attr( $value ) . '" ';
|
||||
}
|
||||
|
||||
$this->json['choices']['min'] = ( isset( $this->choices['min'] ) ) ? $this->choices['min'] : '0';
|
||||
$this->json['choices']['max'] = ( isset( $this->choices['max'] ) ) ? $this->choices['max'] : '100';
|
||||
$this->json['choices']['step'] = ( isset( $this->choices['step'] ) ) ? $this->choices['step'] : '1';
|
||||
}
|
||||
|
||||
public function enqueue() {
|
||||
wp_enqueue_style( 'rara-business-slider', get_template_directory_uri() . '/inc/custom-controls/slider/slider.css', null );
|
||||
wp_enqueue_script( 'rara-business-slider', get_template_directory_uri() . '/inc/custom-controls/slider/slider.js', array( 'jquery' ), false, true ); //for slider
|
||||
}
|
||||
|
||||
protected function content_template() {
|
||||
?>
|
||||
<# if ( data.tooltip ) { #>
|
||||
<a href="#" class="tooltip hint--left" data-hint="{{ data.tooltip }}"><span class='dashicons dashicons-info'></span></a>
|
||||
<# } #>
|
||||
<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="wrapper">
|
||||
<input {{{ data.inputAttrs }}} type="range" min="{{ data.choices['min'] }}" max="{{ data.choices['max'] }}" step="{{ data.choices['step'] }}" value="{{ data.value }}" {{{ data.link }}} data-reset_value="{{ data.default }}" />
|
||||
<div class="range_value">
|
||||
<span class="value">{{ data.value }}</span>
|
||||
<# if ( data.choices['suffix'] ) { #>
|
||||
{{ data.choices['suffix'] }}
|
||||
<# } #>
|
||||
</div>
|
||||
<div class="slider-reset">
|
||||
<span class="dashicons dashicons-image-rotate"></span>
|
||||
</div>
|
||||
</div>
|
||||
</label>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
.customize-control-slider input[type=range] {
|
||||
-webkit-appearance: none;
|
||||
-webkit-transition: background .3s;
|
||||
-moz-transition: background .3s;
|
||||
transition: background .3s;
|
||||
background-color: rgba(0, 0, 0, 0.1);
|
||||
height: 5px;
|
||||
width: calc(100% - 70px);
|
||||
padding: 0;
|
||||
}
|
||||
.customize-control-slider input[type=range]:focus {
|
||||
box-shadow: none;
|
||||
outline: none;
|
||||
}
|
||||
.customize-control-slider input[type=range]:hover {
|
||||
background-color: rgba(0, 0, 0, 0.25);
|
||||
}
|
||||
.customize-control-slider input[type=range]::-webkit-slider-thumb {
|
||||
-webkit-appearance: none;
|
||||
width: 15px;
|
||||
height: 15px;
|
||||
border-radius: 50%;
|
||||
-webkit-border-radius: 50%;
|
||||
background-color: #3498D9;
|
||||
}
|
||||
.customize-control-slider input[type=range]::-webkit-slider-thumb {
|
||||
-webkit-appearance: none;
|
||||
width: 15px;
|
||||
height: 15px;
|
||||
border: none;
|
||||
border-radius: 50%;
|
||||
background-color: #3498D9;
|
||||
}
|
||||
.customize-control-slider input[type=range]::-moz-range-thumb {
|
||||
width: 15px;
|
||||
height: 15px;
|
||||
border: none;
|
||||
border-radius: 50%;
|
||||
background-color: #3498D9;
|
||||
}
|
||||
.customize-control-slider input[type=range]::-ms-thumb {
|
||||
width: 15px;
|
||||
height: 15px;
|
||||
border-radius: 50%;
|
||||
border: 0;
|
||||
background-color: #3498D9;
|
||||
}
|
||||
.customize-control-slider input[type=range]::-moz-range-track {
|
||||
border: inherit;
|
||||
background: transparent;
|
||||
}
|
||||
.customize-control-slider input[type=range]::-ms-track {
|
||||
border: inherit;
|
||||
color: transparent;
|
||||
background: transparent;
|
||||
}
|
||||
.customize-control-slider input[type=range]::-ms-fill-lower, .customize-control-slider input[type=range]::-ms-fill-upper {
|
||||
background: transparent;
|
||||
}
|
||||
.customize-control-slider input[type=range]::-ms-tooltip {
|
||||
display: none;
|
||||
}
|
||||
.customize-control-slider .range_value {
|
||||
display: inline-block;
|
||||
font-size: 14px;
|
||||
padding: 0 5px;
|
||||
font-weight: 400;
|
||||
position: relative;
|
||||
top: 2px;
|
||||
}
|
||||
.customize-control-slider .range_value {
|
||||
display: inline-block;
|
||||
font-size: 14px;
|
||||
padding: 0 5px;
|
||||
font-weight: 400;
|
||||
position: relative;
|
||||
top: 2px;
|
||||
}
|
||||
.customize-control-slider .slider-reset {
|
||||
color: rgba(0, 0, 0, 0.2);
|
||||
float: right;
|
||||
-webkit-transition: color .5s ease-in;
|
||||
-moz-transition: color .5s ease-in;
|
||||
-ms-transition: color .5s ease-in;
|
||||
-o-transition: color .5s ease-in;
|
||||
transition: color .5s ease-in;
|
||||
}
|
||||
.customize-control-slider .slider-reset span {
|
||||
font-size: 16px;
|
||||
line-height: 22px;
|
||||
}
|
||||
.customize-control-slider .slider-reset:hover {
|
||||
color: red;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
wp.customize.controlConstructor['slider'] = wp.customize.Control.extend({
|
||||
|
||||
ready: function() {
|
||||
|
||||
'use strict';
|
||||
|
||||
var control = this,
|
||||
value,
|
||||
thisInput,
|
||||
inputDefault,
|
||||
changeAction;
|
||||
|
||||
// Update the text value
|
||||
jQuery(document).on('input change', 'input[type=range]', function() {
|
||||
jQuery( this ).closest( 'label' ).find( '.range_value .value' ).html(jQuery(this).val());
|
||||
});
|
||||
|
||||
// Handle the reset button
|
||||
jQuery( '.slider-reset' ).on( 'click', function() {
|
||||
thisInput = jQuery( this ).closest( 'label' ).find( 'input' );
|
||||
inputDefault = thisInput.data( 'reset_value' );
|
||||
thisInput.val( inputDefault );
|
||||
thisInput.change();
|
||||
jQuery( this ).closest( 'label' ).find( '.range_value .value' ).text( inputDefault );
|
||||
});
|
||||
|
||||
if ( 'postMessage' === control.setting.transport ) {
|
||||
changeAction = 'mousemove change';
|
||||
} else {
|
||||
changeAction = 'change';
|
||||
}
|
||||
|
||||
// Save changes.
|
||||
this.container.on( changeAction, 'input', function() {
|
||||
control.setting.set( jQuery( this ).val() );
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user