function wpsg_switchProductview(index, page, order, mode) { var atts = jQuery.parseJSON(jQuery('#wpsg_productview_' + index + ' input[name="wpsg_atts"]').val()); atts.page = page; if (typeof order !== "undefined") atts.order = order; if (typeof mode !== "undefined") atts.mode = mode; else { if (jQuery('#wpsg_productview_' + index + ' .wpsg_mod_productview_modeswitch > a').length > 0) { if (jQuery('#wpsg_productview_' + index + ' .wpsg_mod_productview_modeswitch > a.fa-th').hasClass('active')) atts.mode = 'grid'; else atts.mode = 'list'; } } if (jQuery('#wpsg_mod_productview_filter').length > 0) { atts.filter = jQuery('#wpsg_mod_productview_filter input').serialize(); } jQuery('#wpsg_productview_' + index).append('
'); jQuery.ajax( { 'url': wpsg_ajax.ajaxurl, 'data': { 'wpsg_mod': 'wpsg_mod_productview', 'wpsg_action': 'refresh', 'wpsg_atts': atts }, 'success': function(data) { jQuery('#wpsg_productview_' + index).replaceWith(data); wpsg_correctProductview(index); } } ); return false; } function wpsg_correctProductview(index) { var max_height = 0; jQuery('#wpsg_productview_' + index + ' .wpsg_productview_product_grid .wpsg_mod_productview_name').each(function() { if (jQuery(this).outerHeight() > max_height) max_height = jQuery(this).outerHeight(); } ).outerHeight(max_height); var max_height = 0; jQuery('#wpsg_productview_' + index + ' .wpsg_productview_product_grid .wpsg_mod_productview_description').each(function() { if (jQuery(this).outerHeight() > max_height) max_height = jQuery(this).outerHeight(); } ).outerHeight(max_height); // Sortierungslayer jQuery('.wpsg_mod_productview-order').bind('click', function(event) { if (jQuery(this).find('.wpsg_mod_productview-order-layer').is(':visible')) { jQuery(this).find('.wpsg_mod_productview-order-layer').slideUp(); } else { jQuery(this).find('.wpsg_mod_productview-order-layer').slideDown(); } event.stopPropagation(); } ).disableSelection(); // Sortierung jQuery('.wpsg_mod_productview-order-layer a').bind('click', function() { var productview_index = jQuery(this).attr("data-productview-index"); var order = jQuery(this).attr("data-order"); wpsg_switchProductview(productview_index, 1, order); return false; } ).disableSelection(); // Umschalten der List/Grid Ansichten jQuery('.wpsg_mod_productview_modeswitch > a').bind('click', function() { if (jQuery(this).hasClass('fa-th') &&!jQuery(this).hasClass('active')) { jQuery('.wpsg_productview_product_list').hide(250); jQuery('.wpsg_productview_product_grid').show(250); } else if (jQuery(this).hasClass('fa-list') && !jQuery(this).hasClass('active')) { jQuery('.wpsg_productview_product_grid').hide(250); jQuery('.wpsg_productview_product_list').show(250); } jQuery('.wpsg_mod_productview_modeswitch a').removeClass('active'); jQuery(this).addClass('active'); return false; } ); } function wpsg_filter_insert(values, set) { var arValues = []; if (jQuery.trim(values) != '') arValues = jQuery.trim(values).split(','); if (jQuery.inArray(set, arValues) >= 0) arValues = jQuery.grep(arValues, function(value) { return value != set; } ); else arValues.push(set); return jQuery.unique(arValues).join(','); } jQuery(document).ready(function() { // Preisfilter var filter_min = parseFloat(jQuery('#wpsg_mod_productview_filter_price_info input[name="price_min"]').val()); var filter_max = parseFloat(jQuery('#wpsg_mod_productview_filter_price_info input[name="price_max"]').val()); jQuery("#wpsg_mod_productview_filter_price-range").slider( { range: true, min: filter_min, max: filter_max, values: [filter_min, filter_max], slide: function(event, ui) { jQuery('#wpsg_mod_productview_filter_price_info input[name="price_min"]').val(ui.values[0]); jQuery('#wpsg_mod_productview_filter_price_info input[name="price_max"]').val(ui.values[1]); jQuery('#wpsg_mod_productview_filter_price_info .min').html(wpsg_numberformat(ui.values[0], 2)); jQuery('#wpsg_mod_productview_filter_price_info .max').html(wpsg_numberformat(ui.values[1], 2)); }, stop: function(event, ui) { wpsg_switchProductview(1, 1); } } ); // Variantenfilter Small jQuery('.wpsg_mod_productview_filter_item a.switch').bind('click', function() { var input = jQuery(this).parents('.wpsg_mod_productview_filter_item').find('input.val'); input.val(wpsg_filter_insert(input.val(), jQuery(this).attr('data-value'))); jQuery(this).toggleClass('active'); wpsg_switchProductview(1, 1); return false; } ); jQuery('.wpsg_productview').each(function() { var x = jQuery(this).attr("id").substr(17); wpsg_correctProductview(x); } ); jQuery('body, html').bind('click', function() { jQuery('.wpsg_mod_productview-order-layer:visible').each(function() { jQuery(this).parent().click(); } ); } ); } );