frontend price-slider jshinted and coding standards
This commit is contained in:
parent
eebe726c10
commit
55698e6c59
|
@ -1,72 +1,73 @@
|
|||
jQuery(function($) {
|
||||
jQuery( function( $ ) {
|
||||
|
||||
// woocommerce_price_slider_params is required to continue, ensure the object exists
|
||||
if (typeof woocommerce_price_slider_params === "undefined")
|
||||
if ( typeof woocommerce_price_slider_params === 'undefined' ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get markup ready for slider
|
||||
$('input#min_price, input#max_price').hide();
|
||||
$('.price_slider, .price_label').show();
|
||||
$( 'input#min_price, input#max_price' ).hide();
|
||||
$( '.price_slider, .price_label' ).show();
|
||||
|
||||
// Price slider uses jquery ui
|
||||
var min_price = $('.price_slider_amount #min_price').data('min');
|
||||
var max_price = $('.price_slider_amount #max_price').data('max');
|
||||
var min_price = $( '.price_slider_amount #min_price' ).data( 'min' ),
|
||||
max_price = $( '.price_slider_amount #max_price' ).data( 'max' );
|
||||
|
||||
current_min_price = parseInt(min_price);
|
||||
current_max_price = parseInt(max_price);
|
||||
current_min_price = parseInt( min_price, 10 );
|
||||
current_max_price = parseInt( max_price, 10 );
|
||||
|
||||
if (woocommerce_price_slider_params.min_price) current_min_price = parseInt(woocommerce_price_slider_params.min_price);
|
||||
if (woocommerce_price_slider_params.max_price) current_max_price = parseInt(woocommerce_price_slider_params.max_price);
|
||||
if ( woocommerce_price_slider_params.min_price ) current_min_price = parseInt( woocommerce_price_slider_params.min_price, 10 );
|
||||
if ( woocommerce_price_slider_params.max_price ) current_max_price = parseInt( woocommerce_price_slider_params.max_price, 10 );
|
||||
|
||||
$('body').bind('price_slider_create price_slider_slide', function( event, min, max ) {
|
||||
if (woocommerce_price_slider_params.currency_pos == "left") {
|
||||
$( 'body' ).bind( 'price_slider_create price_slider_slide', function( event, min, max ) {
|
||||
if ( woocommerce_price_slider_params.currency_pos === 'left' ) {
|
||||
|
||||
$( ".price_slider_amount span.from" ).html( woocommerce_price_slider_params.currency_symbol + min );
|
||||
$( ".price_slider_amount span.to" ).html( woocommerce_price_slider_params.currency_symbol + max );
|
||||
$( '.price_slider_amount span.from' ).html( woocommerce_price_slider_params.currency_symbol + min );
|
||||
$( '.price_slider_amount span.to' ).html( woocommerce_price_slider_params.currency_symbol + max );
|
||||
|
||||
} else if (woocommerce_price_slider_params.currency_pos == "left_space") {
|
||||
} else if ( woocommerce_price_slider_params.currency_pos === 'left_space' ) {
|
||||
|
||||
$( ".price_slider_amount span.from" ).html( woocommerce_price_slider_params.currency_symbol + " " + min );
|
||||
$( ".price_slider_amount span.to" ).html( woocommerce_price_slider_params.currency_symbol + " " + max );
|
||||
$( '.price_slider_amount span.from' ).html( woocommerce_price_slider_params.currency_symbol + " " + min );
|
||||
$( '.price_slider_amount span.to' ).html( woocommerce_price_slider_params.currency_symbol + " " + max );
|
||||
|
||||
} else if (woocommerce_price_slider_params.currency_pos == "right") {
|
||||
} else if ( woocommerce_price_slider_params.currency_pos === 'right' ) {
|
||||
|
||||
$( ".price_slider_amount span.from" ).html( min + woocommerce_price_slider_params.currency_symbol );
|
||||
$( ".price_slider_amount span.to" ).html( max + woocommerce_price_slider_params.currency_symbol );
|
||||
$( '.price_slider_amount span.from' ).html( min + woocommerce_price_slider_params.currency_symbol );
|
||||
$( '.price_slider_amount span.to' ).html( max + woocommerce_price_slider_params.currency_symbol );
|
||||
|
||||
} else if (woocommerce_price_slider_params.currency_pos == "right_space") {
|
||||
} else if ( woocommerce_price_slider_params.currency_pos === 'right_space' ) {
|
||||
|
||||
$( ".price_slider_amount span.from" ).html( min + " " + woocommerce_price_slider_params.currency_symbol );
|
||||
$( ".price_slider_amount span.to" ).html( max + " " + woocommerce_price_slider_params.currency_symbol );
|
||||
$( '.price_slider_amount span.from' ).html( min + " " + woocommerce_price_slider_params.currency_symbol );
|
||||
$( '.price_slider_amount span.to' ).html( max + " " + woocommerce_price_slider_params.currency_symbol );
|
||||
|
||||
}
|
||||
|
||||
$('body').trigger('price_slider_updated', min, max );
|
||||
$( 'body' ).trigger( 'price_slider_updated', min, max );
|
||||
});
|
||||
|
||||
$('.price_slider').slider({
|
||||
$( '.price_slider' ).slider({
|
||||
range: true,
|
||||
animate: true,
|
||||
min: min_price,
|
||||
max: max_price,
|
||||
values: [current_min_price,current_max_price],
|
||||
values: [ current_min_price, current_max_price ],
|
||||
create : function( event, ui ) {
|
||||
|
||||
$( ".price_slider_amount #min_price" ).val(current_min_price);
|
||||
$( ".price_slider_amount #max_price" ).val(current_max_price);
|
||||
$( '.price_slider_amount #min_price' ).val( current_min_price );
|
||||
$( '.price_slider_amount #max_price' ).val( current_max_price );
|
||||
|
||||
$('body').trigger('price_slider_create', [current_min_price, current_max_price]);
|
||||
$( 'body' ).trigger( 'price_slider_create', [ current_min_price, current_max_price ] );
|
||||
},
|
||||
slide: function( event, ui ) {
|
||||
|
||||
$( "input#min_price" ).val(ui.values[ 0 ]);
|
||||
$( "input#max_price" ).val(ui.values[ 1 ]);
|
||||
$( 'input#min_price' ).val( ui.values[0] );
|
||||
$( 'input#max_price' ).val( ui.values[1] );
|
||||
|
||||
$('body').trigger('price_slider_slide', [ui.values[ 0 ], ui.values[ 1 ]] );
|
||||
$( 'body' ).trigger( 'price_slider_slide', [ ui.values[0], ui.values[1] ] );
|
||||
},
|
||||
change: function( event, ui ) {
|
||||
|
||||
$('body').trigger('price_slider_change', [ui.values[ 0 ], ui.values[ 1 ]] );
|
||||
$( 'body' ).trigger( 'price_slider_change', [ ui.values[0], ui.values[1] ] );
|
||||
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1 +1 @@
|
|||
jQuery(function(a){if("undefined"==typeof woocommerce_price_slider_params)return!1;a("input#min_price, input#max_price").hide(),a(".price_slider, .price_label").show();var b=a(".price_slider_amount #min_price").data("min"),c=a(".price_slider_amount #max_price").data("max");current_min_price=parseInt(b),current_max_price=parseInt(c),woocommerce_price_slider_params.min_price&&(current_min_price=parseInt(woocommerce_price_slider_params.min_price)),woocommerce_price_slider_params.max_price&&(current_max_price=parseInt(woocommerce_price_slider_params.max_price)),a("body").bind("price_slider_create price_slider_slide",function(b,c,d){"left"==woocommerce_price_slider_params.currency_pos?(a(".price_slider_amount span.from").html(woocommerce_price_slider_params.currency_symbol+c),a(".price_slider_amount span.to").html(woocommerce_price_slider_params.currency_symbol+d)):"left_space"==woocommerce_price_slider_params.currency_pos?(a(".price_slider_amount span.from").html(woocommerce_price_slider_params.currency_symbol+" "+c),a(".price_slider_amount span.to").html(woocommerce_price_slider_params.currency_symbol+" "+d)):"right"==woocommerce_price_slider_params.currency_pos?(a(".price_slider_amount span.from").html(c+woocommerce_price_slider_params.currency_symbol),a(".price_slider_amount span.to").html(d+woocommerce_price_slider_params.currency_symbol)):"right_space"==woocommerce_price_slider_params.currency_pos&&(a(".price_slider_amount span.from").html(c+" "+woocommerce_price_slider_params.currency_symbol),a(".price_slider_amount span.to").html(d+" "+woocommerce_price_slider_params.currency_symbol)),a("body").trigger("price_slider_updated",c,d)}),a(".price_slider").slider({range:!0,animate:!0,min:b,max:c,values:[current_min_price,current_max_price],create:function(){a(".price_slider_amount #min_price").val(current_min_price),a(".price_slider_amount #max_price").val(current_max_price),a("body").trigger("price_slider_create",[current_min_price,current_max_price])},slide:function(b,c){a("input#min_price").val(c.values[0]),a("input#max_price").val(c.values[1]),a("body").trigger("price_slider_slide",[c.values[0],c.values[1]])},change:function(b,c){a("body").trigger("price_slider_change",[c.values[0],c.values[1]])}})});
|
||||
jQuery(function(e){if(typeof woocommerce_price_slider_params==="undefined"){return false}e("input#min_price, input#max_price").hide();e(".price_slider, .price_label").show();var t=e(".price_slider_amount #min_price").data("min"),n=e(".price_slider_amount #max_price").data("max");current_min_price=parseInt(t,10);current_max_price=parseInt(n,10);if(woocommerce_price_slider_params.min_price)current_min_price=parseInt(woocommerce_price_slider_params.min_price,10);if(woocommerce_price_slider_params.max_price)current_max_price=parseInt(woocommerce_price_slider_params.max_price,10);e("body").bind("price_slider_create price_slider_slide",function(t,n,r){if(woocommerce_price_slider_params.currency_pos==="left"){e(".price_slider_amount span.from").html(woocommerce_price_slider_params.currency_symbol+n);e(".price_slider_amount span.to").html(woocommerce_price_slider_params.currency_symbol+r)}else if(woocommerce_price_slider_params.currency_pos==="left_space"){e(".price_slider_amount span.from").html(woocommerce_price_slider_params.currency_symbol+" "+n);e(".price_slider_amount span.to").html(woocommerce_price_slider_params.currency_symbol+" "+r)}else if(woocommerce_price_slider_params.currency_pos==="right"){e(".price_slider_amount span.from").html(n+woocommerce_price_slider_params.currency_symbol);e(".price_slider_amount span.to").html(r+woocommerce_price_slider_params.currency_symbol)}else if(woocommerce_price_slider_params.currency_pos==="right_space"){e(".price_slider_amount span.from").html(n+" "+woocommerce_price_slider_params.currency_symbol);e(".price_slider_amount span.to").html(r+" "+woocommerce_price_slider_params.currency_symbol)}e("body").trigger("price_slider_updated",n,r)});e(".price_slider").slider({range:true,animate:true,min:t,max:n,values:[current_min_price,current_max_price],create:function(t,n){e(".price_slider_amount #min_price").val(current_min_price);e(".price_slider_amount #max_price").val(current_max_price);e("body").trigger("price_slider_create",[current_min_price,current_max_price])},slide:function(t,n){e("input#min_price").val(n.values[0]);e("input#max_price").val(n.values[1]);e("body").trigger("price_slider_slide",[n.values[0],n.values[1]])},change:function(t,n){e("body").trigger("price_slider_change",[n.values[0],n.values[1]])}})})
|
Loading…
Reference in New Issue