Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(".js_shop_depend_param, .shop_form .depend_param").change(function() {
- select_param_price($(this).parents('form'));
- });
- $(".js_shop_form, .shop_form").each(function() {
- empty_param_price($(this));
- select_param_price($(this));
- });
- $("input[action=buy]").click(function() {
- $(this).parents('form').find('input[name=action]').val('buy');
- $(this).parents('form').submit();
- });
- $("input[action=wish]").click(function() {
- $(this).parents('form').find('input[name=action]').val('wish');
- $(this).parents('form').submit();
- });
- $("input[action=wait]").click(function() {
- $(this).parents('form').find('input[name=action]').val('wait');
- $(this).parents('form').submit();
- });
- $("input[action=one_click]").click(function() {
- $('form[one_click=true]').removeAttr('one_click');
- $(this).parents('form').attr('one_click', 'true');
- $(this).parents('.js_shop').find('.js_cart_one_click, .cart_one_click').show();
- });
- $(".js_cart_one_click_form, .cart_one_click_form").on('click', ":button", function(){
- var self = $(this).parents(".js_cart_one_click_form, .cart_one_click_form");
- $('.js_shop_form_param input, .js_shop_form_param select, .shop_form_param input, .shop_form_param select, input[name=count]', 'form[one_click=true]').each(function(){
- $("input[name="+$(this).attr('name')+"]", self).remove();
- self.prepend('<input type="hidden" name="'+$(this).attr('name')+'" value="'+$(this).val()+'">');
- });
- self.submit();
- });
- $('.js_shop_wishlist, .shop-like').click(function() {
- var form = $(this).parents('.js_shop, .shop').find('.js_shop_form, .shop_form').first();
- form.find('input[name=action]').val('wish')
- form.submit();
- });
- $('.js_shop_add_compare, .shop_compare_button').click(function() {
- $(this).parents('form').submit();
- });
- function select_param_price(th)
- {
- var param_code = '';
- $(".js_shop_depend_param, .depend_param", th).each(function(){
- param_code = param_code + '[' + $(this).attr('name') + '=' + $(this).val() + ']';
- });
- if($('.js_shop_param_price, .shop_param_price', th).length)
- {
- $('.js_shop_param_price, .shop_param_price', th).hide();
- if($('.js_shop_param_price' + param_code + ', .shop_param_price' + param_code, th).length)
- {
- $('.js_shop_param_price' + param_code + ', .shop_param_price'+param_code, th).show();
- var image_id = $('.js_shop_param_price' + param_code + ', .shop_param_price' + param_code, th).attr('image_id');
- if(image_id)
- {
- th.parents('.js_shop, .shop').find('.js_shop_img, .shop-item-big-images a, .shop-photo img').each(function(){
- if($(this).attr('image_id') == image_id)
- {
- $(this).show();
- }
- else
- {
- if($('.js_shop_param_price[image_id='+$(this).attr('image_id')+'], .shop_param_price[image_id='+$(this).attr('image_id')+']', th).length)
- {
- $(this).hide();
- }
- }
- });
- }
- if($('.js_shop_param_price' + param_code + ', .shop_param_price'+param_code, th).find('.js_shop_no_buy, .shop_no_buy').length)
- {
- $('.js_show_waitlist, .shop_waitlist', th).show();
- $('.js_shop_buy, .to-cart', th).hide();
- $('.js_shop_one_click, .shop_one_click', th).hide();
- }
- else
- {
- if($('.js_shop_no_buy_good, .shop_no_buy_good', th).length)
- {
- $('.js_shop_waitlist, .shop_waitlist', th).show();
- }
- else
- {
- $('.js_shop_waitlist, .shop_waitlist', th).hide();
- }
- $('.js_shop_buy, .to-cart', th).show();
- $('.js_shop_one_click, .shop_one_click', th).show();
- }
- }
- else
- {
- th.parents('.js_shop, .shop').find('.js_shop_img, .shop_img img, .shop_all_img img').each(function(){
- if($('.js_shop_param_price[image_id='+$(this).attr('image_id')+'], .shop_param_price[image_id='+$(this).attr('image_id')+']', th).length)
- {
- $(this).hide();
- }
- });
- $('.js_shop_buy, .to-cart', th).hide();
- $('.js_shop_one_click, .shop_one_click', th).hide();
- $('.js_shop_waitlist, .shop_waitlist', th).hide();
- }
- }
- }
- function empty_param_price(th)
- {
- var param_code = '';
- $(".js_shop_depend_param", th).each(function(){
- param_code = param_code + '['+$(this).attr('name')+'='+$(this).val()+']';
- });
- if($('.js_shop_param_price', th).length)
- {
- if($('.js_shop_param_price' + param_code, th).length)
- {
- if($('.js_shop_param_price' + param_code +' .js_shop_no_buy', th).length)
- {
- var shop_depend_param = $(".js_shop_depend_param", th).first();
- if(get_selected(shop_depend_param).next('option').length)
- {
- get_selected(shop_depend_param).next('option').attr('selected', 'selected');
- empty_param_price(th);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement