1// GCSRewards Locations js 2 3HTMLElement.prototype.getBoundingClientRect = (function () { 4 var oldGetBoundingClientRect = HTMLElement.prototype.getBoundingClientRect; 5 return function() { 6 try { 7 return oldGetBoundingClientRect.apply(this, arguments); 8 } catch (e) { 9 return { 10 left: '', 11 right: '', 12 top: '', 13 bottom: '' 14 }; 15 } 16 }; 17})(); 18 19var maps = { 20 init: function(){ 21 22 var map; 23 var route; 24 25 26GMaps.prototype.markerById=function(id){ 27 for(var m=0;m<this.markers.length;++m){ 28 if(this.markers[m].get('id')===id){ 29 return this.markers[m]; 30 } 31 } 32 return new google.maps.marker.AdvancedMarkerElement(); 33}; 34 35map = new GMaps({ 36 el: '#directions_map', 37 lat: '34.8526', 38 lng: '-82.3940', 39 zoom: 12, 40 mapTypeControl: true, 41 mapTypeControlOptions: { 42 style: google.maps.MapTypeControlStyle.DEFAULT, 43 position: google.maps.ControlPosition.TOP_RIGHT, 44 mapTypeIds: ['roadmap', 'satellite'] 45 }, 46 fullscreenControl: true, 47 fullscreenControlOptions: { 48 position: google.maps.ControlPosition.BOTTOM_RIGHT 49 }, 50 zoomControl : true, 51 zoomControlOptions: { 52 position: google.maps.ControlPosition.TOP_RIGHT 53 54 }, 55 streetViewControl: false 56 }); 57 58var maperror = $('#mapError'); 59 // maperror.modal('hide'); 60 61$('#mapError').on('show.bs.modal', function (event) { 62 var errortext = $('p.error'); 63 var modal = $(this); 64 65 modal.find(errortext).show(); 66}); 67 68 $('#mapError').on('hidden.bs.modal', function () { 69 var errortext = $('p.error'); 70 errortext.empty(); 71 }); 72 73var styles = [{ "featureType": "all", "elementType": "labels.text.fill", "stylers": [ { "saturation": "0" }, { "color": "#555555" } ] }, { "featureType": "all", "elementType": "labels.icon", "stylers": [ { "hue": 74"#00afd7" }, {"saturation": "-20"}]}, { "featureType": "landscape.man_made", "elementType": "geometry.fill", "stylers": [ { "lightness": "27" } ] }, { "featureType": "landscape.natural.terrain", "elementType": "all", 75"stylers": [ { "visibility": "off" } ] }, { "featureType": "road.highway", "elementType": "geometry.fill", "stylers": [ { "lightness": "23" } ] }, { "featureType": "road.highway", "elementType": 76"geometry.stroke", "stylers": [ { "lightness": "25" } ] }, { "featureType": "road.highway.controlled_access", "elementType": "geometry.fill", "stylers": [ { "saturation": "0" }, { "lightness": "25" } 77] }, { "featureType": "road.highway.controlled_access", "elementType": "geometry.stroke", "stylers": [ { "lightness": "50" } ] }, { "featureType": "road.highway.controlled_access", "elementType": 78"labels", "stylers": [ { "lightness": "20" } ] }, { "featureType": "road.arterial", "elementType": "geometry.fill", "stylers": [ { "lightness": "66" } ] }, { "featureType": "road.arterial", 79"elementType": "geometry.stroke", "stylers": [ { "lightness": "70" } ] }, { "featureType": "road.local", "elementType": "geometry.stroke", "stylers": [ { "visibility": "off" } ] }, { "featureType": 80"road.local", "elementType": "labels.icon", "stylers": [ { "saturation": "-100" } ] }, { "featureType": "transit.line", "elementType": "labels.icon", "stylers": [ { "saturation": "-100" } ] }, { 81"featureType": "transit.station", "elementType": "labels.icon", "stylers": [ { "saturation": "-100" } ]}]; 82 83 84 map.addStyle({ 85 styledMapName:"Styled Map", 86 styles: styles, 87 mapTypeId: "map_style" 88 }); 89 90 $('.maplist').find('.locations').each(function() { 91 var $this = $(this); 92 var busname = $this.data('indname'); 93 var locname = $this.data('locname'); 94 var busid = $this.attr('id'); 95 var street = $this.data('street'); 96 var city = $this.data('city'); 97 var address = street +', '+ city; 98 var phone = $this.data('phone'); 99 var fulladdress = $this.data('address'); 100 101 var latitude = $this.data('latitude'); 102 var longitude = $this.data('longitude'); 103 104 if (locname){ 105 var windowcontent = '<div class="infowindow"><div class="title">'+busname+'<span>'+locname+'</span></div><div class="address"><div class="address-line">'+street+'</div><div class="address-line">'+city+'</div><div class="address-line">'+phone+'</div></div></div>'; 106 } 107 if (!locname){ 108 var windowcontent = '<div class="infowindow"><div class="title">'+busname+'</div><div class="address"><div class="address-line">'+street+'</div><div class="address-line">'+city+'</div><div class="address-line">'+phone+'</div></div></div>'; 109 } 110 111 112 var pins = ['pin-1.png','pin-2.png','pin-3.png','pin-4.png','pin-5.png','pin-6.png']; 113 var pinrandom = Math.floor(Math.random() * pins.length); 114 var index = Math.floor(Math.random()*pins.length); 115 var img = pins.splice(index, 1)[0]; 116 117 var pinicon = { 118 url: "/assets/images/pin.png", // url 119 scaledSize: new google.maps.Size(40, 40), // scaled size 120 origin: new google.maps.Point(0,0), // origin 121 anchor: new google.maps.Point(0, 0) // anchor 122 }; 123 124map.addMarker({ 125 lat: latitude, 126 lng: longitude, 127 title: busname, 128 draggable: false, 129 animation: google.maps.Animation.DROP, 130 icon: pinicon, 131 id: busid, 132 details: { 133 database_id: busid 134 }, 135 infoWindow: { 136 content: windowcontent 137 }, 138 click: function(){ 139 $('input#latitude').empty().val(latitude); 140 $('input#longitude').empty().val(longitude); 141 $('input#indname').empty().val(busname); 142 $('input#locname').empty().val(locname); 143 $('input#address').empty().val(address); 144 removeData(); 145 146 setTimeout(function(){ 147 $('.gm-style-iw').parent('div').addClass('test'); 148 $('.gm-style-iw').parent('div').children('div').eq(2).addClass('mapclose'); 149 150 },400); 151 152 // $('.maplist > li').removeClass('active'); 153 // $('.maplist > li > a').removeClass('activelink'); 154 $('#directionlist li').removeClass('active'); 155 $('#directionlist li a').removeClass('activelink'); 156 157 $('#directionlist li').each(function(){ 158 var linkId = $(this).attr('id'); 159 if (linkId === busid) { 160 $(this).find('a').addClass('activelink').parent('li').addClass('active'); 161 } 162 }); 163 164 165 166 //map.setCenter(latitude,longitude); 167 168 }, 169 mousedown: function(){ 170 //google.maps.event.trigger(map.markerById(busid), 'click'); 171 } 172 }); // end map.addMarker 173 174 175 if ($this.hasClass('single')){ 176 177 178 179 180 setTimeout(function(){ 181 google.maps.event.trigger(map.markerById(busid), 'click'); 182 map.setZoom(17); 183 map.setCenter(latitude, longitude); 184 },600); 185 186 } // end if single location 187 188else { 189 map.fitZoom(); 190 $('input#latitude').val(''); 191 $('input#longitude').val(''); 192 193 $this.on('click', function(e){ 194 e.preventDefault(); 195 196 google.maps.event.trigger(map.markerById(busid), 'click'); 197 removeData(); 198 199 //$('.maplist > li').removeClass('active'); 200 $('.maplist > div > h3 > a').removeClass('activelink'); 201 202 var link = $this.find('a'); 203 $('#directionlist').find('a').removeClass('activelink'); 204 link.addClass('activelink'); 205 206 207 map.setCenter(latitude,longitude); 208 }); 209 210 211} // end if multiple locations 212 213}
213); // each location 214 215function removeData(){ 216 map.cleanRoute(); 217 map.removePolylines(); 218 $('#destination').empty(); 219 $('#instructions').empty(); 220 $('span#fromLocation').empty(); 221 $('h2#name').empty(); 222 $('#directions').fadeOut(200); 223 $('#location-form').addClass('nodirections'); 224 $('span.trafficTime').removeClass('traffic').empty(); 225 $('span.distanceTime').empty() 226 227} // remove map data 228 229 230$('#my-location').on('click', function(e){ 231 e.preventDefault(); 232 $('input#clientAddress').val(''); 233 $('input#clientAddress').addClass('transparent'); 234 removeData(); 235 236var geodata; 237 238var apiGeolocationSuccess = function(position) { 239 //alert("API geolocation success!\n\nlat = " + position.coords.latitude + "\nlng = " + position.coords.longitude); 240 241}; 242 // AIzaSyCz_mYnB7ymmc23VADSjvYOWe9fX9YRj3w 243var tryAPIGeolocation = function() { 244 $.post( "https://www.googleapis.com/geolocation/v1/geolocate?key=AIzaSyAgna79f9wHhOFesWYsqwLYbQU1SujUI2g", function(success) { 245 apiGeolocationSuccess({coords: {latitude: success.location.lat, longitude: success.location.lng}}); 246 $('#clientCoords').attr('value', success.location.lat+','+success.location.lng); 247 248 geosuccess(); 249 }) 250 .fail(function(err) { 251 // alert("API Geolocation error! \n\n"+err); 252 }); 253}; 254 255var browserGeolocationSuccess = function(position) { 256 //alert("Browser geolocation success!\n\nlat = " + position.coords.latitude + "\nlng = " + position.coords.longitude); 257 258 geodata = position.coords; 259 $('#clientCoords').attr('value', position.coords.latitude+','+position.coords.longitude); 260 geosuccess(); 261 262}; 263 264var browserGeolocationFail = function(error) { 265 //console.log(error); 266 switch (error.code) { 267 case error.TIMEOUT: 268 // alert("Browser geolocation error !\n\nTimeout."); 269 geoerror(); 270 271 break; 272 case error.PERMISSION_DENIED: 273 if(error.message.indexOf("Only secure origins are allowed") == 0) { 274 tryAPIGeolocation(); 275 } 276 break; 277 278 case error.POSITION_UNAVAILABLE: 279 // alert("Browser geolocation error !\n\nPosition unavailable."); 280 //geoerror(); 281 282 if(error.message.indexOf("Origin does not have permission") == 0) { 283 tryAPIGeolocation(); 284 } 285 else { 286 geoerror(); 287 } 288 break; 289 } 290}; 291 292var tryGeolocation = function() { 293 if (navigator.geolocation) { 294 if ($('html.safari.mac').length || $('html.chrome53').length) { 295 tryAPIGeolocation(); 296 } 297 else { 298 navigator.geolocation.getCurrentPosition( 299 browserGeolocationSuccess, 300 browserGeolocationFail, 301 {maximumAge: 10000, timeout: 10000, enableHighAccuracy: true}); 302 } 303 } 304}; 305 306tryGeolocation(); 307 308function geosuccess() { 309 310 var mypin = { 311 url: "/assets/images/mypin.png", // url 312 scaledSize: new google.maps.Size(40, 40), // scaled size 313 origin: new google.maps.Point(0,0), // origin 314 anchor: new google.maps.Point(0, 0) // anchor 315 }; 316 var latlng = document.getElementById('clientCoords').value; 317 var lat = latlng.split(',')[0]; 318 var lng = latlng.split(',')[1]; 319 320 map.setCenter(lat, lng); 321 322 var geomarker = $('input#geoid').val(); 323 324 GMaps.geocode({ 325 address: latlng, 326 callback: function(results,status) { 327 if (status === 'OK') { 328 $('#clientAddress').val(results[0].formatted_address); 329 330 if (geomarker) { 331 map.markerById(0).setPosition(new google.maps.LatLng(lat, lng)); 332 } 333 else { 334 335 map.addMarker({ 336 lat: lat, 337 lng: lng, 338 id: 0, 339 icon: mypin, 340 //shadow: 'schools_maps.shadow.png', 341 infoWindow: { 342 content: '<div class="infoWindow"><h5>You are here</h5></div>' 343 }, 344 mouseover: function(){ 345 //google.maps.event.trigger(map.markerById(0), 'click'); 346 }, 347 click: function() { 348 349 setTimeout(function(){ 350 $('.gm-style-iw').parent('div').children('div').eq(2).addClass('mapclose'); 351 },400); 352 } 353 }); // add marker 354 355 $('input#geoid').val('0'); 356 google.maps.event.trigger(map.markerById(0), 'click'); 357 358 359 } // if new marker needs to be added 360 361 } // if status ok 362 363 else { 364 $(maperror).find('p.error').html('Please enter a valid address.'); 365 $(maperror).modal('show'); 366 $('.mapContent').addClass('manualentry'); 367 } 368 } // callback 369 370 }); // geocode 371 372 map.hideInfoWindows(); 373 $('input#clientAddress').removeClass('empty'); 374 375 376} // geosuccess 377 378function geoerror() { 379 $('input#clientAddress').removeClass('empty').addClass('empty'); 380 $(maperror).modal('show'); 381 $(maperror).find('p.error').html('Geolocation failed.<br>Please enter your location.'); 382 383 384 $('.mapContent').addClass('manualentry'); 385} // geoerror 386 387}); // mylocation click 388 389$('#getDirections').on('click', function(){ 390 391 392 var addresslength = $('#clientAddress').val().length; 393 394 if (!$('#clientAddress').val() ){ 395 $(maperror).modal('show'); 396 $('#mapError').find('p.error').html('Please enter your address.'); 397 } 398 else if ($('#clientAddress').hasClass('empty')) { 399 $(maperror).modal('show'); 400 $('#mapError').find('p.error').html('Please enter a valid address.'); 401 } 402 else if (!$('input#latitude').val() ){ 403 $(maperror).modal('show'); 404 $('#mapError').find('p.error').html('Please select a location.'); 405 } 406 else { 407 $('#location-form').removeClass('nodirections'); 408 $('#instructions').empty(); 409 map.cleanRoute(); 410 map.removePolylines(); 411 $('#directions').fadeIn(100); 412 413 var geocoder = new google.maps.Geocoder(); 414 var address = document.getElementById("clientAddress").value; 415 var destinationlat = document.getElementById('latitude').value; 416 var destinationlng = document.getElementById('longitude').value; 417 var destinationaddress = document.getElementById("address").value; 418 419 var indname = document.getElementById("indname").value; 420 var locname = document.getElementById("locname").value; 421 422 geocoder.geocode( { 'address': address}, function(results, status) { 423 424 if (status == google.maps.GeocoderStatus.OK) { 425 var latitude = results[0].geometry.location.lat(); 426 var longitude = results[0].geometry.location.lng(); 427 // alert(latitude+','+longitude); 428 //var dt = new Date(); 429 // var currenttime = dt.getHours() + ":" + dt.getMinutes() + ":" + dt.getSeconds(); 430 431 432 var dt = new Date(Date.now()); 433 434 // console.log(currenttime); 435 map.getRoutes({ 436 origin: [latitude, longitude], 437 destination: [destinationlat, destinationlng], 438 travelMode: 'driving', 439 unitSystem: 'imperial', 440 provideRouteAlternatives: true, 441 drivingOptions: { 442 departureTime: dt 443 }, 444 callback: function (e, response) { 445 var time = 0; 446 var distance = 0; 447 for (var i=0; i<e[0].legs.length; i++) { 448 time += e[0].legs[i].duration.text; 449 distance += e[0].legs[i].distance.text; 450 //console.log(e[0].legs[i]); 451 452 var traffictime = e[0].legs[i].duration_in_traffic.text; 453 var traffictime2 = traffictime.replace('hours', 'h'); 454 var traffictime2 = traffictime2.replace('mins', 'min'); 455 456 $('span.trafficTime').empty().html('In current traffic: <span>'+traffictime2+'</span>'); 457 } 458 459 /* for (var x = 0, len = response.routes.length; x < len; x++) { 460 461 var routeoptions = response.routes[1].legs[x].duration.text+'-'+response.routes[1].legs[x].distance.text; 462 console.log(routeoptions); 463 $('#directions').append(response.routes[x].summary); 464 }*/ 465 466 467 468 function trimLeadZero(s) { 469 return s.replace(/^0+/, ""); 470 } 471 //var abbrtime = time.replace('hours', 'hr'); 472 //var abbrtime2 = abbrtime.replace('mins', 'min'); 473 //var distance2 = distance.replace('mi', 'miles'); 474 var abbrtime = time.replace('hours', 'h'); 475 var abbrtime2 = abbrtime.replace('mins', 'min'); 476 var distance2 = distance; 477 478 $('span.distanceTime').empty().html(trimLeadZero(abbrtime2)+' <sp
478an>('+trimLeadZero(distance2)+')</span>'); 479 //alert("TIME: " +time + " DISTANCE: " + distance); 480 481 //console.log(trimLeadZero(abbrtime2)+' - '+traffictime2); 482 483 if (trimLeadZero(abbrtime2) < traffictime2){ 484 //console.log('yes traffic'); 485 $('span.trafficTime').addClass('traffic'); 486 } 487 if (trimLeadZero(abbrtime2) >= traffictime2){ 488 //console.log('no traffic'); 489 $('span.trafficTime').removeClass('traffic'); 490 } 491 492 493 } 494 495 }); // get route 496 497 map.travelRoute({ 498 origin: [latitude, longitude], 499 destination: [destinationlat, destinationlng], 500 travelMode: 'driving', 501 unitSystem: 'imperial', 502 start: function(e) { 503 map.hideInfoWindows(); 504 var streetaddress= address.substr(0, address.indexOf(',')); 505 var city = address.split(',')[1]; 506 var state = address.split(',')[2]; 507 508 var destination = destinationaddress.substr(0, destinationaddress.indexOf(',')); 509 var destinationcity = destinationaddress.split(',')[1]; 510 var destinationstate = destinationaddress.split(',')[2]; 511 512 if ($('.mapContent').hasClass('manualentry')) { 513 514 $('h3.fromLocation').empty().html(address); 515 } 516 else { 517 $('h3.fromLocation').empty().html(streetaddress+'<span>'+city+', '+state+'</span>'); 518 } 519 520 //var locname = $('input#locname').val(); 521 if (! locname) { 522 $('h3.toLocation').empty().html('<span class="destination_name">'+indname+'</span><span class="destination_address">'+destination+','+destinationcity+', '+destinationstate+'</span>'); 523 } 524 else { 525$('h3.toLocation').empty().html('<span class="destination_name">'+indname+'</span> <span class="destination_loc">('+locname+')</span><span class="destination_address">'+destination+','+destinationcity+', '+destinationstate+'</span>'); 526 } 527 528 }, 529 step: function(e) { 530 // console.log(e.duration.text); 531 532//$('#instructions').append('<li><span class="dis">'+e.duration.text+'('+e.distance.text+')</span>'+e.instructions+'</li>'); 533 534 //<img src="//maps.gstatic.com/tactile/directions/text_mode/maneuvers-2x.png" width="19" height="630" jstcache="0"> 535 536 $('#instructions').append('<li><div class="dir-tt"><img src="/assets/images/maneuvers-2x.png" width="19" height="630" jstcache="0"></div><span class="steps"><span class="instruct">'+e.instructions+'</span><span class="dis">'+e.distance.text+' ('+e.duration.text+')</span></span></li>'); 537 //console.log(e.maneuver); 538 $('#instructions li:eq(' + e.step_number + ')').delay(150 * e.step_number).fadeIn(200, function() { 539 map.drawPolyline({ 540 path: e.path, 541 strokeColor: '#111111', 542 strokeOpacity: 0.6, 543 strokeWeight: 4 544 }); 545 }); 546 }, 547 end: function(e){ 548 549 550 $(function() { 551 var merge = $("#instructions > li:contains('Merge')").find('div'); 552 $(merge).addClass("dir-tt-merge"); 553 554 var slightright = $("#instructions > li:contains('Slight'):contains('right')").find('div'); 555 $(slightright).addClass("dir-tt-turn-slight-right"); 556 557 var slightleft = $("#instructions > li:contains('Slight'):contains('left')").find('div'); 558 $(slightleft).addClass("dir-tt-turn-slight-left"); 559 560 var rampleft = $(""); 561 $(rampleft).addClass("dir-tt-ramp-left"); 562 563 var rampright = $("#instructions > li:contains('exit')").find('div'); 564 var rampright2 = $("#instructions > li:contains('Take')").find('div'); 565 566 $(rampright).addClass("dir-tt-ramp-right"); 567 $(rampright2).addClass("dir-tt-ramp-right"); 568 569 var roundabout_right = $("#instructions > li:contains('traffic'):contains('circle')").find('div'); 570 $(roundabout_right).addClass("dir-tt-roundabout-right"); 571 572 var roundabout_left = $(""); 573 $(roundabout_left).addClass("dir-tt-roundabout-left"); 574 575 var straight = $("#instructions > li:contains('Head'), #instructions > li:contains('Continue')").find('div'); 576 $(straight).addClass("dir-tt-straight"); 577 578 var turnright = $("#instructions > li:contains('Turn'):contains('right'), #instructions > li:contains('Keep'):contains('right')").find('div'); 579 $(turnright).addClass("dir-tt-turn-right"); 580 581 var turnleft = $("#instructions > li:contains('Turn'):contains('left'), #instructions > li:contains('Keep'):contains('left')").find('div'); 582 $(turnleft).addClass("dir-tt-turn-left"); 583 584 var ferry = $(""); 585 $(ferry).addClass("dir-tt-ferry"); 586 587 var forkleft = $("#instructions > li:contains('fork'):contains('left')").find('div'); 588 // if (!$("#instructions > li:contains('right')")) { 589 $(forkleft).removeClass('dir-tt-turn-left').addClass("dir-tt-fork-left"); 590 // } 591 592 593 var forkright = $("#instructions > li:contains('fork'):contains('right')").find('div'); 594 $(forkright).removeClass('dir-tt-turn-right').addClass("dir-tt-fork-right"); 595 596 597 //$(merge).prepend('<div class="dir-tt dir-tt-merge">
597<img src="//maps.gstatic.com/tactile/directions/text_mode/maneuvers-2x.png" width="19" height="630" jstcache="0"></div>'); 598 599 }); 600 601 } 602 }); // travel route 603 604 setTimeout(function(){ 605 map.fitZoom(); 606 map.refresh(); 607 },200); 608} 609 }); 610 611} // if all data okay 612 613 return false; 614}); // getdirections click 615 616$('#clientAddress').keydown(function (e){ 617 if(e.keyCode == 13){ 618 // alert('you pressed enter ^_^'); 619 return false; 620 } 621}) 622 623 $("#clientAddress").on("change paste", function(){ 624 $("#clientAddress").removeClass('empty').addClass('empty'); 625 $('.mapContent').addClass('manualentry'); 626 627$('input[id="clientCoords"]').val(''); 628 removeData(); 629 map.removeMarkers(0); 630 631var addresslength = $('#clientAddress').val().length; 632 633function geocodeInput() { 634 var geocoder = new google.maps.Geocoder(); 635 var address = document.getElementById("clientAddress").value; 636 637 geocoder.geocode( { 'address': address}, function(results, status) { 638 639 if (status == google.maps.GeocoderStatus.OK) { 640 var latitude = results[0].geometry.location.lat(); 641 var longitude = results[0].geometry.location.lng(); 642 $('#clientCoords').attr('value', latitude+','+longitude); 643 644 var geomarker = $('input#geoid').val(); 645 if (geomarker) { 646 //console.log('yes:'+geomarker); 647 map.markerById(0).setPosition(new google.maps.LatLng(latitude, longitude)); 648 map.setCenter(latitude, longitude); 649 } 650 else { 651 //console.log('no'); 652 653 var mypin = { 654 url: "/assets/images/mypin.png", // url 655 scaledSize: new google.maps.Size(40, 40), // scaled size 656 origin: new google.maps.Point(0,0), // origin 657 anchor: new google.maps.Point(0, 0) // anchor 658 }; 659 660 map.addMarker({ 661 lat: latitude, 662 lng: longitude, 663 id: 0, 664 icon: mypin, 665 infoWindow: { 666 content: '<div class="infoWindow"><h5>You are here</h5></div>' 667 }, 668 mouseover: function(){ 669 //google.maps.event.trigger(map.markerById(0), 'click'); 670 }, 671 click: function() { 672 673 setTimeout(function(){ 674 $('.gm-style-iw').parent('div').children('div').eq(2).addClass('mapclose'); 675 },400); 676 } 677 }); // add marker 678 679 map.setCenter(latitude, longitude); 680 google.maps.event.trigger(map.markerById(0), 'click'); 681 $('input#geoid').val('0'); 682 } // if new marker needs to be added 683 684 } // if status ok 685 686 }); 687 } // geocode input 688 689if (addresslength >= 5) { 690 geocodeInput(); 691 $("#clientAddress").removeClass('empty'); 692 } 693}); // change address input 694 695var previousValue = $("#clientAddress").val(); 696$("#clientAddress").keyup(function(e) { 697 var currentValue = $(this).val(); 698 if(currentValue != previousValue) { 699 previousValue = currentValue; 700 if (currentValue === '') { 701 //alert("Value empty!"); 702 $("#clientAddress").addClass('empty'); 703 } 704 else { 705 $("#clientAddress").removeClass('empty'); 706 } 707 708 } 709}); // keyup 710 711$(window).resize(function(){ 712 map.fitZoom(); 713 map.refresh(); 714}); // window resize 715 716map.setStyle("map_style"); 717 718$('button#print').on('click',function(e) { 719 e.preventDefault(); 720 721 // var title = $('#toptitle > h1').text(); 722 723 setTimeout(function(){ 724 //window.print(); 725 726 $('#directions').print({ 727 stylesheet: '/assets/css/print.css' 728 //pageTitle: title+' - Directions', 729 //loadCSS: '/assets/css/print.css', 730 //importStyle: true, 731 //printContainer: false 732 }); 733 },300); 734}); // print window 735 736 } 737}; // maps init 738 739var locations = { 740 init: function(){ 741 742 var map2; 743 744GMaps.prototype.markerById=function(id){ 745 for(var m=0;m<this.markers.length;++m){ 746 if(this.markers[m].get('id')===id){ 747 return this.markers[m]; 748 } 749 } 750 return new google.maps.marker.AdvancedMarkerElement(); 751}; 752 753 754map2 = new GMaps({ 755 el: '#location_map', 756 lat: '34.8526', 757 lng: '-82.3940', 758 zoom: 12, 759 zoomControl : true, 760 zoomControlOptions: { 761 position: google.maps.ControlPosition.TOP_RIGHT 762 763 }, 764 fullscreenControl: true, 765 fullscreenControlOptions: { 766 position: google.maps.ControlPosition.BOTTOM_RIGHT 767 }, 768 mapTypeControl: true, 769 mapTypeControlOptions: { 770 style: google.maps.MapTypeControlStyle.DEFAULT, 771 position: google.maps.ControlPosition.TOP_LEFT, 772 mapTypeIds: ['roadmap', 'satellite'] 773 }, 774 streetViewControl: false 775 776}); 777 778var styles = [{ "featureType": "all", "elementType": "labels.text.fill", "stylers": [ { "saturation": "0" }, { "color": "#555555" } ] }, { "featureType": "all", "elementType": "labels.icon", "stylers": [ { "hue": 779"#00afd7" }, {"saturation": "-20"}]}, { "featureType": "landscape.man_made", "elementType": "geometry.fill", "stylers": [ { "lightness": "27" } ] }, { "featureType": "landscape.natural.terrain", "elementType": "all", 780"stylers": [ { "visibility": "off" } ] }, { "featureType": "road.highway", "elementType": "geometry.fill", "stylers": [ { "lightness": "23" } ] }, { "featureType": "road.highway", "elementType": 781"geometry.stroke", "stylers": [ { "lightness": "25" } ] }, { "featureType": "road.highway.controlled_access", "elementType": "geometry.fill", "stylers": [ { "saturation": "0" }, { "lightness": "25" } 782] }, { "featureType": "road.highway.controlled_access", "elementType": "geometry.stroke", "stylers": [ { "lightness": "50" } ] }, { "featureType": "road.highway.controlled_access", "elementType": 783"labels", "stylers": [ { "lightness": "20" } ] }, { "featureType": "road.arterial", "elementType": "geometry.fill", "stylers": [ { "lightness": "66" } ] }, { "featureType": "road.arterial", 784"elementType": "geometry.stroke", "stylers": [ { "lightness": "70" } ] }, { "featureType": "road.local", "elementType": "geometry.stroke", "stylers": [ { "visibility": "off" } ] }, { "featureType": 785"road.local", "elementType": "labels.icon", "stylers": [ { "saturation": "-100" } ] }, { "featureType": "transit.line", "elementType": "labels.icon", "stylers": [ { "saturation": "-100" } ] }, { 786"featureType": "transit.station", "elementType": "labels.icon", "stylers": [ { "saturation": "-100" } ]}]; 787 788map2.addStyle({ 789 styledMapName:"Styled Map", 790 styles: styles, 791 mapTypeId: "map_style" 792 }); 793 794$('.locationlist').find('.loc').each(function() { 795 var $this = $(this); 796 var busname = $this.data('indname'); 797 var locname = $this.data('locname'); 798 var busid = $this.attr('id'); 799 var street = $this.data('street'); 800 var city = $this.data('city'); 801 var address = street +', '+ city; 802 var phone = $this.data('phone'); 803 var fulladdress = $this.data('address'); 804 805 var latitude = $this.data('latitude'); 806 var longitude = $this.data('longitude'); 807 808 var discountlink = $this.find('input#maplink'); 809 810 if (locname){ 811 var windowcontent = '<div class="infowindow"><div class="title">'+busname+'<span>'+locname+'</span></div><div class="address"><div class="address-line">'+street+'</div><div class="address-line">'+city+'</div><div class="address-line">'+phone+'</div></div><div class="discountlink"><a class="btn btn-outline" href="'+discountlink.val()+'"><span>View Discount</span></a></div></div>'; 812 } 813 if (!locname){ 814 var windowcontent = '<div class="infowindow"><div class="title">'+busname+'</div><div class="address"><div class="address-line">'+street+'</div><div class="address-line">'+city+'</div><div class="address-line">'+phone+'</div></div><div class="discountlink"><a class="btn btn-outline" href="'+discountlink.val()+'"><span>View Discount</span></a></div></div>'; 815 } 816 817 var pins = ['pin-1.png','pin-2.png','pin-3.png','pin-4.png','pin-5.png','pin-6.png']; 818 var pinrandom = Math.floor(Math.random() * pins.length); 819 var index = Math.floor(Math.random()*pins.length); 820 var img = pins.splice(index, 1)[0]; 821 822 var pinicon = { 823 url: "/assets/images/pin.png", 824 scaledSize: new google.maps.Size(40, 40), // scaled size 825 origin: new google.maps.Point(0,0), // origin 826 anchor: new google.maps.Point(0, 0) // anchor 827 }; 828 829map2.addMarker({ 830 lat: latitude, 831 lng: longitude, 832 title: busname, 833 draggable: false, 834 animation: google.maps.Animation.DROP, 835 icon: pinicon, 836 id: busid, 837 details: { 838 database_id: busid 839 }, 840 infoWindow: { 841 content: windowcontent 842 }, 843 click: function(){ 844 845 setTimeout(function(){ 846 $('.gm-style-iw').parent('div').children('div').eq(2).addClass('mapclose'); 847 848 },400); 849 850 /* 851 var listItem2 = $( "ul.locscroll li.active" ); 852 if (listItem2.length){ 853 $('ul.locscroll > ul').mCustomScrollbar('scrollTo', listItem2,{ 854 timeout:500 855 }); 856 } 857 */ 858 859 860 $('.locationlist .loc a').removeClass('activelink'); 861 $('.locationlist .loc').removeClass('active'); 862 $('.locationlist .accordion-item.special h3').removeClass('active'); 863 $('.locationlist .accordion-item h3 > a').removeClass('activelink'); 864 //$('.locationlist .single.loc > h3 > a').removeClass('activelink'); 865 //$('.locationlist .accordion-item').removeClass('active'); 866 867 $('.locationlist .loc').each(function(){ 868 var linkId = $(this).attr('id'); 869 var link = $(this).find('a'); 870 871 if (linkId === busid) { 872 873 //$('.locationlist .accordion-item a').removeClass('activelink'); 874 $(this).addClass('active'); 875 $('.locationlist div.active').find('a').addClass('activelink'); 876 877 878 879 // if ($('a.activelink').parent().parent().parent('li').prev('li').hasClass('toploc')){ 880 881 //$('a.activelink').parent().parent().parent('li').prev('li.toploc').addClass('active').siblings('li.toploc').removeClass('active').next('li.thirdnav').slideUp(); 882 883 // $('li.toploc.active').next('li.thirdnav').slideDown(); 884 // } else { 885 // $('li.toploc').removeClass('active').next('li.thirdnav').slideUp(); 886 887 // } 888 889 if ($(this).hasClass('multiplelocations')){ 890 $('.locationlist .accordion-item h3').removeClass('active'); 891 $('.locationlist .accordion-item.special h3 > a').removeClass('activelink'); 892 $(this).closest('.collapse').collapse('show'); 893 $(this).closest('.accordion-body').parent().parent().find('h3').addClass('active'); 894 895 896 } else { 897 $('.locationlist .loc').removeClass('active'); 898 $('.locationlist .accordion-item h3').removeClass('active'); 899 $('.locationlist .accordion-item.special h3 > a').removeClass('activelink'); 900 $('.collapse').collapse('hide'); 901 $(this).find('h3').addClass('active'); 902 //alert('click'); 903 } 904 905 } 906 907 908 909 910 /* 911 912 if (link.parent().hasClass('currentlocation')){ 913 914 } else { 915 link.parent().addClass('currentlocation'); 916 link.parent().siblings().removeClass('currentlocation').next('li.thirdnav').slideUp(); 917 link.parent().next('li.thirdnav').slideDown(); 918 } 919 920 */ 921 }); 922 923 924 925 } 926 }); // end map.addMarker 927 928 map2.fitZoom(); 929 930 $this.on('click', function(e){ 931 e.preventDefault(); 932 google.maps.event.trigger(map2.markerById(busid), 'click'); 933 map2.setCenter(latitude,longitude); 934 //var test = map2.setCenter(latitude,longitude); 935 //console.log('test'); 936 937 }); 938 939}); // each location 940 941$(window).resize(function(){ 942 map2.fitZoom(); 943 map2.refresh(); 944}); // window resize 945 946map2.setStyle("map_style"); 947 948 $('.locationlist').find('> div > h3 > a[href=#]').on('click', function(){ 949 $('.locationlist .accordion-item h3').removeClass('active'); 950 $('.locationlist .accordion-item.special h3').removeClass('active'); 951 $('.locationlist .loc').removeClass('active').find('a').removeClass('activelink'); 952 $(this).addClass('activelink').parent().addClass('active'); 953 954 map2.hideInfoWindows(); 955 956 return false;
957 }); 958 959 // if ($('.leftnav ul ul li.active').length) { 960 // $('.leftnav ul ul li.active').closest('ul.submenu').parent().addClass('active'); 961 // } 962 963 } 964}; //locations init 965 966function startmaps(){ 967 "use strict"; 968 969 if($('.locationContent').length) { 970 locations.init(); 971 972 showLoader(); 973 setTimeout(function() { 974 hideLoader(); 975 setTimeout(function() { 976 $('.locationContent').fadeTo(400,1); 977 },400); 978 },500); 979 980 var countlocations = $('.locationlist > div').length; 981 if (countlocations > 14) { 982 $('.locationlist').addClass('addscroll'); 983 } 984 985 $('.locationlist.addscroll').mCustomScrollbar({ 986 theme:"dark-thin", 987 setTop: '0', 988 axis: "y", 989 scrollbarPosition: 'inside', 990 scrollInertia: 500, 991 scrollButtons: {enable: true}, 992 autoHideScrollbar:false, 993 mouseWheel: { 994 enable: true, 995 preventDefault: true 996 }, 997 callbacks:{ 998 onInit:function(){ 999 //console.log("Scrollbars initialized"); 1000 }, 1001 onCreate:function(){ 1002 $('.mCSB_buttonUp').attr('aria-label', 'Scroll Up'); 1003 $('.mCSB_buttonDown').attr('aria-label', 'Scroll Down'); 1004 } 1005 } 1006 }); 1007 1008 $(".locationlist.addscroll").on("click", ".mCSB_scrollTools > *", function(e) { 1009 e.stopPropagation(); 1010 }); 1011 1012 1013 } 1014 1015 if($('.mapContent').length) { 1016 maps.init(); 1017 1018 showLoader(); 1019 setTimeout(function() { 1020 hideLoader(); 1021 setTimeout(function() { 1022 $('.mapContent').fadeTo(400,1); 1023 },400); 1024 },500); 1025 1026 1027 1028 1029 } // if mapcontent 1030 1031} // startmaps 1032 1033jQuery(function($) { 1034 "use strict"; 1035 1036 startmaps(); 1037 1038}); // end ready
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.