1/** 2 * Main JS 3 * @version 2015 4 * @author vioma GmbH - www.vioma.de 5 * @license this code is distributed under the terms of the WTFPL 6 */ 7var responsive = function ($) { 8 "use strict"; 9 10 // globally accessible for external template calls 11 var me = (window.nst2015 = {}); 12 13 me.browser = { 14 nua: navigator.userAgent, 15 Android: function () { 16 return me.browser.nua.match(/Android/i); 17 }, 18 AndroidVanilla: function () { 19 return me.browser.nua.match( 20 /^(?=.*\bMozilla\/5\.0\b)(?=.*\bAndroid\b)(?=.*\bAppleWebKit\b)(?!.*\bChrome\b).*$/ 21 ); 22 }, 23 BlackBerry: function () { 24 return me.browser.nua.match(/BlackBerry/i); 25 }, 26 iOS: function () { 27 return me.browser.nua.match(/iPhone|iPad|iPod/i); 28 }, 29 OperaMini: function () { 30 return me.browser.nua.match(/Opera Mini/i); 31 }, 32 OperaWebkit: function () { 33 return me.browser.nua.match(/^(?=.*\bOPR\/\b)(?!.*\bMobile\b)/); 34 }, 35 Chrome: function () { 36 return me.browser.nua.match( 37 /^(?=.*\bAppleWebKit\b)(?=.*\bChrome\b).*$/ 38 ); 39 }, 40 Safari: function () { 41 return me.browser.nua.match( 42 /^(?=.*\bAppleWebKit\b)(?!.*\bChrome\b)(?=.*\bSafari\b).*$/ 43 ); 44 }, 45 Webkit: function () { 46 return ( 47 me.browser.Chrome() || 48 me.browser.Safari() || 49 me.browser.OperaWebkit() 50 ); 51 }, 52 IE8: function () { 53 return me.browser.nua.match(/^(?=.*\bmsie\b)(?=.*\b8\.\b).*$/); 54 }, 55 IE10: function () { 56 return me.browser.nua.match(/^(?=.*\bmsie\b)(?=.*\b10\.\b).*$/); 57 }, 58 IE11: function () { 59 return me.browser.nua.match(/^(?=.*\bTrident\b)(?=.*\b11\.\b).*$/); 60 }, 61 WinPhone: function () { 62 return me.browser.nua.match(/IEMobile/i); 63 }, 64 mobile: function () { 65 return ( 66 me.browser.Android() || 67 me.browser.BlackBerry() || 68 me.browser.iOS() || 69 me.browser.OperaMini() || 70 me.browser.WinPhone() 71 ); 72 }, 73 }; 74 75 me.id = function (el, js_node) { 76 var node = document.getElementById(el); 77 return js_node ? node : $(node); 78 }; 79 80 me.opt = { 81 variants: { 82 template: "", 83 header: "", 84 navigation: "", 85 }, 86 dnt: navigator["doNotTrack"] == "1" || navigator["doNotTrack"] == "yes", 87 window: $(window), 88 body_scroll: $("html,body"), 89 is_mobile: me.browser.mobile(), 90 html: $("html"), 91 site: $("#site"), 92 head: $("head"), 93 header: $("#header").add("#header_c"), 94 hash: "", 95 nav: $("#nav_0"), 96 menu: $("#nav_menu"), 97 menu_open: false, 98 menu_fade_delay: 1000, 99 menu_animating: false, 100 menu_animation: 700, // timing (ms) 101 menu_button: $("#nav_menu_button"), 102 main: $("#main"), 103 scroll: 0, 104 scroll_breakpoint: function () { 105 return me.opt.scroll >= me.opt.main_top * 0.5; 106 }, 107 already_scrolled: false, 108 noscript_afterload: $("noscript.styleafterscroll"), 109 std_domain: "", 110 mq: { 111 obj: $("#layout"), 112 width: 0, 113 portrait: false, 114 }, 115 gals: [], 116 gal_std_ratio: 16 / 9, 117 gal_parallax: [], 118 gal_parallax_listening: false, 119 gmaps_styles: undefined, 120 fancyboxDefaultPadding: undefined, 121 ytLinks: false /* true/false, jQuery object or selector as string */, 122 ytLinksSel: 'a[href*="youtube"],a[href*="youtu.be"]', 123 flex_layouts: { 124 "roomtype-slider": function () { 125 this.options = $.extend( 126 { 127 slideshow: false, 128 animation: "slide", 129 prevText: "", 130 nextText: "", 131 }, 132 this.options 133 ); 134 }, 135 "content-slider-wide": function () { 136 this.resp_img_src = true; 137 this.w = Math.min(1200, me.opt.mq.width); 138 this.h = (this.w * 580) / 1200; 139 this.options = $.extend( 140 { 141 slideshow: false, 142 animation: "slide", 143 prevText: "", 144 nextText: "", 145 controlNav: true, 146 directionNav: true, 147 }, 148 this.options 149 ); 150 }, 151 "content-slider-images": function () { 152 this.options = $.extend( 153 { 154 slideshow: false, 155 animation: "fade", 156 prevText: "", 157 nextText: "", 158 directionNav: true, 159 }, 160 this.options 161 ); 162 }, 163 "content-slider-texts": function () { 164 this.options = $.extend( 165 { 166 slideshow: false, 167 animation: "slide", 168 prevText: "", 169 nextText: "", 170 smoothHeight: true, 171 controlNav: true, 172 directionNav: true, 173 }, 174 this.options 175 ); 176 }, 177 "tiles-slider": function () { 178 var columns = { 179 1920: 3, 180 1600: 3, 181 1280: 3, 182 959: 2, 183 768: 2, 184 640: 1, 185 480: 1, 186 320: 1, 187 }; 188 this.options = $.extend( 189 { 190 slideshow: false, 191 animation: "slide", 192 prevText: "", 193 nextText: "", 194 selector: ".slides > .tile-gallery", 195 controlNav: false, 196 directionNav: true, 197 itemWidth: 380, 198 itemMargin: 30, 199 minItems: columns[me.opt.mq.width], 200 maxItems: columns[me.opt.mq.width], 201 start: function (slider) { 202 $(window).bind("resize.tiles_slider", function () { 203 slider.vars.smoothHeight = 204 columns[me.opt.mq.width] === 1; 205 slider.vars.minItems = columns[me.opt.mq.width]; 206 slider.vars.maxItems = columns[me.opt.mq.width]; 207 }); 208 }, 209 }, 210 this.options 211 ); 212 }, 213 }, 214 }; 215 216 me.setup = function () { 217 if (window.devicePixelRatio === undefined) { 218 window.devicePixelRatio = 1; 219 } 220 me.opt.touch = ('ontouchstart' in window) || (navigator.maxTouchPoints > 0) || (navigator.msMaxTouchPoints > 0); 221 me.opt.lang = me.opt.html.attr("lang"); 222 me.opt.dev = me.opt.html.data("dev") === "yes"; 223 me.opt.std_domain = me.opt.html.data("dev-domain") || ""; 224 me.opt.main_menu_items = me.opt.menu.find(".main-menu-item"); 225 me.opt.variants.header = me.opt.header.data("variant"); 226 me.opt.variants.template_id = me.opt.site.data("template"); 227 me.opt.variants.navigation = me.opt.nav.data("variant"); 228 me.opt.banner = me.opt.header.children().filter(".banner"); 229 me.opt.logo = me.opt.banner.children().filter(".logo"); 230 me.opt.nav_hover = me.opt.nav.data("hover") === "yes"; 231 me.opt.smoothscroll = me.opt.site.data("smoothscroll") !== "no"; 232 me.opt.main_top = me.opt.main.length ? me.opt.main.offset().top : 0; 233 me.opt.scroll = me.opt.window.scrollTop(); 234 me.opt.mq.width = me.opt.mq.obj.width(); 235 me.opt.gmaps_markers = window["nst_markers"] || [ 236 { 237 marker_1x: 238 "/static/template-" + 239 me.opt.variants.template_id + 240 "/i/marker.png", 241 marker_2x: 242 "/static/template-" + 243 me.opt.variants.template_id + 244 "/i/marker_2x.png", 245 }, 246 ]; 247 if (me.opt.dev) { 248 window.me = me; 249 } 250 }; 251 252 me.init = function () { 253 me.content_place(); 254 me.listeners(); 255 me.custom_events(); 256 }; 257 258 me.content_place = function () { 259 me.scroll_event(); 260 me.accordion_build(); 261 me.fancybox_build(); 262 me.resp_iframe_build(); 263 me.text_ellipsis(); 264 265 if (document.location.hash && !document.location.hash.match(/^#\//)) { 266 me.opt.hash = document.location.hash; 267 } 268 }; 269 270 me.text_ellipsis = function () { 271 if ($.fn.dotdotdot !== undefined) { 272 me.opt.main.find(".dotdotdot").dotdotdot({ 273 watch: "window", 274 }); 275 } 276 }; 277 278 me.resp_iframe_build = function () { 279 if (me.opt.ytLinks) { 280 var ytLinks; 281 try { 282 if (me.opt.ytLinks instanceof $) { 283 ytLinks = me.opt.ytLinks; 284 } 285 if ( 286 typeof me.opt.ytLinks === "string" || 287 me.opt.ytLinks instanceof String 288 ) { 289 ytLinks = $(me.opt.ytLinks).find(me.opt.ytLinksSel); 290 } else { 291 ytLinks = me.opt.main.find(me.opt.ytLinksSel); 292 } 293 ytLinks.each(function (i, el) { 294 var $el = $(el); 295 var videoID = 296 el.href.match(/youtube.*v=([^&]*|.*$)/) || 297 el.href.match(/youtu\.be\/(.*)$/);
298 if (videoID !== null) { 299 var iframe = $( 300 '<iframe frameborder="0" width="1200" height="675" sandbox="allow-scripts allow-same-origin allow-presentation" allowfullscreen="allowfullscreen" mozallowfullscreen="mozallowfullscreen" webkitallowfullscreen="webkitallowfullscreen" src="https://www.youtube-nocookie.com/embed/' + 301 videoID[1] + 302 '"></iframe>' 303 ); 304 iframe.attr("title", $el.text() + " (YouTube)"); 305 if ($el.parent().is("p")) { 306 $el = $el.parent(); 307 } 308 $el.replaceWith(iframe); 309 } 310 }); 311 } catch (e) { 312 console.warn(e); 313 } 314 } 315 316 var css = ""; 317 //.yt-frames = legacy for cms 3113 318 me.opt.site 319 .find(":not(.yt-frame, .yt-iframe) > iframe") 320 .each(function (i, el) { 321 var $iframe = $(el), 322 iframe_w = $iframe.attr("width") || 0, 323 iframe_h = $iframe.attr("height") || 0; 324 if ($iframe.data("src")) { 325 $iframe.attr("src", $iframe.data("src")); 326 } 327 if (iframe_w * iframe_h > 0) { 328 var iframe_id = "yt-" + Math.round(1000000 * Math.random()); 329 $iframe.wrap('<div class="yt-iframe ' + iframe_id + '"/>'); 330 css += 331 "." + 332 iframe_id + 333 "{max-width:" + 334 iframe_w + 335 "px}." + 336 iframe_id + 337 "::before{padding-bottom:" + 338 (100 * iframe_h) / iframe_w + 339 "%}"; 340 } 341 }); 342 if (css.length > 0) { 343 var styletag = document.createElement("style"); 344 styletag.type = "text/css"; 345 if (styletag.styleSheet) { 346 // IE 347 styletag.styleSheet.cssText = css; 348 } else { 349 // W3 350 styletag.appendChild(document.createTextNode(css)); 351 } 352 document.head.appendChild(styletag); 353 } 354 }; 355 356 me.accordion_build = function (context) { 357 if ($.fn.accordion !== undefined) { 358 context = context || me.opt.main; 359 var accordions = context.find( 360 ".accordion, .accordion-open, .accordion-open-desktop" 361 ); 362 accordions.addClass("accordion").each(function (i, el) { 363 var accHeader = $(el); 364 var accContainer, 365 accContent, 366 nextElement, 367 accFragment, 368 currentFragment; 369 var accActive = false; 370 var nextSelector = ":not(.accordion, .accordion-stop)"; 371 372 if (accHeader.parent().hasClass(".accordion-article")) { 373 return; 374 } 375 376 if (accHeader.next().is("div.accordion-content")) { 377 accContainer = accHeader 378 .parent() 379 .addClass("accordion-article"); 380 } else { 381 accContainer = $(document.createElement("div")).addClass( 382 "accordion-article" 383 ); 384 accContent = document.createElement("div"); 385 accContent.className = "accordion-content"; 386 387 accFragment = document.createDocumentFragment(); 388 nextElement = accHeader.next(nextSelector); 389 390 while (nextElement.length != 0) { 391 currentFragment = nextElement.get(0); 392 nextElement = nextElement.next(nextSelector); 393 accFragment.appendChild(currentFragment); 394 } 395 accContainer.insertAfter(accHeader); 396 accContent.appendChild(accFragment); 397 accContainer.append(accHeader, accContent); 398 } 399 400 if ( 401 accHeader.hasClass("accordion-open") || 402 (accHeader.hasClass("accordion-open-desktop") && 403 me.opt.mq.width > 959) 404 ) { 405 accActive = 0; 406 } 407 408 accContainer.accordion({ 409 icons: false, 410 active: accActive, 411 header: "> .accordion", 412 heightStyle: "content", 413 autoHeight: false, 414 collapsible: true, 415 }); 416 }); 417 } 418 }; 419 420 me.fancyboxAfterShow = function () { 421 if ($.fn.sti !== undefined) { 422 $("img", ".fancybox-outer").sti({ 423 selector: ".fancybox-outer", 424 style: "flat", 425 orientation: "horizontal", 426 }); 427 } 428 if (me.opt.touch && typeof $.fn.swipe == "function") { 429 $(".fancybox-nav").css("display", "none"); 430 $(".fancybox-wrap").swipe({ 431 swipe: function (event, direction) { 432 if (direction === "left" || direction === "up") { 433 $.fancybox.next(direction); 434 } else { 435 $.fancybox.prev(direction); 436 } 437 }, 438 }); 439 } 440 }; 441 442 me.fancybox_build = function (context) { 443 context = context || me.opt.main; 444 445 if ($.fn.fancybox !== undefined) { 446 // single 447 var fb_links = context.find(".fancybox, .cms-zoom-content"); 448 fb_links.not("[rel],[data-fancybox-group]").each(function (i, el) { 449 var fb_options = { 450 helpers: { 451 title: { type: "inside" }, 452 }, 453 afterShow: me.fancyboxAfterShow, 454 }, 455 $this = $(el), 456 height = parseInt($this.data("height"), 10), 457 width = parseInt($this.data("width"), 10), 458 padding = parseInt($this.attr("data-fancybox-padding"), 10); 459 460 if ( 461 $this.attr("onclick") && 462 $this.attr("onclick").indexOf("hs.expand") > -1 463 ) { 464 $this.removeAttr("onclick"); 465 } 466 if ( 467 !$this.attr("data-fancybox-type") && 468 $this.hasClass("cms-zoom-content") && 469 el.href 470 ) { 471 if (el.href.indexOf("/media/") > -1) { 472 fb_options.type = "image"; 473 $this.attr("data-fancybox-type", "image"); 474 } else if (el.href.indexOf("http") === 0) { 475 fb_options.type = "iframe"; 476 $this.attr("data-fancybox-type", "iframe"); 477 } 478 } 479 if (height > 0 && width > 0) { 480 fb_options.height = height; 481 fb_options.width = width; 482 } 483 if (padding >= 0) { 484 fb_options.padding = padding; 485 } else if (me.opt.fancyboxDefaultPadding >= 0) { 486 fb_options.padding = me.opt.fancyboxDefaultPadding; 487 } 488 $this.fancybox(fb_options); 489 }); 490 491 // grouped 492 var fb_group = fb_links.filter("[rel],[data-fancybox-group]"); 493 var fb_group_options = (function ($this) { 494 var height = parseInt($this.data("height"), 10), 495 width = parseInt($this.data("width"), 10), 496 padding = parseInt($this.attr("data-fancybox-padding"), 10); 497 var fb_default = { 498 helpers: { 499 title: { type: "inside" }, 500 }, 501 afterShow: me.fancyboxAfterShow, 502 }; 503 504 if (height > 0 && width > 0) { 505 fb_default.height = height; 506 fb_default.width = width; 507 } 508 if (padding >= 0) { 509 fb_default.padding = padding; 510 } else if (me.opt.fancyboxDefaultPadding >= 0) { 511 fb_default.padding = me.opt.fancyboxDefaultPadding; 512 } 513 514 return fb_default; 515 })(fb_group.eq(0)); 516 fb_group.fancybox(fb_group_options); 517 518 // grouped with thumbnail 519 520 var fb_thumb = context.find(".fancybox-thumb"); 521 var fb_thumb_options = (function ($this) { 522 var height = parseInt($this.data("height"), 10), 523 width = parseInt($this.data("width"), 10), 524 padding = parseInt($this.attr("data-fancybox-padding"), 10); 525 var fb_default = { 526 helpers: { 527 title: { type: "inside" }, 528 thumbs: { 529 width: 50, 530 height: 50, 531 source: function (current) { 532 return $(current.element).attr( 533 "data-fancybox-thumb" 534 ); 535 }, 536 }, 537 }, 538 afterShow: me.fancyboxAfterShow, 539 }; 540 541 if (height > 0 && width > 0) { 542 fb_default.height = height; 543 fb_default.width = width; 544 } 545 if (padding >= 0) { 546 fb_default.padding = padding; 547 } else if (me.opt.fancyboxDefaultPadding >= 0) { 548 fb_default.padding = me.opt.fancyboxDefaultPadding; 549 } 550 551 return fb_default; 552 })(fb_thumb.eq(0)); 553 fb_thumb.fancybox(fb_thumb_options); 554 } 555 }; 556 557 me.listeners = function () { 558 if (me.opt.variants.header == "C") { 559 me.opt.headc_chk = $("#header_c_nav_chk"); 560 $(".main-menu-handle").on("click", function () { 561 var handle = $(this); 562 var item = handle.closest(".main-menu-item"); 563 564 if (me.opt.mq.width <= 768) { 565 item.toggleClass("open-mobile"); 566 } 567 }); 568 $("a").on("click", me.smooth_scroll); 569 } else if ( 570 me.opt.variants.navigation && 571 "ABC".indexOf(me.opt.variants.navigation) > -1 572 ) { 573 me.opt.menu_button.click(function (ev) { 574 ev.preventDefault(); 575 ev.stopPropagation(); 576 if (!me.opt.menu_animating) { 577 me.opt.menu_animating = true; 578 setTimeout(function () { 579 me.opt.menu_animating = false;
580 }, me.opt.menu_animation + 100); 581 me.opt.window.scrollTop(0); 582 if (!me.opt.menu_open) { 583 me.opt.site.addClass("open open-delay"); 584 } else { 585 me.opt.site.removeClass("open"); 586 setTimeout(function () { 587 me.opt.site.removeClass("open-delay"); 588 }, me.opt.menu_animation + 100); 589 } 590 me.opt.menu_open = !me.opt.menu_open; 591 } 592 }); 593 594 $("a").not(".main-menu-link").on("click", me.smooth_scroll); 595 596 me.menu_fade_cancel = $.noop; 597 598 if (!me.opt.touch && me.opt.mq.width >= 960 && me.opt.nav_hover) { 599 me.opt.submenus = me.opt.main_menu_items.find(".sub-menu"); 600 601 me.menu_fade = function () { 602 me.menu_fade_cancel(); 603 if (me.opt.menu_fade_delay > 0) { 604 me.opt.menu_fade_timer = setTimeout(function () { 605 me.opt.main_menu_items.removeClass("open"); 606 me.opt.submenus 607 .removeClass("overlay") 608 .attr("style", ""); 609 }, me.opt.menu_fade_delay); 610 } else { 611 me.opt.main_menu_items.removeClass("open"); 612 me.opt.submenus 613 .removeClass("overlay") 614 .attr("style", ""); 615 } 616 }; 617 me.menu_fade_cancel = function () { 618 if (me.opt.menu_fade_timer) { 619 clearTimeout(me.opt.menu_fade_timer); 620 } 621 }; 622 me.opt.main_menu_items 623 .on("mouseenter", me.menu_fade_cancel) 624 .not(".single") 625 .on("mouseenter", me.menu_click); 626 me.opt.nav.find(".main-menu").on("mouseleave", me.menu_fade); 627 me.opt.submenus.on("mouseenter", me.menu_fade_cancel); 628 } else { 629 me.opt.main_menu_items.on("click", me.menu_click); 630 } 631 632 me.opt.main_menu_items.find(".close").on("click", function (ev) { 633 ev.preventDefault(); 634 ev.stopPropagation(); 635 if (me.menu_fade_timer) { 636 clearTimeout(me.menu_fade_timer); 637 } 638 me.opt.main_menu_items.removeClass("open"); 639 $(ev.target) 640 .closest(".sub-menu") 641 .removeClass("overlay") 642 .attr("style", ""); 643 }); 644 645 me.opt.body_scroll.on("click touchstart", function (ev) { 646 if ( 647 me.opt.mq.width >= 960 && 648 !$(ev.target).closest(me.opt.menu).length 649 ) { 650 me.opt.menu.find(".close").trigger("click"); 651 } 652 }); 653 654 if (me.opt.touch && typeof $.fn.swipe == "function") { 655 me.opt.site.swipe({ 656 preventDefaultEvents: false, 657 swipe: function (event, direction) { 658 if ( 659 me.opt.site.hasClass("open") && 660 direction === "right" 661 ) { 662 me.opt.menu_button.click(); 663 } 664 }, 665 }); 666 } 667 } 668 me.opt.header.find(".widget-handle").click(function (ev) { 669 $(ev.target).closest(".nst15-widget").toggleClass("open"); 670 }); 671 672 me.opt.window.on("resize orientationchange", function () { 673 me.opt.main_top = me.opt.main.length ? me.opt.main.offset().top : 0; 674 var layout_prev = me.opt.mq.width; 675 me.opt.mq.width = me.opt.mq.obj.width(); 676 if (layout_prev !== me.opt.mq.width) { 677 me.layout_change(); 678 } 679 }); 680 681 me.opt.window.on("scroll touchmove", function (ev) { 682 me.opt.scroll = me.opt.window.scrollTop(); 683 me.scroll_event(ev); 684 }); 685
686 me.id("site_anchor").click(function () { 687 var scrollspeed = me.opt.smoothscroll ? 400 : 1; 688 me.opt.body_scroll.animate({ scrollTop: 0 }, scrollspeed); 689 }); 690 691 me.opt.header.find(".gallery-fullscreen").on("click", function () { 692 me.opt.site.toggleClass("fullscreen"); 693 }); 694 695 if (me.opt.hash !== "") { 696 me.opt.window.on("load", function () { 697 setTimeout(function () { 698 me.smooth_scroll({ 699 hash: me.opt.hash.replace(/^#+/, ""), 700 banner_height: window["scrolledBannerHeight"] || false, 701 }); 702 }, 300); 703 }); 704 } else if (me.opt.site.data("autoscroll")) { 705 var scrollto = $(me.opt.site.data("autoscroll")); 706 if (scrollto.length && me.opt.scroll == 0) { 707 me.opt.window.on("load", function () { 708 setTimeout(function () { 709 me.smooth_scroll({ 710 scrollto: scrollto.eq(0), 711 banner_height: 712 window["scrolledBannerHeight"] || false, 713 }); 714 }, 300); 715 }); 716 } 717 } 718 }; 719 720 me.custom_events = $.noop; 721 722 me.menu_click = function (ev) { 723 ev.stopPropagation(); 724 var item, 725 is_single, 726 pos, 727 overlay_css, 728 overlay, 729 link_container = $(this); 730 731 /* do not try to invert the state of the menu if the item is already opened */ 732 if (ev.type === "mouseenter" && link_container.hasClass("open")) { 733 me.menu_fade_cancel(); 734 return; 735 } 736 item = link_container.find(".main-menu-item-name"); 737 is_single = 738 item.hasClass("single") || link_container.hasClass("single"); 739 740 /* No sub-menu handling for the navigation layout C */ 741 if (me.opt.variants.navigation === "C" && me.opt.mq.width >= 960) { 742 ev.target = item.find("a")[0]; 743 me.smooth_scroll(ev); 744 } else if (is_single) { 745 746 /* Top level items without a submenu fire an event to close the other overlays and follow the current link */ 747 me.opt.main_menu_items.removeClass("open"); // close all 748 ev.target = item.find("a")[0]; 749 me.smooth_scroll(ev); 750 } else if (!$(ev.target).closest(".sub-menu").length) { 751 752 /* Handling items with submenu (not being located in the submenu) */ 753 ev.preventDefault(); 754 overlay = link_container.find(".sub-menu"); 755 me.opt.main_menu_items.not(link_container).removeClass("open"); // close all others 756 757 if ( 758 me.opt.mq.width < 960 && 759 me.opt.main_menu_items.filter(".open-mobile").length === 1 760 ) { 761 if (link_container.hasClass("open-mobile")) { 762 link_container.removeClass("open-mobile"); 763 } else { 764 me.opt.main_menu_items.removeClass("open-mobile"); 765 link_container.toggleClass("open"); 766 } 767 } else { 768 link_container.toggleClass("open"); 769 } 770 switch (me.opt.variants.navigation) { 771 case "A": 772 pos = item.offset(); 773 overlay_css = { 774 top: pos.top - link_container.offset().top, 775 }; 776 if (overlay.width() + pos.left > me.opt.site.width()) { 777 overlay_css.right = 0; 778 overlay.addClass("rtl"); 779 } 780 overlay 781 .css(overlay_css) 782 .animate( 783 { 784 opacity: link_container.hasClass("open") 785 ? 1 786 : 0, 787 }, 788 "fast" 789 ); 790 break; 791 case "B": 792 pos = link_container.offset(); 793 if (overlay.width() + pos.left > me.opt.site.width()) { 794 overlay.addClass("rtl"); 795 } 796 break; 797 } 798 } 799 }; 800 801 me.smooth_scroll = function (ev) { 802 var scrollspeed = me.opt.smoothscroll 803 ? parseInt(ev.speed, 10) || 400 804 : 1, 805 boundingrect, 806 target_hash, 807 link, 808 link_href, 809 target, 810 match, 811 offset_px, 812 banner_height = 813 parseInt(ev["banner_height"], 10) ||
814 window["scrolledBannerHeight"] || 815 me.opt.banner.outerHeight() || 816 0; 817 818 /* if the click event is fired by javascript on an anchor in the page */ 819 if (ev.hash) { 820 target_hash = me.id(ev.hash); 821 if (target_hash.length) { 822 if (me.opt.menu_open) { 823 me.opt.menu_open = false; 824 me.opt.site.removeClass("open open-delay"); 825 } 826 /* removing the hash from the url to prevent the browser from jumping on its own after the animation */ 827 document.location.hash = ""; 828 offset_px = Math.round( 829 target_hash.offset().top - banner_height 830 ); 831 me.opt.body_scroll.animate( 832 { scrollTop: offset_px }, 833 scrollspeed 834 ); 835 } 836 return; 837 } 838 if (ev.scrollto && ev.scrollto.length > 0) { 839 if (me.opt.menu_open) { 840 me.opt.menu_open = false; 841 me.opt.site.removeClass("open open-delay"); 842 } 843 offset_px = Math.round( 844 ev.scrollto.eq(0).offset().top - banner_height 845 ); 846 me.opt.body_scroll.animate({ scrollTop: offset_px }, scrollspeed); 847 return; 848 } 849 link = ev.target ? $(ev.target) : $(this); 850 851 if (!link.is("a")) { 852 link = link.closest("a"); 853 } 854 /* if the click event is fired on a link */ 855 if (link.length === 1) { 856 link_href = link.attr("href"); 857 /* links with an attached event or which open in a new window are not treated */ 858 if ( 859 !link_href || 860 link.attr("target") || 861 link.attr("onclick") || 862 link.hasClass("fancybox") 863 ) { 864 return; 865 } 866 867 match = link_href.match(/^([^#]*)#+(.+)$/); 868 /* if the link has a page#anchor, comparing the current page with the requested page and try to softscroll if it's the same */ 869 if ( 870 match && 871 (!match[1] || 872 match[1] === document.location.pathname || 873 (document.location.pathname === "/" && 874 match[1] === "/" + me.opt.lang + "/")) 875 ) { 876 target = me.id(match[2]); 877 if (target.length === 0) { 878 target = $( 879 '[id="' + match[2] + '"],[name="' + match[2] + '"]' 880 ); 881 } 882 if (target && target.filter(":visible").length > 0) { 883 ev.preventDefault(); 884 me.smooth_scroll_callback(ev, target); 885 offset_px = Math.round( 886 target.eq(0).offset().top - banner_height 887 ); 888 if (me.opt.banner.css("position") == "fixed") { 889 boundingrect = me.opt.banner 890 .get(0) 891 .getBoundingClientRect(); 892 if (boundingrect && boundingrect.top) { 893 offset_px -= boundingrect.top; 894 } 895 } 896 me.opt.body_scroll.animate( 897 { scrollTop: offset_px }, 898 scrollspeed 899 ); 900 } 901 } 902 } 903 }; 904 905 me.smooth_scroll_callback = function () { 906 if (me.opt.headc_chk && me.opt.headc_chk.is(":checked")) { 907 me.opt.headc_chk.prop("checked", false); 908 } else if (me.opt.menu_open) { 909 me.opt.menu_open = false; 910 me.opt.site.removeClass("open open-delay"); 911 } 912 }; 913 914 me.scroll_event = function () { 915 me.opt.site.toggleClass("scrolled", me.opt.scroll_breakpoint()); 916 if ( 917 me.opt.already_scrolled == false && 918 me.opt.scroll_breakpoint() == true 919 ) { 920 me.opt.noscript_afterload.each(function () { 921 var i = $(this); 922 me.opt.head.append(i.html()); 923 i.remove(); 924 }); 925 me.opt.already_scrolled = true; 926 } 927 }; 928 929 me.flex = function (container, layout, build, options) { 930 var params = { 931 w: 0, 932 h: 0, 933 quality: -1, // jpeg quality, -1 = standard 934 max_w: 2048, 935 resp_img_bg: false, // define css background-image 936 resp_img_src: false, // change img src 937 container: container, 938 layout: layout, 939 build: build, 940 options: typeof options !== "object" ? {} : options, 941 default_options: { 942 selector: ".slides > .slide", 943 controlNav: false, 944 directionNav: true, 945 slideshow: true, 946 slideshowSpeed: 5000, 947 animationSpeed: 400, 948 animationLoop: false, 949 keyboard: false, 950 prevText: "‹", 951 nextText: "›", 952 }, 953 flex_build: function () { 954 params.container.flexslider(params.options); 955 }, 956 }, 957 slides, 958 existing_img, 959 img; 960 961 if (params.layout) { 962 params.container.data("layout", params.layout); 963 } else if (params.container.data("layout")) { 964 params.layout = params.container.data("layout"); 965 } 966 967 if (typeof me.opt.flex_layouts[params.layout] === "function") { 968 me.opt.flex_layouts[params.layout].bind(params)(); 969 if (params.options.selector) { 970 params.options.selector = params.options.selector.replace( 971 ">", 972 ">" 973 ); 974 } 975 } else { 976 params.w = Math.min(params.max_w, me.opt.mq.width); 977 params.h = 978 params.w / 979 (me.opt.gal_std_ratio > 0 ? me.opt.gal_std_ratio : 16 / 9); 980 } 981 982 params.options = $.extend(params.default_options, params.options); 983 984 if (!params.container.data("slides")) { 985 slides = params.container.find(params.options.selector); 986 if (slides.length === 0) { 987 return; 988 } 989 params.container.data("slides", slides); 990 } 991 992 if (params.resp_img_bg || params.resp_img_src) { 993 params.w = Math.round(params.w); 994 params.h = Math.round(params.h); 995 996 params.container.data("slides").each(function (i, el) { 997 var slide = $(el), 998 media_id, 999 media_url, 1000 url; 1001 1002 media_id = slide.data("media"); 1003 media_url = slide.data("media-url"); 1004 1005 if (media_id || media_url) { 1006 if (!slide.data("img")) { 1007 slide.data("img", slide.find("img")); 1008 } 1009 url = media_id 1010 ? me.opt.std_domain + 1011 "/(cms)/media/resize/size=" + 1012 params.w + 1013 "x" + 1014 params.h + 1015 ",scale=crop/" + 1016 media_id 1017 : media_url + "/" + params.w + "x" + params.h + "s"; 1018 if (params.resp_img_bg) { 1019 slide.css("background-image", "url('" + url + "')"); 1020 } 1021 if (params.resp_img_src) { 1022 if (slide.data("img").length) { 1023 slide 1024 .data("img") 1025 .attr({ 1026 src: url, 1027 width: params.w, 1028 height: params.h, 1029 }); 1030 } else { 1031 existing_img = slide.find("img"); 1032 if (existing_img.length > 0) { 1033 slide.data("img", existing_img.eq(0)); 1034 } else { 1035 img = $( 1036 '<img src="' + 1037 url + 1038 '" width="' + 1039 params.w + 1040 '" height="' + 1041 params.h + 1042 '" />' 1043 ); 1044 slide.append(img).data("img", img); 1045 } 1046 } 1047 } 1048 } 1049 }); 1050 } 1051 1052 if (params.build) { 1053 if (params.resp_img_bg || params.resp_img_src) {
1054 me.opt.gals.push(params.container); 1055 } 1056 if (params.container.data("slides").length > 1) { 1057 if (params.resp_img_bg || params.resp_img_src) { 1058 params.container 1059 .data("slides") 1060 .eq(0) 1061 .data("img") 1062 .load(params.flex_build); 1063 } else { 1064 params.flex_build(); 1065 } 1066 } else { 1067 params.container.data("slides").show(); 1068 } 1069 } 1070 }; 1071 1072 me.layout_change = function () { 1073 $(me.opt.gals).map(function (i, el) { 1074 me.flex(el); 1075 }); 1076 }; 1077 1078 me.map_generate = function (container, coordinates, options) { 1079 var form = container.closest(".grp-mem").find("form"); 1080 var config = form.data("config"); 1081 if (typeof config != "object") { 1082 config = {}; 1083 } 1084 var autobuild = config.Autobuild; 1085 1086 if (config.Markers && config.Markers.length) { 1087 coordinates = []; 1088 $(config.Markers).map(function (i, el) { 1089 coordinates.push([ 1090 parseFloat(el.Latitude), 1091 parseFloat(el.Longitude), 1092 el.Name, 1093 el.Url, 1094 ]); 1095 if (el.MediaID > 0) { 1096 me.opt.gmaps_markers[i] = { 1097 marker_1x: 1098 me.opt.std_domain + 1099 "/(cms)/media/resize/size=0x100/" + 1100 el.MediaID, 1101 marker_2x: 1102 me.opt.std_domain + 1103 "/(cms)/media/resize/size=0x200/" + 1104 el.MediaID, 1105 }; 1106 } 1107 }); 1108 } else { 1109 if (!$.isArray(coordinates)) { 1110 console.warn("Map Module: invalid coordinates", coordinates); 1111 return; 1112 } 1113 if (!$.isArray(coordinates[0])) { 1114 coordinates = [coordinates]; 1115 } 1116 } 1117 1118 if (options === undefined) { 1119 options = {}; 1120 } 1121 1122 if (options.zoom) { 1123 options.zoom = parseFloat(options.zoom); 1124 } 1125 1126 if (options.resize) { 1127 options.resize = Math.max(1, parseFloat(options.resize)); 1128 } 1129 1130 me.gmapsinit = function () { 1131 var mapOptions, 1132 currentMarker, 1133 currentPos, 1134 center_lat, 1135 center_long, 1136 boundaries, 1137 markers = [], 1138 searchBox, 1139 container_h = container.height(), 1140 $input = $(".nst15-map-input", form), 1141 $submit = $(".nst15-map-submit", form), 1142 $saddr = $('input[name="saddr"]', form), 1143 $daddr = $('input[name="daddr"]', form); 1144 1145 if (options.resize && !autobuild) { 1146 container 1147 .height(container_h * options.resize) 1148 .addClass("gmaps"); 1149 me.opt.body_scroll.animate({ 1150 scrollTop: 1151 me.opt.scroll + (options.resize - 1) * container_h, 1152 }); 1153 } else { 1154 container.height(container_h); 1155 } 1156 1157 container.addClass("gmaps"); 1158 if (config.UseCustomCenter && $.isArray(config.CustomCenter)) { 1159 center_lat = config.CustomCenter[0]; 1160 center_long = config.CustomCenter[1]; 1161 } else { 1162 currentPos = [coordinates[0][0], coordinates[0][1]]; 1163 center_lat = currentPos[0]; 1164 center_long = currentPos[1]; 1165 1166 if (!config.UseCustomCenter && coordinates.length > 1) { 1167 boundaries = { 1168 minLat: currentPos[0], 1169 maxLat: currentPos[0], 1170 minLong: currentPos[1], 1171 maxLong: currentPos[1], 1172 }; 1173 $(coordinates).map(function (i, markerPos) { 1174 boundaries.minLat = Math.min( 1175 boundaries.minLat, 1176 markerPos[0] 1177 ); 1178 boundaries.maxLat = Math.max( 1179 boundaries.maxLat, 1180 markerPos[0] 1181 ); 1182 boundaries.minLong = Math.min( 1183 boundaries.minLong, 1184 markerPos[1] 1185 ); 1186 boundaries.maxLong = Math.max( 1187 boundaries.maxLong, 1188 markerPos[1] 1189 ); 1190 }); 1191 center_lat = (boundaries.minLat + boundaries.maxLat) / 2; 1192 center_long = (boundaries.minLong + boundaries.maxLong) / 2; 1193 } 1194 } 1195 1196 mapOptions = $.extend( 1197 { 1198 zoom: 12, 1199 center: new google.maps.LatLng(center_lat, center_long), 1200 gestureHandling: "cooperative", 1201 }, 1202 options 1203 ); 1204 1205 if (me.opt["gmaps_styles"] !== undefined) { 1206 mapOptions.styles = me.opt["gmaps_styles"]; 1207 } 1208 1209 me.opt.gmap = new google.maps.Map(container[0], mapOptions); 1210 form.on("submit", function (ev) { 1211 ev.preventDefault(); 1212 window.open( 1213 form.attr("action") + 1214 "?" +
1215 $.param($('input[type="hidden"]', form)) 1216 ); 1217 }); 1218 1219 $(coordinates).map(function (i, markerPos) { 1220 var marker_pos = new google.maps.LatLng( 1221 markerPos[0], 1222 markerPos[1] 1223 ); 1224 var marker_img = document.createElement("img"); 1225 var marker_scale = 1; 1226 var marker_srcs = 1227 me.opt.gmaps_markers[i] || me.opt.gmaps_markers[0]; 1228 var marker_src = marker_srcs.marker_1x; 1229 1230 if (window.devicePixelRatio > 1) { 1231 marker_scale = 0.5; 1232 marker_src = marker_srcs.marker_2x; 1233 } 1234 1235 $(marker_img).on("load", function () { 1236 var map_icon = { 1237 url: this.src, 1238 scaledSize: new google.maps.Size( 1239 parseInt(this.width * marker_scale), 1240 parseInt(this.height * marker_scale) 1241 ), 1242 }; 1243 1244 var marker_options = { 1245 position: marker_pos, 1246 map: me.opt.gmap, 1247 icon: map_icon, 1248 }; 1249 1250 try { 1251 if (config.Markers[i].Name.length > 0) { 1252 marker_options.title = config.Markers[i].Name; 1253 } 1254 } catch (e) {} 1255 1256 var marker = new google.maps.Marker(marker_options); 1257 1258 markers[i] = marker; 1259 1260 marker.addListener("click", function () { 1261 currentMarker = marker; 1262 currentPos = [markerPos[0], markerPos[1]]; 1263 me.opt.gmap.panTo(marker.getPosition()); 1264 $daddr.val(currentPos.join(",")); 1265 if (markerPos[3]) { 1266 window.open(markerPos[3], "_blank"); 1267 } else { 1268 $input.focus(); 1269 } 1270 }); 1271 1272 if (!currentMarker) { 1273 currentMarker = marker; 1274 $daddr.val(currentPos.join(",")); 1275 } 1276 }); 1277 1278 marker_img.src = marker_src; 1279 }); 1280 1281 me.opt.gmap.controls[google.maps.ControlPosition.TOP_LEFT].push( 1282 $input.get(0) 1283 ); 1284 me.opt.gmap.controls[google.maps.ControlPosition.TOP_LEFT].push( 1285 $submit.get(0) 1286 ); 1287 searchBox = new google.maps.places.SearchBox($input.get(0)); 1288 1289 var rendererOptions = { 1290 map: me.opt.gmap, 1291 suppressMarkers: true, 1292 }; 1293 var directionsService = new google.maps.DirectionsService(); 1294 var directionsDisplay = new google.maps.DirectionsRenderer( 1295 rendererOptions 1296 ); 1297 1298 google.maps.event.addListener( 1299 searchBox, 1300 "places_changed", 1301 function () { 1302 var places = searchBox.getPlaces(); 1303 1304 if (places.length === 0) { 1305 return; 1306 } 1307 $input.val(places[0].formatted_address); 1308 $saddr.val( 1309 places[0].geometry.location.lat() + 1310 "," + 1311 places[0].geometry.location.lng() 1312 ); 1313 $submit.addClass("visible"); 1314 1315 if (directionsDisplay != null) { 1316 directionsDisplay.setMap(null); 1317 directionsDisplay = new google.maps.DirectionsRenderer( 1318 rendererOptions 1319 ); 1320 } 1321 1322 directionsDisplay.setMap(me.opt.gmap); 1323 directionsService.route( 1324 { 1325 origin: places[0].geometry.location, 1326 destination: currentMarker.position, 1327 travelMode: google.maps.TravelMode.DRIVING, 1328 }, 1329 function (response, status) { 1330 if (status === google.maps.DirectionsStatus.OK) { 1331 directionsDisplay.setDirections(response); 1332 } else { 1333 console.error( 1334 "Directions request failed due to " + status 1335 ); 1336 } 1337 } 1338 ); 1339 } 1340 ); 1341 }; 1342 1343 if (window.google !== undefined && window.google.maps !== undefined) { 1344 me.gmapsinit(); 1345 } else { 1346 var apikey = options["apikey"] ? "&key=" + options["apikey"] : ""; 1347 $.getScript(
1348 "https://maps.googleapis.com/maps/api/js?libraries=places&callback=nst2015.gmapsinit" + 1349 apikey 1350 ); 1351 } 1352 }; 1353 1354 me.gal_parallax = function (container) { 1355 if (container && !container.data("parallax")) { 1356 container.data("parallax", true); 1357 container.data("slides", container.find(".slide")); 1358 me.opt.gal_parallax.push(container); 1359 1360 if (!me.opt.gal_parallax_listening) { 1361 me.opt.gal_parallax_listening = true; 1362 me.opt.window_h = me.opt.window.height(); 1363 me.gal_parallax(); 1364 1365 me.opt.window 1366 .on( 1367 "resize.nst_parallax orientationchange.nst_parallax", 1368 function () { 1369 me.opt.window_h = me.opt.window.height(); 1370 me.gal_parallax(); 1371 } 1372 ) 1373 .on( 1374 "scroll.nst_parallax touchmove.nst_parallax", 1375 function () { 1376 me.gal_parallax(); 1377 } 1378 ); 1379 } 1380 } else { 1381 $.map(me.opt.gal_parallax, function (el) { 1382 var scroll_pos, 1383 pos = el.get(0).getBoundingClientRect(); 1384 if (pos.height + pos.top > 0 && me.opt.window_h - pos.top > 0) { 1385 scroll_pos = 1386 (100 * (pos.top + pos.height)) / 1387 (me.opt.window_h + pos.height); 1388 el.data("slides").css({ 1389 "background-position": "0 " + scroll_pos + "%", 1390 }); 1391 } 1392 }); 1393 } 1394 }; 1395 1396 me.left_pad = function (value, fill, return_length) { 1397 fill = fill !== undefined ? fill.toString() : "0"; 1398 return_length = return_length !== undefined ? return_length : 2; 1399 while (value.toString().length < return_length) { 1400 value = fill + value.toString(); 1401 } 1402 return value; 1403 }; 1404 1405 me.date_convert = function ( 1406 data, 1407 format_in, 1408 format_out, 1409 day_offset, 1410 min_today 1411 ) { 1412 day_offset = typeof day_offset === "number" ? day_offset : 0; 1413 min_today = !!min_today; 1414 var test, 1415 date_calc = false, 1416 today = new Date(); 1417 switch (format_in) { 1418 case "dmy": 1419 case "d.m.y": 1420 case "dd.mm.yy": 1421 case "dd.mm.yyyy": 1422 test = 1423 /^0?([1-2]?[0-9]|3[0-1])\.0?([1-9]|1[0-2])\.(19|20[\d]{2})$/.exec( 1424 data 1425 ); 1426 date_calc = test 1427 ? new Date( 1428 parseInt(test[3], 10), 1429 parseInt(test[2], 10) - 1, 1430 parseInt(test[1], 10) + day_offset 1431 ) 1432 : false; 1433 break; 1434 case "d/m/y": 1435 case "dd/mm/yy": 1436 case "dd/mm/yyyy": 1437 test = 1438 /^0?([1-2]?[0-9]|3[0-1])\/0?([1-9]|1[0-2])\/(19|20[\d]{2})$/.exec( 1439 data 1440 ); 1441 date_calc = test 1442 ? new Date( 1443 parseInt(test[3], 10), 1444 parseInt(test[2], 10) - 1, 1445 parseInt(test[1], 10) + day_offset 1446 ) 1447 : false; 1448 break; 1449 case "iso": 1450 case "ymd": 1451 case "yyyy-mm-dd": 1452 test = 1453 /^(19|20[\d]{2})\-0?([1-9]|1[0-2])\-0?([1-2]?[0-9]|3[0-1])$/.exec( 1454 data 1455 ); 1456 date_calc = test 1457 ? new Date( 1458 parseInt(test[1], 10), 1459 parseInt(test[2], 10) - 1, 1460 parseInt(test[3], 10) + day_offset 1461 ) 1462 : false;
1463 break; 1464 case "Date": 1465 date_calc = 1466 data.getMonth !== undefined 1467 ? new Date( 1468 data.getFullYear(), 1469 data.getMonth(), 1470 data.getDate() + day_offset 1471 ) 1472 : false; 1473 break; 1474 default: 1475 date_calc = false; 1476 break; 1477 } 1478 if (date_calc === false) { 1479 return false; 1480 } 1481 date_calc = min_today && date_calc < today ? new Date() : date_calc; 1482 switch (format_out) { 1483 case "Date": 1484 return date_calc; 1485 case "array": 1486 return [ 1487 date_calc.getFullYear(), 1488 date_calc.getMonth(), 1489 date_calc.getDate(), 1490 ]; 1491 case "dmy": 1492 case "d.m.y": 1493 case "dd.mm.yy": 1494 case "dd.mm.yyyy": 1495 return ( 1496 me.left_pad(date_calc.getDate()) + 1497 "." + 1498 me.left_pad(date_calc.getMonth() + 1) + 1499 "." + 1500 date_calc.getFullYear() 1501 ); 1502 case "d/m/y": 1503 case "dd/mm/yy": 1504 case "dd/mm/yyyy": 1505 return ( 1506 me.left_pad(date_calc.getDate()) + 1507 "/" + 1508 me.left_pad(date_calc.getMonth() + 1) + 1509 "/" + 1510 date_calc.getFullYear() 1511 ); 1512 case "iso": 1513 case "ymd": 1514 case "yyyy-mm-dd": 1515 return ( 1516 date_calc.getFullYear() + 1517 "-" + 1518 me.left_pad(date_calc.getMonth() + 1) + 1519 "-" + 1520 me.left_pad(date_calc.getDate()) 1521 ); 1522 } 1523 return false; 1524 }; 1525 1526 me.cal_avail = function (date) { 1527 var avail_tf = window["calendar_avail_tf"] || [], 1528 len = avail_tf.length, 1529 avail = true, 1530 i = 0; 1531 if (len > 0) { 1532 avail = false; 1533 while (!avail && i < len) { 1534 avail = 1535 avail || 1536 (date >= me.date_convert(avail_tf[i][0], "ymd", "Date") && 1537 date <= me.date_convert(avail_tf[i][1], "ymd", "Date")); 1538 i++; 1539 } 1540 } 1541 return [avail, ""]; 1542 }; 1543 1544 me.setup(); 1545 1546 if (window["nst_manual_init"] !== true) { 1547 me.init(); 1548 } 1549}; 1550 1551jQuery(responsive($));
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.