1// JavaScript Document 2/***************** JS Functions ******************/ 3 4checkHeaderStatus() 5/***************** Page Title Change ******************/ 6$(document).ready(function () { 7 "use strict"; 8 // Get page title 9 var pageTitle = $("title").text(); 10 // Change page title on blur 11 $(window).blur(function() { 12 $("title").text("Discover Valencia! âï¸"); 13 }); 14 15 // Change page title back on focus 16 $(window).focus(function() { 17 $("title").text(pageTitle); 18 }); 19 20}); 21 22/***************** Book Now Button ******************/ 23var booknow = document.getElementById("book_now_banner"); 24if(booknow != null){ 25 var book_now_banner = document.getElementById('book_now_banner'); //tester 26 var booking_form = document.getElementById('booking-engine'); //wrapper 27 28 window.onscroll = function() { 29 book_now_banner.style.visibility = checkVisible(booking_form) ? 'hidden' : 'visible'; 30 }; 31 32 function checkVisible(elm) { 33 var rect = elm.getBoundingClientRect(); 34 var viewHeight = Math.max(document.documentElement.clientHeight, window.innerHeight); 35 return !(rect.bottom < 0 || rect.top - viewHeight >= 0); 36 } 37} 38 39/***************** Navigation ******************/ 40$(document).ready(function () { 41 "use strict"; 42 43 $('.navigation_burger').click(function () { 44 navigationToggle(); 45 }); 46 function navigationToggle() { 47 $('.navigation_burger').toggleClass('navigation_burger--is-open'); 48 $('.navigation_group').toggleClass('navigation_group--is-open'); 49 $('html, body').toggleClass('scroll-lock'); 50 } 51}); 52 53$(document).ready(function() { 54 "use strict"; 55 checkHeaderStatus() 56 $(window).scroll(function () { 57 checkHeaderStatus() 58 }); 59 60}); 61 62function checkHeaderStatus() { 63 var amountScrolled = 60; 64 65 $(window).scroll(function() { 66 if ( $(window).scrollTop() > amountScrolled ) { 67 $('.navigation_container').addClass('show'); 68 $('.logo').removeClass('logo_white'); 69 $('.logo').addClass('logo_blue'); 70 $('.navigation_burger-el').addClass('blue_background'); 71 $('.navigation li a').addClass('blue_font'); 72 $('.navigation li a').addClass('transform_link_blue'); 73 $('.dropdown-content').addClass('show'); 74 } else { 75 $('.navigation_container').removeClass('show'); 76 $('.logo').addClass('logo_white'); 77 $('.logo').removeClass('logo_blue'); 78 $('.navigation_burger-el').removeClass('blue_background'); 79 $('.navigation li a').removeClass('blue_font'); 80 $('.navigation li a').removeClass('transform_link_blue'); 81 $('.dropdown-content').removeClass('show'); 82 } 83 }); 84} 85 86/***************** Page Scroll ******************/ 87$(document).ready(function(){ 88 // Add smooth scrolling to all links 89 $("a").on('click', function(event) { 90 91 // Make sure this.hash has a value before overriding default behavior 92 if (this.hash !== "") { 93 // Prevent default anchor click behavior 94 event.preventDefault(); 95 96 // Store hash 97 var hash = this.hash; 98 99 // Using jQuery's animate() method to add smooth page scroll 100 // The optional number (800) specifies the number of milliseconds it takes to scroll to the specified area 101 $('html, body').animate({ 102 scrollTop: $(hash).offset().top 103 }, 1000, function(){ 104 105 // Add hash (#) to URL when done scrolling (default click behavior) 106 window.location.hash = hash; 107 }); 108 } // End if 109 }); 110}); 111 112/***************** Review Slider ******************/ 113$(document).ready(function () { 114 if (document.getElementsByClassName("testiSlide").length) { 115 $('.testiSlide').slick({ 116 slidesToShow: 2, 117 slidesToScroll: 1, 118 autoplay: true, 119 autoplaySpeed: 6000, 120 responsive: [{ 121 breakpoint: 950, 122 settings: { 123 slidesToShow: 1, 124 slidesToScroll: 1, 125 infinite: true, 126 } 127 }] 128 }); 129 } 130}); 131 132/***************** Tour Gallery Slider ******************/ 133$(document).ready(function () { 134 if (document.getElementsByClassName("TourSlides").length) { 135 $('.TourSlides').slick({ 136 infinite: true, 137 autoplay: true, 138 autoplaySpeed: 4000, 139 dots: true, 140 arrows: true, 141 prevArrow: $('.previous'), 142 nextArrow: $('.next'), 143 responsive: [ 144 { 145 breakpoint: 730, 146 settings: {
147 arrows: false, 148 } 149 } 150 ] 151 }); 152 } 153}); 154 155/***************** Home Page Gallery Slider ******************/ 156$(document).ready(function () { 157 if (document.getElementsByClassName("HomepageGallery").length) { 158 $('.HomepageGallery').slick({ 159 infinite: true, 160 autoplay: true, 161 autoplaySpeed: 4000, 162 dots: true, 163 centerMode: true, 164 centerPadding: '0px', 165 slidesToShow: 3, 166 responsive: [ 167 { 168 breakpoint: 600, 169 settings: { 170 arrows: false, 171 centerMode: true, 172 centerPadding: '50px', 173 slidesToShow: 1 174 } 175 } 176 ] 177 }) 178 } 179}); 180 181/***************** Review Star Functionality ******************/ 182$(document).ready(function() { 183 var star_rating_width = $('.fill_ratings span').width(); 184 $('.star_ratings').width(star_rating_width); 185}); 186 187/***************** Gallery Modal Functionality ******************/ 188// Open the Modal 189var slideIndex = 1; 190function openModal() { 191 document.getElementById("myModal").style.display = "block"; 192 showSlides(slideIndex); 193} 194 195// Close the Modal 196function closeModal() { 197 document.getElementById("myModal").style.display = "none"; 198} 199 200// Next/previous controls 201function plusSlides(n) { 202 showSlides(slideIndex += n); 203} 204 205// Thumbnail image controls 206function currentSlide(n) { 207 showSlides(slideIndex = n); 208} 209 210function showSlides(n) { 211 var i; 212 var slides = document.getElementsByClassName("mySlides"); 213 if (n > slides.length) {slideIndex = 1} 214 if (n < 1) {slideIndex = slides.length} 215 for (i = 0; i < slides.length; i++) { 216 slides[i].style.display = "none"; 217 } 218 slides[slideIndex-1].style.display = "block"; 219} 220 221 222 223/***************** Menu Tabs ******************/ 224if (document.getElementsByClassName("tabcontent").length) { 225 tabcontent = document.getElementsByClassName("tabcontent"); 226 tabcontent[0].style.display = "block"; 227} 228 229function openCity(evt, cityName) { 230 // Declare all variables 231 var i, tabcontent, tablinks; 232 233 // Get all elements with class="tabcontent" and hide them 234 tabcontent = document.getElementsByClassName("tabcontent"); 235 for (i = 0; i < tabcontent.length; i++) { 236 tabcontent[i].style.display = "none"; 237 } 238 239 // Get all elements with class="tablinks" and remove the class "active" 240 tablinks = document.getElementsByClassName("tablinks"); 241 for (i = 0; i < tablinks.length; i++) { 242 tablinks[i].className = tablinks[i].className.replace(" active", ""); 243 } 244 245 // Show the current tab, and add an "active" class to the button that opened the tab 246 document.getElementById(cityName).style.display = "block"; 247 evt.currentTarget.className += " active"; 248} 249 250/***************** Ajax Contact Form ******************/ 251$(document).ready(function(){ 252 "use strict"; 253 var formMessages = $('#form-messages'); 254 $('#contact-us').on('submit', function(event){ 255 event.preventDefault(); 256 console.log("form submitted!") // sanity check 257 create_post(); 258 }); 259 260 261 // AJAX for posting 262 function create_post() { 263 var recaptchaToken = grecaptcha.getResponse(); 264 if(recaptchaToken === '') { 265 $(formMessages).removeClass('success'); 266 $(formMessages).addClass('error'); 267 $(formMessages).text('Looks like you need to click the button above...'); 268 return 269 } 270 $("#error-message").hide(); 271 $.ajax({ 272 //url: $(this).attr('action'), 273 url: "/", 274 type : "POST", 275 data : { name : $('#name-text').val(), 276 email: $('#email-text').val(), 277 phone_number: $('#phone-text').val(), 278 message: $('#message-text').val(), 279 "g-recaptcha-response": recaptchaToken}, 280 method: $(this).attr('method'), 281 // handle a successful response 282 success : function(json) { 283 $('#name-text').val(''); 284 $('#email-text').val(''); 285 $('#phone-text').val(''); 286 $('#message-text').val(''); 287 grecaptcha.reset(); // remove the value from the input' 288 $(formMessages).addClass('success'); 289 290 // Set the message text.
291 $(formMessages).text("Thank you for your message! We'll be in touch - Check your Spam folder just in case!"); 292 console.log("success"); 293 }, 294 }) 295 .fail(function() { 296 // Make sure that the formMessages div has the 'error' class. 297 $(formMessages).removeClass('success'); 298 $(formMessages).addClass('error'); 299 $(formMessages).text('Oops! An error occured and your message could not be sent.'); 300 }); 301 }; 302}); 303 304 // This function gets cookie with a given name 305 function getCookie(name) { 306 var cookieValue = null; 307 if (document.cookie && document.cookie != '') { 308 var cookies = document.cookie.split(';'); 309 for (var i = 0; i < cookies.length; i++) { 310 var cookie = jQuery.trim(cookies[i]); 311 // Does this cookie string begin with the name we want? 312 if (cookie.substring(0, name.length + 1) == (name + '=')) { 313 cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); 314 break; 315 } 316 } 317 } 318 return cookieValue; 319 } 320 var csrftoken = getCookie('csrftoken'); 321 322 /* 323 The functions below will create a header with csrftoken 324 */ 325 326 function csrfSafeMethod(method) { 327 // these HTTP methods do not require CSRF protection 328 return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method)); 329 } 330 function sameOrigin(url) { 331 // test that a given url is a same-origin URL 332 // url could be relative or scheme relative or absolute 333 var host = document.location.host; // host + port 334 var protocol = document.location.protocol; 335 var sr_origin = '//' + host; 336 var origin = protocol + sr_origin; 337 // Allow absolute or scheme relative URLs to same origin 338 return (url == origin || url.slice(0, origin.length + 1) == origin + '/') || 339 (url == sr_origin || url.slice(0, sr_origin.length + 1) == sr_origin + '/') || 340 // or any other URL that isn't scheme relative or absolute i.e relative. 341 !(/^(\/\/|http:|https:).*/.test(url)); 342 } 343 344 $.ajaxSetup({ 345 beforeSend: function(xhr, settings) { 346 if (!csrfSafeMethod(settings.type) && sameOrigin(settings.url)) { 347 // Send the token to same-origin, relative URLs only. 348 // Send the token only if the method warrants CSRF protection 349 // Using the CSRFToken value acquired earlier 350 xhr.setRequestHeader("X-CSRFToken", csrftoken); 351 } 352 } 353 });
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.