jQuery(document).ready(function($){ /*** disable menu ***/ $("a.mmenu-2").attr('href','#'); /*** main carousel ***/ function maincarousel_initCallback(carousel) { // Pause autoscrolling if the user moves with the cursor over the clip. carousel.clip.hover(function() { carousel.stopAuto(); }, function() { carousel.startAuto(); }); } $('#maincarousel').jcarousel({ auto:5, scroll:1, wrap:"circular", initCallback: maincarousel_initCallback }); $(".jcarousel-prev, .jcarousel-next").css("display","none"); //hide nav on load $('.jcarousel-container').hover( //show nav on hover function(){ $(".jcarousel-prev, .jcarousel-next").css("display","block") }, function(){ $(".jcarousel-prev, .jcarousel-next").css("display","none") }); /*** /main carousel ***/ //Отключаем метод оплаты баллами var $input = $("[value = 'commerce_payment_balls|commerce_payment_commerce_payment_balls']"); //если в корзине есть товары, которые нельзя оплатить этим методом if (Drupal.settings.balls_payment_method_cart_disabled == true) { $input.attr("disabled", "disabled"); $input.closest('div').append('
Некоторые товары Вашего заказа нельзя оплатить в счет баллов
'); } //Отключаем метод оплаты баллами, если у пользователя недостаточно баллов else if (Drupal.settings.balls_payment_method_user_disabled == true) { $input.attr("disabled", "disabled"); $input.closest('div').append('
У Вас недостаточно баллов для оплаты заказа
'); } var $supermarket = $('#supermarket'); if ($supermarket.size() > 0) { $supermarket.find('.search').each(function() { $(this).css('z-index', 150).bind('focus', function() { var $this = $(this); var $searchBox = $this.siblings('.search-box'); $this.css('z-index', 200); $searchBox.css('z-index', 190); var $overlay = $searchBox.siblings('.searchbox-overlay'); $overlay.css('z-index', 180).show(); $overlay.click(function() { $this.css('z-index', 150); $searchBox.css('z-index', 150).hide(); $overlay.css('z-index', 150).hide(); }) $this.once(function() { var $results = $searchBox.find('.results'); var $a = $results.find('a'); var type = $this.attr('data-type'); var timeoutId; if (type == 'region') { $this.bind('keyup', function() { var searchText = $(this).val(); searchText = searchText.toLowerCase(); $a.show(); if (searchText != '') { $a.each(function() { var $this = $(this); var text = $this.text(); text = text.toLowerCase(); if (text.indexOf(searchText) == -1) { $this.hide(); } }); } }); } else { $this.bind('keyup', function() { $results.empty(); var searchText = $(this).val(); if (searchText.length >= 3) { clearTimeout(timeoutId); timeoutId = setTimeout(function() { $.post('/custom_nano/ajax', {'op': 'search', 'type': type, 'text': searchText}, function(data) { $results(data.content); }, 'json'); }, 500); } else { clearTimeout(timeoutId); $results('Необходимо набрать не менее 3х символов для начала поиска.'); } }); } $searchBox.find('.close').bind('click', function() { $this.css('z-index', 150); $searchBox.css('z-index', 150).hide(); $overlay.css('z-index', 150).hide(); }); }); $searchBox.show(); }); }); } var $cartFormTable = $('#views-form-commerce-cart-form-default table.views-table'); if ($cartFormTable.size()) { $cartFormTable.find('td.views-field-edit-quantity input').each(function() { var $this = $(this); var quantity = parseInt($this.val(), 10); var minus = $('-'); minus.bind('click', function() { quantity = quantity > 1 ? quantity - 1 : 0; $this.val(quantity); }); var plus = $('+'); plus.bind('click', function() { quantity = quantity + 1; $this.val(quantity); }); $this.before(minus).after(plus); }); } var $viewCompany = $('.companies-alphabet'); if ($viewCompany.size()) { var $ul = $(''); var $letterBoxes = $viewCompany.find('.letter-box'); var $li = $('
  • Все
  • '); $li.click(function() { $letterBoxes.show(); }) $ul.append($li); $viewCompany.find('h4').each(function() { var $this = $(this); var $div = $this.closest('div'); var $li = $('
  • ' + $this() + '
  • '); $li.click(function() { $letterBoxes.hide(); $div.show(); }); $ul.append($li); }); var $search = $(''); $viewCompany.prepend($search); $search.keyup(function() { $letterBoxes.show(); $letterBoxes.find('li').show(); var text = $search.val().toLowerCase(); var found; $letterBoxes.each(function() { var $this = $(this); found = false; $this.find('li').each(function() { var $li = $(this); if ($li.text().toLowerCase().indexOf(text) == -1) { $li.hide(); } else { found = true; } }) if (!found) { $this.hide(); } }) }) $viewCompany.prepend($('').append($search).append($ul)); } $('.nano-serach-ajax').each(function() { var $this = $(this); var $results = $this.next(); var type = $this.attr('data-type'); var view = $this.attr('data-view'); var timeoutId; $this.find('input').bind('keyup', function() { $results.empty(); var searchText = $(this).val(); if (searchText.length >= 3) { clearTimeout(timeoutId); timeoutId = setTimeout(function() { $.post('/custom_nano/ajax', {'op': 'search', 'type': type, 'view': view, 'text': searchText}, function(data) { $results.show()(data.content); }, 'json'); }, 500); } else { clearTimeout(timeoutId); $results('Необходимо набрать не менее 3х символов для начала поиска.'); } }); }); /* $('input[type="text"]') .focus(function() { $(this).addClass('input-active'); }) .blur(function() { $(this).removeClass('input-active'); }) */ /** * Если нет поддержки плейсхолдеров, то придется вставлять этот текст напрямую в поле */ var placeholderSupport = ("placeholder" in document.createElement("input")); if(!placeholderSupport){ $('input[placeholder]').each(function(ind){ var $this = $(this); $this.val($this.attr('placeholder')); $this .bind('focus', function(evt){ if ( $this.val() == $this.attr('placeholder') ){ $this.val(''); } }) .bind('blur', function(){ if ( $this.val() == '' ){ $this.val($this.attr('placeholder')); } }); }); } /*** comment menu tabs ***/ $(function() { $('ul.tabs').delegate('li:not(.current)', 'click', function() { $(this).addClass('active').siblings().removeClass('active') .parents('div.comments').find('div.box').eq($(this).index()).fadeIn(150).siblings('div.box').hide(); }) }) var $companyMenu = $('.company-menu'); if ($companyMenu.size()) { $companyMenu.find('a').bind('click', function() { var $this = $(this); $('.company-tabs .' + $(this).attr('href').substr(1)).show().siblings().hide(); $this.parent().addClass('active').siblings().removeClass('active'); }); var hash = location.hash; if (hash) { $companyMenu.find('a[href="' + hash + '"]').trigger('click'); } else { location.hash = $companyMenu.find('.active a').attr('href'); } } var $toCartWindow = $('#add-to-cart-window'); if ($toCartWindow.size() > 0) { $toCartWindow.find('.add-overlay').live('click', function() { $toCartWindow.hide(); }); $toCartWindow.find('.close').live('click', function() { $toCartWindow.hide(); }); } var $toCompanyContact = $('.contact a[href^="mailto:"]'); if ($toCompanyContact.size()) { var $companyContactForm = $('#company-contact-form-window') $companyContactFormIn = $companyContactForm.find('>.in'); $toCompanyContact.click(function(evt) { evt.preventDefault(); $companyContactFormIn.css( 'top', ( $(document).scrollTop() + 100 ) + 'px'); console.log($(document).scrollTop()); $companyContactForm.show(); }); $('#company-contact-form-window .close').click(function() { $companyContactForm.hide(); }); } var $confirmBlock = $('#block-block-30'); var $confirmOverlay = $confirmBlock.find('.confirm-overlay'); var $confirmWindow = $confirmBlock.find('.confirm-window'); $confirmBlock .find('.confirm-overlay, .close').click(function() { $confirmOverlay.hide(); $confirmWindow.hide(); }); // Показываем окошко с информацией о том, что услуга платная, прежде чем переходить по ссылке // Временно скрываем это окошко /*$('.add-company').click(function(evt) { evt.preventDefault(); $confirmBlock.find('.confirm').attr('href', evt.target.href); $confirmOverlay.show(); $confirmWindow.show(); });*/ $('#ad1').find('.vad-wrapper').iChanger(); }); /** * Collapsible block */ (function($){ $('.roll-toggle').live('click', function(evt){ evt.preventDefault(); var $this = $(this); $this.toggleClass('roll-toggle-active'); $this.closest('.roll').find('.roll-content').slideToggle(); }); })(jQuery) /** * Сменные картинки */ !(function($){ var holderArray = new Array(); var intervalArray = new Array(); $.fn.iChanger = function(){ this.each(function(ind){ holderArray[ind] = $(this); $('a', holderArray[ind]).not(':first').hide(); intervalArray[ind] = setInterval(function(){ iVisible = $('a:visible', holderArray[ind]); iNext = ( iVisible.next().size() ) ? iVisible.next() : $('a:first', holderArray[ind]); iVisible.fadeOut(500); iNext.fadeIn(500); }, 6000); }) } })(jQuery)