summaryrefslogtreecommitdiff
path: root/maps-extra.js
blob: f1cd2bd1652ed0a5b97188bc08c924b9f31a148b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
// Version 1.3 20081218.1405

//var show_parking_warning=true;

// Start up Shadowbox.
Shadowbox.init({
	players: ['img', 'qt','html'] // See http://www.shadowbox-js.com/options.html#players for more players.
});
	
$(document).ready(function() {
	
	// Set the default message to be displayed in the search box.
	var search_query_message = 'Search the map'
	// The following is the mechanics for the search box to show and hide the default message.
	if ($('#query').attr('value') != search_query_message)
	{
		if (search_posted != '')
		{
			$('#query').attr('value', search_posted);
		}
		else
		{
			$('#query').attr('value', search_query_message);
		}
	}
	$('#query').focus(function() {
		if ($(this).attr('value') == search_query_message)
		{
			$(this).attr('value', '');
		}
	});
	$('#query').blur(function() {
		if (!$(this).attr('value') || $(this).attr('value').replace(/^\s*/, "").replace(/\s*$/, "") == '')
		{
			$(this).attr('value', search_query_message);
		}
	});
	// Set the action when the search box form is submitted.
	if ($('#headerform')) {
		$('#headerform').bind('submit', function() {
			var el = document.getElementById('query');
			onsearch(el.value);
			return false;
 		});
	};
	// Set the default height for the map.
	if ($('#map') && parseInt($('#map').css('height'), 10) < 201) {
		$('#map').css('height', '200px');
	};
	
	
});
//
function callback_for_resizing() {
	
	// Chuck the map icons in and prepare the events.
	if ($('#mapicons'))
	{
		// Display the map icon buttons. <li id="Parking" title="Toggle parking areas"><a href="#Parking">Parking</a></li>
		$('#mapicons').html('<h3>Map toggles</h3><ul><li id="Parking" title="Toggle enabled parking"><a href="#Parking">Enabled parking</a></li><li id="Entrances" title="Toggle entrances"><a href="#Entrances">Entrances</a></li><li id="Loops" title="Toggle hearing aid loops"><a href="#Loops">Hearing aid loops</a></li><li id="Enabled_toilets" title="Toggle enabled toilets"><a href="#Enabled_toilets">Enabled toilets</a></li></ul><div class="clear-right"></div>');
		// Set the click event.
		$('#mapicons li').click(function() {
			if ($(this).attr('id')=="Parking"&&show_parking_warning) {
				Shadowbox.open({
					content:    "<div id='parking-msg'>There is no public parking available in Trinity; parking is permit or by arrangement only. <br><br>The icons displayed show the locations of enabled parking for those with a permit or prior arrangement to park on the grounds.</div>",
					player:     "html",
					title:      "Parking Notice",
					height:     350,
					width:      360
				    });
				show_parking_warning=false;
			}
			show_markers($(this).attr('id'));
			if (markers[$(this).attr('id')].visible)
			{
				$(this).attr('class', 'selected');
			}
			else
			{
				$(this).attr('class', '');
			}
			return false;
		});
		// Set the key event.
		$('#mapicons li').keyup(function(event) {
			if (event.keyCode == 13 || event.keyCode == 32) // Return/enter or space.
			{
				show_markers($(this).attr('id'));
				if (markers[$(this).attr('id')].visible)
				{
					$(this).attr('class', 'selected');
				}
				else
				{
					$(this).attr('class', '');
				}
				return false;
			}
		});
	}
	// Get the element mapwrap and apply the class js_active. This will give a means for different styles to be applied when Javascript is off.
	var mapwrap = $('.wrap');
	mapwrap[0].className = mapwrap[0].className + ' js_active';
	// Do the same but with the searchoptions element.
	//var mapwrap = document.getElementById('searchoptions');
	//mapwrap.parentNode.className += ' js_active';
	resize_map_and_results();
	$(window).resize(function() {
		resize_map_and_results();
	});
	// Check if the POST quicklinks variable were passed to Javascript.
	if (quicklinks_posted != '')
	{
		// Update the search results.
		do_menu(quicklinks_posted);
	}
}
function resize_map_and_results() {
	// Fix mapicons and searchresulttitle so that they have the same height by adding padding to the top.
	if ($('#searchresulttitle') && $('#map') && $('#mapicons'))
	{
		var diff = $('#searchresults').offset().top - $('#map').offset().top;
		var searchresulttitle_padding = parseFloat($('#searchresulttitle').css('padding-top'), 10);
		var mapicons_padding = parseFloat($('#mapicons').css('padding-top'), 10);
		if (diff > 0)
		{
			// Increase the height of mapicons by adding padding to the top.
			mapicons_padding = mapicons_padding + diff;
		}
		else if (diff < 0)
		{
			searchresulttitle_padding = searchresulttitle_padding - diff;
		}
		diff = 0;
		if (searchresulttitle_padding > 0 && mapicons_padding > 0)
		{
			diff = Math.min(searchresulttitle_padding, mapicons_padding);
		}
		$('#mapicons').css('padding-top', mapicons_padding - diff + 'px');
		$('#searchresulttitle').css('padding-top', searchresulttitle_padding - diff + 'px');
	}
	// Fix the vertical dimensions of the map.
	if ($('#searchresults') && $('#map'))
	{
		var diff = Math.abs($(window).height() - $('#map').offset().top - 10); // The 10 is the base padding value used throughout the design.
		if (diff < 400) {
			diff = 400;
		}
		$('#map').css('height', diff + 'px');
		$('#searchresults').css('height', diff + 2 + 'px'); // The 2 is a bit random but adjusts the bottom of the results to match the map.
	}

	//map.setCenter(STARTPOS, 17);
}
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}