ru-se.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

slider.js (1171B)


      1 wp.customize.controlConstructor['kirki-slider'] = wp.customize.Control.extend({
      2 
      3 	ready: function() {
      4 
      5 		'use strict';
      6 
      7 		var control = this,
      8 		    value,
      9 		    thisInput,
     10 		    inputDefault,
     11 		    changeAction;
     12 
     13 		// Update the text value
     14 		jQuery( 'input[type=range]' ).on( 'mousedown', function() {
     15 			value = jQuery( this ).attr( 'value' );
     16 			jQuery( this ).mousemove( function() {
     17 				value = jQuery( this ).attr( 'value' );
     18 				jQuery( this ).closest( 'label' ).find( '.kirki_range_value .value' ).text( value );
     19 			});
     20 		});
     21 
     22 		// Handle the reset button
     23 		jQuery( '.kirki-slider-reset' ).click( function() {
     24 			thisInput    = jQuery( this ).closest( 'label' ).find( 'input' );
     25 			inputDefault = thisInput.data( 'reset_value' );
     26 			thisInput.val( inputDefault );
     27 			thisInput.change();
     28 			jQuery( this ).closest( 'label' ).find( '.kirki_range_value .value' ).text( inputDefault );
     29 		});
     30 
     31 		if ( 'postMessage' === control.setting.transport ) {
     32 			changeAction = 'mousemove change';
     33 		} else {
     34 			changeAction = 'change';
     35 		}
     36 
     37 		// Save changes.
     38 		this.container.on( changeAction, 'input', function() {
     39 			control.setting.set( jQuery( this ).val() );
     40 		});
     41 	}
     42 
     43 });