1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
jQuery( function( $ )
{
'use strict';
function wcqd_metabox_update_slider()
{
var $input = $( this ),
$slider = $input.siblings( '.rwmb-slider' ),
$valueLabel = $slider.siblings( '.rwmb-slider-value-label' ).find( 'span' ),
value = $input.val(),
options = $slider.data( 'options' );
$slider.html( '' );
if ( !value )
{
value = 0;
$input.val( 0 );
$valueLabel.text( '0' );
}
else
{
$valueLabel.text( value );
}
// Assign field value and callback function when slide
options.value = value;
options.slide = function( event, ui )
{
$input.val( ui.value );
$valueLabel.text( ui.value );
};
$slider.slider( options );
}
$( ':input.rwmb-slider-value' ).each( wcqd_metabox_update_slider );
$( '.rwmb-input' ).on( 'clone', ':input.rwmb-slider-value', wcqd_metabox_update_slider );
} );