SHOW:
|
|
- or go back to the newest paste.
1 | // Custom JS for the Theme | |
2 | ||
3 | // Config | |
4 | //------------------------------------------------------------- | |
5 | ||
6 | var companyName = "NCC Roma Taxi"; // Enter your event title | |
7 | ||
8 | ||
9 | // Initialize Tooltip | |
10 | //------------------------------------------------------------- | |
11 | ||
12 | $('.my-tooltip').tooltip(); | |
13 | ||
14 | ||
15 | ||
16 | // Initialize jQuery Placeholder | |
17 | //------------------------------------------------------------- | |
18 | ||
19 | $('input, textarea').placeholder(); | |
20 | ||
21 | ||
22 | ||
23 | // Toggle Header / Nav | |
24 | //------------------------------------------------------------- | |
25 | ||
26 | $(document).on("scroll",function(){ | |
27 | if($(document).scrollTop()>39){ | |
28 | $("header").removeClass("large").addClass("small"); | |
29 | } | |
30 | else{ | |
31 | $("header").removeClass("small").addClass("large"); | |
32 | } | |
33 | }); | |
34 | ||
35 | ||
36 | ||
37 | // Vehicles Tabs / Slider | |
38 | //------------------------------------------------------------- | |
39 | ||
40 | $(".vehicle-data").hide(); | |
41 | var activeVehicleData = $(".vehicle-nav .active a").attr("href"); | |
42 | $(activeVehicleData).show(); | |
43 | ||
44 | $(".vehicle-nav li").on("click", function(){ | |
45 | ||
46 | $(".vehicle-nav .active").removeClass("active"); | |
47 | $(this).addClass('active'); | |
48 | ||
49 | $(activeVehicleData).fadeOut( "slow", function() { | |
50 | activeVehicleData = $(".vehicle-nav .active a").attr("href"); | |
51 | $(activeVehicleData).fadeIn("slow", function() {}); | |
52 | }); | |
53 | ||
54 | return false; | |
55 | }); | |
56 | ||
57 | ||
58 | ||
59 | // Vehicles Responsive Nav | |
60 | //------------------------------------------------------------- | |
61 | ||
62 | $("<div />").appendTo("#vehicle-nav-container").addClass("styled-select-vehicle-data"); | |
63 | $("<select />").appendTo(".styled-select-vehicle-data").addClass("vehicle-data-select"); | |
64 | $("#vehicle-nav-container a").each(function() { | |
65 | var el = $(this); | |
66 | $("<option />", { | |
67 | "value" : el.attr("href"), | |
68 | "text" : el.text() | |
69 | }).appendTo("#vehicle-nav-container select"); | |
70 | }); | |
71 | ||
72 | $(".vehicle-data-select").change(function(){ | |
73 | $(activeVehicleData).fadeOut( "slow", function() { | |
74 | activeVehicleData = $(".vehicle-data-select").val(); | |
75 | $(activeVehicleData).fadeIn("slow", function() {}); | |
76 | }); | |
77 | ||
78 | return false; | |
79 | }); | |
80 | ||
81 | ||
82 | // Initialize Datepicker | |
83 | //-------------------------------------------------------------------------------format: 'dd/mm/yyyy' | |
84 | ||
85 | var nowDate = new Date(); | |
86 | var today = new Date(nowDate.getFullYear(), nowDate.getMonth(), nowDate.getDate(), 0, 0, 0, 0); | |
87 | ||
88 | $('.datepicker').datepicker({ format: "dd/mm/yyyy", language: "it", startDate: today, maxDate: today, pickTime: false }).on('changeDate', function () { | |
89 | $(this).datepicker('hide'); | |
90 | }); | |
91 | ||
92 | ||
93 | ||
94 | ||
95 | // Toggle Drop-Off Location | |
96 | //------------------------------------------------------------------------------- | |
97 | // eliminata funzione di ricerca drop-off diversa da pick-up --> sempre necessario specificare drop-off | |
98 | //$(".input-group.drop-off").hide(); | |
99 | //$(".different-drop-off").on("click", function(){ | |
100 | // $(".input-group.drop-off").toggle(); | |
101 | // $(".autocomplete-suggestions").css("width", $('.pick-up .autocomplete-location').outerWidth()); | |
102 | // return false; | |
103 | //}); | |
104 | ||
105 | ||
106 | ||
107 | // Scroll to Top Button | |
108 | //------------------------------------------------------------------------------- | |
109 | ||
110 | $(window).scroll(function(){ | |
111 | if ($(this).scrollTop() > 100) { | |
112 | $('.scrollup').removeClass("animated fadeOutRight"); | |
113 | $('.scrollup').fadeIn().addClass("animated fadeInRight"); | |
114 | } else { | |
115 | $('.scrollup').removeClass("animated fadeInRight"); | |
116 | $('.scrollup').fadeOut().addClass("animated fadeOutRight"); | |
117 | } | |
118 | }); | |
119 | ||
120 | $('.scrollup, .navbar-brand').click(function(){ | |
121 | $("html, body").animate({ scrollTop: 0 }, 'slow', function(){ | |
122 | $("nav li a").removeClass('active'); | |
123 | }); | |
124 | return false; | |
125 | }); | |
126 | ||
127 | ||
128 | ||
129 | // Location Map Function | |
130 | //------------------------------------------------------------------------------- | |
131 | ||
132 | function loadMap(addressData){ | |
133 | ||
134 | var path = document.URL; | |
135 | ||
136 | var locationContent = "<h2>"+companyName+"</h2>" | |
137 | + "<p>" + "Via Lisbona, 23, Roma, 00198" + "</p>"; | |
138 | ||
139 | $('#locations .map').gmap3({ | |
140 | map: { | |
141 | options: { | |
142 | maxZoom: 14, | |
143 | scrollwheel: false, | |
144 | center: true, | |
145 | zoom: 15 | |
146 | } | |
147 | }, | |
148 | infowindow:{ | |
149 | //address: addressData, | |
150 | address: "Via Lisbona, 23, Roma, 00198", | |
151 | options:{ | |
152 | content: locationContent | |
153 | } | |
154 | }, | |
155 | marker:{ | |
156 | address: "Via Lisbona, 23, Roma, 00198", | |
157 | options: { | |
158 | icon: new google.maps.MarkerImage( | |
159 | "/img/mapmarker.png", | |
160 | new google.maps.Size(59, 58, "px", "px"), | |
161 | new google.maps.Point(0, 0), //sets the origin point of the icon | |
162 | new google.maps.Point(29, 34) //sets the anchor point for the icon | |
163 | ) | |
164 | } | |
165 | } | |
166 | }, | |
167 | "autofit" ); | |
168 | } | |
169 | ||
170 | loadMap(locations[0].value); | |
171 | ||
172 | $("#location-map-select").append('<option value="'+locations[0].value+'">Please select a location</option>'); | |
173 | $.each(locations, function( index, value ) { | |
174 | var option = '<option value="'+value.value+'">'+value.value+'</option>'; | |
175 | $("#location-map-select").append(option); | |
176 | }); | |
177 | ||
178 | $('#location-map-select').on('change', function() { | |
179 | $('#locations .map').gmap3('destroy'); | |
180 | loadMap(this.value); | |
181 | }); | |
182 | ||
183 | ||
184 | ||
185 | // Scroll To Animation | |
186 | //------------------------------------------------------------------------------- | |
187 | ||
188 | var scrollTo = $(".scroll-to"); | |
189 | ||
190 | scrollTo.click( function(event) { | |
191 | $('.modal').modal('hide'); | |
192 | var position = $(document).scrollTop(); | |
193 | var scrollOffset = 260; | |
194 | ||
195 | if(position > 39) | |
196 | { | |
197 | scrollOffset = 114; | |
198 | } | |
199 | ||
200 | var marker = $(this).attr('href'); | |
201 | $('html, body').animate({ scrollTop: $(marker).offset().top - scrollOffset}, 'slow'); | |
202 | return false; | |
203 | }); | |
204 | ||
205 | ||
206 | ||
207 | // setup autocomplete - pulling from locations-autocomplete.js | |
208 | //------------------------------------------------------------------------------- | |
209 | ||
210 | $('.autocomplete-location').autocomplete({ | |
211 | lookup: locations | |
212 | }); | |
213 | ||
214 | ||
215 | ||
216 | // Newsletter Form | |
217 | //------------------------------------------------------------------------------- | |
218 | ||
219 | $( "#newsletter-form" ).submit(function() { | |
220 | ||
221 | $('#newsletter-form-msg').addClass('hidden'); | |
222 | $('#newsletter-form-msg').removeClass('alert-success'); | |
223 | $('#newsletter-form-msg').removeClass('alert-danger'); | |
224 | ||
225 | $('#newsletter-form input[type=submit]').attr('disabled', 'disabled'); | |
226 | ||
227 | $.ajax({ | |
228 | type: "POST", | |
229 | url: "send.asmx/NewsletterForm", | |
230 | data: { formVars: $("#newsletter-form").serialize() }, | |
231 | dataType: "json", | |
232 | success: function(data) {}, | |
233 | error: function () | |
234 | { | |
235 | $('#newsletter-form-msg').css('visibility', 'visible').hide().fadeIn().removeClass('hidden').addClass('alert-success'); | |
236 | $('#newsletter-form-msg').html('Iscrizione correttamente inviata, Grazie.'); | |
237 | $('#newsletter-form input[type=submit]').removeAttr('disabled'); | |
238 | $('#newsletter-form')[0].reset(); | |
239 | } | |
240 | ||
241 | }); | |
242 | ||
243 | return false; | |
244 | }); | |
245 | ||
246 | //if ('success' == data.result) { | |
247 | // $('#newsletter-form-msg').css('visibility', 'visible').hide().fadeIn().removeClass('hidden').addClass('alert-success'); | |
248 | // $('#newsletter-form-msg').html(data.msg[0]); | |
249 | // $('#newsletter-form input[type=submit]').removeAttr('disabled'); | |
250 | // $('#newsletter-form')[0].reset(); | |
251 | //} | |
252 | ||
253 | //if ('error' == data.result) { | |
254 | // $('#newsletter-form-msg').css('visibility', 'visible').hide().fadeIn().removeClass('hidden').addClass('alert-danger'); | |
255 | // $('#newsletter-form-msg').html(data.msg[0]); | |
256 | // $('#newsletter-form input[type=submit]').removeAttr('disabled'); | |
257 | //} | |
258 | ||
259 | // Contact Form | |
260 | //------------------------------------------------------------------------------- | |
261 | ||
262 | $( "#contact-form" ).submit(function() { | |
263 | ||
264 | $('#contact-form-msg').addClass('hidden'); | |
265 | $('#contact-form-msg').removeClass('alert-success'); | |
266 | $('#contact-form-msg').removeClass('alert-danger'); | |
267 | ||
268 | $('#contact-form input[type=submit]').attr('disabled', 'disabled'); | |
269 | ||
270 | $.ajax({ | |
271 | type: "POST", | |
272 | url: "send.asmx/ContactForm", | |
273 | data: { formVars: $("#contact-form").serialize() }, | |
274 | dataType: "json", | |
275 | success: function(data) { | |
276 | }, | |
277 | error: function () | |
278 | { | |
279 | $('#contact-form-msg').css('visibility', 'visible').hide().fadeIn().removeClass('hidden').addClass('alert-success'); | |
280 | $('#contact-form-msg').html('Richiesta correttamente inviata, Grazie.'); | |
281 | $('#contact-form input[type=submit]').removeAttr('disabled'); | |
282 | $('#contact-form')[0].reset(); | |
283 | ||
284 | var iframe = document.createElement('iframe'); | |
285 | iframe.style.display = "none"; | |
286 | iframe.src = "google_conversione.html"; | |
287 | document.body.appendChild(iframe); | |
288 | } | |
289 | }); | |
290 | ||
291 | return false; | |
292 | }); | |
293 | ||
294 | //if('success' == data.result) | |
295 | //{ | |
296 | // $('#contact-form-msg').css('visibility','visible').hide().fadeIn().removeClass('hidden').addClass('alert-success'); | |
297 | // $('#contact-form-msg').html(data.msg[0]); | |
298 | // $('#contact-form input[type=submit]').removeAttr('disabled'); | |
299 | // $('#contact-form')[0].reset(); | |
300 | //} | |
301 | ||
302 | //if('error' == data.result) | |
303 | //{ | |
304 | // $('#contact-form-msg').css('visibility','visible').hide().fadeIn().removeClass('hidden').addClass('alert-danger'); | |
305 | // $('#contact-form-msg').html(data.msg[0]); | |
306 | // $('#contact-form input[type=submit]').removeAttr('disabled'); | |
307 | //} | |
308 | ||
309 | // Car Select Form | |
310 | //------------------------------------------------------------------------------- | |
311 | ||
312 | $( "#car-select-form" ).submit(function() { | |
313 | ||
314 | var pax = $("#nr_pax").val(); | |
315 | var selectedCar = $("#car-select").find(":selected").text(); | |
316 | var selectedCarVal = $("#car-select").find(":selected").val(); | |
317 | var selectedCarImage = $("#car-select").val(); | |
318 | var pickupLocation = $("#pick-up-location").val(); | |
319 | var dropoffLocation = $("#drop-off-location").val(); | |
320 | var pickUpDate = $("#pick-up-date").val(); | |
321 | var pickUpTime = $("#pick-up-time").val(); | |
322 | var dropOffDate = $("#drop-off-date").val(); | |
323 | var dropOffTime = $("#drop-off-time").val(); | |
324 | ||
325 | var error = 0; | |
326 | ||
327 | if (validateNotEmpty(pax)) { error = 1; } | |
328 | if(validateNotEmpty(selectedCarVal)) { error = 1; } | |
329 | if(validateNotEmpty(pickupLocation)) { error = 1; } | |
330 | if(validateNotEmpty(pickUpDate)) { error = 1; } | |
331 | if(validateNotEmpty(dropOffDate)) { error = 1; } | |
332 | ||
333 | if(0 == error) | |
334 | { | |
335 | - | console.log('form senza errori'); |
335 | + | console.log('Form Compiled with no errors'); |
336 | - | ga('send', 'event', 'Form'); |
336 | + | ga('send', 'event', 'Form', 'Submit'); |
337 | $("#pax-ph").html(pax); | |
338 | $("#pax").val(pax); | |
339 | ||
340 | $("#selected-car-ph").html(selectedCar); | |
341 | $("#selected-car").val(selectedCar); | |
342 | $("#selected-vehicle-image").attr('src', selectedCarImage); | |
343 | ||
344 | $("#pickup-location-ph").html(pickupLocation); | |
345 | $("#pickup-location").val(pickupLocation); | |
346 | ||
347 | if("" == dropoffLocation) | |
348 | { | |
349 | $("#dropoff-location-ph").html(pickupLocation); | |
350 | $("#dropoff-location").val(pickupLocation); | |
351 | } | |
352 | else | |
353 | { | |
354 | $("#dropoff-location-ph").html(dropoffLocation); | |
355 | $("#dropoff-location").val(dropoffLocation); | |
356 | } | |
357 | ||
358 | $("#pick-up-date-ph").html(pickUpDate); | |
359 | $("#pick-up-time-ph").html(pickUpTime); | |
360 | $("#pick-up").val(pickUpDate+' at '+pickUpTime); | |
361 | ||
362 | $("#drop-off-date-ph").html(dropOffDate); | |
363 | $("#drop-off-time-ph").html(dropOffTime); | |
364 | $("#drop-off").val(dropOffDate+' at '+dropOffTime); | |
365 | ||
366 | $('#checkoutModal').modal(); | |
367 | } | |
368 | else | |
369 | { | |
370 | $('#car-select-form-msg').css('visibility','visible').hide().fadeIn().removeClass('hidden').delay(2000).fadeOut(); | |
371 | } | |
372 | ||
373 | return false; | |
374 | }); | |
375 | ||
376 | ||
377 | ||
378 | // Check Out Form | |
379 | //------------------------------------------------------------------------------- | |
380 | ||
381 | $( "#checkout-form" ).submit(function() { | |
382 | ||
383 | $('#checkout-form-msg').addClass('hidden'); | |
384 | $('#checkout-form-msg').removeClass('alert-success'); | |
385 | $('#checkout-form-msg').removeClass('alert-danger'); | |
386 | ||
387 | $('#checkout-form input[type=submit]').attr('disabled', 'disabled'); | |
388 | ||
389 | $.ajax({ | |
390 | type: "POST", | |
391 | url: "send.asmx/RapidForm", | |
392 | data: { formVars: $("#checkout-form").serialize() }, | |
393 | dataType: "json", | |
394 | success: function () { | |
395 | }, | |
396 | error: function () { | |
397 | ||
398 | $('#checkout-form-msg').css('visibility','visible').hide().fadeIn().removeClass('hidden').addClass('alert-success'); | |
399 | $('#checkout-form-msg').html('Richiesta correttamente inviata, Grazie.'); | |
400 | $('#checkout-form input[type=submit]').removeAttr('disabled'); | |
401 | ||
402 | setTimeout(function(){ | |
403 | $('.modal').modal('hide'); | |
404 | $('#checkout-form-msg').addClass('hidden'); | |
405 | $('#checkout-form-msg').removeClass('alert-success'); | |
406 | ||
407 | $('#checkout-form')[0].reset(); | |
408 | $('#car-select-form')[0].reset(); | |
409 | }, 5000); | |
410 | ||
411 | var iframe = document.createElement('iframe'); | |
412 | iframe.style.display = "none"; | |
413 | iframe.src = "google_conversione.html"; | |
414 | document.body.appendChild(iframe); | |
415 | ||
416 | } | |
417 | //success: function(data) { | |
418 | ||
419 | //if('success' == data.result) | |
420 | //{ | |
421 | // $('#checkout-form-msg').css('visibility','visible').hide().fadeIn().removeClass('hidden').addClass('alert-success'); | |
422 | // $('#checkout-form-msg').html(data.msg[0]); | |
423 | // $('#checkout-form input[type=submit]').removeAttr('disabled'); | |
424 | ||
425 | // setTimeout(function(){ | |
426 | // $('.modal').modal('hide'); | |
427 | // $('#checkout-form-msg').addClass('hidden'); | |
428 | // $('#checkout-form-msg').removeClass('alert-success'); | |
429 | ||
430 | // $('#checkout-form')[0].reset(); | |
431 | // $('#car-select-form')[0].reset(); | |
432 | // }, 5000); | |
433 | ||
434 | //} | |
435 | ||
436 | //if('error' == data.result) | |
437 | //{ | |
438 | // alert(data.result); | |
439 | // $('#checkout-form-msg').css('visibility','visible').hide().fadeIn().removeClass('hidden').addClass('alert-danger'); | |
440 | // $('#checkout-form-msg').html(data.msg[0]); | |
441 | // $('#checkout-form input[type=submit]').removeAttr('disabled'); | |
442 | //} | |
443 | ||
444 | //} | |
445 | }); | |
446 | ||
447 | return false; | |
448 | }); | |
449 | ||
450 | ||
451 | ||
452 | // Not Empty Validator Function | |
453 | //------------------------------------------------------------------------------- | |
454 | ||
455 | function validateNotEmpty(data){ | |
456 | if (data == ''){ | |
457 | return true; | |
458 | }else{ | |
459 | return false; | |
460 | } | |
461 | } |