jQuery( document ).ready( function() {
/* If there are required actions, add an icon with the number of required actions in the About bumbeelbee page -> Actions required tab */
var bumbeelbee_nr_actions_required = bumbeelbeeWelcomeScreenObject.nr_actions_required,
context = jQuery( '.widget-content' ),
sliders = context.find( '.slider-container' ),
slider, input, inputId, id, min, max, step;
if ( (typeof bumbeelbee_nr_actions_required !== 'undefined') && (bumbeelbee_nr_actions_required != '0') ) {
jQuery( 'li.bumbeelbee-w-red-tab a' ).append( '' + bumbeelbee_nr_actions_required + '' );
}
/* Dismiss required actions */
jQuery( '.bumbeelbee-required-action-button' ).click( function() {
var id = jQuery( this ).attr( 'id' ),
action = jQuery( this ).attr( 'data-action' );
jQuery.ajax( {
type: 'GET',
data: { action: 'bumbeelbee_dismiss_required_action', id: id, todo: action },
dataType: 'html',
url: bumbeelbeeWelcomeScreenObject.ajaxurl,
beforeSend: function( data, settings ) {
jQuery( '.bumbeelbee-tab-pane#actions_required h1' ).
append( '

' );
},
success: function( data ) {
location.reload();
jQuery( '#temp_load' ).remove();
/* Remove loading gif */
},
error: function( jqXHR, textStatus, errorThrown ) {
console.log( jqXHR + ' :: ' + textStatus + ' :: ' + errorThrown );
}
} );
} );
function bumbeelbee_rangesliders_init() {
jQuery.each( sliders, function() {
var slider = jQuery( this ).find( '.ss-slider' ),
input = jQuery( this ).find( '.rl-slider' ),
inputId = input.attr( 'id' ),
id = slider.attr( 'id' ),
min = jQuery( '#' + id ).attr( 'data-attr-min' ),
max = jQuery( '#' + id ).attr( 'data-attr-max' ),
step = jQuery( '#' + id ).attr( 'data-attr-step' );
jQuery( '#' + id ).slider( {
value: jQuery( '#' + inputId ).attr( 'value' ),
range: 'min',
min: parseFloat( min ),
max: parseFloat( max ),
step: parseFloat( step ),
/**
* Removed Change event because server was flooded with requests from
* javascript, sending changesets on each increment.
*
* @param event
* @param ui
*/
slide: function( event, ui ) {
jQuery( '#' + inputId ).attr( 'value', ui.value );
},
/**
* Bind the change event to the "actual" stop
* @param event
* @param ui
*/
stop: function( event, ui ) {
jQuery( '#' + inputId ).trigger( 'change' );
}
} );
jQuery( input ).on( 'focus', function() {
jQuery( this ).blur();
} );
jQuery( '#' + inputId ).attr( 'value', ( jQuery( '#' + id ).slider( 'value' ) ) );
jQuery( '#' + inputId ).on( 'change', function() {
jQuery( '#' + id ).slider( {
value: jQuery( this ).val()
} );
} );
} );
};
bumbeelbee_rangesliders_init();
jQuery( document ).ajaxStop( function() {
bumbeelbee_rangesliders_init();
} );
} );