jQuery(document).ready(function ($) { $(".subway-lines input[type='checkbox']").each(function () { if ($(this).is(":checked")) { var name = $(this).attr('id'); $(".subway-station." + name + "").addClass('active'); } }); $("#subway-map-select").click(function () { $("#subway-map-select").hide(); //clear $(".subway-lines input[type='checkbox']").each(function () { $(this).attr("checked", false); }); $(".subway-station").each(function () { $(this).removeClass('active'); }); var selected = $(".ms-subway").val(); if (selected && selected.length > 0) { for (var i = 0; i < selected.length; i++) { $(".subway-popup input[value='" + selected[i] + "']").each(function () { $(this).attr("checked", true); $(this).prop("checked", true); var name = $(this).attr('id'); $(".subway-station." + name + "").addClass('active'); }); } } $(".overlay").show(); $("body").addClass("lock"); $(".subway-popup").show(); $("#subway__map").show(); $("body").animate({scrollTop: 200}, 500); return false; }); $("a.uncheck-all").click(function (event) { event.preventDefault(); $("input[name='metro[]']").each(function () { $(this).attr("checked", false); $(this).removeClass(""); var name = $(this).attr('id'); $(".subway-station." + name + "").each(function () { $(this).removeClass('active'); }); }); }); $(".subway-closer, .button-a.agree.confirm").click(function () { $("body").removeClass("lock"); var selected = []; $(".subway-lines input[type='checkbox']").each(function () { if($(this).is(":checked")){ selected.push($(this).attr('value')); } }); $(".ms-subway").val(selected); $(".ms-subway").multiselect("reload"); $(".subway-popup").hide(); $("#subway__map").hide(); $("#subway-map-select").show(); $("body").animate({scrollTop: 500}, 500); }); $(".subway-select li a").click(function (event) { event.preventDefault(); if ($(this).parent('li').hasClass('active')) { var num_line = $(this).attr('data-line-number'); $(this).parent('li').removeClass('active'); $(".subway-lines .line-" + num_line + " input[type='checkbox']").attr("checked", false); $(".subway-lines .line-" + num_line + " input[type='checkbox']").removeClass('active'); } else { var num_line = $(this).attr('data-line-number'); $(this).parent('li').addClass('active'); $(".subway-lines .line-" + num_line + " input[type='checkbox']").attr("checked", true); $(".subway-lines .line-" + num_line + " input[type='checkbox']").addClass('active'); } }); $(".subway-lines input:checkbox").siblings('span').click(function () { $(this).siblings('input').addClass("Active"); }); $("input[name='metro[]']").change(function () { var v = $(this).val(); var name = $(this).attr('id'); var chk = $(this).prop("checked"); $(".subway-popup input[value='" + v + "']").each(function () { $(this).attr("checked", chk); }); $(".subway-station." + name + "").each(function () { $(this).toggleClass('active'); }); }); });