jQuery(document).ready(function($) { var kol_s = 0; $(".subway-lines input[type='checkbox']").each(function(){ if($(this).is(":checked")){ kol_s++; var name = $(this).attr('id'); $(".subway-station."+ name +"").addClass('active'); } }); if ( kol_s >0 ) { $('#raion-select').attr('disabled', true); } else { } $("#subway-map-select").click(function(){ $("#subway-map-select").hide(); $(".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() { var kol_s = 0; $("body").removeClass("lock"); $(".subway-lines input[type='checkbox']").each(function(){ $(".subway-popup").hide(); if($(this).is(":checked")){ kol_s++;} }); if ( kol_s >0 ) { $('#raion-select').addClass('disabled'); $('#raion-select').attr("disabled",true); } else { $('#raion-select').removeClass('disabled'); $('#raion-select').attr("disabled",false); } $(".subway-popup").hide(); $("#subway__map").hide(); $("#subway-map-select").show(); console.log($(".subway-lines input:checked").length); $("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'); }); }); });