///
///
$(document).ready(function () {
loadCards({
cardsToDisplay: 6,
cardClass: 'settingUpOtherInformationCard',
loadMoreButtonClass: 'industries__more'
});
loadRelated(apiDomain + '/api/related-cards?type=setting-up-hong-kong&language=' + htmlLang, 'related__cards');
cssObjectFit($('.setting-up-card__image'));
setSettingUpCardHeight();
setSettingUpHKStepTitle();
function setSettingUpHKStepTitle() {
$('.step-by-step__box__item').each(function () {
$(this).find('a').attr('aria-label', $(this).find('h3').text());
});
}
function setSettingUpCardHeight() {
var obj = $('.setting-up-card');
function setHeight(obj) {
var extraHeight = 160;
var titleMaxHeight = 0;
var ulMaxHeight = 0;
if ($(window).width() > 580) {
obj.find('ul').each(function (index, item) {
var h = $(this).outerHeight();
ulMaxHeight = h > ulMaxHeight ? h : ulMaxHeight;
ulMaxHeight = Math.ceil(ulMaxHeight);
});
obj.find('.title').each(function (index, item) {
var h = $(this).outerHeight();
titleMaxHeight = h > titleMaxHeight ? h : titleMaxHeight;
titleMaxHeight = Math.ceil(titleMaxHeight);
});
obj.attr('style', 'height:' + (titleMaxHeight + ulMaxHeight + extraHeight) + 'px');
}
}
function resetHeight(obj) {
obj.removeAttr('style');
}
resetHeight(obj);
setHeight(obj);
$(window).resize(function () {
resetHeight(obj);
if ($(window).width() >= 580) {
setHeight(obj);
}
});
}
setVideo();
function setVideo() {
var geoLocationApi = apiDomain + "/api/locate";
var youtubeLink = $('.setting-up-in-hk__youtube-player').attr('data-youtube');
var youkuLink = $('.setting-up-in-hk__youtube-player').attr('data-youku');
if (youtubeLink == '' && youkuLink == '') {
}
else {
$.ajax({
url: geoLocationApi
}).done(function (data) {
var location = data.code;
var videoLink;
if (location == 'CN') {
videoLink = youkuLink;
}
else {
videoLink = youtubeLink;
}
if (videoLink != '') {
$('.setting-up-in-hk__youtube-player').addClass('hasVideo');
$('.setting-up-in-hk__youtube-player').attr('src', videoLink);
}
});
}
}
});