34 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
		
		
			
		
	
	
			34 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
| 
								 | 
							
								function checkSwitch() {
							 | 
						||
| 
								 | 
							
								    $(".groups").each(function() {
							 | 
						||
| 
								 | 
							
								        $(this).find('.form-horizontal > .hide').length < $(this).find('.form-horizontal > div').length ? $(this).removeClass("disabled") : $(this).addClass("disabled")
							 | 
						||
| 
								 | 
							
								    });
							 | 
						||
| 
								 | 
							
								    // $(".groups").addClass('disabled').has('.groups > .form-horizontal > div:not(.hide)').removeClass('disabled');
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								$(document).ready(function(){
							 | 
						||
| 
								 | 
							
								    checkSwitch();
							 | 
						||
| 
								 | 
							
								    $('.onoff').click(function () {
							 | 
						||
| 
								 | 
							
								        if($(this).parents("h4").length==1) {
							 | 
						||
| 
								 | 
							
								            $(this).parents(".map-block").toggleClass("disabled");
							 | 
						||
| 
								 | 
							
								            $(this).parents(".map-block").find(".form-horizontal").toggleClass("hide");
							 | 
						||
| 
								 | 
							
								            if($(this).parents(".map-block").hasClass("disabled")){
							 | 
						||
| 
								 | 
							
								                $(this).text("OFF");
							 | 
						||
| 
								 | 
							
								            }else{
							 | 
						||
| 
								 | 
							
								                $(this).text("ON");
							 | 
						||
| 
								 | 
							
								            }
							 | 
						||
| 
								 | 
							
								        }
							 | 
						||
| 
								 | 
							
								        if($(this).parents("legend").length==1) {
							 | 
						||
| 
								 | 
							
								            $(this).toggleClass("disabled");
							 | 
						||
| 
								 | 
							
								            $(this).parents("legend").next("div").toggleClass("hide");
							 | 
						||
| 
								 | 
							
								            if($(this).parents("legend").next("div").hasClass("hide")){
							 | 
						||
| 
								 | 
							
								                $(this).text("OFF");
							 | 
						||
| 
								 | 
							
								            }else{
							 | 
						||
| 
								 | 
							
								                $(this).text("ON");
							 | 
						||
| 
								 | 
							
								            }
							 | 
						||
| 
								 | 
							
								            checkSwitch();
							 | 
						||
| 
								 | 
							
								        }
							 | 
						||
| 
								 | 
							
								       return false;
							 | 
						||
| 
								 | 
							
								    });
							 | 
						||
| 
								 | 
							
								});
							 | 
						||
| 
								 | 
							
								
							 |