1
This commit is contained in:
@@ -2,7 +2,7 @@ var isMobile = null;
|
||||
var wasMobile = isMobile;
|
||||
var isMiniHeader = false;
|
||||
|
||||
import $ from 'jquery'
|
||||
// 移除 jQuery 导入,使用原生 JavaScript
|
||||
|
||||
class Common {
|
||||
constructor(name, age) {
|
||||
@@ -10,66 +10,252 @@ class Common {
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
init() {
|
||||
// 封装原生 JavaScript 方法,提高代码复用性
|
||||
add_event_listener(selector, event_type, callback, use_id = false) {
|
||||
const element = use_id ? document.getElementById(selector) : document.querySelector(selector);
|
||||
if (element) {
|
||||
element.addEventListener(event_type, callback);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
toggle_class(selector, class_name, use_id = false) {
|
||||
const element = use_id ? document.getElementById(selector) : document.querySelector(selector);
|
||||
if (element) {
|
||||
element.classList.toggle(class_name);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
add_class(selector, class_name, use_id = false) {
|
||||
const element = use_id ? document.getElementById(selector) : document.querySelector(selector);
|
||||
if (element) {
|
||||
element.classList.add(class_name);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
remove_class(selector, class_name, use_id = false) {
|
||||
const element = use_id ? document.getElementById(selector) : document.querySelector(selector);
|
||||
if (element) {
|
||||
element.classList.remove(class_name);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
show_element(selector, use_id = false) {
|
||||
const element = use_id ? document.getElementById(selector) : document.querySelector(selector);
|
||||
if (element) {
|
||||
element.style.display = 'block';
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
hide_element(selector, use_id = false) {
|
||||
const element = use_id ? document.getElementById(selector) : document.querySelector(selector);
|
||||
if (element) {
|
||||
element.style.display = 'none';
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
get_element_value(selector, use_id = false) {
|
||||
const element = use_id ? document.getElementById(selector) : document.querySelector(selector);
|
||||
return element ? element.value : '';
|
||||
}
|
||||
|
||||
set_element_value(selector, value, use_id = false) {
|
||||
const element = use_id ? document.getElementById(selector) : document.querySelector(selector);
|
||||
if (element) {
|
||||
element.value = value;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// 滚动到页面顶部 - 支持平滑滚动
|
||||
scroll_to_top(behavior = 'smooth') {
|
||||
window.scrollTo({
|
||||
top: 0,
|
||||
left: 0,
|
||||
behavior: behavior
|
||||
});
|
||||
}
|
||||
|
||||
// 滚动到指定元素 - 支持平滑滚动和偏移
|
||||
scroll_to_element(selector, offset = 0, behavior = 'smooth', use_id = false) {
|
||||
const element = use_id ? document.getElementById(selector) : document.querySelector(selector);
|
||||
if (element) {
|
||||
const elementTop = element.offsetTop - offset;
|
||||
window.scrollTo({
|
||||
top: elementTop,
|
||||
left: 0,
|
||||
behavior: behavior
|
||||
});
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// 滚动到指定位置 - 支持平滑滚动
|
||||
scroll_to_position(top = 0, left = 0, behavior = 'smooth') {
|
||||
window.scrollTo({
|
||||
top: top,
|
||||
left: left,
|
||||
behavior: behavior
|
||||
});
|
||||
}
|
||||
|
||||
// 获取当前滚动位置
|
||||
get_scroll_position() {
|
||||
return {
|
||||
top: window.pageYOffset || document.documentElement.scrollTop,
|
||||
left: window.pageXOffset || document.documentElement.scrollLeft
|
||||
};
|
||||
}
|
||||
|
||||
// 检查是否在页面顶部
|
||||
is_at_top() {
|
||||
return window.pageYOffset === 0;
|
||||
}
|
||||
|
||||
// 检查是否在页面底部
|
||||
is_at_bottom() {
|
||||
return window.innerHeight + window.pageYOffset >= document.documentElement.scrollHeight;
|
||||
}
|
||||
|
||||
// 创建返回顶部按钮
|
||||
create_back_to_top_button() {
|
||||
// 检查是否已存在返回顶部按钮
|
||||
if (document.getElementById('backToTopBtn')) {
|
||||
return;
|
||||
}
|
||||
|
||||
const button = document.createElement('button');
|
||||
button.id = 'backToTopBtn';
|
||||
button.innerHTML = '↑';
|
||||
button.title = '返回顶部';
|
||||
button.className = 'back-to-top-btn';
|
||||
|
||||
// 添加样式
|
||||
button.style.cssText = `
|
||||
position: fixed;
|
||||
bottom: 30px;
|
||||
right: 30px;
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
background: #3498db;
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 50%;
|
||||
font-size: 20px;
|
||||
cursor: pointer;
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
transition: all 0.3s ease;
|
||||
z-index: 1000;
|
||||
box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
|
||||
`;
|
||||
|
||||
// 悬停效果
|
||||
button.addEventListener('mouseenter', () => {
|
||||
button.style.background = '#2980b9';
|
||||
button.style.transform = 'scale(1.1)';
|
||||
});
|
||||
|
||||
button.addEventListener('mouseleave', () => {
|
||||
button.style.background = '#3498db';
|
||||
button.style.transform = 'scale(1)';
|
||||
});
|
||||
|
||||
// 点击事件
|
||||
button.addEventListener('click', () => {
|
||||
this.scroll_to_top('smooth');
|
||||
});
|
||||
|
||||
// 添加到页面
|
||||
document.body.appendChild(button);
|
||||
|
||||
// 监听滚动事件,控制按钮显示/隐藏
|
||||
window.addEventListener('scroll', () => {
|
||||
if (window.pageYOffset > 300) {
|
||||
button.style.opacity = '1';
|
||||
button.style.visibility = 'visible';
|
||||
} else {
|
||||
button.style.opacity = '0';
|
||||
button.style.visibility = 'hidden';
|
||||
}
|
||||
});
|
||||
|
||||
return button;
|
||||
}
|
||||
|
||||
init() {
|
||||
var self = this;
|
||||
|
||||
isMobile = common.isMobile();
|
||||
|
||||
//create trigger to resizeEnd event, called after event is finished
|
||||
$(window).resize(function() {
|
||||
if (this.resizeTO) clearTimeout(this.resizeTO);
|
||||
this.resizeTO = setTimeout(function() {
|
||||
$(this).trigger('resizeEnd');
|
||||
// 创建 resizeEnd 事件触发器,在事件完成后调用
|
||||
let resizeTO;
|
||||
window.addEventListener('resize', function() {
|
||||
if (resizeTO) clearTimeout(resizeTO);
|
||||
resizeTO = setTimeout(function() {
|
||||
// 触发自定义 resizeEnd 事件
|
||||
window.dispatchEvent(new CustomEvent('resizeEnd'));
|
||||
}, 100);
|
||||
});
|
||||
|
||||
//cdetermine scren type and call style functions after window resize is completed
|
||||
$(window).on('resizeEnd', function() {
|
||||
|
||||
// 确定屏幕类型并在窗口调整大小完成后调用样式函数
|
||||
window.addEventListener('resizeEnd', function() {
|
||||
self.adjustElementsForScreen();
|
||||
|
||||
});
|
||||
|
||||
$(window).scroll(function() {
|
||||
if ($(window).scrollTop() > 200) {
|
||||
// 创建返回顶部按钮
|
||||
this.create_back_to_top_button();
|
||||
|
||||
window.addEventListener('scroll', function() {
|
||||
if (window.pageYOffset > 200) {
|
||||
if (isMiniHeader === false && !self.isMobile()) {
|
||||
$('.header').addClass('mini');
|
||||
common.add_class('.header', 'mini');
|
||||
isMiniHeader = true;
|
||||
}
|
||||
} else {
|
||||
if (isMiniHeader === true) {
|
||||
$('.header').removeClass('mini');
|
||||
common.remove_class('.header', 'mini');
|
||||
isMiniHeader = false;
|
||||
}
|
||||
|
||||
}
|
||||
//var scroll = $(window).scrollTop();
|
||||
});
|
||||
|
||||
|
||||
|
||||
$.scrollToElement = function($element) {
|
||||
|
||||
var adjustment = 0;
|
||||
if (isMiniHeader) {
|
||||
adjustment = 35;
|
||||
// 滚动到元素的原生实现
|
||||
this.scrollToElement = function(selector) {
|
||||
const element = document.querySelector(selector);
|
||||
if (element) {
|
||||
const adjustment = isMiniHeader ? 35 : 0;
|
||||
const header = document.querySelector('.header:first-child');
|
||||
const headerHeight = header ? header.offsetHeight : 0;
|
||||
const targetPosition = element.offsetTop - headerHeight - adjustment;
|
||||
|
||||
window.scrollTo({
|
||||
top: targetPosition,
|
||||
behavior: 'smooth'
|
||||
});
|
||||
}
|
||||
var $header = $('.header:first');
|
||||
$('html,body').animate({ scrollTop: $element.offset().top - ($header.length > 0 ? $header.height() : 0) - adjustment }, 'slow');
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
adjustElementsForScreen() {
|
||||
|
||||
isMobile = this.isMobile();
|
||||
|
||||
if (!this.isMobile()) {
|
||||
$(".mobileContent").hide();
|
||||
const mobileContents = document.querySelectorAll(".mobileContent");
|
||||
mobileContents.forEach(content => content.style.display = 'none');
|
||||
}
|
||||
|
||||
if (isMobile) wasMobile = true;
|
||||
@@ -77,293 +263,404 @@ class Common {
|
||||
if (wasMobile && !isMobile) location.reload();
|
||||
|
||||
if (isMobile && isMiniHeader === true) {
|
||||
$('.header').removeClass('mini');
|
||||
common.remove_class('.header', 'mini');
|
||||
isMiniHeader = false;
|
||||
}
|
||||
|
||||
|
||||
this.adjustContentBannersForScreen();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
initHeader() {
|
||||
|
||||
//go to main page if not there on logo click
|
||||
$(".logoCell .logo").on("click", function() {
|
||||
// 点击 logo 返回主页
|
||||
this.add_event_listener(".logoCell .logo", "click", function() {
|
||||
if (window.location.href.indexOf("index") === -1) {
|
||||
window.location.href = "#/index";
|
||||
}
|
||||
});
|
||||
|
||||
//show/hide main menu dropdowns on hover
|
||||
$(".mainMenu > tbody > tr > td")
|
||||
.on("mouseenter", function(e) {
|
||||
// 显示/隐藏主导航下拉菜单(悬停)
|
||||
const mainMenuItems = document.querySelectorAll(".mainMenu > tbody > tr > td");
|
||||
mainMenuItems.forEach(item => {
|
||||
item.addEventListener("mouseenter", function(e) {
|
||||
e.stopPropagation();
|
||||
$(".dropDown").hide();
|
||||
$("table.mainMenu > tbody > tr > td.selected").css("box-shadow", "none");
|
||||
$(this).find(".dropDown").addClass("droppedDown");
|
||||
$(this).find(".dropDown").slideDown();
|
||||
})
|
||||
.on("mouseleave", function(e) {
|
||||
e.stopPropagation();
|
||||
$(this).find(".dropDown").removeClass("droppedDown");
|
||||
$(this).find(".dropDown").hide();
|
||||
$("table.mainMenu > tbody > tr > td.selected").css("box-shadow", "0 -3px 0 #ff0000 inset");
|
||||
const dropDowns = document.querySelectorAll(".dropDown");
|
||||
dropDowns.forEach(dd => dd.style.display = 'none');
|
||||
|
||||
const selectedItems = document.querySelectorAll("table.mainMenu > tbody > tr > td.selected");
|
||||
selectedItems.forEach(selected => selected.style.boxShadow = 'none');
|
||||
|
||||
const currentDropDown = this.querySelector(".dropDown");
|
||||
if (currentDropDown) {
|
||||
currentDropDown.classList.add("droppedDown");
|
||||
currentDropDown.style.display = 'block';
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
item.addEventListener("mouseleave", function(e) {
|
||||
e.stopPropagation();
|
||||
const currentDropDown = this.querySelector(".dropDown");
|
||||
if (currentDropDown) {
|
||||
currentDropDown.classList.remove("droppedDown");
|
||||
currentDropDown.style.display = 'none';
|
||||
}
|
||||
|
||||
const selectedItems = document.querySelectorAll("table.mainMenu > tbody > tr > td.selected");
|
||||
selectedItems.forEach(selected => selected.style.boxShadow = '0 -3px 0 #ff0000 inset');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
initListeners() {
|
||||
|
||||
$("#hamburger").on("click", function() {
|
||||
|
||||
if ($("#mobileLanguageMenu").hasClass("showing")) {
|
||||
$("#mobileLanguageMenu").hide();
|
||||
$("#mobileLanguageMenu").removeClass("showing");
|
||||
// 汉堡菜单点击事件
|
||||
this.add_event_listener("hamburger", "click", function() {
|
||||
const mobileLanguageMenu = document.getElementById("mobileLanguageMenu");
|
||||
if (mobileLanguageMenu && mobileLanguageMenu.classList.contains("showing")) {
|
||||
common.hide_element("mobileLanguageMenu", true);
|
||||
common.remove_class("mobileLanguageMenu", "showing", true);
|
||||
}
|
||||
|
||||
if ($("#mobileMenu").hasClass("showing")) {
|
||||
const mobileMenu = document.getElementById("mobileMenu");
|
||||
if (mobileMenu && mobileMenu.classList.contains("showing")) {
|
||||
common.hideMobileMenu();
|
||||
} else {
|
||||
common.showMobileMenu();
|
||||
}
|
||||
});
|
||||
}, true);
|
||||
|
||||
$("#mobileLanguage").on("click", function() {
|
||||
|
||||
if ($("#mobileMenu").hasClass("showing")) {
|
||||
$("#mobileMenu").hide();
|
||||
$("#mobileMenu").removeClass("showing");
|
||||
// 移动端语言菜单点击事件
|
||||
this.add_event_listener("mobileLanguage", "click", function() {
|
||||
const mobileMenu = document.getElementById("mobileMenu");
|
||||
if (mobileMenu && mobileMenu.classList.contains("showing")) {
|
||||
common.hide_element("mobileMenu", true);
|
||||
common.remove_class("mobileMenu", "showing", true);
|
||||
}
|
||||
|
||||
if (!$("#mobileLanguageMenu").hasClass("showing")) {
|
||||
const mobileLanguageMenu = document.getElementById("mobileLanguageMenu");
|
||||
if (mobileLanguageMenu && !mobileLanguageMenu.classList.contains("showing")) {
|
||||
common.showMobileLanguageMenu();
|
||||
}
|
||||
}, true);
|
||||
|
||||
});
|
||||
|
||||
|
||||
$("#screenOverlayBehindHeader, .linkGoBack").on("click", function() {
|
||||
if ($("#mobileMenu").hasClass("showing")) {
|
||||
common.hideMobileMenu();
|
||||
// 屏幕覆盖层和返回按钮点击事件
|
||||
const screenOverlay = document.getElementById("screenOverlayBehindHeader");
|
||||
const goBackLinks = document.querySelectorAll(".linkGoBack");
|
||||
|
||||
if (screenOverlay) {
|
||||
screenOverlay.addEventListener("click", function() {
|
||||
const mobileMenu = document.getElementById("mobileMenu");
|
||||
if (mobileMenu && mobileMenu.classList.contains("showing")) {
|
||||
common.hideMobileMenu();
|
||||
}
|
||||
if ($("#mobileLanguageMenu").hasClass("showing")) {
|
||||
common.hideMobileLanguageMenu();
|
||||
const mobileLanguageMenu = document.getElementById("mobileLanguageMenu");
|
||||
if (mobileLanguageMenu && mobileLanguageMenu.classList.contains("showing")) {
|
||||
common.hideMobileLanguageMenu();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
goBackLinks.forEach(link => {
|
||||
link.addEventListener("click", function() {
|
||||
const mobileMenu = document.getElementById("mobileMenu");
|
||||
if (mobileMenu && mobileMenu.classList.contains("showing")) {
|
||||
common.hideMobileMenu();
|
||||
}
|
||||
const mobileLanguageMenu = document.getElementById("mobileLanguageMenu");
|
||||
if (mobileLanguageMenu && mobileLanguageMenu.classList.contains("showing")) {
|
||||
common.hideMobileLanguageMenu();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$("#mobileLanguageMenu a").on("click", function(e) {
|
||||
e.preventDefault();
|
||||
// 移动端语言菜单链接点击事件
|
||||
const mobileLanguageMenuLinks = document.querySelectorAll("#mobileLanguageMenu a");
|
||||
mobileLanguageMenuLinks.forEach(link => {
|
||||
link.addEventListener("click", function(e) {
|
||||
e.preventDefault();
|
||||
});
|
||||
});
|
||||
|
||||
//show support form
|
||||
$("a.linkSupport").on("click", function(e) {
|
||||
e.preventDefault();
|
||||
common.showForm("support");
|
||||
// 显示支持表单
|
||||
const supportLinks = document.querySelectorAll("a.linkSupport");
|
||||
supportLinks.forEach(link => {
|
||||
link.addEventListener("click", function(e) {
|
||||
e.preventDefault();
|
||||
common.showForm("support");
|
||||
});
|
||||
});
|
||||
|
||||
//show contact form
|
||||
$("a.linkContactUs").on("click", function(e) {
|
||||
e.preventDefault();
|
||||
common.showForm("contact");
|
||||
// 显示联系表单
|
||||
const contactLinks = document.querySelectorAll("a.linkContactUs");
|
||||
contactLinks.forEach(link => {
|
||||
link.addEventListener("click", function(e) {
|
||||
e.preventDefault();
|
||||
common.showForm("contact");
|
||||
});
|
||||
});
|
||||
|
||||
$("#scrollToBoxes").on("click", function(e) {
|
||||
e.preventDefault();
|
||||
$.scrollToElement($("#pageBoxesContainer"));
|
||||
// 滚动到盒子容器
|
||||
const scrollToBoxes = document.getElementById("scrollToBoxes");
|
||||
if (scrollToBoxes) {
|
||||
scrollToBoxes.addEventListener("click", function(e) {
|
||||
e.preventDefault();
|
||||
common.scrollToElement("#pageBoxesContainer");
|
||||
});
|
||||
}
|
||||
|
||||
// Cookie 信息按钮点击事件
|
||||
const cookieButtons = document.querySelectorAll('.cookiesInfo input[type="button"]');
|
||||
cookieButtons.forEach(button => {
|
||||
button.addEventListener("click", function() {
|
||||
const parent = this.parentElement;
|
||||
if (parent) {
|
||||
parent.remove();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
$('.cookiesInfo').children('input[type=button]').on('click', function() {
|
||||
$(this).parent().remove();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
initMobileMenu() {
|
||||
$("#mobileMenu label").on("click", function(e) {
|
||||
e.preventDefault();
|
||||
$("#mobileMenu .subMenu").not($(this).siblings()).slideUp();
|
||||
$(".hasSubmenu").not($(this)).css("font-weight", "normal");
|
||||
$(this).css("font-weight", "bold");
|
||||
//$(this).parent().css("border-bottom", "none");
|
||||
$(this).parent().find(".subMenu").slideDown();
|
||||
// 移动端菜单标签点击事件
|
||||
const mobileMenuLabels = document.querySelectorAll("#mobileMenu label");
|
||||
mobileMenuLabels.forEach(label => {
|
||||
label.addEventListener("click", function(e) {
|
||||
e.preventDefault();
|
||||
const subMenus = document.querySelectorAll("#mobileMenu .subMenu");
|
||||
subMenus.forEach(subMenu => {
|
||||
if (subMenu !== this.nextElementSibling) {
|
||||
subMenu.style.display = 'none';
|
||||
}
|
||||
});
|
||||
|
||||
const hasSubmenuElements = document.querySelectorAll(".hasSubmenu");
|
||||
hasSubmenuElements.forEach(element => {
|
||||
if (element !== this) {
|
||||
element.style.fontWeight = "normal";
|
||||
}
|
||||
});
|
||||
|
||||
this.style.fontWeight = "bold";
|
||||
const currentSubMenu = this.parentElement.querySelector(".subMenu");
|
||||
if (currentSubMenu) {
|
||||
currentSubMenu.style.display = 'block';
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$("#mobileMenu a").on("click", function() {
|
||||
common.hideMobileMenu();
|
||||
|
||||
// 移动端菜单链接点击事件
|
||||
const mobileMenuLinks = document.querySelectorAll("#mobileMenu a");
|
||||
mobileMenuLinks.forEach(link => {
|
||||
link.addEventListener("click", function() {
|
||||
common.hideMobileMenu();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
initForms() {
|
||||
|
||||
|
||||
$(".btnQuitForm").on("click", function() {
|
||||
$("#forms").hide();
|
||||
$("#screenOverlay").hide();
|
||||
$("#formContactContainer").hide();
|
||||
$("#formSupportContainer").hide();
|
||||
// 退出表单按钮
|
||||
const quitButtons = document.querySelectorAll(".btnQuitForm");
|
||||
quitButtons.forEach(button => {
|
||||
button.addEventListener("click", function() {
|
||||
common.hide_element("#forms", true);
|
||||
common.hide_element("#screenOverlay", true);
|
||||
common.hide_element("#formContactContainer", true);
|
||||
common.hide_element("#formSupportContainer", true);
|
||||
});
|
||||
});
|
||||
|
||||
$("#formSupport").on("submit", function(e) {
|
||||
e.preventDefault();
|
||||
common.submitSupportForm($(this));
|
||||
});
|
||||
// 支持表单提交
|
||||
const supportForm = document.getElementById("formSupport");
|
||||
if (supportForm) {
|
||||
supportForm.addEventListener("submit", function(e) {
|
||||
e.preventDefault();
|
||||
common.submitSupportForm(this);
|
||||
});
|
||||
}
|
||||
|
||||
$("#formContact").on("submit", function(e) {
|
||||
e.preventDefault();
|
||||
common.submitContactForm($(this));
|
||||
});
|
||||
// 联系表单提交
|
||||
const contactForm = document.getElementById("formContact");
|
||||
if (contactForm) {
|
||||
contactForm.addEventListener("submit", function(e) {
|
||||
e.preventDefault();
|
||||
common.submitContactForm(this);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
showForm(formName) {
|
||||
common.show_element("#forms", true);
|
||||
common.show_element("#screenOverlay", true);
|
||||
|
||||
$("#forms").show();
|
||||
$("#screenOverlay").show();
|
||||
|
||||
$(".contactTable").show();
|
||||
$(".formInputContainer").show();
|
||||
$(".formResultContainer").hide();
|
||||
const contactTable = document.querySelector(".contactTable");
|
||||
const formInputContainer = document.querySelector(".formInputContainer");
|
||||
const formResultContainer = document.querySelector(".formResultContainer");
|
||||
|
||||
if (contactTable) contactTable.style.display = 'table';
|
||||
if (formInputContainer) formInputContainer.style.display = 'block';
|
||||
if (formResultContainer) formResultContainer.style.display = 'none';
|
||||
|
||||
if (formName === "contact") {
|
||||
var $conCommentsTitle = $("label[for='conComments']");
|
||||
|
||||
if ($(".contentTableRight").find("[data-contact-link]").length) {
|
||||
$conCommentsTitle.html("Berätta vad du vill veta mer om gällande " +
|
||||
$(".contentTableRight").find("[data-contact-link]").data("contact-link") + ": *");
|
||||
} else {
|
||||
$conCommentsTitle.html("Vad vill du veta mer om: ");
|
||||
const conCommentsTitle = document.querySelector("label[for='conComments']");
|
||||
if (conCommentsTitle) {
|
||||
const contactLinkElement = document.querySelector(".contentTableRight [data-contact-link]");
|
||||
if (contactLinkElement && contactLinkElement.dataset.contactLink) {
|
||||
conCommentsTitle.innerHTML = "Berätta vad du vill veta mer om gällande " +
|
||||
contactLinkElement.dataset.contactLink + ": *";
|
||||
} else {
|
||||
conCommentsTitle.innerHTML = "Vad vill du veta mer om: ";
|
||||
}
|
||||
}
|
||||
$("#formContactContainer").show();
|
||||
common.show_element("#formContactContainer", true);
|
||||
} else if (formName === "support") {
|
||||
$("#formSupportContainer").show();
|
||||
common.show_element("#formSupportContainer", true);
|
||||
}
|
||||
|
||||
common.scrollToTop();
|
||||
|
||||
}
|
||||
|
||||
|
||||
submitSupportForm() {
|
||||
// 使用原生 fetch API 替代 jQuery.post
|
||||
const formData = {
|
||||
subject: common.get_element_value("#supSubject", true),
|
||||
company: common.get_element_value("#supCompany", true),
|
||||
name: common.get_element_value("#supName", true),
|
||||
email: common.get_element_value("#supEmail", true),
|
||||
phone: common.get_element_value("#supPhone", true),
|
||||
product: common.get_element_value("#supProduct", true),
|
||||
comments: common.get_element_value("#supComments", true)
|
||||
};
|
||||
|
||||
$.post("http://biz199.inmotionhosting.com/~rustyt6/pythagoras/php/submit_support_form.php", {
|
||||
subject: $("#supSubject").val(),
|
||||
company: $("#supCompany").val(),
|
||||
name: $("#supName").val(),
|
||||
email: $("#supEmail").val(),
|
||||
phone: $("#supPhone").val(),
|
||||
product: $("#supProduct").val(),
|
||||
comments: $("#supComments").val()
|
||||
fetch("http://biz199.inmotionhosting.com/~rustyt6/pythagoras/php/submit_support_form.php", {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
function(data) {
|
||||
console.log(data);
|
||||
}
|
||||
);
|
||||
body: JSON.stringify(formData)
|
||||
})
|
||||
.then(response => response.text())
|
||||
.then(data => {
|
||||
console.log(data);
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error:', error);
|
||||
});
|
||||
|
||||
$(".formInputContainer").hide();
|
||||
$(".formResultContainer").show();
|
||||
common.hide_element("#formInputContainer", true);
|
||||
common.show_element("#formResultContainer", true);
|
||||
common.scrollToTop();
|
||||
|
||||
$("#supSubject").val("");
|
||||
$("#supCompany").val("");
|
||||
$("#supName").val("");
|
||||
$("#supEmail").val("");
|
||||
$("#supPhone").val("");
|
||||
$("#supProduct").val("");
|
||||
$("#supComments").val("");
|
||||
// 清空表单
|
||||
common.set_element_value("#supSubject", "", true);
|
||||
common.set_element_value("#supCompany", "", true);
|
||||
common.set_element_value("#supName", "", true);
|
||||
common.set_element_value("#supEmail", "", true);
|
||||
common.set_element_value("#supPhone", "", true);
|
||||
common.set_element_value("#supProduct", "", true);
|
||||
common.set_element_value("#supComments", "", true);
|
||||
}
|
||||
|
||||
|
||||
submitContactForm() {
|
||||
// 使用原生 fetch API 替代 jQuery.post
|
||||
const formData = {
|
||||
name: common.get_element_value("#conName", true),
|
||||
email: common.get_element_value("#conEmail", true),
|
||||
phone: common.get_element_value("#conPhone", true),
|
||||
comments: common.get_element_value("#conComments", true)
|
||||
};
|
||||
|
||||
$.post("http://biz199.inmotionhosting.com/~rustyt6/pythagoras/php/submit_contact_form.php", {
|
||||
name: $("#conName").val(),
|
||||
email: $("#conEmail").val(),
|
||||
phone: $("#conPhone").val(),
|
||||
comments: $("#conComments").val()
|
||||
fetch("http://biz199.inmotionhosting.com/~rustyt6/pythagoras/php/submit_contact_form.php", {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
function(data) {
|
||||
console.log(data);
|
||||
}
|
||||
);
|
||||
body: JSON.stringify(formData)
|
||||
})
|
||||
.then(response => response.text())
|
||||
.then(data => {
|
||||
console.log(data);
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error:', error);
|
||||
});
|
||||
|
||||
$(".contactTable").hide();
|
||||
$(".formResultContainer").show();
|
||||
common.hide_element(".contactTable");
|
||||
common.show_element("#formResultContainer", true);
|
||||
common.scrollToTop();
|
||||
|
||||
$("#conName").val("");
|
||||
$("#conEmail").val("");
|
||||
$("#conPhone").val("");
|
||||
$("#conComments").val("");
|
||||
// 清空表单
|
||||
common.set_element_value("#conName", "", true);
|
||||
common.set_element_value("#conEmail", "", true);
|
||||
common.set_element_value("#conPhone", "", true);
|
||||
common.set_element_value("#conComments", "", true);
|
||||
}
|
||||
|
||||
|
||||
adjustContentBannersForScreen() {
|
||||
|
||||
if (this.isMobile()) {
|
||||
$("#pageBannerImage1").attr("src", "images/banner_page_mobile_solutions_mobile.jpg");
|
||||
$("#pageBannerImage2").attr("src", "images/banner_page_ifrs16_mobile.jpg");
|
||||
$("#pageBannerImage3").attr("src", "images/banner_page_gdpr_mobile.jpg");
|
||||
const banner1 = document.getElementById("pageBannerImage1");
|
||||
const banner2 = document.getElementById("pageBannerImage2");
|
||||
const banner3 = document.getElementById("pageBannerImage3");
|
||||
|
||||
if (banner1) banner1.src = "images/banner_page_mobile_solutions_mobile.jpg";
|
||||
if (banner2) banner2.src = "images/banner_page_ifrs16_mobile.jpg";
|
||||
if (banner3) banner3.src = "images/banner_page_gdpr_mobile.jpg";
|
||||
} else {
|
||||
$("#pageBannerImage1").attr("src", "images/banner_page_mobile_solutions.jpg");
|
||||
$("#pageBannerImage2").attr("src", "images/banner_page_ifrs16.jpg");
|
||||
$("#pageBannerImage3").attr("src", "images/banner_page_gdpr.jpg");
|
||||
const banner1 = document.getElementById("pageBannerImage1");
|
||||
const banner2 = document.getElementById("pageBannerImage2");
|
||||
const banner3 = document.getElementById("pageBannerImage3");
|
||||
|
||||
if (banner1) banner1.src = "images/banner_page_mobile_solutions.jpg";
|
||||
if (banner2) banner2.src = "images/banner_page_ifrs16.jpg";
|
||||
if (banner3) banner3.src = "images/banner_page_gdpr.jpg";
|
||||
}
|
||||
}
|
||||
|
||||
showMobileMenu() {
|
||||
$("#screenOverlayBehindHeader").show();
|
||||
|
||||
$("#mobileMenu").slideDown();
|
||||
$("#mobileMenu").addClass("showing");
|
||||
common.show_element("#screenOverlayBehindHeader", true);
|
||||
const mobileMenu = document.getElementById("mobileMenu");
|
||||
if (mobileMenu) {
|
||||
mobileMenu.style.display = 'block';
|
||||
common.add_class("mobileMenu", "showing", true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
hideMobileMenu() {
|
||||
$("#mobileMenu").slideUp(function() {
|
||||
$("#screenOverlayBehindHeader").hide();
|
||||
});
|
||||
$("#mobileMenu").removeClass("showing");
|
||||
const mobileMenu = document.getElementById("mobileMenu");
|
||||
if (mobileMenu) {
|
||||
mobileMenu.style.display = 'none';
|
||||
common.hide_element("#screenOverlayBehindHeader", true);
|
||||
common.remove_class("mobileMenu", "showing", true);
|
||||
}
|
||||
}
|
||||
|
||||
showMobileLanguageMenu() {
|
||||
$("#screenOverlayBehindHeader").show();
|
||||
|
||||
$("#mobileLanguageMenu").slideDown();
|
||||
$("#mobileLanguageMenu").addClass("showing");
|
||||
common.show_element("#screenOverlayBehindHeader", true);
|
||||
const mobileLanguageMenu = document.getElementById("mobileLanguageMenu");
|
||||
if (mobileLanguageMenu) {
|
||||
mobileLanguageMenu.style.display = 'block';
|
||||
common.add_class("mobileLanguageMenu", "showing", true);
|
||||
}
|
||||
}
|
||||
|
||||
hideMobileLanguageMenu() {
|
||||
$("#mobileLanguageMenu").slideUp(function() {
|
||||
$("#screenOverlayBehindHeader").hide();
|
||||
});
|
||||
$("#mobileLanguageMenu").removeClass("showing");
|
||||
const mobileLanguageMenu = document.getElementById("mobileLanguageMenu");
|
||||
if (mobileLanguageMenu) {
|
||||
mobileLanguageMenu.style.display = 'none';
|
||||
common.hide_element("#screenOverlayBehindHeader", true);
|
||||
common.remove_class("mobileLanguageMenu", "showing", true);
|
||||
}
|
||||
}
|
||||
|
||||
scrollToTop() {
|
||||
$("body,html").animate({ scrollTop: 0 }, "slow");
|
||||
window.scrollTo({
|
||||
top: 0,
|
||||
behavior: 'smooth'
|
||||
});
|
||||
}
|
||||
|
||||
isMobile() {
|
||||
|
||||
var ua = navigator.userAgent;
|
||||
var ipad = ua.match(/(iPad).*OS\s([\d_]+)/),
|
||||
|
||||
isIphone = !ipad && ua.match(/(iPhone\sOS)\s([\d_]+)/),
|
||||
|
||||
isAndroid = ua.match(/(Android)\s+([\d.]+)/),
|
||||
|
||||
isMobile = isIphone || isAndroid;
|
||||
|
||||
return isMobile;
|
||||
@@ -377,5 +674,4 @@ class Common {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const common = new Common();
|
||||
Reference in New Issue
Block a user