(function(){ var $ = jQuery; var body = $("body"); var navOpen = $(".nav-open"); var navMenu = $("header nav"); var filtersBtn = $(".filters"); var filtersCont = $(".filters_container"); var isScrolled = false; var isPreScrolled = false; var lastScrollTop = 0; var navOpened = false; var filtersOpened = false; var correctHeader = function(){ let scrollTop = $(window).scrollTop(); let windowWidth = $(window).width(); if(windowWidth <= 767){ if( isPreScrolled ){ $(body).removeClass("prescrolled"); isPreScrolled = false; } if( isScrolled ){ $(body).removeClass("scrolled"); isScrolled = false; } } else { if( scrollTop < 300 ){ if( lastScrollTop < scrollTop || scrollTop < 10 ){ if( isPreScrolled ){ $(body).removeClass("prescrolled"); isPreScrolled = false; } if( isScrolled ){ $(body).removeClass("scrolled"); isScrolled = false; } } } else { if( !isPreScrolled ){ $(body).addClass("prescrolled"); isPreScrolled = true; } if( lastScrollTop > scrollTop ){ if( !isScrolled ){ $(body).addClass("scrolled"); isScrolled = true; } } else { if( isScrolled ){ $(body).removeClass("scrolled"); isScrolled = false; } } } } lastScrollTop = scrollTop; } //$(window).on("scroll load", correctHeader); var openMenu = function(){ if(navOpened){ $(navMenu).removeClass('open'); $(".nav-open").html(''); navOpened = false; } else { $(navMenu).addClass('open'); $(".nav-open").html(''); navOpened = true; } } $(navOpen).on("click", openMenu); var toggleFiltersBar = function(){ if(filtersOpened){ $(filtersCont).hide(); $(filtersBtn).html($(filtersBtn).attr("data-close-text") + ' '); filtersOpened = false; $(".tag_item").removeClass('active'); filterByTags(); } else { $(filtersCont).show(); $(filtersBtn).html($(filtersBtn).attr("data-open-text") + ' '); filtersOpened = true; } } $(filtersBtn).on("click", toggleFiltersBar); if( $("ul.slider").length ) $("ul.slider").lightSlider({ autoWidth: false, item: 1, auto:true, loop: true, adaptiveHeight:false, pause:7000, speed:1000, pager: false, gallery: true }); $(".booking_people").on("click", "label", function(){ $(".booking_people label").removeClass("active"); $(this).addClass("active"); if( $(this).find("input").val() == 5 ){ $(".booking_people_custom").show(); } else { $(".booking_people_custom").hide(); $(".booking_people_custom").find("option[value='5']").prop("selected", true); } }); $(".booking_message").on("click focus", function(){ $(this).css("height", "96px"); }); //$('.phone').mask('(000) 000-0000', {placeholder: "(___) ___-____"}); var subscribePixel = false; var subscribe = function(){ if( !subscribePixel ){ fbq('track', 'Subscribe'); subscribePixel = true; } $(".subscribe_err").hide(); $(".subscribe_success").hide(); var email = $(".subscribe_email").val(); if( email != '' ){ if( validateEmail( email ) ){ $.ajax({ method: "GET", url: "/site/subscribe", dataType: "json", data: { subscribe: 1, email: email } }) .done(function( data ) { if( data.success == 1 ){ $(".subscribe_success").show(); $(".subscribe_email").val(''); } else { $(".subscribe_err").html( data.msg ); $(".subscribe_err").show(); } }).fail(function(){ $(".subscribe_err").html( subscribe_err.unexpected_err ); $(".subscribe_err").show(); }); } else { $(".subscribe_err").html( subscribe_err.incorrect_err ); $(".subscribe_err").show(); } } else { $(".subscribe_err").html( subscribe_err.empty_err ); $(".subscribe_err").show(); } } $(".subscribe_btn").on("click", function(e){ e.preventDefault(); subscribe(); }); $(".subscribe_email").on("keyup", function(e){ if( e.keyCode == 13 ) subscribe(); }); var changeAfishaDate = function(){ var prev_month = (current_mm - 1) >= 1 ? (current_mm - 1) : 12; var next_month = (current_mm + 1) <= 12 ? (current_mm + 1) : 1; $(".curr_month").html( months[current_mm] + ', ' + current_yy ); $(".prev_month").html( ' ' + months_short[prev_month] ); $(".next_month").html( months_short[next_month] + ' ' ); if( current_yy < max_yy || ( current_yy == max_yy && current_mm < max_mm ) ){ $(".next_month").removeClass("disabled"); } else { $(".next_month").addClass("disabled"); } $(".articles").css("visibility", "hidden"); $(".articles_loading").css("display", "inline-block"); $(".articles_loading_error").hide(); $(".articles_empty").hide(); $.ajax({ method: "GET", url: "/site/getafisha2", dataType: "json", data: { yy: current_yy, mm: current_mm } }).done(function(data){ $(".articles_loading").hide(); if( data["result"] == 1 ){ $(".articles").html(data['content']); fixAfisha(); filterByTags(); if( data['content'] != '' ){ $(".articles").css("visibility", "visible"); } else { $(".articles_empty").css("display", "inline-block"); } } else { $(".articles_loading_error").css("display", "inline-block"); } }).fail(function(){ $(".articles_loading").hide(); $(".articles_loading_error").css("display", "inline-block"); }); } $(".prev_month").on("click", function(){ var year = current_yy; var month = current_mm - 1; if( month < 1 ){ month = 12; year--; } current_yy = year; current_mm = month; changeAfishaDate(); }); $(".next_month").on("click", function(){ if( $(this).hasClass("disabled") ) return false; var year = current_yy; var month = current_mm + 1; if( month > 12 ){ month = 1; year++; } current_yy = year; current_mm = month; changeAfishaDate(); }); var replaceElementTag = function(targetSelector, newTagString) { $(targetSelector).each(function(){ var newElem = $(newTagString, {html: $(this).html()}); $.each(this.attributes, function() { newElem.attr(this.name, this.value); }); $(this).replaceWith(newElem); }); } var filterByTags = function(){ $(".articles_empty").hide(); var tags = []; $(".tag_item.active").each(function(){ tags.push($(this).attr("data-id")); }); var haveopened = 0; $(".afishaItem").each(function(){ let haveall = true; for( let i in tags ){ let tag = tags[i]; let attr = $(this).attr('data-tag-'+tag); if (typeof attr === typeof undefined || attr === false) { haveall = false; } } if( haveall ){ haveopened = 1; $(this).removeClass("hidden"); replaceElementTag($(this), "
"); } else { $(this).addClass("hidden"); replaceElementTag($(this), ""); } }); if( haveopened == 0 ){ $(".articles_empty").css("display", "inline-block"); } } $(".tag_item").on("click", function(e){ e.preventDefault(); if( $(this).hasClass("active") ) $(this).removeClass("active"); else $(this).addClass("active"); filterByTags(); }); var bookingform = function(){ var price = $("#zona").find("option:selected").attr("data-price"); var freeplace = $("#zona").find("option:selected").attr("data-freeplace"); var not_in_7_days = $("#bookingform").hasClass("not_in_7_days"); var booking_buttons = ''; var place_count_radio = $(".place_count:checked").val(); if( place_count_radio == 5 ){ var place_count = $(".booking_people_custom").val(); } else { var place_count = place_count_radio; } var selected_table = $("#bookingformzonahidden").length; var total_price = price * place_count; if( price > 0 ){ if( not_in_7_days || selected_table ){ booking_buttons += ''; } else { booking_buttons += ''; booking_buttons += ''; } } else { booking_buttons += ''; } $(".booking_buttons").html(booking_buttons); } $("#zona").on("change", function(){ bookingform(); }); $(".place_count").on("change", function(){ bookingform(); }); $(".booking_people_custom").on("change", function(){ bookingform(); }); if( $("#bookingform").length ) bookingform(); var validateBooking = function(){ $(".errors").html(''); if( $("#bookingform").hasClass("disabledform") ){ return false; } if( !$("#book_name").val() || !$("#book_email").val() || !$("#book_phone").val() ){ $(".errors").html('
'+ lang_texts['required_fields'] +'
'); scrollTo("#booking", 700); return false; } var freeplace = parseInt($("#zona").find("option:selected").attr("data-freeplace")); var booking_buttons = ''; var place_count_radio = $(".place_count:checked").val(); if( place_count_radio == 5 ){ var place_count = $(".booking_people_custom").val(); } else { var place_count = place_count_radio; } if( place_count > freeplace ){ $(".errors").html('
'+ lang_texts['freeplace_err'] +': '+freeplace+'
'); scrollTo("#booking", 700); return false; } return true; } var clickedOnBookButton = false; $("#bookingform").on("submit", function(){ if( !clickedOnBookButton && !getCookie('clicked_book_button_'+event_date_id) ){ fbq('trackCustom', 'ClickedOnBookButton'); clickedOnBookButton = true; setCookie('clicked_book_button_'+event_date_id, 1, 30); } if( !validateBooking() ){ return false; } else { return true; } }); var archive_page = 1; jQuery(".load_more_archive").on("click", function(e){ e.preventDefault(); jQuery(this).hide(); jQuery(".loading_gif").show(); archive_page++; jQuery.ajax({ method: "GET", url: "/site/archive", dataType: "json", data: { get_archive: 1, archive_page: archive_page, date: media_search_date, keyword: media_search_keyword } }) .success(function( data ) { jQuery(".archivelist").append( data.html ); jQuery(".loading_gif").hide(); if( archive_page == max_archive_pages ){ jQuery(".load_more_archive").hide(); } else { jQuery(".load_more_archive").show(); } }).fail(function(){ jQuery(".loading_gif").hide(); archive_page--; }); }); if( jQuery.datepicker ){ jQuery.datepicker.regional['ru'] = { closeText: 'Закрыть', prevText: '<Пред', nextText: 'След>', currentText: 'Сегодня', monthNames: ['Январь','Февраль','Март','Апрель','Май','Июнь', 'Июль','Август','Сентябрь','Октябрь','Ноябрь','Декабрь'], monthNamesShort: ['Янв','Фев','Мар','Апр','Май','Июн', 'Июл','Авг','Сен','Окт','Ноя','Дек'], dayNames: ['воскресенье','понедельник','вторник','среда','четверг','пятница','суббота'], dayNamesShort: ['вск','пнд','втр','срд','чтв','птн','сбт'], dayNamesMin: ['Вс','Пн','Вт','Ср','Чт','Пт','Сб'], dateFormat: 'yy-mm-dd', firstDay: 1, isRTL: false }; jQuery.datepicker.regional['en'] = { dateFormat: 'yy-mm-dd', firstDay: 1, isRTL: false }; $( ".datepicker" ).datepicker($.datepicker.regional[ datepickerlang ]); } var muz_page=1; jQuery(".load_more_muz").on("click", function(e){ e.preventDefault(); jQuery(this).hide(); jQuery(".loading_gif").show(); muz_page++; jQuery.ajax({ method: "GET", url: "/musicians/index", dataType: "json", data: { get_muz: 1, muz_page: muz_page, char: muz_char, keyword: muz_keyword, filters: muz_filters } }) .success(function( data ) { jQuery(".muzlist").append( data.html ); jQuery(".loading_gif").hide(); if( muz_page == max_muz_pages ){ jQuery(".load_more_muz").hide(); } else { jQuery(".load_more_muz").show(); } }).fail(function(){ jQuery(".loading_gif").hide(); muz_page--; }); }); var feed_page = 1; jQuery(".load_more_feed").on("click", function(e){ e.preventDefault(); jQuery(this).hide(); jQuery(".loading_gif").show(); feed_page++; jQuery.ajax({ method: "GET", url: "/site/feedback", dataType: "json", data: { get_feedback: 1, feed_page: feed_page } }) .success(function( data ) { jQuery(".feedslist").append( data.html ); jQuery(".loading_gif").hide(); if( feed_page == max_feed_pages ){ jQuery(".load_more_feed").hide(); } else { jQuery(".load_more_feed").show(); } }).fail(function(){ jQuery(".loading_gif").hide(); feed_page--; }); }); $(".afishaItem").on("click", function(){ if( gtag ){ gtag('event', 'view_item', { 'event_label' : 'View afisha item' }); } }); var afishaImages = $(".afishaItem .img"); var fixAfishaTimeout; var fixAfisha = function(){ $(afishaImages).each(function(){ $(this).css("height", $(this).width() + "px"); }); } fixAfisha(); $(window).on("load resize", function(){ clearTimeout(fixAfishaTimeout) fixAfishaTimeout = setTimeout(fixAfisha, 100) }); //setInterval(fixAfisha, 5000) // Facebook events var initiateCheckout = false; var event_id = $("#event_id").val(); var event_date_id = $("#event_date_id").val(); $("#bookingform").on("keydown change submit", function(){ if( !initiateCheckout && !getCookie('initiate_checkout_'+event_date_id) ){ fbq('track', 'InitiateCheckout'); fbq('track', 'AddToCart', { content_type: 'product', content_ids: event_id + '_' + event_date_id }); initiateCheckout = true; setCookie('initiate_checkout_'+event_date_id, 1, 30); } }); jQuery(document).on("click", ".tableName", function(){ if( $(".book_step_2").length > 0 ) return false; if( $(this).closest(".sxema_attr_table").attr("data-busy") == 1 ) return false; var name = $(this).attr("data-name"); $("#selected_table_text").find("span").html(name); $("#selected_table_text").find("input").val(name); $("#selected_table_text").css("display", "inline-block"); $("#cancel_select_table").css("display", "inline-block"); $("#select_table").css("display", "none"); //$(".booking_people").css("display", "none"); //$(".place_count").prop("disabled", true); //$(".booking_people_custom").prop("disabled", true); $(".jquery-modal").remove(); $("body").css("overflow", "visible"); var table_char = name.substr(0,1); jQuery("#zona").find("option").each(function(){ if( jQuery(this).attr("data-tablename") == table_char ){ jQuery("#zona").val( jQuery(this).attr("value") ); jQuery("#zona").prop("disabled", true); jQuery("#zona").parent().append(''); } }); bookingform(); }); jQuery("#cancel_select_table").on("click", function(e){ e.preventDefault(); $("#selected_table_text").find("span").html(""); $("#selected_table_text").find("input").val(""); $("#selected_table_text").css("display", "none"); $("#cancel_select_table").css("display", "none"); $("#select_table").css("display", "inline-block"); //$(".booking_people").css("display", "inline-block"); //$(".place_count").prop("disabled", false); //$(".booking_people_custom").prop("disabled", false); jQuery("#zona").prop("disabled", false); jQuery("#bookingformzonahidden").remove(); bookingform(); }); jQuery(".next_book_step").on("click", function(e){ e.preventDefault(); nextBookStep(); }); jQuery(".prev_book_step").on("click", function(e){ e.preventDefault(); prevBookStep(); }); jQuery(".book_step").find("input").on("keyup", function(e){ if(e.keyCode == 13){ e.preventDefault(); nextBookStep(); } }) jQuery(".event_pay_method").on("click", function(){ book_config["payment_method"] = $(this).attr("data-method") $(".event_pay_method").removeClass("active") $(this).addClass("active") if( $(this).attr("data-method") == 'online' && book_config['sxema'] ){ $(".zonas").css("display", "none") $(".places_count_div").css("margin-top", "-3px") } else { $(".zonas").css("display", "inline-block") $(".places_count_div").css("margin-top", "0px") } nextBookStep(); }) jQuery(".places_group").on("click", function(){ if( jQuery(this).hasClass("disabled") ) return false; jQuery(".places_group").removeClass("active"); jQuery(this).addClass("active"); if( jQuery(this).attr("data-value") == 5 ){ jQuery(".places_group_more").css("display", "inline-block"); } else { jQuery(".places_group_more").css("display", "none"); jQuery(".places_group_more").find("select").val(5); } }) jQuery(".zonas").find("label").on("click", function(){ jQuery(".zonas").find("label").removeClass("active"); jQuery(".zonas").find("label").find("i").removeClass("fa-check-square").addClass("fa-square") jQuery(this).addClass("active"); jQuery(this).find("i").removeClass("fa-square").addClass("fa-check-square") }) if( jQuery("#input_time").find("option[data-selected='1']").length ){ let selected_option = jQuery("#input_time").find("option[data-selected='1']") jQuery(selected_option).attr("data-show", "1") jQuery(selected_option).prev().attr("data-show", "1") jQuery(selected_option).prev().prev().attr("data-show", "1") jQuery(selected_option).prev().prev().prev().attr("data-show", "1") jQuery(selected_option).prev().prev().prev().prev().attr("data-show", "1") jQuery(selected_option).prev().prev().prev().prev().prev().attr("data-show", "1") jQuery(selected_option).prev().prev().prev().prev().prev().prev().attr("data-show", "1") jQuery(selected_option).prev().prev().prev().prev().prev().prev().prev().attr("data-show", "1") jQuery(selected_option).prev().prev().prev().prev().prev().prev().prev().prev().attr("data-show", "1") jQuery(selected_option).next().attr("data-show", "1") jQuery(selected_option).next().next().attr("data-show", "1") jQuery(selected_option).next().next().next().attr("data-show", "1") jQuery(selected_option).next().next().next().next().attr("data-show", "1") jQuery(selected_option).next().next().next().next().next().attr("data-show", "1") jQuery(selected_option).next().next().next().next().next().next().attr("data-show", "1") jQuery(selected_option).next().next().next().next().next().next().next().attr("data-show", "1") jQuery(selected_option).next().next().next().next().next().next().next().next().attr("data-show", "1") jQuery("#input_time").find("option[data-show!='1']").each(function(){ jQuery(this).remove() }) } fixBookSxema() $(window).on("load resize", function(){ fixBookSxema() }); buttons_texts(); window.onhashchange = function(hash) { let tb = hash.newURL.split("#tab")[1] if( !tb ) tb = 0; let cc = 0; if( book_step > tb ){ while( book_step > tb ){ prevBookStep(1); cc++; if( cc > 10 ) break; } } else { while( book_step < tb ){ nextBookStep(1); cc++; if( cc > 10 ) break; } } } jQuery(".book_step_2").find(".sxema_attr_table").on("click", function(){ let tableName = jQuery(this).find(".tableName").attr("data-name") let busy = jQuery(this).attr("data-busy") let unavailable = jQuery(this).attr("data-unavailable") || 0 let min_places = jQuery(this).attr("data-min-places") let max_places = jQuery(this).attr("data-max-places") jQuery(".book_step_2").find(".sxema_attr_table").removeClass("active") jQuery(".book_step_2").find(".sxema_attr_table").find(".table_name_inp").each(function(){ $(this).html( $(this).parent().attr("data-name") ) }); if( busy == 0 ){ if( unavailable == 0 ){ jQuery(this).addClass("active") jQuery(this).find(".table_name_inp").html(''); book_config['selected_place'] = tableName; let cnt = parseInt(jQuery(".places_group.active").attr("data-value")); if( cnt == 5 ) cnt = parseInt(jQuery("#input_places_more").val()); let table_char = book_config['selected_place'].substr(0,1); let price = 0; jQuery(".zonas").find("label").each(function(){ if( jQuery(this).attr("data-tablename") == table_char ){ price = parseInt(jQuery(this).attr("data-price")); } }) guests_count(min_places, max_places) showError(book_config['success']['selected_table'] + ' ' + tableName + '. ' + ( min_places != 0 ? ' ' + book_config['texts']['min_places'] + ': ' + min_places : '' ) + ( max_places != 0 ? ' ' + book_config['texts']['max_places'] + ': ' + max_places : '' ) /*+ book_config['texts']['total'] + ' '+ cnt + ' x ' + price + book_config['texts']['rub'] + ' = '+ (price * cnt) + book_config['texts']['rub']*/, book_step, 1); nextBookStep(); } else { book_config['selected_place'] = null; showError(book_config['error']['unavailable_table'], book_step); } } else { book_config['selected_place'] = null; showError(book_config['error']['busy_table'], book_step); } }); jQuery(document).on("click", ".close_sxema_prices", function(e){ e.preventDefault(); jQuery(".sxema_prices").remove(); }) jQuery(document).on("click", ".book_step_2", function(e){ e.preventDefault(); jQuery(".sxema_prices").remove(); }) jQuery(".book_step_2").on("scroll", function(){ jQuery(".sxema_bottom").remove() clearInterval(fadeininterval) }) jQuery(".event_pay_method_2").on("click", function(){ jQuery(".book_step_2").hide() jQuery(".next_book_step").show() jQuery(".step_3_num").html("2") guests_count(0,0) }) jQuery(".event_pay_method_1").on("click", function(){ if( book_config['sxema'] ){ jQuery(".book_step_2").show() jQuery(".step_3_num").html("3") } else { jQuery(".book_step_2").hide() jQuery(".step_3_num").html("2") } jQuery(".next_book_step").show() }) })(); var scrollTo = function(elem, time){ $([document.documentElement, document.body]).animate({ scrollTop: $( ( elem.indexOf('#') == 0 || elem.indexOf('.') == 0 ) ? elem : "#"+elem).offset().top }, time || 1400); } var openrules = function(){ $(".more_rules_link").hide(); $(".more_rules").show(); } function setCookie(name,value,days) { var expires = ""; if (days) { var date = new Date(); date.setTime(date.getTime() + (days*24*60*60*1000)); expires = "; expires=" + date.toUTCString(); } document.cookie = name + "=" + (value || "") + expires + "; path=/"; } function getCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } return null; } function eraseCookie(name) { document.cookie = name+'=; Max-Age=-99999999;'; } var fadein = 0; var fadeininterval; var guests_count = function(min_places, max_places){ let f=0; let sld = jQuery("#input_places_more").val() for( let i=1; i<=15; i++ ){ if( ( min_places > 0 && i < min_places ) || ( max_places > 0 && i > max_places) ){ jQuery("#input_places_more").find("option[value='" + i + "']").prop("disabled", true) } else { jQuery("#input_places_more").find("option[value='" + i + "']").prop("disabled", false) if( f == 0 ) f = i; } } if( min_places <= sld && ( max_places == 0 || max_places >= sld ) ){ jQuery("#input_places_more").find("option[value='" + sld + "']").prop("selected", true) } else { if( min_places <= 2 && ( max_places == 0 || max_places >= 2 ) ){ jQuery("#input_places_more").find("option[value='" + 2 + "']").prop("selected", true) } else { jQuery("#input_places_more").find("option[value='" + f + "']").prop("selected", true) } } } var nextBookStep = function(wihtouthistory){ if( !validate_book_step(book_step) ) return false; if( book_submit(book_step) ){ submit_form(); return false; } if( book_step == 0 && book_config['payment_method'] != 'online' ){ book_step = 2; } else { book_step++; } let max_num = parseInt( $(".book_steps").find(".book_step").length ) - 1; if( book_step > max_num ) book_step = max_num; if( book_config["pay_without_sxema"] == 1 && book_step ==1 ){ book_step = 2; } buttons_texts(); let left = 100 * book_step * -1; if( !wihtouthistory ) window.history.pushState('tab' + book_step, 'Бронирование Шаг ' + (book_step + 1), window.location.href.split('#')[0] + '#tab'+book_step); if( book_step == 1 && book_config['payment_method'] == 'online' ){ jQuery(".sxema_prices").html(jQuery(".zonas").html() + '
'+ book_config['texts']['continue'] +'
').show() } if( book_step == 1 && parseInt($(".book_step_2").width()) <= 767 ){ jQuery(".sxema_bottom").show() setTimeout(function(){ jQuery(".sxema_bottom").remove() }, 3000) fadeininterval = setInterval(function() { if( fadein ){ fadein = 0; jQuery(".sxema_bottom").fadeIn() } else { fadein = 1; jQuery(".sxema_bottom").fadeOut() } }, 500); } // if( book_step == 1 ){ // // $(".sxema_attr_table").each(function(){ // // if( $(this).hasClass("unavailable_table") ){ // $(this).removeAttr("data-unavailable") // $(this).removeClass("unavailable_table") // } // // }) // // let cnt = parseInt(jQuery(".places_group.active").attr("data-value")); // if( cnt == 5 ) // cnt = parseInt(jQuery("#input_places_more").val()); // // $(".sxema_attr_table").each(function(){ // // if( !$(this).hasClass("busy_table") ){ // // let max_places = $(this).attr("data-max-places") // let min_places = $(this).attr("data-min-places") // // if( ( min_places > 0 && min_places > cnt ) || ( max_places > 0 && max_places < cnt ) ){ // // $(this).attr("data-unavailable", "1") // $(this).addClass("unavailable_table") // // if( $(this).hasClass("active") ){ // $(this).removeClass("active") // $(this).find(".table_name_inp").html( $(this).find(".tableName").attr("data-name") ) // book_config["selected_place"] = null; // } // // } // // } // // }) // // } if( book_step == 1 && book_config['selected_place'] ) showError(book_config['success']['selected_table'] + ' ' + book_config['selected_place'], book_step, 1); $(".book_step_" + (book_step + 1)).scrollTop(0) $(".book_steps").css("left", left + '%'); } var prevBookStep = function(wihtouthistory){ if( book_step == 2 && book_config['payment_method'] != 'online' ){ book_step = 0; } else { book_step--; } if( book_config["pay_without_sxema"] == 1 && book_step == 1 ){ book_step = 0; } let minStep = 0; if( book_config['payment_method'] == 'free' || book_config['not_in_7_days'] || book_config['only_online'] || book_config['only_online'] ) minStep = 1; if( book_step < minStep ){ window.location = '/event/index/' + book_config['event_id'] + '/' + book_config['eventDate_id']; return false; } let left = 100 * book_step * -1; buttons_texts(); if( !wihtouthistory ) window.history.pushState('tab' + book_step, 'Бронирование Шаг ' + (book_step + 1), window.location.href.split('#')[0] + '#tab'+book_step); if( book_step == 1 && book_config['selected_place'] ) showError(book_config['success']['selected_table'] + ' ' + book_config['selected_place'], book_step, 1); if( book_step == 1 && book_config['payment_method'] == 'online' ){ } else { jQuery(".sxema_prices").hide() } if( book_step == 1 && parseInt($(".book_step_2").width()) <= 767 ){ } else { clearInterval(fadeininterval) jQuery(".sxema_bottom").hide() } $(".book_step_" + (book_step + 1)).scrollTop(0) $(".book_steps").css("left", left + '%'); } var gotoBookStep = function(step){ book_step = step; let max_num = parseInt( $(".book_steps").find(".book_step").length ) - 1; if( book_step > max_num ) book_step = max_num; if( book_step < 0 ) book_step = 0; let left = 100 * book_step * -1; $(".book_steps").css("left", left + '%'); } var hideError = function(){ $(".event_book_error").html("").css("display", "none") } var showError = function(msg, step, success){ if( success ) $(".book_step_" + ( step+1 )).find(".event_book_error").addClass("error_success") else $(".book_step_" + ( step+1 )).find(".event_book_error").removeClass("error_success") $(".book_step_" + ( step+1 )).find(".event_book_error").html(msg).css("display", "block").fadeOut(200).fadeIn(200).fadeOut(200).fadeIn(200).fadeOut(200).fadeIn(200).fadeOut(200).fadeIn(200) $(".book_step_" + ( step + 1 )).animate({scrollTop:0}, 500, 'swing', function() { }); } var validate_book_step = function(step){ hideError(); if( step == 0 ){ if( book_config['payment_method'] ) return true; else { showError(book_config['error']['payment_method'], step); return false; } } if( step == 2 ){ let inputs = ['name', 'phone', 'email']; for( let i in inputs ){ if( $("#input_" + inputs[i]).val() === '' ){ showError(book_config['error']['fill_input'] + ' "' + $("#input_" + inputs[i]).closest(".input").find("label").html() + '"', step); return false; } } if( !validateEmail( $("#input_email").val() ) ){ showError(book_config['error']['invalid_email'], step); return false; } if( (book_config['payment_method'] != 'online' || book_config["pay_without_sxema"] ) && $(".zonas").find(".active").length == 0 ){ showError(book_config['error']['invalid_place'], step); return false; } return true; } if( step == 1 ){ jQuery(".sxema_prices").remove(); if( !book_config['selected_place'] ){ showError(book_config['error']['invalid_exact_place'], step); return false; } return true; } } function buttons_texts(){ if( typeof book_step === 'undefined' ) return false; if( book_step == 0 ){ $(".next_book_step").html( ( book_config['payment_method'] == 'online' ? book_config["texts"]["select_place"] : book_config["texts"]["fill_info"] ) + ' ') } if( book_step == 2 ){ if( book_config["payment_method"] == 'online' ){ $(".next_book_step").html(book_config["texts"]["pay_and_book"] + ' ') } else { $(".next_book_step").html(book_config["texts"]["book"] + ' ') } } if( book_step == 1 ){ $(".next_book_step").html(( book_config["only_form"] ? ( book_config["payment_method"] == 'online' ? book_config["texts"]["pay_and_book"] : book_config["texts"]["book"] ) : book_config["texts"]["fill_info"] ) + ' ') } } var validateEmail = function(email) { var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; return re.test(email); } function fixBookSxema(){ let sxema_width = 598; let sxema_height = 1235; let sxema_width_rotated = 1235; let sxema_height_rotated = 598; if( typeof book_config !== 'undefined' && book_config.sxema_type == 2 ){ sxema_height = 664; sxema_width_rotated = 664; } let container_width = parseInt( $(".book_step_2").width() ) let container_height = parseInt( $(".book_step_2").height() ) - parseInt( $(".book_step_2").find("h1").height() ) - parseInt( $(".book_step_2").find("h1").css("margin-bottom") ) // Sxema size option 1 let new_container_width_1 = container_width; let new_container_height_1 = Math.round( new_container_width_1 * sxema_height / sxema_width ) if( new_container_height_1 > container_height && container_width > 767 ){ new_container_height_1 = container_height; new_container_width_1 = Math.round( new_container_height_1 * sxema_width / sxema_height ) } let sq1 = new_container_width_1 * new_container_height_1; // Sxema size option 2 let new_container_width_2 = container_width; let new_container_height_2 = Math.round( new_container_width_2 * sxema_height_rotated / sxema_width_rotated ) if( new_container_height_2 > container_height && container_width > 767 ){ new_container_height_2 = container_height; new_container_width_2 = Math.round( new_container_height_2 * sxema_width_rotated / sxema_height_rotated ) } let sq2 = new_container_width_2 * new_container_height_2; if( container_width > 767 && sq2 > sq1 ){ // rotate //$(".book_step").find(".sxema_fixed").css("zoom", new_container_width_2 / sxema_width_rotated ) $(".book_step").find(".sxema_fixed").css("zoom", 1) $(".book_step").find(".sxema_fixed").css("transform", "rotate(-90deg) scale("+ (new_container_width_2 / sxema_width_rotated) +")") $(".book_step").find(".sxema_fixed").css("transform-origin", "top left") $(".book_step").find(".sxema_fixed").css("margin-top", new_container_height_2 + "px") $(".sxema_attr_table").each(function(){ $(this).find(".table_name_inp").css("transform", "rotate(90deg)") $(this).find(".table_name_inp").css("text-align", "left") }) } else { //$(".book_step").find(".sxema_fixed").css("zoom", new_container_width_1 / sxema_width ) $(".book_step").find(".sxema_fixed").css("zoom", 1 ) $(".book_step").find(".sxema_fixed").css("transform", "rotate(0deg) scale("+ ( new_container_width_1 / sxema_width ) +")") $(".book_step").find(".sxema_fixed").css("transform-origin", "top left") $(".book_step").find(".sxema_fixed").css("margin-top", "0px") $(".sxema_attr_table").each(function(){ $(this).find(".table_name_inp").css("transform", "rotate(0deg)") $(this).find(".table_name_inp").css("text-align", "center") }) } } function book_submit(step){ if( (book_config['payment_method'] == 'cash' && step == 2) || ( book_config['payment_method'] != 'cash' && step == 2 ) ){ return true; } else { return false; } } function showLoading(){ $(".book_loading").show(); } function hideLoading(){ $(".book_loading").hide(); } function submit_form(){ showLoading(); let url = '/event/book/' + book_config['event_id'] + '/' + book_config['eventDate_id']; let data = new FormData(); data.append('csrf_token', book_config['csrf']); data.append('Booking[first_name]', jQuery("#input_name").val()); data.append('Booking[email]', jQuery("#input_email").val()); data.append('Booking[phone]', jQuery("#input_phone").val()); data.append('Booking[place_count]', 5/*jQuery(".places_group.active").attr("data-value")*/); data.append('Booking[place_count_custom]', jQuery("#input_places_more").val()); data.append('Booking[arrival_time]', jQuery("#input_time").val()); data.append('Booking[message]', jQuery("#input_message").val()); if( book_config['payment_method'] == 'online' ){ if( book_config['sxema'] ){ data.append('Booking[table]', book_config['selected_place']) let table_char = book_config['selected_place'].substr(0,1); jQuery(".zonas").find("label").each(function(){ if( jQuery(this).attr("data-tablename") == table_char ){ data.append('Booking[zona]', jQuery(this).attr("data-value")) } }) } else { data.append('Booking[zona]', jQuery(".zonas").find(".active").attr("data-value")) } } else { data.append('Booking[zona]', jQuery(".zonas").find(".active").attr("data-value")) data.append('payment_cash', '1') } $.ajax({ url: url, data: data, processData: false, contentType: false, dataType: 'json', type: 'POST', success: function(data){ book_config['csrf'] = data['csrf'] if( typeof data['success'] !== 'undefined' ){ window.location = data['success'] } else { if(typeof data['error'] !== 'undefined'){ showError(data['error'], book_step); } else { showError(book_config['error']['unexpected_error'], book_step) } hideLoading(); } }, error: function(){ showError(book_config['error']['unexpected_error'], book_step) hideLoading(); } }); }