$(document).ready(function () { /*plugins referral*/ var $reff = $('table.referral-channels-report'); if($reff.length){ $reff.addClass('table'); $reff.find('tr:first').addClass('name-coll'); $reff.find('tr:even:not(:first)').addClass('fon-orders'); } var cd = $('#category-description'); if(cd.length && cd.height() > parseInt(cd.data('cutter'))){ var btn_cut = $(''+cd.data('etext')+'').click(function(){ var self = $(this); self.hide(); if(self.hasClass('expand')){ cd.removeClass('cutter').animate({ height: cd.data('orig-height') }, 'slow', function(){ self.text(cd.data('ctext')).show(); }); }else{ cd.animate({ height: cd.data('cutter') }, 'slow', function(){ $(this).addClass('cutter'); self.text(cd.data('etext')).show(); $('body,html').animate({ scrollTop: cd.position().top }, 800); }); } self.toggleClass('expand'); }); cd.data('orig-height',cd.height()).addClass('cutter').css('height',cd.data('cutter')).append(btn_cut); } $('ul[class^="product-slider-"]').jcarousel({ scroll: 1, buttonNextHTML: '
', buttonPrevHTML: '
' }); $('.content').on('submit', 'form.addtocart', function () { var f = $(this); if (f.data('url')) { var d = $('#dialog'); var c = d.find('.cart'); c.addClass('product').load(f.data('url'), function () { d.show(); if($('#dialog-image-product').length) { c.parent().prepend(c.find('h4')); c.css('margin-top', d.find('h4').innerHeight()); } if ((c.height() > c.find('form').height())) { c.css('bottom', 'auto'); } else { c.css('bottom', '15%'); } }); return false; } $.post(f.attr('action') + (sumbolrub ? '?html=1' : ''), f.serialize(), function (response) { if (response.status == 'ok') { var cart_total = $(".cart-total"); if ( $(window).scrollTop()>=35 ) { cart_total.closest('#cart').addClass( "fixed" ); } cart_total.closest('#cart').removeClass('empty'); if ($("table.cart").length) { $('.wrap-cart-load').load(location.href, function () { cart_total.html(response.data.total); $(window).unbind('load.jcarousel, resize.jcarousel'); $('ul[class^="product-slider-"]').jcarousel({ scroll: 1, buttonNextHTML: '
', buttonPrevHTML: '
', reloadCallback: function(carousel){ carousel.scroll(1, false); carousel.list.css('left', 0); } }); }); } else { var origin = f.closest('li'); var block = $('
').append(origin.html()); block.css({ 'z-index': 10, top: origin.offset().top, left: origin.offset().left, width: origin.width()+'px', height: origin.height()+'px', position: 'absolute', overflow: 'hidden' }).insertAfter('#main').animate({//code origin => .content top: cart_total.offset().top, left: cart_total.offset().left, width: 0, height: 0, opacity: 0.5 }, 500, function() { $(this).remove(); cart_total.html(response.data.total); }); var $scd = f.closest('li').find('.soaring-cart-data').data(); if($scd){ var $item = $('#soaring-cart li[data-id="'+response.data.item_id+'"]'); var cnt = parseInt(f.find('input[name="quantity"]').val()) || 1; if($item.length){ var $qty = $item.find('input.soaring-cart-qty'); cnt += parseInt($qty.val()); $qty.val(cnt); $item.find('.price').html(currency_format($scd.price*cnt, !sumbolrub, $.neostylru.currency));//* }else{ $.extend($scd, { id: response.data.item_id, cnt: cnt, price: ''+currency_format($scd.price*cnt, !sumbolrub, $.neostylru.currency) });//* $('#soaring-cart ul').prepend(newItem($scd)); setSoaringHeight(); } $('#soaring-cart').scrollTop( $('#soaring-cart li[data-id="'+response.data.item_id+'"]').position().top ); } } if (response.data.error) { alert(response.data.error); } } else if (response.status == 'fail') { alert(response.errors); } }, "json"); return false; }); /*brands*/ var brands = $('.menu-v.brands'); if(brands.find('li').length>5){ brands.find('li').filter(':gt(4)').hide(); brands.append('
  • '+$.neostylru.locale.showall+'
  • '); $('#brands-switch').click(function(){ brands.find('li:hidden').show(); $(this).parent().hide(); return false; }); } $('.filters.ajax form input, .filters2.ajax form input').change(function () { var f = $(this).closest('form'); var fields = f.serializeArray(); var params = []; for (var i = 0; i < fields.length; i++) { if (fields[i].value !== '') { params.push(fields[i].name + '=' + fields[i].value); } } var url = '?' + params.join('&'); $(window).lazyLoad && $(window).lazyLoad('sleep'); var loading_filter = $('
    '); f.css('position', 'relative').append(loading_filter); $.get(url, function(html) { var tmp = $('
    ').html(html); $('#product-list').html(tmp.find('#product-list').html()); if (!!(history.pushState && history.state !== undefined)) { window.history.pushState({}, '', url); } $(window).lazyLoad && $(window).lazyLoad('reload'); event_category(); loading_filter.remove(); }); }); var event_category = function(){ $('#products-per-page a').click(function(){ if(!$(this).hasClass('selected')){ if($(this).data('pppc')){ $.cookie('products_per_page', $(this).data('pppc'), { expires: 30, path: '/'}); }else{ $.cookie('products_per_page', '', { expires: 0, path: '/'}); } }else{ return false; } }); $('.select-view span').click(function(){ $('.select-view span').removeClass('selected'); if($(this).hasClass('list')){ $(this).addClass('selected'); $('.product-list').addClass('list').removeClass('thumbs'); $.cookie('select-view', 'list', {expires: 30, path: '/'}); }else{ $(this).addClass('selected'); $('.product-list').addClass('thumbs').removeClass('list'); $.cookie('select-view', 'thumbs', {expires: 30, path: '/'}); } }); if($('.sorting').length){ if($('.sorting li.selected a').html().search('asc') > 0) var ss = $('.sorting li.selected a').html().replace('asc', 'desc') else var ss = $('.sorting li.selected a').html().replace('desc', 'asc'); $('.sorting-selection>span').html(ss+''); /*hack hover click sorting*/ $('.sorting-selection').click(function(){ $(this).find('ul').toggle(); }); $('.sorting-selection').hover(function(){ $(this).find('ul').show(); }, function(){ $(this).find('ul').hide(); }); } } event_category(); $("#addition-all-delete").click(function () { $.cookie('shop_'+$(this).data('addition'), null, { expires: 0, path: '/'}); }); }); var currency_format = function(number, no_html, currency) { // Format a number with grouped thousands // // + original by: Jonas Raoni Soares Silva (http://www.jsfromhell.com) // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) // + bugfix by: Michael White (http://crestidg.com) var i, j, kw, kd, km; var decimals = currency.frac_digits; var dec_point = currency.decimal_point; var thousands_sep = currency.thousands_sep; // input sanitation & defaults if( isNaN(decimals = Math.abs(decimals)) ){ decimals = 2; } if( dec_point == undefined ){ dec_point = ","; } if( thousands_sep == undefined ){ thousands_sep = "."; } i = parseInt(number = (+number || 0).toFixed(decimals)) + ""; if( (j = i.length) > 3 ){ j = j % 3; } else{ j = 0; } km = (j ? i.substr(0, j) + thousands_sep : ""); kw = i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thousands_sep); //kd = (decimals ? dec_point + Math.abs(number - i).toFixed(decimals).slice(2) : ""); kd = (decimals && (number - i) ? dec_point + Math.abs(number - i).toFixed(decimals).replace(/-/, 0).slice(2) : ""); var number = km + kw + kd; var s = no_html ? currency.sign : currency.sign_html; if (!currency.sign_position) { return s + currency.sign_delim + number; } else { return number + currency.sign_delim + s; } } var newItem = function($item) { return '
  • '+ '
    '+ ''+ ''+$item.name+''+ ''+ '
    '+ '
    '+ ''+$item.name+' '+(typeof $item.sku_name !== 'undefined' ? $item.sku_name : "")+''+ '
    '+ '
    '+ ''+$item.price+''+//* '
    '+ '
    '+ /*''+*/ ' '+$.neostylru.locale.pcs+ /*''+*/ '
    '+ '
    '+ ''+ '
    '+ '
  • '; } /* playback timings (ms): LoadShardBlock: 207.241 (3) esindex: 0.008 captures_list: 229.504 CDXLines.iter: 17.1 (3) PetaboxLoader3.datanode: 186.611 (4) exclusion.robots: 0.303 exclusion.robots.policy: 0.29 RedisCDXSource: 0.542 PetaboxLoader3.resolve: 91.801 load_resource: 120.915 */