This repository has been archived by the owner on Jan 15, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
javascript.js
120 lines (106 loc) · 3.24 KB
/
javascript.js
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
$('.navbar a').on('click', function(event) {
event.preventDefault();
var location_anchor = $(this).attr('href');
if(location_anchor == '#'){
location_anchor = 'html';
}
$('html, body').animate({
scrollTop: $(location_anchor).offset().top
}, 1000);
});
$('#footer-menu li a').on('click', function(event) {
event.preventDefault();
var location_anchor = $(this).attr('href');
if(location_anchor == '#'){
location_anchor = 'html';
}
$('html, body').animate({
scrollTop: $(location_anchor).offset().top
}, 1000);
});
$('#buscar_caminho').on('click', function(e) {
e.preventdefault()
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
var point = new google.maps.LatLng(position.coords.latitude,
position.coords.longitude);
calcRoute(point);
});
}
});
$('.schedule-tbl a').not('.presentation').on('click', function(event) {
event.preventDefault();
var location_anchor = $(this).attr('href');
if(location_anchor == '#'){
location_anchor = 'html';
}
$('html, body').animate({
scrollTop: $(location_anchor).offset().top
}, 1000);
});
//map
var directionsDisplay;
var directionsService = new google.maps.DirectionsService();
var map;
var ftec = new google.maps.LatLng(-29.173913, -51.218490);
directionsDisplay = new google.maps.DirectionsRenderer();
var mapOptions = {
zoom:15,
center: ftec,
streetViewControl: false,
panControl: true,
overviewMapControl: true,
zoomControl: true,
scaleControl: true
}
map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions);
directionsDisplay = new google.maps.DirectionsRenderer();
directionsDisplay.setMap(map);
directionsDisplay.setPanel(document.getElementById('directions-panel'));
var marker = new google.maps.Marker({
position: ftec,
map: map,
title:"FTEC Caxias do Sul"
});
function calcRoute(starte) {
var start = document.getElementById("search-route").value;
if(starte != undefined) {
start = starte;
}
var end = ftec;
var request = {
origin:start,
destination:end,
travelMode: google.maps.TravelMode.DRIVING
};
directionsService.route(request, function(response, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
}
});
}
autocomplete = new google.maps.places.Autocomplete(
(document.getElementById('search-route')),
{ types: ['geocode'] });
// When the user selects an address from the dropdown,
// populate the address fields in the form.
google.maps.event.addListener(autocomplete, 'place_changed', function() {
calcRoute();
});
document.getElementById("search-route").addEventListener("keypress", function(e){
if (e.keyCode == 13) {
calcRoute();
return false;
}
});
$('body').scrollspy({ target: '#main-navbar' });
$(document).on('click','.navbar-collapse.in',function(e) {
if( $(e.target).is('a') ) {
$(this).collapse('hide');
}
});
$(document).on('click','a.navbar-brand',function(e) {
if( $(e.target).is('a') ) {
$('.navbar-collapse.in').collapse('hide');
}
});