/*jslint nomen: true, regexp: true, unparam: true, sloppy: true, white: true, node: true */ /*global window, console, document, $, jQuery, google */ /** * On document ready */ $(document).ready(function () { $('body').on('click', 'form#order_process button', function() { $.ajax({ url: "/order/process", //Адрес подгружаемой страницы type: "POST", //Тип запроса data: "aj=1", success: function(data) { //Если все нормально ////alert(data); $('form#order_process').append(data).submit(); }, error: function(data) { //Если ошибка } }); return false; }); $('body').on('change', 'input[name=shipping_id]', function() { var shipping_id = $('input[name=shipping_id]:checked').val(); $.ajax({ url: "/order/change_shipping", //Адрес подгружаемой страницы type: "POST", //Тип запроса data: "shipping_id="+shipping_id, success: function(data) { //Если все нормально var result = $.parseJSON(data); $('#total_with_shipping').empty().append(result.total); $('#total_with_shipping_title').empty().append(result.title); }, error: function(data) { //Если ошибка } }); return false; }); if (window.location.hash.substring(1) && (window.location.hash.substring(1)=='old_code' || window.location.hash.substring(1)=='new_password' || window.location.hash.substring(1)=='success_change_name' || window.location.hash.substring(1)=='success_change_address')) { $.magnificPopup.open({ items: { src: '/popup/'+window.location.hash.substring(1) }, type: 'ajax' }); } $('body').on('click', '.warn', function() { $(this).removeClass('warn'); }); /*** FASTCLICK ***/ FastClick.attach(document.body); /*** FORMS ***/ initForms(); /*** AJAX POPUP ***/ $('.js-ajax').magnificPopup({ type: 'ajax' }); /*** HEADER ***/ $('.header').each(function () { var _self = $(this), _nav = $('.nav', _self), body = $('body'); /*** TOGGLE NAVIGATION ***/ _nav.each(function () { $('ul', _nav).wrap("
"); }); _self.find('.wrapper').append(''); $('.toggle', _self).on('click', function () { body.addClass('nav-visible').on('click', function () { if ($(this).hasClass('nav-done')) { $(this).removeClass('nav-done'); setTimeout(function () { body.removeClass('nav-visible'); }, 500); } }); if (!$('body').is('.nav-done')) { setTimeout(function () { body.addClass('nav-done'); }, 20); } else { body.removeClass('nav-done'); setTimeout(function () { body.removeClass('nav-visible'); }, 500); } }); }); /*** JUMBOTRON ***/ $('.jumbotron').each(function () { $('.carousel', this).slick({ slidesToShow: 1, adaptiveHeight: true, arrows: true, autoplay: true, infinite: true, autoplaySpeed: 5000, responsive: [ { breakpoint: 768, settings: { autoplay: true } } ] }); }); /*** FILTER ***/ // FILTER new $('body').on('change', '.filter_form', function () { $('.filter_form').stop().submit(); }); $('body').on('submit','.filter_form', function () { $('#products').empty().html('
'); $.ajax({ url: "/catalog", //Адрес подгружаемой страницы type: "POST", //Тип запроса dataType: "html", //Тип данных data: $("#filter_form").serialize(), success: function(data) { //Если все нормально var result = $.parseJSON(data); $('#products').empty().html(result.products); $('#pr_qty').empty().html(result.qty); $('#pagin, #pagin_bottom').empty().html(result.pages); }, error: function(data) { //Если ошибка } }); return false; }); // end FILTER new $('body').on('click','.reset_keywords', function () { $('.top_search_block input').val(''); $('.filter_form').submit(); }); $('.filter').each(function () { $('.toggle', this).on('click', function () { $(this).toggleClass('open').siblings('form').slideToggle(400); }); $('.heading', this).on('click', function () { var entry = $(this).closest('.entry'), space = $('.space-hidden', entry); space.slideToggle(); entry.toggleClass('open'); if (entry.hasClass('open')) { space.find('[name^="filter_cat"]').removeAttr('disabled'); } else { space.find('[name^="filter_cat"]').attr('disabled', true); } $('.filter_form').submit(); console.log(space.find('[name^="filter_cat"]').is(':disabled')); }); }); $('.filter-link').on("click", function () { $('.filter-content').slideToggle(); }); $('body').on('click','.delete_soc', function () { var id = $(this).attr('data-id'); $.ajax({ url: "/profile/delete_soc", type: "POST", data: "id="+id, success: function (data) { $('p.fn-error').empty(); var result = jQuery.parseJSON(data); if (result.error) { $('p.fn-error').empty().html(result.error); } if (result.result) { $('span#soc_info_block').empty().html(result.result); } } }); return false; }); /*** ITEM CAROUSEL ***/ $('.block-item').each(function () { $('.slider-for', this).slick({ slidesToShow: 1, slidesToScroll: 1, asNavFor: '.slider-nav', prevArrow: '', nextArrow: '' }); $('.slider-nav', this).slick({ slidesToShow: 6, infinite: true, asNavFor: '.slider-for', vertical: true, adaptiveHeight: true, verticalSwiping: true, focusOnSelect: true, arrows: false, responsive: [ { breakpoint: 1200, settings: { slidesToShow: 5 } }, { breakpoint: 768, settings: { slidesToShow: 4 } }, { breakpoint: 568, settings: { vertical: false, verticalSwiping: false, slidesToShow: 5 } } ] }); }); $('.slider-for2').slick({ slidesToShow: 1, slidesToScroll: 1, asNavFor: '.slider-nav2', arrows: false, dots: false, touchMove: false, swipe: false, }); $('.slider-nav2').slick({ slidesToShow: 3, slidesToScroll: 1, asNavFor: '.slider-for2', dots: false, centerMode: true, focusOnSelect: true, arrows: false }); /*** TOGGLE SIZES ***/ $('.size-list').each(function () { $('.toggle', this).on('click', function () { var size_id = $(this).attr('data-id'); var link = $(this) $.ajax({ url: "/sizes/make_default", type: "POST", data: "id="+size_id+"&aj=1", success: function(data) { ////alert(data); } }); $(this).closest('li').toggleClass('active').siblings('li').removeClass('active'); $(this).addClass('hide'); $('.toggle').not(this).removeClass('hide'); $('.toggle_d').addClass('hide'); $(this).siblings('.toggle_d').removeClass('hide'); return false; }); }); $('.size-list').each(function () { $('.delete_size', this).on('click', function () { var link = $(this).attr('href'); var parent = $(this).parent('li'); $.ajax({ url: link, type: "POST", data: "aj=1", success: function(data) { parent.remove(); } }); return false; }); }); /*** RATE TOGGLE ***/ $('.rate-large').each(function () { $('.star', this).on('click', function () { $(this).siblings('input').val($(this).attr('data-value')); $(this).addClass('active').siblings('.star').removeClass('active').closest('.rate').addClass('hover'); return false; }); }); /*** COUNT ***/ $('.count').each(function () { var input = $('input', this), up = $('.up', this), down = $('.down', this); var id = input.attr('data-id'); input.keydown(function (e) { if ($.inArray(e.keyCode, [46, 8, 9, 27, 13, 110, 190]) !== -1 || (e.keyCode == 65 && e.ctrlKey === true) || (e.keyCode >= 35 && e.keyCode <= 39)) { update_cart(id, input.val()); return false; } if ((e.shiftKey || (e.keyCode < 48 || e.keyCode > 57)) && (e.keyCode < 96 || e.keyCode > 105)) { e.preventDefault(); } }); }); $('body').on('click', '.count .up', function(){ var input = $(this).siblings('label').find('input'); var id = input.attr('data-id'); if (+input.val() < 10000) { input.val(+input.val() + 1); update_cart(id, input.val()); } }); $('body').on('click', '.count .down', function(){ var input = $(this).siblings('label').find('input'); var id = input.attr('data-id'); if (+input.val() > 1) { input.val(+input.val() - 1); update_cart(id, input.val()); } }); $('body').on('change', '#use_bonuses', function(){ update_cart('', '', $(this).prop("checked")); }); $('body').on('click', '.delete_product_from_cart', function() { var id = $(this).attr('data-id'); update_cart(id, '', '', true); return false; }); /*** SHOWCASE ***/ $('.showcase').each(function () { $('.item', this).each(function () { var _for = $('.slider-for', this), _nav = $('.slider-nav'); $('.slider-for', this).slick({ adaptiveHeight: true, slidesToShow: 1, slidesToScroll: 1, asNavFor: _nav, arrows: false }); $('.slider-nav', this).slick({ slidesToShow: 4, infinite: true, asNavFor: _for, adaptiveHeight: true, variableWidth: true, focusOnSelect: true, prevArrow: '', nextArrow: '', centerMode: false, responsive: [ { breakpoint: 768, settings: { centerMode: true } } ] }); }); }); /*** TOP ***/ $('.top').each(function () { var _self = $(this), _toggle = $('.search', _self), _form = $('.form-line-search', _self); $('a', _toggle).on('click', function () { if ($(_form.is(":visible"))[0] ){ $.post("/main/params", { search: 0 }); } else { $.post("/main/params", { search: 1 }); } _form.slideToggle(); return false; }); $('.button', _form).on('click', function () { _form.slideUp(); }); }); /*** CART-DROPDOWN ***/ $('.cart-dropdown').each(function () { function handler(event) { var target = $(event.target); if (target.closest('.cart-dropdown').length === 0) { toggle(event); } } function toggle(e) { if (_cart.hasClass('active')) { _cart.removeClass('active'); _body.off('touchstart click', handler); _space.fadeOut(100); } else { _cart.addClass('active'); _body.on('touchstart click', handler); _space.fadeIn(100); } e.preventDefault(); } var _cart = $(this), _space = _cart.find('.space'), _body = $('body'); $('.link', this).on('click', toggle); }); if($('.pager').length){ $(window).on('keydown',function(e){ var keyCode = e.keyCode || e.which, arrow = {left: 37, up: 38, right: 39, down: 40 }; if (e.ctrlKey) { switch (keyCode) { case arrow.left: if($('.pager .prev a').length){ console.log('prev'); $('.pager .prev a')[0].click(); } break; case arrow.right: console.log('next'); if($('.pager .next a').length){ $('.pager .next a')[0].click(); } break; //... } } }); } }); /** * Обновление корзины */ function update_cart(id, qty, use_bonuses, delete_product) { $.ajax({ url: "/cart/update_cart", type: "POST", data: "ajax=1&id=" + id + "&qty=" + qty + "&use_bonuses=" + use_bonuses + "&delete_product=" + delete_product, success: function (data) { var res = jQuery.parseJSON(data); if ($('span#shopping_cart').length && res.shopping_cart) { $('span#shopping_cart').html(res.shopping_cart); } if ($('span#s_cart_main').length && res.cart) { $('span#s_cart_main .space').html(res.cart); $('span#s_cart_main .amount').html(res.qty); } if ($('span#s_cart').length && res.cart_constructor) { $('span#s_cart .space').html(res.cart_constructor); $('span#s_cart .amount').html(res.qty); } if($('.js-ajax').length) { $('.js-ajax').magnificPopup({ type: 'ajax' }); } } }); } /** * Forms initialization */ function initForms(scope) { if (typeof scope === 'undefined') { scope = document; } $('select', scope).selectric({ maxHeight: 200, disableOnMobile: false, responsive: true }); /*** CHECKBOX & RADIO ***/ $('label.checkbox:not(.inited), label.radiobox:not(.inited)').addClass('inited').children('input').after(''); $('.form-subscribe:not(.inited)', scope).on('submit', function () { var form = $(this); var email = form.find('input[name=email]').val(); $.ajax({ url: "/profile/add_newsletter", type: "POST", data: "email=" + email, success: function (data) { ////alert(data); var result = jQuery.parseJSON(data); if (result.error) { $.magnificPopup.open({ items: { src: '/profile/error_newsletter' }, type: 'ajax' }); $(this).addClass('inited'); } else { $.magnificPopup.open({ items: { src: '/profile/success_newsletter' }, type: 'ajax' }); form.find('input[name=email]').val(''); $(this).addClass('inited'); } } }); return false; }); $('.form-login:not(.inited)', scope).on('submit', function () { var form = $(this); var email = form.find('input[name=email]').val(); var password = form.find('input[name=password]').val(); $.ajax({ url: "/login/in", type: "POST", data: "aj=1&email=" + email + "&password=" + password, success: function (data) { var result = jQuery.parseJSON(data); if (result.error) { form.find('p.fn-error').empty().html(result.error); } else { window.location.assign("./"); } } }); return false; }); $('.form-feedback:not(.inited)', scope).on('submit', function () { var form = $(this); var email = form.find('input[name=email]').val(); var name = form.find('input[name=name]').val(); var text = form.find('textarea[name=text]').val(); $.ajax({ url: "/login/send_feedback", type: "POST", data: "aj=1&email=" + email + "&name=" + name + "&text=" + text, success: function (data) { var result = jQuery.parseJSON(data); if (result.error) { form.find('p.fn-error').empty().html(result.error); } else { $('.form-feedback').html(result.text); } } }); return false; }); $('.form-add-review:not(.inited)', scope).on('submit', function () { var form = $(this); var stars = form.find('input[name=radio-stars]:checked').val(); var review = form.find('textarea[name=review]').val(); var product_id = form.find('input[name=product_id]').val(); $.ajax({ url: "/profile/add_review", type: "POST", data: "stars=" + stars + "&review=" + review + "&product_id=" + product_id, success: function (data) { var result = jQuery.parseJSON(data); if (result.error) { form.find('p.fn-error').empty().html(result.error); } else { if (result.already) { $.magnificPopup.open({ items: { src: '/profile/success_already_review' }, type: 'ajax' }); } else { $.magnificPopup.open({ items: { src: '/profile/success_add_review' }, type: 'ajax' }); } $('a[data-id=review_link_'+product_id+']').remove(); } } }); return false; }); $('.form-registration:not(.inited)', scope).on('submit', function () { var form = $(this); var surname = form.find('input[name=surname]').val(); var name = form.find('input[name=name]').val(); var email = form.find('input[name=email]').val(); var password = form.find('input[name=password]').val(); var password_double = form.find('input[name=password_double]').val(); var newsletter = form.find('input[name=newsletter]').prop('checked'); $.ajax({ url: "/login/registration", type: "POST", data: "surname=" + surname + "&name=" + name + "&email=" + email + "&password=" + password + "&password_double=" + password_double + "&newsletter=" + newsletter, success: function (data) { var result = jQuery.parseJSON(data); if (result.error) { form.find('p.fn-error').empty().html(result.error); } else { /* window.location.assign("./profile"); */ $.magnificPopup.open({ items: { src: '/profile/success_registration' }, type: 'ajax' }); $.ajax({ url: "/main/get_header", //Адрес подгружаемой страницы type: "POST", //Тип запроса data: "aj=1", success: function(data) { //Если все нормально $('#h_top').empty().html(data); } }); $(this).addClass('inited'); } } }); return false; }); $('.form-new-password:not(.inited)', scope).on('submit', function () { var form = $(this); var password = form.find('input[name=password]').val(); var password_double = form.find('input[name=password_double]').val(); $.ajax({ url: "/profile/new_password", type: "POST", data: "password=" + password + "&password_double=" + password_double, success: function (data) { var result = jQuery.parseJSON(data); if (result.error) { form.find('p.fn-error').empty().html(result.error); } else { $.magnificPopup.open({ items: { src: '/profile/get_success_password_change' }, type: 'ajax' }); $(this).addClass('inited'); } } }); return false; }); $('.form-change-password:not(.inited)', scope).on('submit', function () { var form = $(this); var password = form.find('input[name=password]').val(); var new_password = form.find('input[name=new_password]').val(); var new_password_double = form.find('input[name=new_password_double]').val(); $.ajax({ url: "/profile/change_password", type: "POST", data: "password=" + password + "&new_password=" + new_password + "&new_password_double=" + new_password_double, success: function (data) { var result = jQuery.parseJSON(data); if (result.error) { form.find('p.fn-error').empty().html(result.error); } else { $.magnificPopup.open({ items: { src: '/profile/get_success_password_change' }, type: 'ajax' }); $(this).addClass('inited'); } } }); return false; }); $('.form-recovery:not(.inited)', scope).on('submit', function () { var form = $(this); var email = form.find('input[name=email]').val(); $.ajax({ url: "/login/recovery", type: "POST", data: "email=" + email, success: function (data) { var result = jQuery.parseJSON(data); if (result.error) { form.find('p.fn-error').empty().html(result.error); } else { $.magnificPopup.open({ items: { src: '/login/get_recovery_success' }, type: 'ajax' }); $(this).addClass('inited'); } } }); return false; }); $('.form-change-name:not(.inited)', scope).on('submit', function () { var form = $(this); var surname = form.find('input[name=surname]').val(); var name = form.find('input[name=name]').val(); var secondname = form.find('input[name=secondname]').val(); var phone = form.find('input[name=phone]').val(); var email = form.find('input[name=email]').val(); $.ajax({ url: "/profile/change_name", type: "POST", data: "email=" + email + "&surname=" + surname + "&name=" + name + "&secondname=" + secondname + "&phone=" + phone, success: function (data) { var result = jQuery.parseJSON(data); if (result.error) { form.find('p.fn-error').empty().html(result.error); } else { $.magnificPopup.open({ items: { src: '/profile/get_success_change_name' }, type: 'ajax' }); $('#data_line').empty().html(result.content); $(this).addClass('inited'); } } }); return false; }); $('.form-change-address:not(.inited)', scope).on('submit', function () { var form = $(this); var city = form.find('input[name=city]').val(); var street = form.find('input[name=street]').val(); var house = form.find('input[name=house]').val(); var flat = form.find('input[name=flat]').val(); var country_id = form.find('select[name=country_id]').val(); var postindex = form.find('input[name=postindex]').val(); $.ajax({ url: "/profile/change_address", type: "POST", data: "country_id=" + country_id + "&city=" + city + "&street=" + street + "&house=" + house + "&flat=" + flat + "&postindex=" + postindex, success: function (data) { var result = jQuery.parseJSON(data); if (result.error) { form.find('p.fn-error').empty().html(result.error); } else { $.magnificPopup.open({ items: { src: '/profile/get_success_change_address' }, type: 'ajax' }); $('#address_line').empty().html(result.content); $(this).addClass('inited'); } } }); return false; }); $('.form-add-gift-card:not(.inited)', scope).on('submit', function () { var form = $(this); var code = form.find('input[name=code]').val(); $.ajax({ url: "/profile/add_gift_card", type: "POST", data: "code=" + code +"&add_gift_card=1", success: function (data) { var result = jQuery.parseJSON(data); if (result.error) { form.find('p.fn-error').empty().html(result.error); } else { $.magnificPopup.open({ items: { src: '/profile/get_success_add_gift_card' }, type: 'ajax' }); $('#profile_regular_bonuses').empty().html(result.content); $('#top_bonuses').empty().html(result.content2); $(this).addClass('inited'); } } }); return false; }); $('body').on('click', 'a.recovery_link', function () { $.magnificPopup.open({items: {src: '/login/get_recovery'},type: 'ajax'}); return false; }); $('body').on('click', 'a.register_link', function () { $.magnificPopup.open({items: {src: '/login/get_register'},type: 'ajax'}); return false; }); $('body').on('click', '.size-title', function () { $('.video-link').hide(); $(this).closest('.current').children('.video-link').show(); var sizeBg = $('.size-bg').width(); if(sizeBg < 767){ $('.actions').hide(); } }); $(document).mouseup(function (e) { var container = $(".video-link"); if (container.has(e.target).length === 0){ container.hide(); $('.actions').show(); } }); $('.size-tabs').each(function () { var _tabs = $('.nav', this); $('.link:not(.square)', _tabs).on('click', function () { var _this = $(this), where = _this.attr('href').replace(/^.*#(.*)/, "$1"); $(this).closest('li').addClass('active').siblings('li.active').removeClass('active'); $('#' + where).each(function () { $(this).removeClass('model-tab-hidden'); var _vid = $('.video-link', this), _size = $('.size', this), _left = _this.offset().left, _a = 0; _a = $(window).width() - _left - _vid.width(); if (_a < 250) { _vid.addClass('swap'); } else { _vid.removeClass('swap'); } _vid.css('left', _left); _size.css('left', _left); }).siblings('.model-tab').addClass('model-tab-hidden'); setTimeout(function(){ if($('#size_form .model.model-tab:not(.model-tab-hidden) .size input').val() == 0){ $('#size_form .model.model-tab:not(.model-tab-hidden) .size input').val(''); } $('#size_form .model.model-tab:not(.model-tab-hidden) .size input').focus(); }, 100); return false; }); $('li', _tabs).eq(0).find('.link').trigger('click'); }); $('.sizes').each(function () { $('.scroll', this).perfectScrollbar(); }); //отправка формы с размерами $('body').on('click', '#save_size', function() { //проверяем заполнен ли input send = true; $('.size input').each(function () { if ($(this).val() <= 0) { $(this).closest('.model').addClass('error-wrap'); var thisId = $(this).closest('.model').attr('id'); $('.bottom .link[href="#' + thisId + '"]').addClass('error-wrap'); send = false; } }); if (send) { var c_size_id = $('input[name=c_size_id]').val(); $.magnificPopup.open({items: {src: '/sizes/add_name/'+c_size_id},type: 'ajax'}); ///$('form#size_form').submit(); } return false; }); $('body').on('click', '#add_size_name,#add_size_name_new', function() { form = $('form#size_form'); if ($(this).attr('id')=='add_size_name_new') { /////alert(); $('').appendTo(form); } $('input[name=size_name]').clone().appendTo(form); form.submit(); return false; }); if($('#size_form').length){ if($('#size_form .model.model-tab:not(.model-tab-hidden) .size input').val() == 0){ $('#size_form .model.model-tab:not(.model-tab-hidden) .size input').val(''); } $('#size_form .model.model-tab:not(.model-tab-hidden) .size input').focus(); $('#size_form .size input').on('keypress', function(e) { var thisInput = $(this); e = e || event; if (e.ctrlKey || e.altKey || e.metaKey) return; var chr = getChar(e, thisInput); // с null надо осторожно в неравенствах, т.к. например null >= '0' => true! // на всякий случай лучше вынести проверку chr == null отдельно if (chr == null) return; if (chr != ',' && chr != '.' && chr < '0' || chr > '9' || e.keyCode == 8) { return false; } setTimeout(function(){ var valThis = thisInput.val(); var thisIdmodal = thisInput.closest('.model').attr('id'); if(valThis == ""){ valThis = '0'; } $('.bottom .link[href="#' + thisIdmodal + '"] .number').text(valThis); if(valThis > 0) { thisInput.closest('.model').removeClass('error-wrap'); var thisId = thisInput.closest('.model').attr('id'); $('.bottom .link[href="#' + thisId + '"]').removeClass('error-wrap'); } }, 100); }); $('#size_form .model.model-tab .size input').blur(function(){ var thisVal = $(this).val(); if(thisVal == "") { $(this).val(0); } }); function getChar(event, thisInput) { if (event.which == null) { if (event.keyCode < 32) return null; return String.fromCharCode(event.keyCode) // IE } if (event.which != 0 && event.charCode != 0) { if (event.which < 32) return null; return String.fromCharCode(event.which) // остальные } setTimeout(function(){ var valThis = thisInput.val(); if(valThis == ""){ valThis = '0'; } var thisIdmodal = thisInput.closest('.model').attr('id'); $('.bottom .link[href="#' + thisIdmodal + '"] .number').text(valThis); }, 100); return null; // специальная клавиша } } if($('.size-tabs').length) { $(document).on('keydown', function(e) { if(e.which === 9 && e.shiftKey) { if( $('.size-tabs li.active').prev().length ) { $('.size-tabs li.active').prev().children('a').click(); }else { $('.size-tabs li:last-child').prev().children('a').click(); } }else { if(e.keyCode == 9) { if($('.size-tabs li.active + li > a').hasClass('reset') ) { $('.size-tabs li:first-child > a').click(); }else { $('.size-tabs li.active + li > a').click(); } } } }); } $('.modal-video > a, .modal-video .mfp-close').click(function(){ $('.modal-video-open video').stop(); $('.modal-video-open video')[0].currentTime = 0; $('.modal-video').removeClass('modal-video-open'); return false }); $(document).keyup(function( event ) { if (event.keyCode == 27) { $('.modal-video-open video').stop(); $('.modal-video-open video')[0].currentTime = 0; $('.modal-video').removeClass('modal-video-open'); } }); $('.video-link-popup').click(function(){ var hrefPopup = $(this).attr('href'); $(hrefPopup).addClass('modal-video-open'); $(hrefPopup).find('video')[0].play(); return false }); } $(function() { var widthPAge = $('body').width(); if(widthPAge > 1025){ $('.main-scroll').perfectScrollbar(); if($('.my-foto').length) { if(!$.fn.imagezoomsl){ $('.msg').show(); return; } else $('.msg').hide(); $('.my-foto').imagezoomsl({ innerzoommagnifier: true, zoomrange: [1, 10], cursorshadeborder: "5px solid #000", magnifiereffectanimate: "fadeIn", }); } } // if($('.content-comment').length){ // $('.content-comment').perfectScrollbar(); // } }); /** * Magnific Popup default settings */ $.extend(true, $.magnificPopup.defaults, { tClose: 'Закрыть (Esc)', closeMarkup: '
×
', tLoading: 'Загрузка…', gallery: { tPrev: 'Назад', tNext: 'Вперед', tCounter: '%curr% из %total%', arrowMarkup: '
', cursor: null }, image: { tError: 'Изображение не найдено.', cursor: null }, ajax: { tError: 'Контент не найден.' }, settings: { cache: false }, midClick: true, mainClass: 'mfp-fade', removalDelay: 300, callbacks: { ajaxContentAdded: function () { initForms(this.container); } } }); $(document).ready(function(){ $('.group-slide').hover(function(){ console.log('in'); }, function(){ console.log('out'); }); }); $(document).ready(function(){ $(".group-slide").mousemove(function(e){ var parentOffset = $(this).parent().offset(); var relativeXPosition = (e.pageX - parentOffset.left); //offset -> method allows you to retrieve the current position of an element 'relative' to the document var relativeYPosition = (e.pageY - parentOffset.top); //$(".heading").html("

X-Position: "+relativeXPosition+" | Y-Position: "+relativeYPosition+"

") var groupSlideWidth = $('.group-slide').width(); var groupSlideWidth1 = groupSlideWidth / 7; var groupSlideWidth2 = groupSlideWidth / 7 * 2; var groupSlideWidth3 = groupSlideWidth / 7 * 3; var groupSlideWidth4 = groupSlideWidth / 7 * 4; var groupSlideWidth5 = groupSlideWidth / 7 * 5; var groupSlideWidth6 = groupSlideWidth / 7 * 6; var groupSlideWidth7 = groupSlideWidth; console.log(groupSlideWidth6); console.log(groupSlideWidth7); if (0 < relativeXPosition && relativeXPosition < groupSlideWidth1) { $('.group-slide > *').removeClass('active'); $('.group-slide > *:nth-child(1)').addClass('active'); } if (groupSlideWidth1 < relativeXPosition && relativeXPosition < groupSlideWidth2) { $('.group-slide > *').removeClass('active'); $('.group-slide > *:nth-child(2)').addClass('active'); } if (groupSlideWidth2 < relativeXPosition && relativeXPosition < groupSlideWidth3) { $('.group-slide > *').removeClass('active'); $('.group-slide > *:nth-child(3)').addClass('active'); } if (groupSlideWidth3 < relativeXPosition && relativeXPosition < groupSlideWidth4) { $('.group-slide > *').removeClass('active'); $('.group-slide > *:nth-child(4)').addClass('active'); } if (groupSlideWidth4 < relativeXPosition && relativeXPosition < groupSlideWidth5) { $('.group-slide > *').removeClass('active'); $('.group-slide > *:nth-child(5)').addClass('active'); } if (groupSlideWidth5 < relativeXPosition && relativeXPosition < groupSlideWidth6) { $('.group-slide > *').removeClass('active'); $('.group-slide > *:nth-child(6)').addClass('active'); } if (groupSlideWidth6 < relativeXPosition && relativeXPosition < groupSlideWidth7) { $('.group-slide > *').removeClass('active'); $('.group-slide > *:nth-child(7)').addClass('active'); } }).mouseout(function(){ }); }); function validateOrder() { if (!$('#postindex').val()) { $('#postindex').addClass('warn').focus(); return false; } if (!$('#flat').val()) { $('#flat').addClass('warn').focus(); return false; } if (!$('#street').val()) { $('#street').addClass('warn').focus(); return false; } if (!$('#city').val()) { $('#city').addClass('warn').focus(); return false; } if (!$('#email').val()) { $('#email').addClass('warn').focus(); return false; } if (!$('#phone').val()) { $('#phone').addClass('warn').focus(); return false; } if (!$('#name').val()) { $('#name').addClass('warn').focus(); return false; } if (!$('#surname').val()) { $('#surname').addClass('warn').focus(); return false; } if ($('.selectric .label').text() == 'Страна') { $('.selectric-input').addClass('warn'); $('.selectric-responsive').addClass('selectric-open'); return false; } return true; }