$(function()
{
/*
$.get("/api/regions/",
{
params: {},
}, function(response)
{
for(let i in response.regions)
{
//$("#regions_select").append("");
//$("#regions_select_mobile").append("");
}
//$("#regions_select")[0].selectedIndex = 1;
//$("#regions_select_mobile")[0].selectedIndex = 1;
}, "json");
*/
$(".regions_select").on("change", function()
{
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)
{
$(".dropdown_block").removeClass("open");
$("#region_"+parseInt($(this).val(), 10)).addClass("open");
$('html, body').animate({
scrollTop: $("#region_"+parseInt($(this).val(), 10)).offset().top - 100
}, 200);
}
else
{
$('html, body').animate({
scrollTop: $("#contacts_top").offset().top - 100
}, 200);
}
});
$(".contacts_show_office_on_map").on("click", 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);
});
});