Files
wordpress-preseed/wp-content/plugins/advanced-custom-fields/assets/build/js/_acf-field-range.js
2019-09-11 19:08:46 +02:00

42 lines
796 B
JavaScript

(function($, undefined){
var Field = acf.Field.extend({
type: 'range',
events: {
'input input[type="range"]': 'onChange',
'change input': 'onChange'
},
$input: function(){
return this.$('input[type="range"]');
},
$inputAlt: function(){
return this.$('input[type="number"]');
},
setValue: function( val ){
this.busy = true;
// Update range input (with change).
acf.val( this.$input(), val );
// Update alt input (without change).
// Read in input value to inherit min/max validation.
acf.val( this.$inputAlt(), this.$input().val(), true );
this.busy = false;
},
onChange: function( e, $el ){
if( !this.busy ) {
this.setValue( $el.val() );
}
}
});
acf.registerFieldType( Field );
})(jQuery);