1jQuery(document).ready(function($){ 2 "use strict"; 3 var $timetable = $(), //allows to determine which timetable should be used 4 tt_atts; //value depends on the active timetable 5 6 $(".tt_tabs_navigation a").on("click", function(event){ 7 var $this = $(this); 8 $this.parent().parent().find("li").removeClass("ui-tabs-active"); 9 $this.parent().addClass("ui-tabs-active"); 10 }); 11 12 $(".tt_tabs").tabs({ 13 event: "change", 14 show: true, 15 create: function(event, ui){ 16 $timetable = ui.panel.closest(".tt_wrapper"); 17 if($timetable.find(".tt_tabs_navigation.all_filters").length 18 && window.location.href.indexOf("book-event-hour-")===-1) 19 { 20 if(ui.tab.length && $timetable.find(".tt_tabs_navigation.events_categories_filter a[href='" + ui.tab[0].children[0].hash + "']").length) 21 $timetable.find(".tt_tabs_navigation.events_categories_filter a[href='" + ui.tab[0].children[0].hash + "']").parent().addClass("ui-tabs-active"); 22 else 23 $timetable.find(".tt_tabs_navigation.events_categories_filter li:first-child a").parent().addClass("ui-tabs-active"); 24 25 if(ui.tab.length && $timetable.find(".tt_tabs_navigation.events_filter a[href='" + ui.tab[0].children[0].hash + "']").length) 26 $timetable.find(".tt_tabs_navigation.events_filter a[href='" + ui.tab[0].children[0].hash + "']").parent().addClass("ui-tabs-active"); 27 else 28 $timetable.find(".tt_tabs_navigation.events_filter li:first-child a").parent().addClass("ui-tabs-active"); 29 } 30 31// scroll to active timetable 32 var param_fragment = escape_str($.param.fragment()); 33 if(param_fragment!="") 34 { 35 if($('#' + param_fragment).closest(".tt_wrapper").length) 36 $("html, body").animate({scrollTop: $('#' + param_fragment).closest(".tt_wrapper").offset().top-80}, 400); 37 } 38 } 39 }); 40 41 //browser history 42 $(".tt_tabs .ui-tabs-nav a").on("click", function(){ 43 if($(this).attr("href").substr(0,4)!="http") 44 $.bbq.pushState($(this).attr("href")); 45 else 46 window.location.href = $(this).attr("href"); 47 }); 48 49 //dropdown navigation 50 $(".tabs_box_navigation").mouseover(function(){ 51 $(this).find("ul").removeClass("tabs_box_navigation_hidden"); 52 }); 53 54 $(".tabs_box_navigation a").on("click", function(event){ 55 if($.param.fragment()==$(this).attr("href").replace("#", "") || ($.param.fragment()=="" && $(this).attr("href").replace("#", "").substr(0, 10)=="all-events")) 56 event.preventDefault(); 57 $(this).parent().parent().find(".selected").removeClass("selected"); 58 $(this).parent().addClass("selected"); 59 $(this).parent().parent().parent().children("label").text($(this).text()); 60 $(this).parent().parent().addClass("tabs_box_navigation_hidden"); 61 }); 62 63 $(".tt_tabs_navigation:not(.all_filter) a, .tabs_box_navigation:not(.all_filter) a").on("click", function(event){ 64 event.preventDefault(); 65 var $this = $(this), 66 hash, 67 newHref, 68 sharpIdx, 69 event_str, 70 events_category_str, 71 all_events_str; 72 73 $timetable = $this.closest(".tt_wrapper"); 74 all_events_str = "all-events" + (typeof($timetable.attr("id"))!="undefined" ? "-" + $timetable.attr("id") : ""); 75 76 hash = $this.attr("href"); 77 sharpIdx = (window.location.href.indexOf("#")!==-1 ? window.location.href.indexOf("#") : window.location.href.length); 78 event_str = ($timetable.find(".events_filter .selected a").length ? $timetable.find(".events_filter .selected a").attr("href").replace("#", "") : ($timetable.find(".events_filter .ui-tabs-active a").length ? $timetable.find(".events_filter .ui-tabs-active a").attr("href").replace("#", "") : "")); 79 events_category_str = ($timetable.find(".events_categories_filter .selected a").length ? $timetable.find(".events_categories_filter .selected a").attr("href").replace("#", "") : ($timetable.find(".events_categories_filter .ui-tabs-active a").length ? $timetable.find(".events_categories_filter .ui-tabs-active a").attr("href").replace("#", "") : "")); 80 $timetable.find(".tt_error_message").addClass("tt_hide"); 81 if(event_str!=="" && events_category_str!=="") 82 { 83 if((event_str!==all_events_str && events_category_str!==all_events_str && $timetable.find("[id='" + event_str + "'][class*='tt-event-category-" + events_category_str.toLowerCase() +"']").length) || (events_category_str===all_events_str)) 84 { 85 newHref = escape_str(window.location.href.substr(0, sharpIdx)) + decodeURIComponent("#" + event_str); 86 if(window.location.href!=newHref) 87 window.location.href = newHref; 88 } 89 else if(event_str===all_events_str && events_category_str!==all_events_str) 90 { 91 newHref = escape_str(window.location.href.substr(0, sharpIdx)) + decodeURIComponent("#" + events_category_str); 92 if(window.location.href!=newHref) 93 window.location.href = newHref; 94 } 95 else 96 {
97 var scrollTop = $(document).scrollTop(); 98 newHref = escape_str(window.location.href.substr(0, sharpIdx)) + "#"; 99 if(window.location.href!=newHref) 100 window.location.href = newHref; 101 $timetable.find(".tt_tabs").tabs("option", "collapsible", true); 102 $timetable.find(".tt_tabs").tabs("option", "active", false); 103 $timetable.find(".tt_error_message").removeClass("tt_hide"); 104 $("html, body").scrollTop(scrollTop); 105 } 106 } 107 else 108 { 109 newHref = escape_str(window.location.href.substr(0, sharpIdx)) + decodeURIComponent(hash); 110 if(window.location.href!=newHref) 111 window.location.href = newHref; 112 //window.location.hash is causing issues on Safari, because of that 113 //it's necessary to use window.location.href 114 } 115 }); 116 117 //hashchange 118 $(window).on("hashchange", function(event){ 119 var param_fragment = escape_str($.param.fragment()); 120 //some browsers will have the URL fragment already encoded, 121 //while others will not, thus it's necessary to handle both cases. 122 123 //URL fragment is already encoded: 124 $(".tabs_box_navigation a[href='#" + param_fragment + "']").trigger("click"); 125 $(".tt_tabs .ui-tabs-nav [href='#" + param_fragment + "']").trigger("change"); 126 //URL fragment must be encoded: 127 $(".tabs_box_navigation a[href='#" + encodeURIComponent(param_fragment) + "']").trigger("click"); 128 $(".tt_tabs .ui-tabs-nav [href='#" + encodeURIComponent(param_fragment) + "']").trigger("change"); 129 }).trigger("hashchange"); 130 131 //tooltip 132 $(".tt_tooltip").on("mouseover click", function(){ 133 var $this = $(this), 134 $attach_to = $this, 135 $tooltip_text, 136 position, 137 top, 138 left; 139 140 if($this.is(".event_container")) 141 $attach_to = $this.parent(); 142 $tooltip_text = $this.children(".tt_tooltip_text"); 143 144 $tooltip_text.css("width", $this.outerWidth() + "px"); 145 $tooltip_text.css("height", $tooltip_text.height() + "px"); 146 147 if($('body').hasClass('rtl')) 148 { 149 //RTL MODE, TD is static 150 position = $attach_to.position(); 151 top = position.top-$tooltip_text.innerHeight() + "px"; 152 left = position.left + "px"; 153 } 154 else 155 { 156 //LTR MODE, TD is relative 157 top = -($tooltip_text.parent().offset().top-$attach_to.offset().top+$tooltip_text.innerHeight()) + "px"; 158 left = "0px"; 159 } 160 161 $tooltip_text.css({ 162 "top": top, 163 "left": left 164 }); 165 }); 166 167 //Handle hover booking buttons in RTL mode 168 $("body.rtl .booking_hover_buttons td.event").on("mouseover click", function(){ 169 var $td = $(this), 170 button_height = 50, /* fixed value */ 171 height, 172 width; 173 174 if($td.hasClass("tt_single_event")) 175 { 176 height = Math.ceil($td[0].getBoundingClientRect().height); 177 width = Math.ceil($td[0].getBoundingClientRect().width); 178 $td.find(".event_hour_booking_wrapper.on_hover").css({ 179 'top': $td.position().top+height-button_height, 180 'left': $td.position().left, 181 //On FF elements may have fractional height/width, 182 //we need to get the exact value and round it up. 183 'width': width, 184 }); 185 } 186 else 187 { 188 $td.find(".event_container").each(function() { 189 var $event_container = $(this), 190 $booking_wrapper = $event_container.find(".event_hour_booking_wrapper.on_hover"); 191 192 height = Math.ceil($event_container[0].getBoundingClientRect().height); 193 width = Math.ceil($event_container[0].getBoundingClientRect().width); 194 $booking_wrapper.css({ 195 'top': $event_container.position().top+height-button_height, 196 'left': $event_container.position().left, 197 //On FF elements may have fractional height/width, 198 //we need to get the exact value and round it up. 199 'width': width, 200 }); 201 }); 202 } 203 }); 204 205 //upcoming events 206 $(".tt_upcoming_events").each(function(){ 207 var self = $(this), 208 autoscroll = 0, 209 elementClasses = self.attr("class").split(" "); 210 211 for(var i=0; i<elementClasses.length; i++) 212 { 213 if(elementClasses[i].indexOf("autoscroll-")!=-1) 214 autoscroll = elementClasses[i].replace("autoscroll-", ""); 215 } 216 self.carouFredSel({ 217 direction: "up", 218 items: { 219 visible: (self.children().length>2 ? 3 : self.children().length), 220 height: "variable" 221 }, 222 scroll: { 223 items: 1, 224 easing: "swing", 225 pauseOnHover: true 226 }, 227 prev: {button: self.next().children("#upcoming_event_prev")}, 228 next: {button: self.next().children("#upcoming_event_next")}, 229 auto: { 230 play: (parseInt(autoscroll) ? true : false) 231 } 232 }); 233
234 self.find("li a.tt_upcoming_events_event_container, li>span").on({ 235 mouseenter: function(){ 236 self.trigger("configuration", ["debug", false, true]); 237 }, 238 mouseleave: function(){ 239 setTimeout(function(){ 240 self.trigger("configuration", ["debug", false, true]); 241 }, 1); 242 } 243 }); 244 }); 245 $(window).resize(function(){ 246 $(".tt_upcoming_events").trigger("configuration", ["debug", false, true]); 247 }); 248 249 //timetable row heights 250 /*var maxHeight = Math.max.apply(null, $(".timetable:visible tr td:first-child").map(function () 251 { 252 return $(this).height(); 253 }).get()); 254 $(".timetable:visible tr td").css("height", maxHeight); 255 //timetable height fix 256 $(".timetable .event").each(function(){ 257 if($(this).children(".event_container").length>1) 258 { 259 var childrenHeight = 0; 260 $(this).children(".event_container").not(":last").each(function(){ 261 childrenHeight += $(this).innerHeight(); 262 }); 263 var height = $(this).height()-childrenHeight-($(this).parent().parent().width()<=750 ? 9 : 22); 264 if(height>$(this).children(".event_container").last().height()) 265 $(this).children(".event_container").last().css("height", height + "px"); 266 } 267 });*/ 268 269 //show/hide event hours on mobile device 270 $(document.body).on("click", ".tt_timetable.small .plus.box_header", function(event) { 271 var $this = $(this), 272 $list = $this.next("ul.tt_items_list"); 273 $list.slideDown(500); 274 $this.removeClass("plus"); 275 $this.addClass("minus"); 276 }); 277 $(document.body).on("click", ".tt_timetable.small .minus.box_header", function(event) { 278 var $this = $(this), 279 $list = $this.next("ul.tt_items_list"); 280 $list.slideUp(500, function() { 281 $this.removeClass("minus"); 282 $this.addClass("plus"); 283 }); 284 }); 285 286 if($(".tt_booking").length && $(".tt_booking_overlay").length) 287 { 288 $(".tt_booking_overlay").slice(1).remove(); 289 $(".tt_booking_overlay").appendTo("body"); 290 $(".tt_booking").slice(1).remove(); 291 $(".tt_booking").appendTo("body"); 292 } 293 294 if($(".tt_booking").length && in_iframe()) 295 { 296 $(".tt_booking").addClass("in_iframe"); 297 } 298 299 $(document.body).on("click", ".event_hour_booking:not(.redirect)", get_event_hour_details); 300 301 302 $(document.body).on("click", ".tt_booking_overlay", close_booking_popup); 303 //don't close popup if scroll occurs 304 var touchmoved; 305 $(document.body).on("touchend", ".tt_booking_overlay", function(event) { 306 if(touchmoved != true) 307 close_booking_popup(); 308 }).on("touchmove", ".tt_booking_overlay", function(event) { 309 touchmoved = true; 310 }).on("touchstart", ".tt_booking_overlay", function(event) { 311 touchmoved = false; 312 }); 313 314 315 function get_event_hour_details(event) 316 { 317 event.preventDefault(); 318 var $this = $(this), 319 $booking_popup = $('.tt_booking'), 320 $booking_popup_message = $booking_popup.find('.tt_booking_message'), 321 $booking_popup_preloader = $booking_popup.find('.tt_preloader'), 322 event_hour_id = $this.attr('data-event-hour-id'), 323 redirect_url = window.location.href; 324 325 $timetable = $this.closest('.tt_wrapper'); 326 tt_atts = $.parseJSON($timetable.find('.timetable_atts').val()); 327 328 if(redirect_url.indexOf('#')===-1) 329 redirect_url = redirect_url + '#book-event-hour-' + event_hour_id; 330 else 331 redirect_url = redirect_url.substr(0, redirect_url.indexOf('#')) + '#book-event-hour-' + event_hour_id; 332 333 if($this.hasClass('unavailable') || $this.hasClass('booked')) 334 return; 335 336 $booking_popup_message.html(''); 337 open_booking_popup(event); 338 resize_booking_popup(); 339 $booking_popup_message.attr('data-event-hour-id', event_hour_id); 340 341 $.post(tt_config.ajaxurl, 342 { 343 action: 'timetable_ajax_event_hour_details', 344 redirect_url: redirect_url, 345 event_hour_id: event_hour_id, 346 atts: tt_atts, 347 }, 348 function(result){ 349 $booking_popup_preloader.addClass('tt_hide'); 350 351 result = parse_server_response(result); 352 if(typeof(result.msg!=='undefined')) 353 { 354 if(!result.error) 355 $booking_popup_message.html(result.msg); 356 else 357 { 358 $booking_popup_message.html('<p>' + result.msg + '</p><div><a href="#" class="tt_btn cancel">' + tt_atts.cancel_popup_label + '</a></div>'); 359 } 360 resize_booking_popup(); 361 } 362 }, 363 "html" 364 ); 365 } 366 367 $(document.body).on('click', '.tt_booking .tt_btn.book', create_event_hour_booking); 368 369 function create_event_hour_booking(event) 370 { 371 event.preventDefault(); 372 var $this = $(this), 373 $booking_popup = $('.tt_booking'), 374 $booking_popup_message = $booking_popup.find('.tt_booking_message'), 375 $booking_popup_preloader = $booking_popup.find('.tt_preloader'), 376 slots_number = $booking_popup.find('.tt_slots_number').val(), 377 guest_name = $booking_popup.find('.tt_guest_name').val(), 378 guest_email = $booking_popup.find('.tt_guest_email').val(), 379 guest_phone = $booking_popup.find('.tt_guest_phone').val(), 380 guest_message = $booking_popup.find('.tt_guest_message').val(), 381 terms_checkbox = $booking_popup.find('.tt_terms_checkbox').is(':checked'), 382 event_hour_id = $booking_popup_message.attr('data-event-hour-id'); 383 384 $this.qtip('destroy').removeClass('tt-qtip2'); 385 386 $booking_popup_message.addClass('tt_hide'); 387 $booking_popup_preloader.removeClass('tt_hide'); 388 resize_booking_popup(); 389 390 $.post(tt_config.ajaxurl, 391 { 392 action: 'timetable_ajax_event_hour_booking', 393 event_hour_id: event_hour_id, 394 atts: tt_atts, 395 slots_number: slots_number, 396 guest_name: guest_name, 397 guest_email: guest_email, 398 guest_phone: guest_phone, 399 guest_message: guest_message, 400 terms_checkbox: terms_checkbox, 401 }, 402 function(result){ 403 $booking_popup_preloader.addClass('tt_hide'); 404 $booking_popup_message.removeClass('tt_hide'); 405 resize_booking_popup(); 406 result = parse_server_response(result); 407 if(typeof(result.msg)!=='undefined') 408 { 409 if(!result.error) 410 { 411 $booking_popup_message.html(result.msg); 412 resize_booking_popup(); 413 414 $timetable.find(".event_hour_booking.id-" + event_hour_id).parent().replaceWith(result.booking_button); 415 416 if(typeof(result.available_slots_label)!=='undefined') 417 { 418 $timetable.find('.available_slots.id-' + event_hour_id).html(result.available_slots_label); 419 } 420 } 421 else 422 { 423 $this.addClass('tt-qtip2').qtip( 424 { 425 style: 426 { 427 classes: 'ui-tooltip-error tt-qtip2' 428 }, 429 content: 430 { 431 text: result.msg 432 }, 433 position: 434 { 435 my: 'bottom center', 436 at: 'top center', 437 target: $this, 438 }, 439 }); 440 441 //show qtip after animation completes 442 setTimeout(function() { 443 $this.qtip('show'); 444 }, 200); 445 446 } 447 } 448 }, 449 "html" 450 ); 451 } 452 453 function handle_orinentation_change() 454 { 455 var no_change_count_to_end = 100, 456 no_end_timeout = 1000; 457 458 (function () { 459 var orientationchange_interval, 460 orientationchange_timeout, 461 end_timming, 462 curr_inner_width, 463 curr_inner_height, 464 last_inner_width, 465 last_inner_height, 466 no_change_count; 467 468 end_timming = function () 469 { 470 clearInterval(orientationchange_interval); 471 clearTimeout(orientationchange_timeout); 472 473 orientationchange_interval = null; 474 orientationchange_timeout = null; 475 476 //orientationchange has ended 477 resize_booking_popup(); 478 }; 479 480 orientationchange_interval = setInterval(function () 481 { 482 curr_inner_width = $(window).width(); 483 curr_inner_height = $(window).height(); 484 if (curr_inner_width === last_inner_width && curr_inner_height === last_inner_height) 485 { 486 no_change_count++; 487 488 if (no_change_count === no_change_count_to_end) 489 { 490 end_timming(); 491 } 492 } 493 else 494 { 495 last_inner_width = curr_inner_width; 496 last_inner_height = curr_inner_height; 497 no_change_count = 0; 498 } 499 }); 500 orientationchange_timeout = setTimeout(function () { 501 end_timming(); 502 }, no_end_timeout); 503 })(); 504 } 505 506 $(document.body).on('click', '.tt_guest_option a', function(event) { 507 event.preventDefault(); 508 var $booking = $('.tt_booking'), 509 $booking_form_user = $booking.find('.tt_booking_form.user'), 510 $booking_form_guest = $booking.find('.tt_booking_form.guest'); 511 512 $booking_form_user.addClass('tt_hide'); 513 $booking_form_guest.removeClass('tt_hide'); 514
515 $(this).parent().addClass('tt_hide') 516 .next('.tt_login_option').removeClass('tt_hide'); 517 $booking.find('.tt_btn.login').addClass('tt_hide'); 518 $booking.find('.tt_btn.book').removeClass('tt_hide'); 519 resize_booking_popup(); 520 }); 521 522 $(document.body).on('click', '.tt_slots_number_plus, .tt_slots_number_minus', function(event) { 523 event.preventDefault(); 524 var $booking = $('.tt_booking'), 525 $booking_form = $booking.find('.tt_booking_form'), 526 $slots_number = $booking_form.find('.tt_slots_number'), 527 slots_number = parseInt($slots_number.val()), 528 min = parseInt($slots_number.attr('min')), 529 max = parseInt($slots_number.attr('max')), 530 step = parseInt($slots_number.attr('step')); 531 532 if(isNaN(slots_number)) 533 slots_number = 1; 534 535 if($(this).hasClass('tt_slots_number_plus')) 536 { 537 if(slots_number<max) 538 slots_number += step; 539 else 540 slots_number = max; 541 } 542 543 if($(this).hasClass('tt_slots_number_minus')) 544 { 545 if(slots_number>min) 546 slots_number -= step; 547 else 548 slots_number = min; 549 } 550 551 $slots_number.val(slots_number); 552 }); 553 554 $(document.body).on('click', '.tt_btn.cancel, .tt_btn.continue', function(event) { 555 event.preventDefault(); 556 close_booking_popup(event); 557 }); 558 559 560 function calc_popup_params() 561 { 562 //init vars 563 var $booking_popup = $('.tt_booking'); 564 var booking_popup_margin_left = parseInt($booking_popup.css('margin-left')); 565 566 var booking_popup_width_new; 567 var booking_popup_width = $booking_popup.outerWidth(); 568 var booking_popup_width_auto = $booking_popup.css('width', '').outerWidth(); 569 $booking_popup.css('width', booking_popup_width) 570 571 var window_height = ($booking_popup.hasClass('in_iframe') ? $(parent.window).height() : $(window).height()); 572 var window_width = ($booking_popup.hasClass('in_iframe') ? $(parent.window).width() : $(window).width()); 573 var offset_top = ($(document).scrollTop()>=$(parent.document).scrollTop() ? $(document).scrollTop() : $(parent.document).scrollTop()); 574 575 576 //calc width 577 if((booking_popup_width_auto+booking_popup_margin_left*2)>=window_width) 578 booking_popup_width_new = window_width-booking_popup_margin_left*2; 579 else 580 booking_popup_width_new = booking_popup_width_auto; 581 582 //calc left position 583 var booking_popup_left = (window_width-booking_popup_width_new-booking_popup_margin_left*2)/2; 584 585 //calc height 586 var booking_popup_height = $booking_popup.outerHeight(); 587 var booking_popup_height_new = $booking_popup.css({ 588 'width': booking_popup_width_new, 589 'height': '', 590 }).outerHeight(); 591 $booking_popup.css({ 592 'width': booking_popup_width, 593 'height': booking_popup_height, 594 }); 595 596 //calc top position 597 var booking_popup_top = offset_top; 598 if(booking_popup_height_new<window_height) 599 booking_popup_top += (window_height-booking_popup_height_new)/2; 600 601 var result = { 602 'top': booking_popup_top, 603 'left': booking_popup_left, 604 'width': booking_popup_width_new, 605 'height': booking_popup_height_new, 606 }; 607 return result; 608 } 609 610 function open_booking_popup(event) 611 { 612 var 613 $booking_popup = $(".tt_booking"), 614 $booking_overlay = $(".tt_booking_overlay"), 615 $booking_popup_preloader = $booking_popup.find('.tt_preloader'); 616 617 $booking_overlay.removeClass("tt_hide"); 618 $booking_popup.removeClass("tt_hide"); 619 $booking_popup_preloader.removeClass('tt_hide'); 620 621 622 $booking_overlay.css({ 623 'height' : $(document).height(), 624 }); 625 626 var popup_params = calc_popup_params(); 627 628 $booking_popup.css({ 629 'top': popup_params.top, 630 'left': popup_params.left, 631 'width': popup_params.width, 632 'height': popup_params.height, 633 }); 634 } 635 636 function close_booking_popup() 637 { 638 var $booking_popup = $(".tt_booking"), 639 $booking_overlay = $(".tt_booking_overlay"); 640 641 $booking_popup.find('.tt-qtip2').qtip('destroy').removeClass('tt-qtip2'); 642 $booking_popup.addClass("tt_hide"); 643 $booking_overlay.addClass("tt_hide"); 644 645 $booking_popup.css({ 646 "top": "", 647 "left": "", 648 "width": "", 649 "height": "", 650 }); 651 if(window.location.href.indexOf("book-event-hour-")!==-1) 652 { 653 window.location.href = escape_str(window.location.href.substr(0, window.location.href.indexOf("#"))) + "#"; 654 } 655 return false;
656 } 657 658 function resize_booking_popup() 659 { 660 var $booking_popup = $('.tt_booking'), 661 $booking_overlay = $(".tt_booking_overlay"); 662 663 if($booking_popup.hasClass('tt_hide')) 664 return; 665 666 $booking_overlay.css({ 667 'height' : $(document).height(), 668 }); 669 670 var popup_params = calc_popup_params(); 671 $booking_popup.stop(false, true).animate({ 672 'top': popup_params.top, 673 'left': popup_params.left, 674 'width': popup_params.width, 675 'height': popup_params.height, 676 }, 200); 677 } 678 679 //IIFE: wait till resize event ends 680 (function() { 681 var last_resize, 682 timeout = false, 683 delta = 200; 684 685 $(window).resize(function() { 686 last_resize = new Date(); 687 if(timeout === false) 688 { 689 timeout = true; 690 setTimeout(resize_end, delta); 691 } 692 }); 693 694 function resize_end() 695 { 696 if(new Date()-last_resize<delta) 697 setTimeout(resize_end, delta); 698 else 699 { 700 timeout = false; 701 $(window).trigger('resize_end'); //trigger custom event 702 } 703 } 704 })(); 705 $(window).on('resize_end', resize_booking_popup); //handle custom event 706 707 window.addEventListener('orientationchange', handle_orinentation_change); 708 709 if(window.location.href.indexOf('book-event-hour-')!==-1) 710 { 711 var event_hour_id = window.location.href.substr(window.location.href.indexOf('book-event-hour-')+16), 712 $booking_link = $('a.event_hour_booking.id-' + event_hour_id).eq(0); 713 if($booking_link.length) 714 { 715 $('html, body').animate({scrollTop: $booking_link.offset().top-80}, 400); 716 $booking_link.trigger("click"); 717 } 718 } 719 720 function escape_str($text) 721 { 722 return $('<div/>').text($text).html(); 723 } 724 725 $('form.tt_generate_pdf').on('submit', function(event) { 726 var $this = $(this), 727 $timetable_copy, 728 timetable_html; 729 730 $timetable = $this.closest('.tt_wrapper'); 731 732 $timetable_copy = $timetable.find('.tt_tabs div.ui-tabs-panel:visible .tt_timetable.small').clone(); 733 $timetable_copy.find('*').attr('style', ''); //helps to remove the colors 734 timetable_html = $timetable_copy[0].outerHTML; 735 if($('body').hasClass('rtl')) 736 timetable_html = "<div class='rtl'>" + timetable_html + "</div>"; 737 $this.find("textarea[name='tt_pdf_html_content']").val(timetable_html); 738 return true; 739 }); 740 741 function in_iframe() 742 { 743 try { 744 return window.self !== window.top; 745 } catch (e) { 746 return true; 747 } 748 } 749 750 function parse_server_response(response) 751 { 752 var indexStart = response.indexOf('timetable_start')+15, 753 indexEnd = response.indexOf('timetable_end')-indexStart; 754 return $.parseJSON(response.substr(indexStart, indexEnd)); 755 } 756 757});
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.