1/* 2 * Title: Travelo | Responsive Wordpress Booking Template - Main Javascript file 3 * Author: http://themeforest.net/user/soaptheme 4 */ 5 6/////////////////////////////////////////////////////////////////////////////// 7////////////////////////////////// MAIN FUNCTIONS ///////////////////////////// 8/////////////////////////////////////////////////////////////////////////////// 9"use strict"; 10var tjq = jQuery.noConflict(); 11var stGlobals = {}; 12var enableChaser = 1; // Enable Chaser menu (open on scroll) ? 1 - Yes / 0 - No 13if ( settings.sticky_menu ) enableChaser = settings.sticky_menu; 14stGlobals.isMobile = (/(Android|BlackBerry|iPhone|iPod|iPad|Palm|Symbian)/.test(navigator.userAgent)); 15stGlobals.isMobileWebkit = /WebKit/.test(navigator.userAgent) && /Mobile/.test(navigator.userAgent); 16stGlobals.isIOS = (/iphone|ipad|ipod/gi).test(navigator.appVersion); 17 18/* middle block plugin(set image in the middle of its parent object) */ 19(function($) { 20 var middleblock; 21 var prototype = $.fn; 22 middleblock = prototype.middleblock = function() { 23 var $this = this; 24 if ($(this).is(":visible")) { 25 $this.bind("set.middleblock", set_middle_block).trigger('set.middleblock'); 26 } 27 return $this; 28 }; 29 30 function set_middle_block() { 31 var $this = $(this); 32 var $middleItem = $this.find(".middle-item"); 33 if ($middleItem.length < 1) { 34 $middleItem = $this.children("img"); 35 } 36 if ($middleItem.length < 1) { 37 return; 38 } 39 var width = $middleItem.width(); 40 var height = $middleItem.height(); 41 var parentObj; 42 if ($this.width() <= 1) { 43 parentObj = $this; 44 while (parentObj.width() <= 1) { 45 parentObj = parentObj.parent(); 46 } 47 $this.css("width", parentObj.width() + "px"); 48 } 49 $this.css("position", "relative"); 50 $middleItem.css("position", "absolute"); 51 52 if ($this.hasClass("middle-block-auto-height")) { 53 $this.removeClass("middle-block-auto-height"); 54 $this.height(0); 55 } 56 if ($this.height() <= 1) { 57 parentObj = $this; 58 while (parentObj.height() <= 1) { 59 if (parentObj.css("float") =="left" && parentObj.index() == 0 && parentObj.next().length > 0) { 60 parentObj = parentObj.next(); 61 } else if (parentObj.css("float") == "left" && parentObj.index() > 0) { 62 parentObj = parentObj.prev(); 63 } else { 64 parentObj = parentObj.parent(); 65 } 66 } 67 $this.css("height", parentObj.outerHeight() + "px"); 68 $this.addClass("middle-block-auto-height"); 69 70 width = $middleItem.width(); 71 height = $middleItem.height(); 72 if (height <= 1) { 73 height = parentObj.outerHeight(); 74 } 75 } 76 $middleItem.css("top", "50%"); 77 $middleItem.css("margin-top", "-" + (height / 2) + "px"); 78 if (width >= 1) { 79 /*if ($this.width() == width) { 80 $this.width(width); 81 }*/ 82 $middleItem.css("left", "50%"); 83 $middleItem.css("margin-left", "-" + (width / 2) + "px"); 84 } else { 85 $middleItem.css("left", "0"); 86 } 87 } 88}(jQuery)); 89 90/* calendar */
91function Calendar() { 92 this.html = ""; 93} 94(function ($) { 95 Calendar.prototype.generateHTML = function(Month, Year, notAvailableDays, priceArr) { 96 var days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; 97 var daynames = new Array("sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"); 98 var today = new Date(); 99 var thisDay = today.getDate(); 100 var thisMonth = today.getMonth(); 101 var thisYear = 1900 + today.getYear(); 102 var i; 103 if (typeof notAvailableDays == "undefined") { 104 notAvailableDays = []; 105 } 106 if (typeof priceArr == "undefined") { 107 priceArr = []; 108 } 109 var html = ""; 110 var firstDay = new Date(Year, Month, 1); 111 var startDay = firstDay.getDay(); 112 113 if (((Year % 4 == 0) && (Year % 100 != 0)) || (Year % 400 == 0)) { 114 days[1] = 29; 115 } else { 116 days[1] = 28; 117 } 118 119 html += "<table><thead><tr>"; 120 121 for ( i= 0; i < 7; i++) { 122 html += "<td>" + daynames[i] + "</td>"; 123 } 124 125 html += "</tr></thead><tbody><tr>"; 126 127 var column = 0; 128 var lastMonth = Month - 1; 129 if (lastMonth == -1) { lastMonth = 11; } 130 for (i = 0; i < startDay; i++) { 131 //html += "<td class='date-passed prev-month'><span>" + (days[lastMonth] - startDay + i + 1) + "</span></td>"; 132 html += "<td class='prev-month'></td>"; 133 column++; 134 } 135 136 for (i = 1; i <= days[Month]; i++) { 137 var className = []; 138 if ((i == thisDay) && (Month == thisMonth) && (Year == thisYear)) { 139 className.push("today"); 140 } 141 142 var priceText = ""; 143 if (Year > thisYear || (Year == thisYear && Month > thisMonth) || (Year == thisYear && Month == thisMonth && i >= thisDay)) { 144 if ($.inArray(i, notAvailableDays) !== -1) { 145 className.push("unavailable"); 146 } else { 147 className.push("available"); 148 if (typeof priceArr[i] != "undefined") { 149 priceText += "<span class='price-text'>" + priceArr[i] + "</span>"; 150 } 151 } 152 } else { 153 className.push("date-passed"); 154 } 155 156 if (i < thisDay || $.inArray(i, notAvailableDays) !== -1) { 157 html += "<td class='" + className.join(" ") + "'><span>" + i + "</span></td>"; 158 } else { 159 html += "<td class='" + className.join(" ") + "'><a href='#' class='no-redirect'>" + i + priceText + "</a></td>"; 160 } 161 162 column++; 163 if (column == 7) { 164 html += "</tr><tr>"; 165 column = 0; 166 } 167 } 168 html += "</tr></tbody></table>"; 169 this.html = html; 170 }; 171 172 Calendar.prototype.getHTML = function() { 173 return this.html; 174 }; 175}(jQuery)); 176 177/* jQuery CountTo plugin */ 178(function(a){a.fn.countTo=function(g){g=g||{};return a(this).each(function(){function e(a){a=b.formatter.call(h,a,b);f.html(a)}var b=a.extend({},a.fn.countTo.defaults,{from:a(this).data("from"),to:a(this).data("to"),speed:a(this).data("speed"),refreshInterval:a(this).data("refresh-interval"),decimals:a(this).data("decimals")},g),j=Math.ceil(b.speed/b.refreshInterval),l=(b.to-b.from)/j,h=this,f=a(this),k=0,c=b.from,d=f.data("countTo")||{};f.data("countTo",d);d.interval&&clearInterval(d.interval);d.interval=setInterval(function(){c+=l;k++;e(c);"function"==typeof b.onUpdate&&b.onUpdate.call(h,c);k>=j&&(f.removeData("countTo"),clearInterval(d.interval),c=b.to,"function"==typeof b.onComplete&&b.onComplete.call(h,c))},b.refreshInterval);e(c)})};a.fn.countTo.defaults={from:0,to:0,speed:1E3,refreshInterval:100,decimals:0,formatter:function(a,e){return a.toFixed(e.decimals)},onUpdate:null,onComplete:null}})(jQuery); 179 180/* soaptheme popup plugin */ 181(function($) { 182 var stp, SoapPopup = function(){}; 183 SoapPopup.prototype = { 184 constructor: SoapPopup, 185 init: function() { 186 // 187 }, 188 open: function(options, obj) { 189 if (typeof options == "undefined") { 190 options = {}; 191 } 192 var wrapObj = options.wrapId ? "#" + options.wrapId : ".opacity-overlay"; 193 if ($(wrapObj).length < 1) { 194 var idStr = options.wrapId ? " id='" + options.wrapId + "'" : ""; 195 $("<div class='opacity-overlay' " + idStr + "><div class='container'><div class='popup-wrapper'><i class='fa fa-spinner fa-spin spinner'></i><div class='col-xs-12 col-sm-9 popup-content'></div></div></div></div>").appendTo("body"); 196 } 197 stp.wrap = $(wrapObj); 198 stp.content = stp.wrap.find(".popup-content"); 199 stp.spinner = stp.wrap.find(".spinner"); 200 stp.contentContainer = stp.wrap.find(".popup-wrapper"); 201 202 if (stGlobals.isMobile) { 203 stp.wrap.css({ 204 height: $(document).height(), 205 position: 'absolute' 206 }); 207 stp.contentContainer.css("top", $(window).scrollTop()); 208 } 209 210 stp.updateSize(); 211 var sourceId = obj.attr("href"); 212 if (typeof sourceId == "undefined") { 213 sourceId = obj.data("target"); 214 } 215 216 if (options.type == "ajax") { 217 stp.content.html(''); 218 stp.content.height('auto').css("visibility", "hidden"); 219 stp.wrap.fadeIn(); 220 stp.spinner.show(); 221 $("body").addClass("overlay-open"); 222 $.ajax({
223 url: options.url, 224 type: 'post', 225 data: options.data, 226 success: function(html) { 227 stp.content.html("<a href=\"javascript:void(0);\" data-dismiss=\"modal\" style=\"text-align: right; display: block;\">X</a>" + html); 228 if (options.callBack) { 229 options.callBack(stp); 230 } 231 setTimeout(function() { 232 stp.content.css("visibility", "visible"); 233 stp.spinner.hide(); 234 }, 100); 235 } 236 }); 237 } else if (options.type == "map") { 238 stp.wrap.fadeIn(); 239 stp.spinner.show(); 240 var lngltd = options.lngltd.split(","); 241 var contentWidth = stp.content.width(); 242 stp.content.gmap3({ 243 clear: { 244 name: "marker", 245 last: true 246 } 247 }); 248 var zoom = options.zoom ? parseInt(options.zoom, 10) : 12; 249 stp.content.height(contentWidth * 0.5).gmap3({ 250 map: { 251 options: { 252 center: lngltd, 253 zoom: zoom 254 } 255 }, 256 marker: { 257 values: [ 258 {latLng: lngltd} 259 260 ], 261 options: { 262 draggable: false 263 }, 264 } 265 }); 266 $("body").addClass("overlay-open"); 267 } else { 268 stp.content.children().hide(); 269 if (stp.content.children(sourceId).length > 0) { 270 ;// ignore 271 } else { 272 $(sourceId).appendTo(stp.content); 273 } 274 $(sourceId).show(); 275 stp.spinner.hide(); 276 stp.wrap.fadeIn(function() { 277 $(sourceId).find(".input-text").eq(0).focus(); 278 $("body").addClass("overlay-open"); 279 }); 280 } 281 }, 282 close: function() { 283 $("body").removeClass("overlay-open"); 284 $("html").css("overflow", ""); 285 $("html").css("margin-right", ""); 286 stp.spinner.hide(); 287 stp.wrap.fadeOut(); 288 }, 289 updateSize: function() { 290 if (stGlobals.isIOS) { 291 var zoomLevel = document.documentElement.clientWidth / window.innerWidth; 292 var height = window.innerHeight * zoomLevel; 293 stp.contentContainer.css('height', height); 294 } else if (stGlobals.isMobile) { 295 stp.contentContainer.css('height', $(window).height()); 296 } 297 }, 298 getScrollbarSize: function() { 299 if (document.body.scrollHeight <= $(window).height()) { 300 return 0; 301 } 302 if(stp.scrollbarSize === undefined) { 303 var scrollDiv = document.createElement("div"); 304 scrollDiv.style.cssText = 'width: 99px; height: 99px; overflow: scroll; position: absolute; top: -9999px;'; 305 document.body.appendChild(scrollDiv); 306 stp.scrollbarSize = scrollDiv.offsetWidth - scrollDiv.clientWidth; 307 document.body.removeChild(scrollDiv); 308 } 309 return stp.scrollbarSize; 310 } 311 } 312 313 $.fn.soapPopup = function(options) { 314 stp = new SoapPopup(); 315 stp.init(); 316 317 $(document).bind('keydown', function (e) { 318 var key = e.keyCode; 319 if ($(".opacity-overlay:visible").length > 0 && key === 27) { 320 e.preventDefault(); 321 stp.close(); 322 } 323 }); 324 325 $(document).on("click touchend", ".opacity-overlay", function(e) { 326 if ( !$(e.target).is(".opacity-overlay .popup-content *")) { 327 e.preventDefault(); 328 stp.close(); 329 } 330 }); 331 332 $(window).resize(function() { 333 stp.updateSize(); 334 }); 335 336 stp.open(options, $(this)); 337 338 $(document).on("click touchend", ".opacity-overlay [data-dismiss='modal']", function(e) { 339 stp.close(); 340 }); 341 return $(this); 342 }; 343})(jQuery); 344 345/* jQuery set same height plugin */ 346tjq.fn.setSameHeight=function(){ 347 var max_height = 0; 348 tjq(this).height('auto'); 349 tjq(this).each(function(index){ 350 if (tjq(this).outerHeight() > max_height) { max_height = tjq(this).outerHeight(); } 351 }); 352 tjq(this).css('min-height', max_height); 353 return this; 354} 355 356/* change UI of input, select, option, checkbox, datepicker */ 357function changeTraveloElementUI() { 358 // change UI of select box 359 tjq(".selector select").each(function() { 360 var obj = tjq(this); 361 if (obj.parent().children(".custom-select").length < 1) { 362 obj.after("<span class='custom-select'>" + obj.children("option:selected").html() + "</span>"); 363 364 if (obj.hasClass("white-bg")) { 365 obj.next("span.custom-select").addClass("white-bg"); 366 } 367 if (obj.hasClass("full-width")) { 368 //obj.removeClass("full-width"); 369 //obj.css("width", obj.parent().width() + "px"); 370 //obj.next("span.custom-select").css("width", obj.parent().width() + "px"); 371 obj.next("span.custom-select").addClass("full-width"); 372 } 373 } 374 }); 375 tjq("body").on("change", ".selector select", function() { 376 if (tjq(this).next("span.custom-select").length > 0) { 377 tjq(this).next("span.custom-select").text(tjq(this).children("option:selected").text()); 378 } 379 }); 380 381 tjq("body").on("keydown", ".selector select", function() { 382 if (tjq(this).next("span.custom-select").length > 0) { 383 tjq(this).next("span.custom-select").text(tjq(this).children("option:selected").text()); 384 } 385 }); 386 387 // change UI of file input 388 tjq(".fileinput input[type=file]").each(function() { 389 var obj = tjq(this); 390 if (obj.parent().children(".custom-fileinput").length < 1) { 391 obj.after('<input type="text" class="custom-fileinput" />'); 392 if (typeof obj.data("placeholder") != "undefined") { 393 obj.next(".custom-fileinput").attr("placeholder", obj.data("placeholder")); 394 } 395 if (typeof obj.prop("class") != "undefined") { 396 obj.next(".custom-fileinput").addClass(obj.prop("class")); 397 } 398 obj.parent().css("line-height", obj.outerHeight() + "px"); 399 } 400 }); 401 402 tjq(".fileinput input[type=file]").on("change", function() { 403 var fileName = this.value; 404 var slashIndex = fileName.lastIndexOf("\\"); 405 if (slashIndex == -1) { 406 slashIndex = fileName.lastIndexOf("/"); 407 } 408 if (slashIndex != -1) { 409 fileName = fileName.substring(slashIndex + 1); 410 } 411 tjq(this).next(".custom-fileinput").val(fileName); 412 }); 413 // checkbox 414 tjq(".checkbox input[type='checkbox'], .radio input[type='radio']").each(function() { 415 if (tjq(this).is(":checked")) { 416 tjq(this).closest(".checkbox").addClass("checked"); 417 tjq(this).closest(".radio").addClass("checked"); 418 } 419 }); 420 tjq(".checkbox input[type='checkbox']").bind("change", function() { 421 if (tjq(this).is(":checked")) { 422 tjq(this).closest(".checkbox").addClass("checked"); 423 } else { 424 tjq(this).closest(".checkbox").removeClass("checked"); 425 } 426 }); 427 //radio 428 tjq(".radio input[type='radio']").bind("change", function(event, ui) { 429 if (tjq(this).is(":checked")) { 430 var name = tjq(this).prop("name"); 431 if (typeof name != "undefined") { 432 tjq(".radio input[name='" + name + "']").closest('.radio').removeClass("checked"); 433 } 434 tjq(this).closest(".radio").addClass("checked"); 435 } 436 }); 437 438 // datepicker 439 tjq('.datepicker-wrap input').each(function() { 440 var minDate = tjq(this).data("min-date"); 441 var maxDate = tjq(this).data("max-date"); 442 if (typeof minDate == "undefined") { 443 minDate = 0; 444 } 445 if (typeof maxDate == "undefined") { 446 maxDate = null; 447 } 448 if (tjq(this).closest('.datepicker-wrap').hasClass('to-today')) { minDate = null; maxDate = 0; } 449 450 tjq(this).datepicker({ 451 showOn: 'button', 452 buttonImage: themeurl + '/images/icon/blank.png', 453 buttonText: '', 454 buttonImageOnly: true, 455 changeYear: false, 456 /*showOtherMonths: true,*/ 457 minDate: minDate, 458 maxDate: maxDate, 459 dateFormat: date_format, 460 dayNamesMin: ["S", "M", "T", "W", "T", "F", "S"], 461 beforeShow: function(input, inst) { 462 var themeClass = tjq(input).parent().attr("class").replace("datepicker-wrap", ""); 463 tjq('#ui-datepicker-div').attr("class", ""); 464 tjq('#ui-datepicker-div').addClass("ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"); 465 tjq('#ui-datepicker-div').addClass(themeClass); 466 }, 467 onClose: function(selectedDate) { 468 if ( tjq(this).attr('name') == 'date_from' ) { 469 if ( tjq(this).closest('form').find('input[name="date_to"]').length > 0 ) { 470 tjq(this).closest('form').find('input[name="date_to"]').datepicker("option", "minDate", selectedDate); 471 } 472 } 473 if ( tjq(this).attr('name') == 'date_to' ) { 474 if ( tjq(this).closest('form').find('input[name="date_from"]').length > 0 ) { 475 tjq(this).closest('form').find('input[name="date_from"]').datepicker("option", "maxDate", selectedDate); 476 } 477 } 478 } 479 }); 480 }); 481 482 // placeholder for ie8, 9 483 try { 484 tjq('input, textarea').placeholder(); 485 } catch (e) {} 486} 487 488/* display photo gallery */ 489function displayPhotoGallery($item) { 490 if (! tjq.fn.flexslider || $item.length < 1 || $item.is(":hidden")) { 491 return; 492 } 493 var dataAnimation = $item.data("animation"); 494 var dataSync = $item.data("sync"); 495 if (typeof dataAnimation == "undefined") { 496 dataAnimation = "slide"; 497 } 498 var dataFixPos = $item.data("fix-control-nav-pos"); 499 500 $item.flexslider({ 501 animation: dataAnimation, 502 controlNav: true, 503 animationLoop: true, 504 slideshow: true, 505 pauseOnHover: true, 506 sync: dataSync, 507 start: function(slider) { 508 if (typeof dataFixPos != "undefined" && dataFixPos == "1") { 509 var height = tjq(slider).find(".slides img").height(); 510 tjq(slider).find(".flex-control-nav").css("top", (height - 44) + "px"); 511 } 512 }, 513 }); 514} 515 516/* display image carousel */ 517function displayImageCarousel($item) { 518 if (! tjq.fn.flexslider || $item.length < 1 || $item.is(":hidden")) { 519 return; 520 } 521 var dataAnimation = $item.data("animation"); 522 var dataItemWidth = $item.data("item-width"); 523 var dataItemMargin = $item.data("item-margin"); 524 var dataSync = $item.data("sync"); 525 if (typeof dataAnimation == "undefined") { 526 dataAnimation = "slide"; 527 } 528 if (typeof dataItemWidth == "undefined") { 529 dataItemWidth = 70; 530 } 531 if (typeof dataItemMargin == "undefined") { 532 dataItemMargin = 10; 533 } 534 dataItemWidth = parseInt(dataItemWidth, 10); 535 dataItemMargin = parseInt(dataItemMargin, 10); 536 537 var dataAnimationLoop = true; 538 var dataSlideshow = false; 539 if (typeof dataSync == "undefined") { 540 dataSync = "";
541 //dataAnimationLoop = true; 542 dataSlideshow = true; 543 } 544 $item.flexslider({ 545 animation: dataAnimation, 546 controlNav: true, 547 animationLoop: dataAnimationLoop, 548 slideshow: dataSlideshow, 549 itemWidth: dataItemWidth, 550 itemMargin: dataItemMargin, 551 minItems: 2, 552 pauseOnHover: true, 553 asNavFor: dataSync, 554 start: function(slider) { 555 if (dataSync == "") { 556 tjq(slider).find(".middle-block img, .middle-block .middle-item").each(function() { 557 if(tjq(this).width() < 1) { 558 tjq(this).load(function() { 559 tjq(this).closest(".middle-block").middleblock(); 560 }); 561 } else { 562 tjq(this).closest(".middle-block").middleblock(); 563 } 564 }); 565 } 566 if (tjq('.listing-style1').length > 0) { 567 tjq('.listing-style1').each(function(index){ 568 tjq(this).find('article.box .details .description').setSameHeight(); 569 tjq(this).find('article.box .details .box-title').setSameHeight(); 570 tjq(this).find('article.box').setSameHeight(); 571 }); 572 } 573 }, 574 after: function(slider) { 575 if (slider.currentItem == 0) { 576 var target = 0; 577 if (slider.transitions) { 578 target = (slider.vars.direction === "vertical") ? "translate3d(0," + target + ",0)" : "translate3d(" + target + ",0,0)"; 579 slider.container.css("-" + slider.pfx + "-transition-duration", "0s"); 580 slider.container.css("transition-duration", "0s"); 581 } 582 slider.args[slider.prop] = target; 583 slider.container.css(slider.args); 584 slider.container.css('transform',target); 585 } 586 } 587 588 }); 589} 590 591/* third level menu position to left */ 592function fixPositionSubmenu() { 593 tjq("#main-menu .menu li.menu-item-has-children > ul, .ribbon ul.menu.mini, .chaser .container li.menu-item-has-children > ul").each(function(e) { 594 if (tjq(this).closest(".megamenu").length > 0) { 595 return; 596 } 597 var leftPos = tjq(this).parent().offset().left + tjq(this).parent().width(); 598 if (leftPos + tjq(this).width() > tjq("body").width()) { 599 tjq(this).addClass("left"); 600 } else { 601 tjq(this).removeClass("left"); 602 } 603 }); 604} 605 606/* mega menu */ 607//var megamenu_items_per_column = 6; 608function fixPositionMegaMenu(parentObj) { 609 if (typeof parentObj == "undefined") { 610 parentObj = ""; 611 } else { 612 parentObj += " "; 613 } 614 tjq(parentObj + ".megamenu-menu").each(function() { 615 var paddingLeftStr = tjq(this).closest(".container").css("padding-left"); 616 var paddingLeft = parseInt(paddingLeftStr, 10); 617 var offsetX = tjq(this).offset().left - tjq(this).closest(".container").offset().left - paddingLeft; 618 if (offsetX == 0) { return; } 619 tjq(this).children(".megamenu-wrapper").css("left", "-" + offsetX + "px"); 620 tjq(this).children(".megamenu-wrapper").css("width", tjq(this).closest(".container").width() + "px"); 621 /*if (typeof tjq(this).children(".megamenu-wrapper").data("items-per-column") != "undefined") { 622 megamenu_items_per_column = parseInt(tjq(this).children(".megamenu-wrapper").data("items-per-column"), 10); 623 }*/ 624 //tjq(this).children(".megamenu-wrapper").show(); 625 var columns_arr = new Array(); 626 var sum_columns = 0; 627 tjq(this).find(".megamenu > li").each(function() { 628 //var each_columns = Math.ceil(tjq(this).find("li > a").length / megamenu_items_per_column); 629 var each_columns = tjq(this).children('ul').children('li.menu-item-has-children').length; 630 if (each_columns == 0) { 631 each_columns = 1; 632 } 633 columns_arr.push(each_columns); 634 sum_columns += each_columns; 635 }); 636 tjq(this).find(".megamenu > li").each(function(index) { 637 tjq(this).css("width", (columns_arr[index] / sum_columns * 100) + "%"); 638 tjq(this).addClass("megamenu-columns-" + columns_arr[index]); 639 }); 640 641 tjq(this).find(".megamenu > li.menu-item-has-children").each(function(index) { 642 if (tjq(this).children(".sub-menu").length < 1) { 643 tjq(this).append("<ul class='sub-menu'></ul>"); 644 for (var j = 0; j < columns_arr[index]; j++) { 645 tjq(this).children(".sub-menu").append("<li><ul></ul></li>") 646 } 647 var lastIndex = tjq(this).children("ul").eq(0).children("li").length - 1; 648 tjq(this).children("ul").eq(0).children("li").each(function(i) { 649 var parentIndex = Math.floor(i / megamenu_items_per_column); 650 tjq(this).closest("li.menu-item-has-children").children(".sub-menu").children("li").eq(parentIndex).children("ul").append(tjq(this).clone()); 651 if (i == lastIndex) { 652 tjq(this).closest(".menu-item-has-children").children("ul").eq(0).remove(); 653 } 654 }); 655 } 656 }); 657 tjq(this).children(".megamenu-wrapper").show(); 658 }); 659} 660 661/* testimonial height fix */ 662function fixTestimonialHeight(slider) { 663 tjq(slider).find(".slides > li").css("height", "auto"); 664 setTimeout(function() { 665 tjq(slider).each(function(){ 666 var maxHeight = 0; 667 tjq(this).each(function() { 668 if (tjq(this).height() > maxHeight) { 669 maxHeight = tjq(this).height(); 670 } 671 }); 672 tjq(this).find(" > li").height(maxHeight); 673 }); 674 }, 50); 675} 676 677/* render testimonial*/ 678function displayTestimonials() { 679 try { 680 if (tjq('.testimonial.style1').length > 0 && tjq('.testimonial.style1').is(":visible")) { 681 tjq('.testimonial.style1').flexslider({ 682 namespace: "testimonial-", 683 animation: "slide", 684 controlNav: true, 685 animationLoop: true, 686 directionNav: false, 687 slideshow: true, 688 start: fixTestimonialHeight 689 }); 690 } 691 } catch (e) {} 692 try { 693 if (tjq('.testimonial.style2').length > 0 && tjq('.testimonial.style2').is(":visible")) { 694 tjq('.testimonial.style2').flexslider({ 695 namespace: "testimonial-", 696 animation: "slide", 697 controlNav: false, 698 animationLoop: true, 699 directionNav: true, 700 slideshow: true, 701 start: fixTestimonialHeight 702 }); 703 } 704 } catch (e) {} 705 try { 706 if (tjq('.testimonial.style3').length > 0 && tjq('.testimonial.style3').is(":visible")) { 707 tjq('.testimonial.style3').flexslider({ 708 namespace: "testimonial-", 709 controlNav: false, 710 animationLoop: true, 711 directionNav: true, 712 slideshow: true, 713 start: fixTestimonialHeight 714 }); 715 } 716 } catch (e) {} 717} 718 719/*promo box */ 720function fixPromoBoxHeight() { 721 tjq(".promo-box").each(function() { 722 if (tjq(this).find(".content-section").css("float") == "right" || tjq(this).find(".image-container").css("float") == "right") { 723 var maxHeight = tjq(this).find(".image-container > img").height(); 724 tjq(this).find(".content-section .table-wrapper").css("height", "auto"); 725 var calcPaddingTop = tjq(".content-section").css("padding-top");
726 var calcPaddingBottom = tjq(".content-section").css("padding-bottom"); 727 var calcPadding = 0; 728 try { 729 calcPadding = parseInt(calcPaddingTop, 10) + parseInt(calcPaddingBottom, 10); 730 } catch (e) { } 731 var contentHeight = tjq(this).find(".content-section >.table-wrapper").length > 0 ? tjq(this).find(".content-section > .table-wrapper").height() + calcPadding : tjq(this).find(".content-section").innerHeight(); 732 if (maxHeight < contentHeight) { 733 maxHeight = contentHeight; 734 } else { 735 maxHeight += 15; 736 } 737 tjq(this).find(".image-container").height(maxHeight); 738 tjq(this).find(".content-section").innerHeight(maxHeight); 739 tjq(this).find(".content-section .table-wrapper").css("height", "100%"); 740 tjq(this).find(".image-container").css("position", "relative"); 741 tjq(this).find(".image-container > img").css("position", "absolute"); 742 tjq(this).find(".image-container > img").css("bottom", "0"); 743 if (tjq(this).find(".image-container").css("float") == "right") { 744 tjq(this).find(".image-container > img").css("right", "0"); 745 tjq(this).find(".image-container").css("margin-right", "-5%"); 746 } else { 747 tjq(this).find(".image-container > img").css("left", "0"); 748 tjq(this).find(".image-container").css("margin-left", "-5%"); 749 } 750 tjq(this).find(".image-container > img").css("left", "0"); 751 } else { 752 tjq(this).find(".image-container").css("height", "auto"); 753 tjq(this).find(".image-container").css("margin", "0"); 754 tjq(this).find(".content-section").css("height", "auto"); 755 tjq(this).find(".image-container > img").css("position", "static"); 756 } 757 if (! tjq(this).find(".image-container > img").hasClass("animated")) { 758 tjq(this).find(".image-container > img").css("visibility", "visible"); 759 } 760 }); 761} 762 763/* init function */ 764function trav_init() { 765 // 766} 767 768function trav_init_chasermenu() { 769 if (enableChaser == 1 && tjq('#content').length > 0 && tjq('#main-menu ul.menu').length > 0) { 770 var forchBottom; 771 var chaser = tjq('#main-menu ul.menu').clone().hide().appendTo(document.body).wrap("<div class='chaser hidden-mobile'><div class='container'></div></div>"); 772 tjq('header .container h1.logo').clone().insertBefore('.chaser .menu'); 773 var forch = tjq('#content').first(); 774 forchBottom = forch.offset().top + 2; 775 tjq(window).on('scroll', function () { 776 var top = tjq(document).scrollTop(); 777 if (tjq(".chaser").is(":hidden") && top > forchBottom) { 778 tjq(".chaser").slideDown(300); 779 //chaser.fadeIn(300, shown); 780 } else if (tjq(".chaser").is(":visible") && top < forchBottom) { 781 tjq(".chaser").slideUp(200); 782 //chaser.fadeOut(200, hidden); 783 } 784 }); 785 tjq(window).on('resize', function () { 786 var top = tjq(document).scrollTop(); 787 if (tjq(".chaser").is(":hidden") && top > forchBottom) { 788 tjq(".chaser").slideDown(300); 789 } else if (tjq(".chaser").is(":visible") && top < forchBottom) { 790 tjq(".chaser").slideUp(200); 791 } 792 }); 793 794 tjq(".chaser").css("visibility", "hidden"); 795 chaser.show(); 796 fixPositionMegaMenu(".chaser"); 797 tjq(".chaser .megamenu-menu").removeClass("light"); 798 //chaser.hide(); 799 tjq(".chaser").hide(); 800 tjq(".chaser").css("visibility", "visible"); 801 } 802 803} 804var loaded = 0; 805function trav_ready() { 806 changeTraveloElementUI(); 807 if ( stGlobals.isMobile ) { 808 tjq("body").addClass("is-mobile"); 809 } 810 811 // parallax for wekbit mobile 812 if (stGlobals.isMobileWebkit) { 813 tjq(".parallax").css("background-attachment", "scroll"); 814 } 815 // testimonials 816 displayTestimonials(); 817 fixPositionMegaMenu(); 818 fixPositionSubmenu(); 819 // accordion & toggles 820 tjq(".toggle-container .panel-collapse").each(function() { 821 if (! tjq(this).hasClass("in")) { 822 tjq(this).closest(".panel").find("[data-toggle=collapse]").addClass("collapsed"); 823 } 824 }); 825 // tooltip 826 tjq("[data-toggle=tooltip]").tooltip(); 827 // activate tab 828 var traveloLocationHash = window.location.hash; 829 if (traveloLocationHash != "") { 830 traveloLocationHash = escape(traveloLocationHash.replace("#", "")); 831 if (tjq('a[href="#' + traveloLocationHash + '"]').length > 0) { 832 setTimeout(function() { 833 tjq('a[href="#' + traveloLocationHash + '"]').tab('show'); 834 }, 100); 835 } 836 } 837 // chaser 838 trav_init_chasermenu(); 839 840 // footer menu position to top 841 tjq("#footer #main-menu .menu > li.menu-item-has-children").each(function(e) { 842 var height = tjq(this).children("ul, .megamenu-wrapper").height(); 843 tjq(this).children("ul, .megamenu-wrapper").css("top", "-" + height + "px"); 844 }); 845 846 // filters on search result page 847 if (tjq(".filters-container").length > 0) { 848 849 // price range 850 if ( tjq("#price-range").length ) { 851 var price_slide_min_val = 0; 852 var price_slide_step = tjq("#price-range").data('slide-step'); 853 var price_slide_last_val = tjq("#price-range").data('slide-last-val'); 854 var price_slide_max_val = price_slide_last_val + price_slide_step; 855 856 var def_currency = tjq("#price-range").data('def-currency'); 857 var min_price = tjq("#price-range").data('min-price'); 858 var max_price = tjq("#price-range").data('max-price'); 859 if (max_price == "no_max") { max_price = price_slide_max_val; } 860 var url_noprice = tjq("#price-range").data('url-noprice').replace(/&/g, '&'); 861 if ((min_price != 0) || (max_price != price_slide_max_val)) { 862 tjq('#price-filter').collapse('show'); 863 tjq('a[href="#price-filter"]').removeClass('collapsed'); 864 } 865 tjq("#price-range").slider({ 866 range: true, 867 min: price_slide_min_val, 868 max: price_slide_max_val, 869 step: price_slide_step, 870 values: [ min_price, max_price ], 871 slide: function(event, ui) { 872 // make handles uncollapse 873 if ((ui.values[0] + 1) >= ui.values[1]) { 874 return false; 875 } 876 877 // min price text 878 tjq(".min-price-label").text(def_currency + ui.values[ 0 ]); 879 880 // max price text 881 max_price = ui.values[1]; 882 if (max_price == price_slide_max_val) { 883 max_price = price_slide_last_val + '+'; 884 } 885 tjq(".max-price-label").text(def_currency + max_price); 886 }, 887 change: function(event, ui) { 888 if (ui.values[0] != 0) { 889 url_noprice += '&min_price=' + ui.values[0]; 890 } 891 if (ui.values[1] != price_slide_max_val) { 892 url_noprice += '&max_price=' + ui.values[1]; 893 } 894 if (url_noprice.indexOf("?") < 0) { url_noprice = url_noprice.replace(/&/, '?'); } 895 window.location.href = url_noprice; 896 } 897 }); 898
899 tjq(".min-price-label").text(def_currency + tjq("#price-range").slider("values", 0)); 900 if (tjq("#price-range").slider("values", 1) == price_slide_max_val) { 901 tjq(".max-price-label").text(def_currency + price_slide_last_val + "+"); 902 } else { 903 tjq(".max-price-label").text(def_currency + tjq("#price-range").slider("values", 1)); 904 } 905 } 906 907 // rating 908 if ( tjq("#rating").length ) { 909 var url_norating = tjq("#rating").data('url-norating').replace(/&/g, '&'); 910 var rating = tjq("#rating").data('rating'); 911 /*if (rating > 0) { 912 tjq('#rating-filter').collapse('show'); 913 tjq('a[href="#rating-filter"]').removeClass('collapsed'); 914 }*/ 915 tjq("#rating").slider({ 916 range: "min", 917 value: rating, 918 min: 0, 919 max: 5, 920 step: 0.5, 921 slide: function(event, ui) { 922 var label_rating = ''; 923 if (ui.value == 0) { 924 label_rating = tjq("#rating").data('label-norating'); 925 } else if (ui.value == 5) { 926 label_rating = tjq("#rating").data('label-fullrating'); 927 } else { 928 label_rating = ui.value + ' ' + tjq("#rating").data('label-rating'); 929 } 930 tjq("#rating-filter .panel-content > span").text(label_rating); 931 }, 932 change: function(event, ui) { 933 if (ui.value != 0) { 934 url_norating += '&rating=' + ui.value; 935 } 936 if (url_norating.indexOf("?") < 0) { url_norating = url_norating.replace(/&/, '?'); } 937 window.location.href = url_norating; 938 } 939 }); 940 941 var label_rating = ''; 942 if (rating == 0) { 943 label_rating = tjq("#rating").data('label-norating'); 944 } else if (rating == 5) { 945 label_rating = tjq("#rating").data('label-fullrating'); 946 } else { 947 label_rating = rating + ' ' + tjq("#rating").data('label-rating'); 948 } 949 tjq("#rating-filter .panel-content > span").text(label_rating); 950 } 951 952 } 953 954 // fit video 955 if (tjq('.full-video').length > 0 && tjq.fn.fitVids) { 956 tjq('.full-video').fitVids(); 957 } 958 959 tjq(".toggle-container.with-image").each(function() { 960 var type = ""; 961 var duration = "1s"; 962 if (typeof tjq(this).data("image-animation-type") != "undefined") { 963 type = tjq(this).data("image-animation-type"); 964 } 965 if (typeof tjq(this).data("image-animation-duration") != "undefined") { 966 duration = tjq(this).data("image-animation-duration"); 967 } 968 var imageHtml = '<div class="image-container'; 969 if (type != "") { 970 imageHtml += ' animated" data-animation-type="' + type + '" data-animation-duration="' + duration; 971 } 972 imageHtml += '"><img src="" alt="toggle-image" /></div>'; 973 tjq(this).prepend(imageHtml); 974 if (tjq(this).find(".panel-collapse.in").length > 0) { 975 var activeImg = tjq(this).find(".panel-collapse.in").parent().children("img"); 976 var src = activeImg.attr("src"); 977 var width = activeImg.attr("width"); 978 var height = activeImg.attr("height"); 979 var alt = activeImg.attr("alt"); 980 981 var imgObj = tjq(this).find(".image-container img"); 982 imgObj.attr("src", src); 983 if (typeof width != "undefined") { 984 imgObj.attr("width", width); 985 } 986 if (typeof height != "undefined") { 987 imgObj.attr("height", height); 988 } 989 if (typeof alt != "undefined") { 990 imgObj.attr("alt", alt); 991 } 992 tjq(this).children(".image-container").show(); 993 } 994 }); 995 996 tjq('.toggle-container.with-image').on('show.bs.collapse', function (e) { 997 var activeImg = tjq(e.target).parent().children("img"); 998 if (activeImg.length > 0) { 999 var src = activeImg.attr("src"); 1000 1001 var width = activeImg.attr("width"); 1002 var height = activeImg.attr("height"); 1003 var alt = activeImg.attr("alt"); 1004 1005 var imgObj = tjq(this).find(".image-container img"); 1006 imgObj.attr("src", src); 1007 if (typeof width != "undefined") { 1008 imgObj.attr("width", width); 1009 } 1010 if (typeof height != "undefined") { 1011 imgObj.attr("height", height); 1012 } 1013 if (typeof alt != "undefined") { 1014 imgObj.attr("alt", alt); 1015 } 1016 1017 imgObj.parent().css("visibility", "hidden"); 1018 imgObj.parent().removeClass(imgObj.parent().data("animation-type")); 1019 setTimeout(function() { 1020 imgObj.parent().addClass(imgObj.parent().data("animation-type")); 1021 imgObj.parent().css("visibility", "visible"); 1022 }, 10); 1023 } 1024 }); 1025 1026 tjq('a[data-toggle="tab"]').on('shown.bs.tab', function (e) { 1027 if (loaded == 1) { 1028 var contentId = tjq(e.target).attr("href"); 1029 if (tjq(contentId).find(".image-carousel").length > 0) { 1030 displayImageCarousel(tjq(contentId).find(".image-carousel"));
1031 } 1032 if (tjq(contentId).find(".photo-gallery").length > 0) { 1033 displayPhotoGallery(tjq(contentId).find(".photo-gallery")); 1034 } 1035 if (tjq(contentId).find(".testimonial").length > 0) { 1036 displayTestimonials(); 1037 } 1038 1039 tjq(window).trigger('resize'); 1040 } 1041 }); 1042 1043 //waypoint 1044 if(tjq().waypoint) { 1045 // animation effect 1046 tjq('.animated').waypoint(function() { 1047 var type = tjq(this).data("animation-type"); 1048 if (typeof type == "undefined" || type == false) { 1049 type = "fadeIn"; 1050 } 1051 tjq(this).addClass(type); 1052 1053 var duration = tjq(this).data("animation-duration"); 1054 if (typeof duration == "undefined" || duration == false) { 1055 duration = "1"; 1056 } 1057 tjq(this).css("animation-duration", duration + "s"); 1058 1059 var delay = tjq(this).data("animation-delay"); 1060 if (typeof delay != "undefined" && delay != false) { 1061 tjq(this).css("animation-delay", delay + "s"); 1062 } 1063 1064 tjq(this).css("visibility", "visible"); 1065 1066 setTimeout(function() { tjq.waypoints('refresh'); }, 1000); 1067 }, { 1068 triggerOnce: true, 1069 offset: 'bottom-in-view' 1070 }); 1071 1072 // display counter 1073 tjq('.counters-box').waypoint(function() { 1074 tjq(this).find('.display-counter').each(function() { 1075 var value = tjq(this).data('value'); 1076 tjq(this).countTo({from: 0, to: value, speed: 3000, refreshInterval: 10}); 1077 }); 1078 setTimeout(function() { tjq.waypoints('refresh'); }, 1000); 1079 }, { 1080 triggerOnce: true, 1081 offset: '100%' 1082 }); 1083 } 1084 1085 // Mobile search 1086 if (tjq('#mobile-search-tabs').length > 0) { 1087 var mobile_search_tabs_slider = tjq('#mobile-search-tabs').bxSlider({ 1088 mode: 'fade', 1089 infiniteLoop: false, 1090 hideControlOnEnd: true, 1091 touchEnabled: true, 1092 pager: false, 1093 onSlideAfter: function($slideElement, oldIndex, newIndex) { 1094 tjq('a[href="' + tjq($slideElement).children("a").attr("href") + '"]').tab('show'); 1095 } 1096 }); 1097 } 1098 1099 // Mobile menu 1100 tjq(".mobile-menu ul.menu > li.menu-item-has-children").each(function(index) { 1101 var menuItemId = "mobile-menu-submenu-item-" + index; 1102 tjq('<button class="dropdown-toggle collapsed" data-toggle="collapse" data-target="#' + menuItemId + '"></button>').insertAfter(tjq(this).children("a")); 1103 /*tjq(this).children(".dropdown-toggle").click(function(e) { 1104 if (tjq(this).hasClass("collapsed")) { 1105 tjq(this).parent().addClass("open"); 1106 } else { 1107 tjq(this).parent().removeClass("open"); 1108 } 1109 });*/ 1110 tjq(this).children("ul").prop("id", menuItemId); 1111 tjq(this).children("ul").addClass("collapse"); 1112 1113 tjq("#" + menuItemId).on("show.bs.collapse", function() { 1114 tjq(this).parent().addClass("open"); 1115 }); 1116 tjq("#" + menuItemId).on("hidden.bs.collapse", function() { 1117 tjq(this).parent().removeClass("open"); 1118 }); 1119 }); 1120} 1121 1122function trav_show_modal(success, title, content) { 1123 var modal; 1124 if (success == 1) { 1125 if (tjq('#travelo-success').length > 0) { 1126 modal = tjq('#travelo-success'); 1127 } else { 1128 modal = tjq('<div id="travelo-success" class="travelo-modal-box travelo-box"><div class="travelo-modal-head"><p class="travelo-modal-icon"><i class="soap-icon-check circle"></i></p><h4 class="travelo-modal-title"></h4></div><div class="travelo-modal-content"></div></div>').appendTo('footer'); 1129 } 1130 } else { 1131 if (tjq('#travelo-failure').length > 0) { 1132 modal = tjq('#travelo-failure'); 1133 } else { 1134 modal = tjq('<div id="travelo-failure" class="travelo-modal-box travelo-box"><div class="travelo-modal-head"><p class="travelo-modal-icon"><i class="soap-icon-notice circle"></i></p><h4 class="travelo-modal-title"></h4></div><div class="travelo-modal-content"></div></div>').appendTo('footer'); 1135 } 1136 } 1137 modal.find('.travelo-modal-title').html(title); 1138 modal.find('.travelo-modal-content').html(content); 1139 if (tjq("#soap-popupbox").length < 1) { 1140 tjq("<div class='opacity-overlay' id='soap-popupbox' tabindex='-1'><div class='container'><div class='popup-wrapper'><div class='popup-content'></div></div></div></div>").appendTo("body"); 1141 } 1142 tjq("#soap-popupbox .popup-content").children().hide(); 1143 modal.appendTo(tjq("#soap-popupbox .popup-content")); 1144 modal.show(); 1145 tjq("#soap-popupbox").fadeIn(function() {
1146 modal.find(".input-text").eq(0).focus(); 1147 }); 1148} 1149 1150/*slideshow bg*/ 1151function resizeSlideshowBGHeight() { 1152 if (tjq(".slideshow-bg.full-screen").length == 1) { 1153 var offsetTop = tjq(".slideshow-bg.full-screen").offset().top; 1154 tjq(".slideshow-bg.full-screen").height(tjq(window).height() - offsetTop); 1155 } 1156} 1157 1158/////////////////////////////////////////////////////////////////////////////// 1159////////////////////////////////// MAIN ACTIONS /////////////////////////////// 1160/////////////////////////////////////////////////////////////////////////////// 1161 1162/* disable click before loading page */ 1163tjq("body").on("click", "a.popup-gallery, a.no-redirect", function(e) { 1164 e.preventDefault(); 1165 return false; 1166}); 1167 1168// back to top 1169tjq("body").on("click", "#back-to-top", function(e) { 1170 e.preventDefault(); 1171 tjq("html,body").animate({scrollTop: 0}, 1000); 1172}); 1173 1174// login box 1175tjq("body").on("click", ".soap-popupbox", function(e) { 1176 e.preventDefault(); 1177 var sourceId = tjq(this).attr("href"); 1178 if (typeof sourceId == "undefined") { 1179 sourceId = tjq(this).data("target"); 1180 } 1181 if (typeof sourceId == "undefined") { 1182 return; 1183 } 1184 if (tjq(sourceId).length < 1) { 1185 return; 1186 } 1187 tjq(this).soapPopup({ 1188 wrapId: "soap-popupbox", 1189 }); 1190}); 1191 1192// go back 1193tjq(".go-back").click(function(e) { 1194 e.preventDefault(); 1195 window.history.go(-1); 1196}); 1197 1198// alert, info box 1199tjq("body").on("click", ".alert > .close, .info-box > .close", function() { 1200 tjq(this).parent().fadeOut(300); 1201}); 1202 1203// redirect to the location 1204tjq(".location-reload").click(function(e) { 1205 e.preventDefault(); 1206 var url = tjq(this).prop("href").split("#")[0]; 1207 if (window.location.href.indexOf(url) != -1) { 1208 var hash = tjq(this).prop("href").split("#")[1]; 1209 if (typeof hash != "undefined" && hash != "" && tjq("a[href='#" + hash + "']").length > 0) { 1210 tjq("a[href='#" + hash + "']").tab('show'); 1211 } 1212 } else { 1213 window.location.href = tjq(this).prop("href"); 1214 } 1215}); 1216 1217// sort of trip 1218tjq(".sort-trip a").click(function(e) { 1219 e.preventDefault(); 1220 tjq(this).parent().parent().children().removeClass("active"); 1221 tjq(this).parent().addClass("active"); 1222}); 1223 1224// filters option 1225tjq(".filters-container .filters-option a").click(function(e) { 1226 e.preventDefault(); 1227 if (tjq(this).parent().hasClass("active")) { 1228 tjq(this).parent().removeClass("active"); 1229 } else { 1230 tjq(this).parent().addClass("active"); 1231 } 1232}); 1233 1234// load more button click action on blog page 1235tjq("body").on("click", ".btn-load-more-posts", function(e){ 1236 e.preventDefault(); 1237 var url = tjq(this).attr('href'); 1238 jQuery.ajax({ 1239 url: url, 1240 type: "GET", 1241 success: function(response){ 1242 var success = tjq(tjq.parseHTML(response)).find(".blog-infinite"); 1243 tjq(".blog-infinite").append(success.html()); 1244 var load_more_btn = tjq(tjq.parseHTML(response)).find('.btn-load-more-posts'); 1245 if (load_more_btn.length) { 1246 tjq('.btn-load-more-posts').attr('href', load_more_btn.attr('href')); 1247 } else { 1248 tjq('.btn-load-more-posts').remove(); 1249 } 1250 1251 tjq('.image-carousel').each(function() { 1252 displayImageCarousel(tjq(this)); 1253 }); 1254 1255 tjq('.photo-gallery').each(function() { 1256 displayPhotoGallery(tjq(this)); 1257 }); 1258 1259 if (tjq('.full-video').length > 0 && tjq.fn.fitVids) { 1260 tjq('.full-video').fitVids(); 1261 } 1262 } 1263 }); 1264 return false; 1265}); 1266 1267// handle kid age filter 1268tjq('select[name=kids]').change(function(){ 1269 var prev_kids = tjq('.age-of-children .child-age-field').length; 1270 tjq('.age-of-children').removeClass('no-display'); 1271 var i; 1272 if (prev_kids > tjq(this).val()) { 1273 1274 var current_kids = tjq(this).val(); 1275 1276 if (current_kids == 0) { 1277 current_kids = 1; 1278 tjq('.age-of-children').addClass('no-display'); 1279 } 1280 1281 for (i = prev_kids; i > current_kids; --i) { 1282 tjq('.age-of-children .child-age-field').eq(i-1).remove(); 1283 } 1284 } else { 1285 for (i = prev_kids + 1; i <= tjq(this).val(); i++) { 1286 var clone_age_last = tjq('.age-of-children .child-age-field:last').clone(); 1287 var clone_age = clone_age_last.clone(); 1288 tjq('.age-of-children .row').append(clone_age); 1289 var name = clone_age.find('label').text().replace(/(\d+)/, function(match, p1) 1290 { 1291 return (parseInt(p1) + 1); 1292 }); 1293 clone_age.find('label').text(name); 1294 clone_age.find('select').val(0); 1295 clone_age.find('.custom-select').text(0); 1296 } 1297 } 1298}); 1299 1300// mobile top nav(language and currency) 1301tjq("body").on("click", function(e) { 1302 var target = tjq(e.target); 1303 if (! target.is(".mobile-topnav .ribbon.opened *")) { 1304 tjq(".mobile-topnav .ribbon.opened > .menu").toggle(); 1305 tjq(".mobile-topnav .ribbon.opened").removeClass("opened"); 1306 } 1307}); 1308tjq(".mobile-topnav .ribbon > a").on("click", function(e) { 1309 e.preventDefault(); 1310 if (tjq(".mobile-topnav .ribbon.opened").length > 0 && ! tjq(this).parent().hasClass("opened")) { 1311 tjq(".mobile-topnav .ribbon.opened > .menu").toggle(); 1312 tjq(".mobile-topnav .ribbon.opened").removeClass("opened"); 1313 } 1314 tjq(this).parent().toggleClass("opened"); 1315 tjq(this).parent().children(".menu").toggle(200); 1316 if (tjq(this).parent().hasClass("opened") && tjq(this).parent().children(".menu").offset().left + tjq(this).parent().children(".menu").width() > tjq("body").width()) { 1317 var offsetX = tjq(this).parent().children(".menu").offset().left + tjq(this).parent().children(".menu").width() - tjq("body").width(); 1318 offsetX = tjq(this).parent().children(".menu").position().left - offsetX - 1; 1319 tjq(this).parent().children(".menu").css("left", offsetX + "px"); 1320 } else { 1321 tjq(this).parent().children(".menu").css("left", "0"); 1322 } 1323}); 1324tjq(".sort-by-container").click(function(){ 1325 if ( tjq(this).hasClass('sorted') ) { 1326 return false; 1327 } 1328 tjq(this).addClass('sorted'); 1329}); 1330 1331tjq(document).ready(function() { 1332 trav_ready(); 1333 // popup 1334 tjq(document).bind('keydown', function (e) { 1335 var key = e.keyCode; 1336 if (tjq(".opacity-overlay:visible").length > 0 && key === 27) { 1337 e.preventDefault(); 1338 tjq(".opacity-overlay").fadeOut(); 1339 } 1340 }); 1341 1342 tjq(document).on("click touchend", ".opacity-overlay", function(e) { 1343 if (! tjq(e.target).is(".opacity-overlay .popup-content *")) { 1344 tjq(".opacity-overlay").fadeOut(); 1345 } 1346 }); 1347 1348 // popup gallery 1349 tjq("body").on("click", "a.popup-gallery", function(e) { 1350 var post_id = tjq(this).data('post_id'); 1351 e.preventDefault(); 1352 tjq(this).soapPopup({ 1353 type: "ajax", 1354 wrapId: "soap-gallery-popup", 1355 url: ajaxurl, 1356 data: { 'action': 'get_post_gallery', 'post_id': post_id }, 1357 callBack: function(stp) { 1358 if (stp.wrap.find('.image-carousel').length > 0) { 1359 displayImageCarousel(stp.wrap.find('.image-carousel')); 1360 } 1361 if (stp.wrap.find('.photo-gallery').length > 0) { 1362 displayPhotoGallery(stp.wrap.find('.photo-gallery')); 1363 } 1364 } 1365 }); 1366 }); 1367 1368 // popup map 1369 tjq("body").on("click", ".popup-map", function(e) { 1370 var lngltd = tjq(this).data("box"); 1371 if (typeof lngltd != "undefined") { 1372 e.preventDefault(); 1373 tjq(this).soapPopup({ 1374 type: "map", 1375 zoom: 12, 1376 wrapId: "soap-map-popup", 1377 lngltd: lngltd 1378 }); 1379 } 1380 }); 1381 1382 //ajax loading overlay
1383 tjq(document).ajaxStart(function(){ 1384 tjq('.opacity-ajax-overlay').show(); 1385 }).ajaxStop(function(){ 1386 tjq('.opacity-ajax-overlay').hide(); 1387 }); 1388}); 1389 1390tjq(window).load(function() { 1391 1392 tjq('.slideshow-bg').each(function() { 1393 tjq(this).flexslider({ 1394 animation: "fade", 1395 controlNav: false, 1396 animationLoop: true, 1397 directionNav: false, 1398 slideshow: true, 1399 slideshowSpeed: 5000 1400 }); 1401 }); 1402 1403 resizeSlideshowBGHeight(); 1404 /* photo gallery and slideshow */ 1405 // photo gallery with thumbnail 1406 tjq('.image-carousel').each(function() { 1407 displayImageCarousel(tjq(this)); 1408 }); 1409 1410 tjq('.photo-gallery').each(function() { 1411 displayPhotoGallery(tjq(this)); 1412 }); 1413 1414 // parallax 1415 if( ( ! stGlobals.isMobileWebkit && tjq(".parallax").length > 0 ) || tjq(".style-changer").length > 0 ) { 1416 tjq.stellar({ 1417 responsive: true, 1418 horizontalScrolling: false 1419 }); 1420 } 1421 //tjq(window).trigger('resize'); 1422 setTimeout(function() { 1423 tjq(window).trigger('resize'); 1424 }, 500); 1425 1426 loaded = 1; 1427}); 1428 1429tjq(window).resize(function() { 1430 tjq(".middle-block").middleblock(); 1431 fixPositionMegaMenu(); 1432 fixPositionSubmenu(); 1433 fixPromoBoxHeight(); 1434 fixTestimonialHeight('.testimonial'); 1435 resizeSlideshowBGHeight(); 1436 // fix slider position of gallery slideshow style2 1437 if (tjq(".photo-gallery.style2").length > 0) { 1438 tjq(".photo-gallery.style2").each(function() { 1439 var dataFixPos = tjq(this).data("fix-control-nav-pos"); 1440 if (typeof dataFixPos != "undefined" && dataFixPos == "1") { 1441 var height = tjq(this).find(".slides img").height(); 1442 tjq(this).find(".flex-control-nav").css("top", (height - 44) + "px"); 1443 } 1444 }); 1445 } 1446 1447 // make listing same height 1448 if (tjq('.listing-style1').length > 0) { 1449 tjq('.listing-style1').each(function(index){ 1450 tjq(this).find('article.box .details .description').setSameHeight(); 1451 tjq(this).find('article.box .details .box-title').setSameHeight(); 1452 tjq(this).find('article.box').setSameHeight(); 1453 }); 1454 } 1455 if (tjq('div.listing-style2').length > 0) { 1456 tjq('div.listing-style2').each(function(index){ 1457 tjq(this).find('article.box').setSameHeight(); 1458 }); 1459 } 1460}); 1461 1462tjq(".login_link").click(function(){ 1463 document.location.href = tjq(this).data('target'); 1464}); 1465trav_init(); 1466 1467/////////////////////////////////////////////////////////////////////////////// 1468////////////////////////////////// OTHER ACTIONS ////////////////////////////// 1469/////////////////////////////////////////////////////////////////////////////// 1470 1471/* CONTACT FORM 7 CODE */ 1472tjq(".wpcf7-submit").click(function(event) { 1473 tjq(document).ajaxComplete(function() { 1474 setTimeout(function(){ 1475 var title = tjq(".wpcf7-response-output").html(); 1476 var message = ''; 1477 var success = ''; 1478 if (tjq(".wpcf7-response-output").hasClass('wpcf7-validation-errors')) { 1479 success = 0; 1480 } else if (tjq(".wpcf7-response-output").hasClass('wpcf7-spam-blocked')) { 1481 success = 0; 1482 } else if (tjq(".wpcf7-response-output").hasClass('wpcf7-mail-sent-ng')) { 1483 success = 0; 1484 } else { 1485 success = 1; 1486 } 1487 trav_show_modal(success, title, message); 1488 },50); 1489 }); 1490}); 1491 1492/* Accommodation Search Page */ 1493// accommodation type filter 1494tjq("#accomodation-type-filter .filters-option li").click(function(){ 1495 var url_noacc_type = tjq("#accomodation-type-filter").data('url-noacc_type').replace(/&/g, '&'); 1496 if (tjq(this).hasClass('all-types')) { 1497 if (! tjq(this).hasClass('active')) { 1498 tjq(this).toggleClass('active'); 1499 return false; 1500 } else { 1501 tjq("#accomodation-type-filter .filters-option li").removeClass('active'); 1502 tjq(this).addClass('active'); 1503 } 1504 } else { 1505 if (tjq("#accomodation-type-filter .filters-option li.active").length == 0) { 1506 tjq("#accomodation-type-filter .filters-option li.all-types").addClass('active'); 1507 } else { 1508 tjq("#accomodation-type-filter .filters-option li.all-types").removeClass('active'); 1509 tjq("#accomodation-type-filter .filters-option li.active").each(function(index){ 1510 url_noacc_type += '&acc_type[]=' + tjq(this).data('term-id'); 1511 }); 1512 } 1513 }
1514 if (url_noacc_type.indexOf("?") < 0) { url_noacc_type = url_noacc_type.replace(/&/, '?'); } 1515 window.location.href = url_noacc_type; 1516}); 1517 1518// amenity filter 1519tjq("#amenities-filter .filters-option li").click(function(){ 1520 var url_noamenities = tjq("#amenities-filter").data('url-noamenities').replace(/&/g, '&'); 1521 tjq("#amenities-filter .filters-option li.active").each(function(index){ 1522 url_noamenities += '&amenities[]=' + tjq(this).data('term-id'); 1523 }); 1524 if (url_noamenities.indexOf("?") < 0) { url_noamenities = url_noamenities.replace(/&/, '?'); } 1525 window.location.href = url_noamenities; 1526 return false; 1527}); 1528 1529// load more button click action on search result page 1530tjq(".btn-load-more-accs").click(function(e){ 1531 e.preventDefault(); 1532 var url = tjq(this).attr('href'); 1533 var _this = tjq(this); 1534 var wrapper = tjq(this).closest('.list-wrapper'); 1535 var wrapper_class = tjq(this).closest('.list-wrapper').attr('class').split(" ").filter(Boolean).join('.'); 1536 jQuery.ajax({ 1537 url: url, 1538 type: "GET", 1539 success: function(response){ 1540 var response_list = tjq(tjq.parseHTML(response)).find('.' + wrapper_class); 1541 wrapper.children('div').append(response_list.children('div').html()); 1542 tjq(window).trigger('resize'); 1543 var load_more_btn = response_list.find('.btn-load-more-accs'); 1544 if (load_more_btn.length) { 1545 _this.attr('href', load_more_btn.attr('href')); 1546 } else { 1547 _this.remove(); 1548 } 1549 } 1550 }); 1551 return false; 1552}); 1553 1554// make accommodation search works with valid date frame 1555tjq('.acc-searchform').submit(function(){ 1556 var error_obj; 1557 tjq('.date-error').remove(); 1558 var date_from_obj = tjq(this).find('input[name="date_from"]'); 1559 var date_to_obj = tjq(this).find('input[name="date_to"]'); 1560 if ((date_from_obj.val() != '') && (date_to_obj.val() != '')) { 1561 if (date_from_obj.datepicker("getDate") >= date_to_obj.datepicker("getDate")) { 1562 error_obj = '<label class="date-error">' + tjq('.search-when').data('error-message1') + '</label>'; 1563 tjq('.search-when').append(error_obj); 1564 date_from_obj.focus(); 1565 return false; 1566 } 1567 var now = tjq.now(); 1568 if (date_from_obj.datepicker("getDate") - now + 86400 * 1000 < 0) { 1569 error_obj = '<label class="date-error">' + tjq('.search-when').data('error-message2') + '</label>'; 1570 tjq('.search-when').append(error_obj); 1571 date_from_obj.focus(); 1572 return false; 1573 } 1574 } 1575}); 1576 1577// remove date-error field when date change 1578tjq('input[name="date_from"], input[name="date_to"]').change(function(){ 1579 tjq('.date-error').remove(); 1580}); 1581 1582/* Tour Search Page */ 1583tjq("#tour-type-filter .filters-option li").click(function(){ 1584 var url_notour_type = tjq("#tour-type-filter").data('url-notour_type').replace(/&/g, '&'); 1585 if (tjq(this).hasClass('all-types')) { 1586 if (! tjq(this).hasClass('active')) { 1587 tjq(this).toggleClass('active'); 1588 return false; 1589 } else { 1590 tjq("#tour-type-filter .filters-option li").removeClass('active'); 1591 tjq(this).addClass('active'); 1592 } 1593 } else { 1594 if (tjq("#tour-type-filter .filters-option li.active").length == 0) { 1595 tjq("#tour-type-filter .filters-option li.all-types").addClass('active'); 1596 } else { 1597 tjq("#tour-type-filter .filters-option li.all-types").removeClass('active'); 1598 tjq("#tour-type-filter .filters-option li.active").each(function(index){ 1599 url_notour_type += '&tour_types[]=' + tjq(this).data('term-id'); 1600 }); 1601 } 1602 } 1603 if (url_notour_type.indexOf("?") < 0) { url_notour_type = url_notour_type.replace(/&/, '?'); } 1604 window.location.href = url_notour_type; 1605}); 1606 1607// make accommodation search works with valid date frame 1608tjq('.tour-searchform').submit(function(){ 1609 var error_obj; 1610 tjq('.date-error').remove(); 1611 var date_from_obj = tjq(this).find('input[name="date_from"]'); 1612 var date_to_obj = tjq(this).find('input[name="date_to"]'); 1613 if ((date_from_obj.val() != '') && (date_to_obj.val() != '')) { 1614 if (date_from_obj.datepicker("getDate") > date_to_obj.datepicker("getDate")) { 1615 error_obj = '<label class="date-error">' + tjq('.search-when').data('error-message1') + '</label>'; 1616 tjq('.search-when').append(error_obj); 1617 date_from_obj.focus(); 1618 return false; 1619 } 1620 var now = tjq.now(); 1621 if (date_from_obj.datepicker("getDate") - now + 86400 * 1000 < 0) { 1622 error_obj = '<label class="date-error">' + tjq('.search-when').data('error-message2') + '</label>'; 1623 tjq('.search-when').append(error_obj); 1624 date_from_obj.focus(); 1625 return false; 1626 } 1627 } 1628});
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.