$(document).ready(function () { var isMobile = false; //initiate as false // device detection if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|ipad|iris|kindle|Android|Silk|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(navigator.userAgent.substr(0, 4))) isMobile = true; $(window).scroll(function () { var viewport = $(window).height(); var totalHeight = $(document).height(); var currentHeight = $(window).scrollTop(); var footerHeight = $('.footer').height(); var targetHeight = totalHeight - viewport - footerHeight + 100; if (currentHeight <= targetHeight) { $('.floatingTools') .addClass('floatingTools__in') .removeClass('floatingTools__out hidden'); } else { $('.floatingTools') .addClass('floatingTools__out') .removeClass('floatingTools__in'); } }); // show social button $('.floatingTools__share > a').click(function (e) { socialToolsShowHide($(this)); }); // print contentfloatingTools__share__social $('.floatingTools__print').click(function () { printContent(); }); $(document).on('keydown', ".floatingTools__share > a", function (e) { if (e.keyCode == 13) { socialToolsShowHide($(this)); } }); $(document).on('keydown', ".floatingTools__share__social__item:first a", function (e) { if (e.keyCode == 9) { if (e.shiftKey) { socialToolsHide(); } else { } } }); $(document).on('keydown', ".floatingTools__share__social__item:last a", function (e) { if (e.keyCode == 9) { if (e.shiftKey) { } else { socialToolsHide(); } } }); // show hide function function socialToolsShowHide($this) { if ($this.closest('.floatingTools').find('ul').hasClass('displayBlock')) { $this.closest('.floatingTools').find('ul').removeClass('displayBlock'); } else { $this.closest('.floatingTools').find('ul').addClass('displayBlock'); } } function socialToolsHide() { $('.floatingTools').find('ul').removeClass('displayBlock'); } function printContent() { window.print(); } function closeFloatingTools() { $('.floatingTools__inner, .floatingTools__share__social').removeClass('displayBlock'); $('.floatingTools__item a').blur(); } function setSocialMediaLink() { var currentPageUrl = window.location.href; var emailSubject = $('.floatingTools .icon-mail-icon').parents('.floatingTools__share__social__item').find('a').attr('data-subject'); var emailBody = $('.floatingTools .icon-mail-icon').parents('.floatingTools__share__social__item').find('a').attr('data-body'); if ($('.floatingTools').length > 0) { $('.floatingTools .icon-linkdin-icon').parents('.floatingTools__share__social__item').find('a').attr('href', 'https://www.linkedin.com/cws/share?url=' + currentPageUrl); $('.floatingTools .icon-facebook-icon').parents('.floatingTools__share__social__item').find('a').attr('href', 'https://www.facebook.com/sharer/sharer.php?u=' + currentPageUrl); $('.floatingTools .icon-wechat-icon').parents('.floatingTools__share__social__item').find('a').attr('href', currentPageUrl); $('.floatingTools .icon-mail-icon').parents('.floatingTools__share__social__item').find('a').attr('href', 'mailto:?subject=' + emailSubject + '&body=' + emailBody + currentPageUrl); } } $(function () { setSocialMediaLink(); if (isMobile) { $('.floatingTools__print').css('display', 'none !important'); } $(document).bind('touchstart click', function (e) { var floatingTools = $(".floatingTools"); if (!floatingTools.is(e.target) && floatingTools.has(e.target).length === 0) { closeFloatingTools(); } }); setWechat(); function setWechat() { $(document).find('.floatingTools__share__social__item .icon-wechat-icon').parents('.floatingTools__share__social__item').find('a').click(function (e) { openWechatLightbox(e, $(this), $(this).attr('href')); }); $(document).on('keydown', ".floatingTools__share__social__item .icon-wechat-icon", function (e) { if (e.keyCode == 13) { openWechatLightbox(e, $(this).parents('.floatingTools__share__social__item').find('a'), $(this).parents('.floatingTools__share__social__item').find('a').attr('href')); } }); $(document).on('wechatlightbox-closed', function () { $('.floatingTools__item a:first').focus(); }); } }); $('.footer__top__icons .icon-wechat-icon').parent('a').on('click keydown', function (e) { if (e.type == 'click' || (e.type == 'keydown' && e.keyCode == 13)) { openWechatLightbox(e, $(this), $(this).attr('href'), true); } }); var captchaAudioUrl = apiDomain + '/contactus/captcha-audio'; var captchaImageUrl = apiDomain + '/contactus/captcha-image'; $(document).ready(function () { setMobileAppLayout(); setVoiceOver(); setEmailLinkClick(); setBestBrowserView(); // tabindex for mobile menu close button $('.headerMobile__close').attr('tabindex', 0); addSelectedToLangDropdown(); function setCookie(name, value, days) { var expires = ""; if (days) { var date = new Date(); date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); expires = "; expires=" + date.toUTCString(); } document.cookie = name + "=" + (value || "") + expires + "; path=/"; } function getCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for (var i = 0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0) == ' ') c = c.substring(1, c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length); } return null; } function eraseCookie(name) { document.cookie = name + '=; Max-Age=-99999999;'; } // Geo location check var geoLocationApi = apiDomain + "/api/locate"; if (typeof getCookie('askGeolocation') == 'undefined' || getCookie('askGeolocation') == null) { if (getCookie('askGeolocation') != 'yes') { // if no cookie, means that need to ask client to change language showLocate(geoLocationApi); } } else { } $('.geo-location .close, .geo-location .link').attr('tabindex', 0); function showLocate(locate) { $.ajax({ url: locate }).done(function (data) { var location = data.code; if ((location == 'JP' && $('html').attr('lang') != 'ja') || (location == 'FR' && $('html').attr('lang') != 'fr')) { $('.geo-location .inner-wrap .text').text($('.geo-location .inner-wrap .text').attr('data-' + location)); if (location == 'JP') { var jaPath = $('.toggle-ja').attr('href'); $('.geo-location .inner-wrap .link').attr('href', jaPath); } if (location == 'FR') { var frPath = $('.toggle-fr').attr('href'); $('.geo-location .inner-wrap .link').attr('href', frPath); } $('.geo-location').fadeIn(function () { setHeaderPosition(); }); } }); } $(document).on('keydown', ".geo-location .close", function (e) { if (e.keyCode == 13) { geolocationCloseClick(); } }); $('.geo-location .close').click(function () { geolocationCloseClick(); }); $('.geo-location a.link').click(function (e) { geolocationLinkClick(e, $(this)); }); $(document).on('keydown', ".geo-location a.link", function (e) { if (e.keyCode == 13) { geolocationLinkClick(e, $(this)); } }); function geolocationLinkClick(e, $this) { e.preventDefault(); setCookie('askGeolocation', 'yes', 7); window.location.href = $(this).attr('href'); } function geolocationCloseClick() { setCookie('askGeolocation', 'yes', 7); $('.geo-location').fadeOut(function () { setHeaderPosition(); $('.headerTop__menu:first-child').focus(); }); } // close header menu if hover outside menu $("#content").mousemove(function () { $('.headerMenu').addClass('hidden'); }); function setBestBrowserView() { $('.resolution-suggestion').insertAfter($('.geo-location')); $('.resolution-suggestion .close').attr('tabindex', 0); // let html = '
The Best Screen Size
'; // $(html).prependTo($('body')); // if (!isMobile) { if (typeof getCookie('showResolutionSuggestion1') == 'undefined' || getCookie('showResolutionSuggestion1') == null) { if (getCookie('showResolutionSuggestion1') != 'yes') { // if no cookie, means that need to ask client to change language $('.resolution-suggestion').addClass('showNotice'); } } else { } $('.resolution-suggestion .close').click(function () { resolutionSuggestionCloseClick(); }); $(document).on('keydown', ".resolution-suggestion .close", function (e) { if (e.keyCode == 13) { resolutionSuggestionCloseClick(); } }); function resolutionSuggestionCloseClick() { setCookie('showResolutionSuggestion1', 'yes', 0.16); $('.resolution-suggestion').fadeOut(function () { setHeaderPosition(); $('.headerTop__menu:first-child').focus(); }); } // } } setCaptcha(); setHeaderPosition(); }); // fix can't back to skip menu if focus on .skipFocusExit $('.skipFocusExit').remove(); // focus menu enter and exit $('.headerFocus').on('focusin', function () { $('.headerFocus').addClass('show'); }); $('.headerFocus').on('focusout', function () { $('.headerFocus').removeClass('show'); $('.headerTop').focus(); }); // focus and scroll to navigation contnet $(document).on('keydown', ".headerFocus__menu", function (e) { if (e.keyCode == 13) { e.preventDefault(); var ele = void 0; if ($(this).index() == 1) { // focus on content ele = $('#content').find('a, [tabindex="0"]').eq(0); } else if ($(this).index() == 2) { // focus on navigation ele = $('.headerTop a:first'); } else if ($(this).index() == 3) { // focus on footer ele = $('.footer__top a:first'); } ele.focus(); // setTimeout(function(){ // ele.scrollIntoView(); // },1000) } }); // wechat popup $('.headerTop__social__item .icon-wechat-icon').parent('a').on('click keydown', function (e) { if (e.type == 'click' || (e.type == 'keydown' && e.keyCode == 13)) { openWechatLightbox(e, $(this), $(this).attr('href'), true); } }); // hide main menu when top menu is focused $('.headerTop').hover(function () { $('.headerMenu__section').addClass('hidden'); }); // hidden dropdown for the top menu buttons, lanauge, size and search $('.headerTop__button').click(function () { headerToButtonClick($(this)); }); $('.headerTop__button').keydown(function (e) { if (e.keyCode == 13) { headerToButtonClick($(this)); } }); // bind keyboard on search input $(document).on('keydown', '.headerTop__section:eq(0) .headerTop__close', function (e) { if (e.keyCode == 9) { if (e.shiftKey) { $('.headerTop__search__input').focus(); return false; } else { } } }); // bind keyboard on lang selector $(document).on('keydown', '.headerTop__section:eq(2) .headerTop__close', function (e) { if (e.keyCode == 9) { if (e.shiftKey) { $('.headerTop__hidden__inner:visible .headerTop__hidden__item:last').focus(); return false; } else { } } }); $(document).on('keydown', '.headerTop__hidden__inner:visible .headerTop__hidden__item:last', function (e) { if (e.keyCode == 9) { if (e.shiftKey) { } else { $('.headerTop__section:eq(2) .headerTop__close').focus(); return false; } } }); function headerToButtonClick($this) { var target = $this.attr('class').replace(/\s+/, ' ').split(' ')[1]; $('.headerTop__close, .headerTop__hidden, .headerTop__hiddenS').addClass('hidden'); $this.closest('.headerTop__section').find('.headerTop__hidden, .headerTop__hiddenS').removeClass('hidden'); $this.closest('.headerTop__section').find('.headerTop__close').removeClass('hidden'); if (target === "headerSearch") { setTimeout(function () { $this.closest('.headerTop__section').find('.headerTop__search__input').focus(); }, 20); } else { setTimeout(function () { $this.closest('.headerTop__section').find('.headerTop__close').focus(); }, 20); } $this.attr('tabindex', -1); } $('.headerTop__end').focus(function () { $(this).closest('.headerTop__section').find('.headerTop__close').focus(); }); // $(document).on('keydown', '.headerTop__search__input', function (e) { // if (e.keyCode == 9) { // if (e.shiftKey) { // $('#content').find('a, [tabindex="0"]').eq(0).focus(); // return false; // } else { // // } // } // }); // close dropdown box $('.headerTop__close').click(function () { headerTopClose($(this)); }); $('.headerTop__close').keydown(function (e) { if (e.keyCode == 13) { headerTopClose($(this)); } }); function headerTopClose($this) { setTimeout(function () { $('.headerTop__hidden, .headerTop__hiddenS').addClass('hidden'); $('.headerTop__close').addClass('hidden'); $this.closest('.headerTop__section').find('.headerTop__button').focus().attr('tabindex', 0); ; }, 50); } // hidden main menu $('.header__menu__item').hover(function () { headerMenuItemOpen($(this)); }); $(document).on('keydown', '.header__menu__item a', function (e) { if (e.keyCode == 9) { if (e.shiftKey) { } else { var headerMenuSection = $(this).parents('.header__menu__item').attr('class').split(' ')[1].substr(0, 6); if ($('.headerMenu').find($('.' + headerMenuSection + '_button')).length > 0) { $('.headerMenu__section:visible .headerMenu__section__text:first a').focus(); return false; } } } }); $('.header__menu__item a').focus(function () { headerMenuItemOpen($(this).parents('.header__menu__item')); // setTimeout(function(){ // // focus to item list // $('.headerMenu .headerMenu__section:visible .headerMenu__section__text a:first').focus(); // }, 10) }); $(document).on('keydown', ".headerMenu__section:visible .headerMenu__section__text:last a", function (e) { if (e.keyCode == 9) { if (e.shiftKey) { } else { var targetItem = $(this).parents('.headerMenu__section').attr('class').split(' ')[1].substr(0, 6); $('.header__menu__item.' + targetItem).next().find('a').focus(); // $('.mobile-menu-trigger a').focus(); return false; } } }); // force last sub item to go next header item $(document).on('keydown', '.headerMenu__section__button', function (e) { if (e.keyCode == 9) { if (e.shiftKey) { } else { var targetItem = $(this).parents('.headerMenu__section').attr('class').split(' ')[1].substr(0, 6); $('.header__menu__item.' + targetItem).next().find('a').focus(); // $('.mobile-menu-trigger a').focus(); return false; } } }); // force first sub item to go prev header item or logo $('.headerMenu .firstFocus').focus(function () { var targetItem = $(this).parents('.headerMenu__section').attr('class').split(' ')[1].substr(0, 6); if ($('.header__menu__item.' + targetItem).prev().find('a').length > 0) { $('.header__menu__item.' + targetItem).prev().find('a').focus(); } else { $('.header__logo a').focus(); $('.headerMenu').addClass('hidden'); } }); function headerMenuItemOpen($this) { var $menuItem = $this.attr('class').replace(/\s+/, ' ').split(' ')[1]; $('.headerMenu').addClass('hidden'); if ($menuItem) { $('.headerMenu__section').addClass('hidden'); var $dropdownItem = '.' + $menuItem + '_button'; $($dropdownItem + ', .headerMenu').removeClass('hidden'); } } // close hidden main menu $('.headerMenu__section').mouseleave(function () { $('.headerMenu__section, .headerMenu').addClass('hidden'); }); // mobile menu expand // add mobile overlay $('
').insertBefore($('#header')); // move mobile menu outside main content $('.headerMobile').insertBefore($('.mainContent')); // set mobile hamburger href to void, prevert from jumping to top when clicking the button $('.header__hamburger').attr('href', 'javascript:void()'); // disable body drag on mobile $('.mobile-overlay').on('touchmove', function (e) { e.preventDefault(); }); $('.headerMobile').wrapInner('
'); $('.header__hamburger').click(function () { $('.mobile-overlay').fadeIn(); $('.headerMobile').removeAttr('style'); setTimeout(function () { $('.headerMobile').removeClass('hidden'); ariaHideDivForMobileMenu(); }, 10); $('body').addClass('mobile-opened'); $('.header__hamburger').on('scroll', function () { var scrollTop = $(this).scrollTop(); if (scrollTop + $(this).innerHeight() >= this.scrollHeight) { alert('end'); } else if (scrollTop <= 0) { alert('top'); } else { $('#message').text(''); } }); bindHeaderMobileTouchMove(); $(window).on('resize', function () { bindHeaderMobileTouchMove(); // }); function bindHeaderMobileTouchMove() { if ($(window).height() > 500) { $('.headerMobile').bind('touchmove', function (e) { e.preventDefault(); }); } else { $('.headerMobile').unbind('touchmove'); } } //if(isKeyboardUser){ // focus on first item setTimeout(function () { $('.headerMobile__options__item:first').focus(); }, 10); // } else { // $('.headerMobile__options').focus(); // } }); // set aria hidden on other div function ariaHideDivForMobileMenu() { $('.header, .mainContent').attr('aria-hidden', 'true'); $('.headerMobile').removeAttr('aria-hidden'); } function ariaShowDivForMobileMenu() { $('.header, .mainContent, .headerMobile').removeAttr('aria-hidden'); $('.headerMobile').attr('aria-hidden', 'true'); } // set tab event on mobile menu $('.headerMobile__menu__sub:last').keydown(function (e) { if (e.keyCode == 9) { if (e.shiftKey) { } else { $('.headerMobile__options__item:first').focus(); return false; } } }); $('.headerMobile__options__item:first').keydown(function (e) { if (e.keyCode == 9) { if (e.shiftKey) { $('.headerMobile__menu__sub:last').focus(); return false; } else { } } }); var $mobileTarget; // mobile menu select options $('.headerMobile__options__item').click(function () { headerMobile__options__itemClick($(this)); }); $('.headerMobile__options__item').keydown(function (e) { if (e.keyCode == 13) { headerMobile__options__itemClick($(this)); } }); function headerMobile__options__itemClick($this) { $mobileTarget = $this.attr('class').replace(/\s+/, ' ').split(' ')[1]; $mobileTarget = $mobileTarget.replace(/\s+/, ' ').split('__')[1]; $('.headerMobile__hidden__section').addClass('hidden'); $('.hm__' + $mobileTarget).removeClass('hidden'); $('.headerMobile__hidden').removeClass('hidden'); if (isKeyboardUser) { if ($mobileTarget === 'search') { $('.hm__' + $mobileTarget + ' input:first').focus(); } else { $('.hm__' + $mobileTarget + ' a:first').focus(); } } } $('.headerMobile__end').focus(function () { $('.headerMobile__hidden').addClass('hidden'); $('.headerMobile__close').focus(); }); $('.headerMobile__hidden__end').focus(function () { $('.hmb__' + $mobileTarget).focus(); }); // mobile menu close $('.headerMobile__close, .mobile-overlay').click(function () { closeMobileMenu(); }); $('.headerMobile__close').keydown(function (e) { if (e.keyCode == 13) { closeMobileMenu(); } }); function closeMobileMenu() { $('.headerMobile').addClass('hidden'); $('body').removeClass('mobile-opened'); //$('.header__hamburger').focus(); $('.headerMobile__hidden').addClass('hidden'); setTimeout(function () { $('.headerMobile').hide(0); }, 800); $('.mobile-overlay').fadeOut(function () { $('.header__hamburger').focus(); }); ariaShowDivForMobileMenu(); } // accessbility mobile menu $('.mobileMenuEnd').focus(function () { $('.headerMobile__options a:first').focus(); }); $('.headerMobileSearch').click(function () { var $searchQuery = $('.headerMobile__search__input').val(); if ($searchQuery) { window.location.href = '/search.html?searchField=' + $searchQuery; } }); // set font size $('.font__size__item').click(function () { if ($(this).hasClass('sizeN')) { $('html').removeClass('size-medium size-large'); } else if ($(this).hasClass('sizeM')) { $('html').removeClass('size-large').addClass('size-medium'); } else if ($(this).hasClass('sizeL')) { $('html').removeClass('size-medium').addClass('size-large'); } }); // Accesible dropdowns // if($('.custom-dropdown').length > 0){ // accessiblePullDown($('.custom-dropdown')); // } function addSelectedToLangDropdown() { var currentLang = $('html').attr('lang'); $('.headerTop__hidden').find('.toggle-' + currentLang).addClass('selected'); } function setVoiceOver() { setHeaderAccessibility(); $(window).on('resize', function () { setHeaderAccessibility(); }); function setHeaderAccessibility() { var objs = $('.headerTop, .headerMenu, .headerMobile'); if ($(window).width() < 1200) { objs.attr('aria-hidden', 'true'); } else { objs.removeAttr('aria-hidden'); } } } function setEmailLinkClick() { $('.email-link').click(function (e) { e.preventDefault(); window.location.href = "mailto:" + $(this).attr('data-e1') + "@" + $(this).attr('data-e2') + "?subject=" + $(this).attr('data-subject'); }); } function setCaptcha() { getCaptchaImage(captchaImageUrl); var captchaObj; var captchaAudioContainer = $('
'); captchaAudioContainer.appendTo($('body')); $('.captcha-tools .speaker, .captcha-tools .refresh').attr('tabindex', 0); // reset captcha $(document).find('.captcha-tools .refresh').click(function (e) { getCaptchaImage(captchaImageUrl); }); $(document).on('keydown', ".captcha-tools .refresh", function (e) { if (e.keyCode == 13) { getCaptchaImage(captchaImageUrl); } }); // open audio $(document).find('.captcha-tools .speaker').click(function (e) { openCaptchaAudioLightbox(e, $(this)); }); $(document).on('keydown', ".captcha-tools .speaker", function (e) { if (e.keyCode == 13) { openCaptchaAudioLightbox(e, $(this)); } }); // close audio $(document).on('click', '.captcha-lightbox .close', function () { closeCaptchaAudioLightbox(); }); $(document).on('keydown', ".captcha-lightbox .close", function (e) { if (e.keyCode == 13) { closeCaptchaAudioLightbox(); } if (e.keyCode == 9) { if (e.shiftKey) { return false; } else { // $('.html5-video-player a').focus(); // return false; } } }); function refreshCaptcha() { } function openCaptchaAudioLightbox(e, $this) { captchaObj = $this; e.preventDefault(); var newDate = new Date(); var d = newDate.getTime(); var audioLink = captchaAudioUrl + '?d=' + d; $('.captcha-lightbox').find('audio').attr('src', audioLink); $('html, body').css('overflow', 'hidden'); $('.captcha-lightbox').fadeIn(function () { $('.captcha-lightbox .close').focus(); }); } function closeCaptchaAudioLightbox() { $('html, body').removeAttr('style'); $('.captcha-lightbox').fadeOut(function () { captchaObj.focus(); }); } function getCaptchaImage(url) { $.ajax({ dataType: 'text/plain', url: url, crossDomain: true, xhrFields: { withCredentials: true }, success: function (data) { } }).always(function (data) { $('.captcha_img').attr('src', data.responseText.replace(/\\/g, '').replace(/\"/g, "")); }); } } function setHeaderPosition() { function setHeaderBufferTop() { var headerBufferTop = 0; if ($('body').hasClass('admin-menu')) { headerBufferTop += $('#admin-menu').outerHeight(); } if ($('.geo-location').is(':visible')) { headerBufferTop += $('.geo-location').outerHeight(); if ($('.resolution-suggestion').is(':visible')) { $('.resolution-suggestion').css('top', $('.geo-location').outerHeight()); } } else { $('.resolution-suggestion').css('top', 0); } // if ($(window).width() >= 800) { if ($('.resolution-suggestion').is(':visible')) { headerBufferTop += $('.resolution-suggestion').outerHeight(); } // } $('#header, .headerFocus').css('top', headerBufferTop + 'px'); $('.mainContent').css('padding-top', headerBufferTop + 'px'); } setHeaderBufferTop(); $(window).on('resize', function () { setHeaderBufferTop(); }); } function setMobileAppLayout() { var userAgent = navigator.userAgent; if (userAgent.indexOf("InvestHK/") >= 0) { $('body').addClass('isMobileApp'); } else { $('body').addClass('desktop'); } } $(window).resize(function () { if ($(window).width() <= 1100) { $('.footer__sitemap__section').not('.footer__sitemap__section__active').find('a').attr('tabindex', -1); $('.footer__sitemap__section.footer__sitemap__section__active').find('a').attr('tabindex', 0); $('.footer__sitemap__section').find('button').attr('tabindex', 0); } else { $('.footer__sitemap__container').stop().removeAttr('style'); $('.footer__sitemap__section').removeClass('footer__sitemap__section__active'); $('.footer__sitemap__section').find('a').attr('tabindex', 0); $('.footer__sitemap__section').find('button').attr('tabindex', -1); } }).trigger('resize'); $('.footer__sitemap__section').click(function () { if ($(window).width() <= 1100) { if (!$(this).hasClass('footer__sitemap__section__active')) { resetFooterSection(); $(this).addClass('footer__sitemap__section__active'); $(this).find('.footer__sitemap__container').stop().slideDown(); $('.footer__sitemap__section').find('a').attr('tabindex', 0); } else { resetFooterSection(); } } //$('.footer__sitemap__section').find('.footer__sitemap__arrows').css({'transform' : 'rotate(135deg)'}); //$('.footer__sitemap__section').css({'max-height':'60px'}); //$('.footer__sitemap__section').find('a').attr('tabindex',-1); // $(this).find('.footer__sitemap__arrows').css({'transform' : 'rotate(-45deg)'}); // if(getHeight <= 60){ // $(this).css({'max-height':'1000px'}); // $('body, html').animate({scrollTop: $(this).offset().top},500); // $(this).find('a').attr('tabindex',0); // }else{ // $(this).css({'max-height':'60px'}) // $('.footer__sitemap__section').find('.footer__sitemap__arrows').css({'transform' : 'rotate(135deg)'}); // $(this).find('a').attr('tabindex',-1); // } function resetFooterSection() { //reset all containers $('.footer__sitemap__section').removeClass('footer__sitemap__section__active'); if ($(window).width() <= 1100) { $('.footer__sitemap__container').stop().slideUp(400); $('.footer__sitemap__section').find('a').attr('tabindex', -1); } } }); /// $(function () { // set dropdown if ($('#contactus-country-dropdown').length > 0) { var contactusCountryDropdown = new Menubutton(document.getElementById('contactus-country-dropdown')); contactusCountryDropdown.init(); } // add focus to contactus__submit $('.contactus__submit').attr('tabindex', 0); $('.contactus__submit').on('click', function (e) { contactusFormSubmit(e); }); $(document).on('keydown', "#contactusForm input", function (e) { if (e.keyCode == 13) { contactusFormSubmit(e); } }); }); function contactusFormSubmit(e) { var isError = false; e.preventDefault(); $('.checkbox-with-desc').each(function () { var input = $(this).find('input'); if (input.attr('required') && !input.is(':checked')) { isError = true; $(this).find('.error-msg').show(0); } else { $(this).find('.error-msg').hide(0); } }); var result = checkValidation({ targetForm: "contactusForm" }); if (result && !isError) { // $('.contactus__submit').off(); $('.contactus__message').remove(); var requestPage_1 = apiDomain + '/api/contactus_form?language=' + htmlLang; var formData = $('#contactusForm').serialize(); sendContactusRequest(requestPage_1, formData); $('.contactus__submit').addClass('hidden'); $('
').appendTo($('.contactus__submit').parents('.m-form__section')); } } function sendContactusRequest(requestPage, formData) { // get session token $.ajax({ url: apiDomain + "?q=services/session/session_token", type: "get", crossDomain: true, xhrFields: { withCredentials: true }, dataType: "text", error: function (jqXHR, textStatus, errorThrown) { //alert(errorThrown); }, success: function (token) { var sessionToken = token; $.ajax({ method: "POST", url: requestPage, //dataType : 'jsonp', data: formData, crossDomain: true, xhrFields: { withCredentials: true }, headers: { 'X-CSRF-Token': sessionToken } // beforeSend: function (request) { // request.setRequestHeader("X-CSRF-Token", sessionToken); // }, }).done(function (data) { if (data.is_sent == 'success') { window.location.href = data.link + '?from=contactUs'; } else if (data.is_sent == 'fail') { $('.contactus__submit').removeClass('hidden'); $('.loader').remove(); var errorMsg_1 = ''; $.each(data.message, function (index, item) { if (index == 0) { errorMsg_1 += item; } else { errorMsg_1 = errorMsg_1 + '
' + item; } }); $('
' + errorMsg_1 + '
').insertAfter($('#contactusForm')); $('.contactus__message').fadeIn(); } }); } }); } // not allow number for input $(document).on('keydown', '#m-lastName, #m-firstName', function (e) { if ((e.keyCode >= 48 && e.keyCode <= 57) || (e.keyCode >= 96 && e.keyCode <= 105)) { return false; } }); /// var requestPage = apiDomain + '/api/request_form?language=' + htmlLang; var sessionToken; $(function () { // set dropdown if ($('#request-dropdown').length > 0) { var requestDropdown = new Menubutton(document.getElementById('request-dropdown')); requestDropdown.init(); } // add focus to request__submit $('.request__submit').attr('tabindex', 0); var formData; $('.request__submit').on('click', function (e) { requestFormSubmit(e); }); $(document).on('keydown', "#requestForm input", function (e) { if (e.keyCode == 13) { requestFormSubmit(e); } }); }); function requestFormSubmit(e) { var isError = false; e.preventDefault(); $('.checkbox-with-desc').each(function () { var input = $(this).find('input'); if (input.attr('required') && !input.is(':checked')) { isError = true; $(this).find('.error-msg').show(0); } else { $(this).find('.error-msg').hide(0); } }); var result = checkValidation({ targetForm: "requestForm" }); if (result && !isError) { // $('.request__submit').off(); $('.request__message').remove(); formData = $('#requestForm').serialize(); sendRequest(requestPage, formData); $('.request__submit').addClass('hidden'); $('
').appendTo($('.request__submit').parents('.m-form__section')); } } function sendRequest(requestPage, formData) { // get session token $.ajax({ url: apiDomain + "?q=services/session/session_token", type: "get", crossDomain: true, xhrFields: { withCredentials: true }, dataType: "text", error: function (jqXHR, textStatus, errorThrown) { //alert(errorThrown); }, success: function (token) { sessionToken = token; $.ajax({ method: "POST", url: requestPage, //dataType : 'jsonp', data: formData, crossDomain: true, xhrFields: { withCredentials: true }, headers: { 'X-CSRF-Token': sessionToken } // beforeSend: function (request) { // request.setRequestHeader("X-CSRF-Token", sessionToken); // }, }).done(function (data) { if (data.is_sent == 'success') { window.location.href = data.link + '?from=stayUpToDate'; } else if (data.is_sent == 'fail') { $('.request__submit').removeClass('hidden'); $('.loader').remove(); var errorMsg_1 = ''; $.each(data.message, function (index, item) { if (index == 0) { errorMsg_1 += item; } else { errorMsg_1 = errorMsg_1 + '
' + item; } }); $('
' + errorMsg_1 + '
').insertAfter($('#requestForm')); $('.request__message').fadeIn(); } }); } }); } // not allow number for input $(document).on('keydown', '#m-name', function (e) { if ((e.keyCode >= 48 && e.keyCode <= 57) || (e.keyCode >= 96 && e.keyCode <= 105)) { return false; } }); }); //open and close right menu $(function () { closeStickyRight(); $('.stickyRightButton').click(function (e) { isKeyboardUser = false; stickyRightButtonCLick(e, $(this)); }); $('.stickyRightButton').keydown(function (e) { if (e.keyCode == 13) { isKeyboardUser = true; stickyRightButtonCLick(e, $(this)); } }); function stickyRightButtonCLick(e, $this) { if ($('.sticky__contentRight').is(':visible')) { closeStickyRight(); } else { openStickyRight(e, $this); closeStickyLeft(); } } $('.stickyRightClose').click(function (e) { stickyRightClose(e); }); $('.stickyRightClose').keydown(function (e) { if (e.keyCode == 9) { if (e.shiftKey) { $('.sticky__right__contact a:last').focus(); return false; } else { $('.sticky__right__contact a:first').focus(); return false; } } else if (e.keyCode == 13) { isKeyboardUser = true; stickyRightClose(e); return false; } }); function stickyRightClose(e) { e.preventDefault(); closeStickyRight(); } function closeStickyRight() { $('.sticky__right__arrow').removeClass('opened'); var contentRightHeight = $('.sticky__contentRight').outerHeight(true); $('.sticky__contentRight').animate({ 'bottom': -contentRightHeight + 'px' }); setTimeout(function () { $('.sticky__contentRight').css({ 'display': 'none' }); }, 700); if (isKeyboardUser) { $('.stickyRightButton').focus(); } } function openStickyRight(e, $this) { $this.find('.sticky__right__arrow').addClass('opened'); e.preventDefault(); $('.sticky__contentRight').css({ 'display': 'block' }).animate({ 'bottom': '45px' }); if ($('.sticky__right__contact').find('a').length > 0) { $('.sticky__right__contact').find('a:first').focus(); } else { $('.stickyRightClose').focus(); } } $('.sticky__right__contact a:last').keydown(function (e) { if (e.keyCode == 9) { if (e.shiftKey) { } else { $('.stickyRightClose').focus(); return false; } } }); // set tab index to left button //$('.sticky__left__header').attr('tabindex',0); closeStickyLeft(); // $('.sticky__left__header').click(function(e:any) { // if($(window).width() <= 1330){ // if($('.sticky__innerLeft.mobileContent').is(':visible')){ // closeStickyLeft(); // }else{ // openStickyLeft(e, $(this)); // closeStickyRight(); // } // } // }); function closeStickyLeft() { $('.sticky__left__header').removeClass('opened'); var mobileContentLeftHeight = $('.sticky__innerLeft.mobileContent').outerHeight(true); $('.sticky__innerLeft.mobileContent').animate({ 'bottom': -mobileContentLeftHeight + 'px' }); setTimeout(function () { $('.sticky__innerLeft.mobileContent').css({ 'display': 'none' }); }, 700); if (isKeyboardUser) { $('.sticky__left__header').focus(); } } function openStickyLeft(e, $this) { $this.addClass('opened'); e.preventDefault(); $('.sticky__innerLeft.mobileContent').css({ 'display': 'block' }).animate({ 'bottom': '45px' }); if (isKeyboardUser) { $('.sticky__left__text a:eq(0)').focus(); } } $(document).bind('touchstart click', function (e) { isKeyboardUser = false; var stickyWrap = $(".sticky"); if (!stickyWrap.is(e.target) && stickyWrap.has(e.target).length === 0) { closeStickyLeft(); closeStickyRight(); } }); }); $(function () { $(window).scroll(function () { var viewport = $(window).height(); var scrollViewport = viewport / 2; var totalHeight = $(document).height(); var currentHeight = $(window).scrollTop(); var footerHeight = $('.footer').height(); var targetHeight = totalHeight - viewport; if (currentHeight >= scrollViewport) { $('.to-top') .addClass('to-top__in') .removeClass('to-top__out hidden'); } else { $('.to-top') .addClass('to-top__out') .removeClass('to-top__in'); } }); //add smooth scroll to top $('.to-top').click(function (e) { toTop(e); }); $('.to-top').keydown(function (e) { if (e.keyCode == 13) { toTop(e); } }); function toTop(e) { e.preventDefault(); var type = e.type; $('html, body').animate({ scrollTop: 0 }, 500, function () { if (type == 'keydown') { $('.headerFocus a:first').focus(); } else { $('.headerTop a:first').focus(); } }); } $(document).bind('touchstart click', function (e) { var toTop = $(".to-top"); if (!toTop.is(e.target) && toTop.has(e.target).length === 0) { toTopNoFocus(); } }); }); function toTopNoFocus() { $('.to-top').blur(); } ; var wechatClickObj; $(function () { var isMobile = false; //initiate as false // device detection if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|ipad|iris|kindle|Android|Silk|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(navigator.userAgent.substr(0, 4))) isMobile = true; if (isMobile) { $('.wechat-lightbox .mobile').css('display', 'block'); $('.wechat-lightbox .desktop').css('display', 'none'); } $(document).on('click', ".wechat-lightbox input", function (e) { $(this)[0].setSelectionRange(0, 9999); }); $(document).on('click', '.wechat-lightbox .close', function () { closeWechatLightbox(); }); $(document).on('keydown', ".wechat-lightbox .close", function (e) { if (e.keyCode == 13) { closeWechatLightbox(); } if (isMobile) { } else { if (e.keyCode == 9) { if (e.shiftKey) { return false; } else { return false; } } } }); }); function openWechatLightbox(e, $this, link, followMode) { if (followMode === void 0) { followMode = false; } wechatClickObj = $this; e.preventDefault(); if (followMode) { $('.wechat-lightbox h2, .wechat-lightbox .instruction.share, input').css('display', 'none'); } else { $('.wechat-lightbox .instruction.follow').css('display', 'none'); } $('.wechat-lightbox').find('input').val(link); $('.wechat-lightbox').find('.qr-image').attr('src', 'https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=' + link); $('html, body').css('overflow', 'hidden'); $('.wechat-lightbox').fadeIn(function () { $('.wechat-lightbox .close').focus(); }); } function closeWechatLightbox() { $('html, body').removeAttr('style'); $('.wechat-lightbox').fadeOut(function () { $('.wechat-lightbox h2, .wechat-lightbox .instruction, input').css('display', ''); $('.wechat-lightbox').find('.qr-image').attr('src', ''); if (wechatClickObj) { wechatClickObj.focus(); } wechatClickObj = null; $(document).trigger('wechatlightbox-closed'); }); } ;