<commit_before><script type="text/javascript">
	dojo.require("esri.map");
	dojo.require("esri/dijit/HomeButton");
	dojo.require("esri/dijit/BasemapToggle");
	<?php foreach($requires as $req) { ?>
		dojo.require('<?=$req?>');
	<?php } ?>

	dojo.addOnLoad(function(){
		var map = new esri.Map("<?=$cssId?>",{
			center: [<?=$center['x']?>, <?=$center['y']?>],
			zoom: <?=$zoom?>,
			basemap: '<?=$baseMap?>'
		});
		
		var toggleLayers = {};
		var addVisibilityToggle = function(layer, layerId, layerLabel, isVisible){
			var inputId = layerId + "VisibilityToggle";
			toggleLayers[inputId] = layer;
			
			//Create the checkbox if it doesn't exist
			if($("#" + inputId).length == 0) {
				var html = "<li><div>";
				html += "<input type=\"checkbox\" id=\"" + inputId + "\"";
				if(isVisible) html += " checked";
				html += "/>";
				html +=	"<label>" + layerLabel + "</label>";
				html += "</div></li>";
				$("div#<?=$name?> ul.visibility-toggles").append(html);
				$("div#<?=$name?> div.legend div.accordion").accordion("refresh");
			}
			
			//Unbind click event in case we are re-creating the layer
			$("#" + inputId).unbind('click');
			
			//Toggle layer visibility when checkbox clicked
			$("#" + inputId).click(function(){
				layer.setVisibility(this.checked);
			});
		};
		
		var disableToggles = function(){
			for(inputId in toggleLayers) {
				var item = $("#" + inputId).parent();
				if(toggleLayers[inputId].visibleAtMapScale) {
					item.removeClass("disabled");
					item.find("*").enable();
				} else {
					item.addClass("disabled");
					item.find("*").disable();
				}
				//alert(inputId);
			}
		};
		
		map.on("zoom-end", disableToggles);

		<?=$layers?>
		
		disableToggles();
		
		<?php if(!empty($altBaseMap)) { ?>
			var toggle = new esri.dijit.BasemapToggle({map: map, basemap: "<?=$altBaseMap?>"}, "basemap-toggle");
			toggle.startup();
		<?php } ?>
		
		<?php if($showHomeButton) { ?>
			var home = new esri.dijit.HomeButton({map: map}, "home-button");
			home.startup();
		<?php } ?>
	});
</script>

<div id="<?=$name?>" class="widget map-widget ui-widget ui-corner-all border-box">
	<h2 class="ui-widget-header ui-corner-all"><?=$label?></h2>
	<div class="ui-widget-content">
		<div class="legend">
			<div class="accordion">
				<h3>Legend</h3>
				<div>
					Show legend image here.
				</div>
				<h3>Show Layers</h3>
				<div>
					<ul class="visibility-toggles">
					</ul>
				</div>
			</div>
		</div>
		<div id="<?=$cssId?>" class="map" data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region: 'center'">
			<div id="home-button"></div>
			<div id="basemap-toggle"></div>
		</div>
	</div>
</div><commit_msg>Allow map legend to be hidden<commit_after><script type="text/javascript">
	dojo.require("esri.map");
	dojo.require("esri/dijit/HomeButton");
	dojo.require("esri/dijit/BasemapToggle");
	<?php foreach($requires as $req) { ?>
		dojo.require('<?=$req?>');
	<?php } ?>

	dojo.addOnLoad(function(){
		var map = new esri.Map("<?=$cssId?>",{
			center: [<?=$center['x']?>, <?=$center['y']?>],
			zoom: <?=$zoom?>,
			basemap: '<?=$baseMap?>'
		});
		
		var toggleLayers = {};
		var addVisibilityToggle = function(layer, layerId, layerLabel, isVisible){
			var inputId = layerId + "VisibilityToggle";
			toggleLayers[inputId] = layer;
			
			//Create the checkbox if it doesn't exist
			if($("#" + inputId).length == 0) {
				var html = "<li><div>";
				html += "<input type=\"checkbox\" id=\"" + inputId + "\"";
				if(isVisible) html += " checked";
				html += "/>";
				html +=	"<label>" + layerLabel + "</label>";
				html += "</div></li>";
				$("div#<?=$name?> ul.visibility-toggles").append(html);
				$("div#<?=$name?> div.legend div.accordion").accordion("refresh");
			}
			
			//Unbind click event in case we are re-creating the layer
			$("#" + inputId).unbind('click');
			
			//Toggle layer visibility when checkbox clicked
			$("#" + inputId).click(function(){
				layer.setVisibility(this.checked);
			});
		};
		
		var disableToggles = function(){
			for(inputId in toggleLayers) {
				var item = $("#" + inputId).parent();
				if(toggleLayers[inputId].visibleAtMapScale) {
					item.removeClass("disabled");
					item.find("*").enable();
				} else {
					item.addClass("disabled");
					item.find("*").disable();
				}
				//alert(inputId);
			}
		};
		
		map.on("zoom-end", disableToggles);

		<?=$layers?>
		
		disableToggles();
		
		<?php if(!empty($altBaseMap)) { ?>
			var toggle = new esri.dijit.BasemapToggle({map: map, basemap: "<?=$altBaseMap?>"}, "basemap-toggle");
			toggle.startup();
		<?php } ?>
		
		<?php if($showHomeButton) { ?>
			var home = new esri.dijit.HomeButton({map: map}, "home-button");
			home.startup();
		<?php } ?>
	});
</script>

<div id="<?=$name?>" class="widget map-widget ui-widget ui-corner-all border-box">
	<h2 class="ui-widget-header ui-corner-all"><?=$label?></h2>
	<div class="ui-widget-content">
		<div class="legend" <?php if(!$showLegend) { ?>style="display: none;"<?php } ?>>
			<div class="accordion">
				<h3>Legend</h3>
				<div>
					Show legend image here.
				</div>
				<h3>Show Layers</h3>
				<div>
					<ul class="visibility-toggles">
					</ul>
				</div>
			</div>
		</div>
		<div id="<?=$cssId?>" class="map <?php if(!$showLegend) { ?>full-map<?php } ?>" data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region: 'center'">
			<div id="home-button"></div>
			<div id="basemap-toggle"></div>
		</div>
	</div>
</div>
{'fraction_non_alphanumeric': 0.23060029282576866, 'fraction_numerical': 0.002562225475841874, 'mean_word_length': 3.5465890183028286, 'pattern_counts': {'":': 0, '<': 115, '<?xml version=': 0, '>': 115, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '945181', 'n_tokens_mistral': 2343, 'n_tokens_neox': 1952, 'n_words': 365}