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