1// prevent repeat dings 2var loading_map = 0; 3var do_ajax_lookup_t; 4 5// load spinner 6var spinner = '<div class="map-loading-overlay" id="map-loading-overlay"><img src="'+shared_root+'/images/shared/loader.gif" alt="" /></div>'; 7$("#ajax-map-result").prepend(spinner); 8 9var view = $('input[name=view]').val(); 10 11// check hash and set form fields as necessary 12var hash = window.location.hash; 13 14function process_get_vars() { 15 $('.map-locations-categories-list input[type=checkbox]').each(function() { 16 $(this).removeAttr('checked') 17 checkCheckedStatus($(this).closest('label')); 18 }); 19 20 var str_arr = []; 21 22 if(history.pushState) { 23 var loc = location.href; 24 if(loc.indexOf('?') !== -1) { 25 var tmp = loc.split('?'); 26 var str = tmp[1]; 27 var str_arr = str.split("&"); 28 } 29 30 } else { 31 if(hash.replace("#","")) { 32 var str = hash.replace("#","").replace("/?",""); 33 var str_arr = str.split("&"); 34 } 35 } 36 37 if(str_arr.length) { 38 for(i=0;i<str_arr.length;i++) { 39 var key_arr = str_arr[i].split("="); 40 key_arr[0] = decodeURIComponent(key_arr[0]); 41 if($("input[name='"+key_arr[0]+"']").length) { 42 var field = $("input[name='"+key_arr[0]+"']"); 43 switch($(field).attr("type")) { 44 case "checkbox": 45 case "radio": 46 $(field).attr("checked","checked"); 47 checkCheckedStatus($(field).closest('label')); 48 break; 49 default: 50 $(field).val(key_arr[1]); 51 break; 52 } 53 } 54 if($("select[name='"+key_arr[0]+"']").length) { 55 var field = $("select[name='"+key_arr[0]+"']"); 56 $(field).val(key_arr[1]); 57 } 58 } 59 } 60} 61 62// add ios-specific focusable element 63$('#map-locations-filter-form').after('<input type="checkbox" id="ios-focusable" style="height:0; margin-left:-200px; clear: both;" />'); 64 65// load the map on load 66load_the_map(); 67 68var mobile_specific_filter_button = $('.button.map-location-search-submit-button').first(); 69 70// set up listener for search field
71$("#map-locations-search-field, #map-locations-zip-field").keyup(function() { 72 if($(mobile_specific_filter_button).css('display') != 'block') do_search(); 73}); 74 75$('.mobile_specific_filter_button').click(function() { 76 timeout_length = 0; 77 do_search(); 78 return false; 79}); 80 81$("#map-locations-radius-select").change(function() { 82 do_search(); 83}); 84 85// set up handlers for loading the map when specifying categories 86$("#map-locations-categories-list input").change(function() { 87 do_search(); 88}); 89 90var ct; 91var timeout_length = 0; // first load should be instant 92function do_search() { 93 // load spinner 94 $("#map-loading-overlay").remove(); 95 $("#ajax-map-result").prepend(spinner); 96 97 clearTimeout(ct); 98 ct = setTimeout(function() { 99 if(history.pushState) { 100 var theurl = base_url + (base_url.indexOf('?') >= 0?'&':'?')+$("#map-locations-filter-form").serialize(); 101 history.pushState(null, null, decodeURIComponent(theurl)); 102 load_the_map(); 103 104 } else { 105 window.location.hash = "/?"+$("#map-locations-filter-form").serialize(); 106 } 107 108 if($(mobile_specific_filter_button).css('display') == 'block') { 109 $('body,html').stop(1,1).animate({'scrollTop':($('.map-locations-map-container').offset().top - 100)+'px'},1000,'easeInOutQuad'); 110 $("#ios-focusable").focus(); 111 } 112 113 timeout_length = 500; 114 },timeout_length); 115} 116 117if(history.pushState) { 118 $(window).on('popstate', function() { 119 process_get_vars(); 120 load_the_map(); 121 }); 122} 123 124// prevent normal submission of form 125$("#map-locations-filter-form").submit(function() { 126 $("#ios-focusable").focus(); 127 timeout_length = 0; 128 do_search(); 129 return false; 130}); 131 132// hash heartbeat 133setInterval(function() { 134 if(window.location.hash != hash) { 135 hash = window.location.hash; 136 load_the_map(); 137 } 138},50); 139 140// function to load map via ajax 141var first_time_load = 1; 142function load_the_map() { 143 var formdata = $("#map-locations-filter-form").serialize(); 144 formdata = formdata.replace("Search...",""); // ie placeholder fix 145 formdata = formdata.replace("Zip",""); // ie placeholder fix 146 147 // get zip code 148 if($("#map-locations-radius-select").val() && $("#map-locations-zip-field").val()) { 149 var zip = $("#map-locations-zip-field").val(); 150 151 var geocoder; 152 var map; 153 geocoder = new google.maps.Geocoder(); 154 155 geocoder.geocode( { "address": zip}, function(results, status) { 156 if (status == google.maps.GeocoderStatus.OK) { 157 formdata += "&slat="+results[0].geometry.location.lat(); 158 formdata += "&slng="+results[0].geometry.location.lng(); 159 160 do_ajax_lookup(formdata); 161 162 } else { 163 do_ajax_lookup(formdata); 164 } 165 }); 166 } else { 167 do_ajax_lookup(formdata); 168 } 169} 170 171function do_ajax_lookup(formdata) { 172 clearTimeout(do_ajax_lookup_t); 173 do_ajax_lookup_t = setTimeout(function() { 174 $.ajax({ 175 type: "GET", 176 url: $("#map-locations-filter-form").attr('action')+($("#map-locations-filter-form").attr('action').indexOf('?')>=0?'&':'?')+(view?"view="+view+"&":'')+"load_map_pins_via_ajax=1", 177 data: formdata, 178 dataType:"json", 179 success: function(response,textStatus) { 180 loading_map = 0; 181 182 raw_markers_arr = response.marker_data; 183 $('#map-loading-overlay').remove(); 184 185 $("#now-viewing-count").html(response.now_viewing); 186 $("#now-viewing-total").html(response.total); 187 188 if($('#map-locations-map-settings').length) { 189 init_map_locations_map(); 190 } else { 191 $('#ajax-map-result').html(response.output); 192 } 193 194 if(typeof all_markers_arr !== 'undefined' && all_markers_arr.length) { 195 markers.addTo(map); 196 setTimeout(function() { 197 map.fitBounds(all_markers_lat_lng); 198 },50); 199 } 200 201 if(window.location.hash.replace("#","").replace("q=","").replace("/?","").replace("/","")) { 202 if(first_time_load) { 203 $("#map-locations-clear-filters-button").show(); 204 } else { 205 $("#map-locations-clear-filters-button").fadeIn("fast"); 206 } 207 } else { 208 if(first_time_load) { 209 $("#map-locations-clear-filters-button").hide(); 210 } else { 211 $("#map-locations-clear-filters-button").fadeOut("fast"); 212 } 213 } 214 first_time_load = 0; 215 216 $('body').trigger('ss-map-locations-refreshed'); 217 } 218 }); 219 }, 50); 220} 221 222// clear filter 223$("#map-locations-clear-filters-button").click(function() { 224 $("#map-locations-categories-list input").removeAttr("checked").closest("label").removeClass("checked").addClass("unchecked"); 225 $("#map-locations-search-field").val(""); 226 227 window.location.hash = "#/"; 228 return false; 229}); 230 231// map view/list view links 232$("#map-view-link").click(function() { 233 if($(this).hasClass("selected")) return false; 234 $('input[name=view]').val('map'); 235 var thedata = $("#map-locations-filter-form").serialize(); 236 var cur_url = $("#map-locations-filter-form").attr('action').split('?'); 237 cur_url = cur_url[0]; 238 window.location.href = cur_url+"?"+decodeURIComponent(thedata); 239 return false; 240});
241$("#list-view-link").click(function() { 242 if($(this).hasClass("selected")) return false; 243 $('input[name=view]').val('list'); 244 var thedata = $("#map-locations-filter-form").serialize(); 245 var cur_url = $("#map-locations-filter-form").attr('action').split('?'); 246 cur_url = cur_url[0]; 247 window.location.href = cur_url+"?"+decodeURIComponent(thedata); 248 return false; 249});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.