122 lines
2.7 KiB
JavaScript
122 lines
2.7 KiB
JavaScript
$(function()
|
|
{
|
|
var hash = document.location.hash.replace("#", "");
|
|
|
|
if(hash !== "")
|
|
{
|
|
var agency = null;
|
|
var region = null;
|
|
|
|
$(".agency_item").each(function()
|
|
{
|
|
if($(this).data('agency') == hash)
|
|
{
|
|
agency = $(this).data('agency');
|
|
region = $(this).data('region');
|
|
|
|
console.log("agency", $(this).data('agency'), "region", $(this).data('region'));
|
|
|
|
/*
|
|
faq_section_index = $(this).data('section');
|
|
faq_item_index = $(this).data('index');
|
|
|
|
$(".faq_section_button").removeClass("active");
|
|
$(".faq_section_button_"+faq_section_index).addClass("active");
|
|
$(".faq_items_list").css("display", "none");
|
|
$(".faq_items_list_"+faq_section_index).css("display", "block");
|
|
|
|
$(".faq_item").removeClass("open");
|
|
$(".faq_item_"+faq_item_index).addClass("open");
|
|
*/
|
|
|
|
|
|
$(".tab").last().click();
|
|
$(".regions_select").val(region);
|
|
onRegionChange(region);
|
|
|
|
return false;
|
|
}
|
|
});
|
|
}
|
|
|
|
$(".regions_select").on("change", function()
|
|
{
|
|
if($(this).val() === "")
|
|
{
|
|
$(".region_selected").remove();
|
|
$(".region_block").css("display", "block");
|
|
|
|
window.map.setCenter([ 55.178521758435, 61.416163746216 ], 3.8);
|
|
}
|
|
else
|
|
{
|
|
var geo = $(this).find(':selected').data("geo");
|
|
var zoom = $(this).find(':selected').data("zoom");
|
|
var coords = geo.split(",");
|
|
|
|
window.map.setCenter([ coords[0], coords[1] ], zoom);
|
|
|
|
if($('.tab.active').index() === 1)
|
|
{
|
|
$('html, body').animate({
|
|
scrollTop: $("#contacts_top").offset().top - 100
|
|
}, 200);
|
|
}
|
|
else
|
|
{
|
|
$('html, body').animate({
|
|
scrollTop: $("#contacts_top").offset().top - 100
|
|
}, 200);
|
|
}
|
|
|
|
onRegionChange($(this).val());
|
|
}
|
|
});
|
|
|
|
$("body").on("click", ".contacts_show_office_on_map", function()
|
|
{
|
|
const geo = $(this).data("geo");
|
|
var coords = geo.split(",");
|
|
window.map.setCenter([ coords[0], coords[1] ], 9);
|
|
|
|
$(".tab").first().click();
|
|
$('html, body').animate({
|
|
scrollTop: $("#contacts_top").offset().top - 100
|
|
}, 100);
|
|
});
|
|
});
|
|
|
|
function onRegionChange(region)
|
|
{
|
|
console.log("region", region);
|
|
|
|
$(".region_selected").remove();
|
|
$(".region_block").css("display", "none");
|
|
|
|
var text_blocks = $(".column_desktop").find(".region_"+parseInt(region, 10));
|
|
|
|
text_blocks.map(function(index, item)
|
|
{
|
|
var n = $(item).clone();
|
|
$(n).addClass("open").addClass("region_selected").css("display", "block");
|
|
|
|
if(index % 2 == 0)
|
|
{
|
|
$(".column_left").append(n);
|
|
}
|
|
else
|
|
{
|
|
$(".column_right").append(n);
|
|
}
|
|
});
|
|
|
|
var text_blocks = $(".column_mobile").find(".region_"+parseInt(region, 10));
|
|
|
|
text_blocks.map(function(index, item)
|
|
{
|
|
var n = $(item).clone();
|
|
$(n).addClass("open").addClass("region_selected").css("display", "block");
|
|
|
|
$(".column_all").append(n);
|
|
});
|
|
} |