397 lines
8.6 KiB
JavaScript
397 lines
8.6 KiB
JavaScript
|
|
var isMobile = null;
|
|
var isPhoneWidth = null;
|
|
var wasMobile = isMobile;
|
|
var wasDesktop = !isMobile;
|
|
|
|
var isMiniHeader = false;
|
|
|
|
var myLocationLat = null;
|
|
var myLocationLong = null;
|
|
|
|
|
|
class Common {
|
|
constructor(name, age) {
|
|
this.name = name;
|
|
this.age = age;
|
|
}
|
|
|
|
init() {
|
|
|
|
var self = this;
|
|
|
|
isMobile = common.isMobile();
|
|
isPhoneWidth = common.isPhone();
|
|
|
|
//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');
|
|
}, 100);
|
|
});
|
|
|
|
//cdetermine scren type and call style functions after window resize is completed
|
|
$(window).on('resizeEnd', function () {
|
|
|
|
self.adjustElementsForScreen();
|
|
|
|
});
|
|
|
|
$(window).scroll(function () {
|
|
if ($(window).scrollTop() > 200) {
|
|
if (isMiniHeader === false && !self.isMobile()) {
|
|
$('.header').addClass('mini');
|
|
isMiniHeader = true;
|
|
}
|
|
} else {
|
|
if (isMiniHeader === true) {
|
|
$('.header').removeClass('mini');
|
|
isMiniHeader = false;
|
|
}
|
|
|
|
}
|
|
//var scroll = $(window).scrollTop();
|
|
});
|
|
|
|
|
|
|
|
$.scrollToElement = function ($element) {
|
|
|
|
var adjustment = 0;
|
|
if (isMiniHeader) {
|
|
adjustment = 35;
|
|
}
|
|
var $header = $('.header:first');
|
|
$('html,body').animate({ scrollTop: $element.offset().top - ($header.length > 0 ? $header.height() : 0) - adjustment }, 'slow');
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
adjustElementsForScreen() {
|
|
|
|
isMobile = this.isMobile();
|
|
isPhoneWidth = this.isPhone();
|
|
|
|
if (!this.isMobile()) {
|
|
$(".mobileContent").hide();
|
|
}
|
|
|
|
if (isMobile) wasMobile = true;
|
|
if (!isMobile) wasDesktop = true;
|
|
|
|
if (wasMobile && !isMobile) location.reload();
|
|
|
|
if (isMobile && isMiniHeader === true) {
|
|
$('.header').removeClass('mini');
|
|
isMiniHeader = false;
|
|
}
|
|
|
|
|
|
this.adjustContentBannersForScreen();
|
|
|
|
}
|
|
|
|
|
|
|
|
initHeader() {
|
|
|
|
//go to main page if not there on logo click
|
|
$(".logoCell .logo").on("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) {
|
|
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");
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
initListeners() {
|
|
|
|
$("#hamburger").on("click", function () {
|
|
|
|
if ($("#mobileLanguageMenu").hasClass("showing")) {
|
|
$("#mobileLanguageMenu").hide();
|
|
$("#mobileLanguageMenu").removeClass("showing");
|
|
}
|
|
|
|
if ($("#mobileMenu").hasClass("showing")) {
|
|
common.hideMobileMenu();
|
|
} else {
|
|
common.showMobileMenu();
|
|
}
|
|
});
|
|
|
|
$("#mobileLanguage").on("click", function (e) {
|
|
|
|
if ($("#mobileMenu").hasClass("showing")) {
|
|
$("#mobileMenu").hide();
|
|
$("#mobileMenu").removeClass("showing");
|
|
}
|
|
|
|
if ($("#mobileLanguageMenu").hasClass("showing")) {
|
|
hideMobileLanguageMenu();
|
|
} else {
|
|
common.showMobileLanguageMenu();
|
|
}
|
|
|
|
});
|
|
|
|
|
|
$("#screenOverlayBehindHeader, .linkGoBack").on("click", function (e) {
|
|
if ($("#mobileMenu").hasClass("showing")) {
|
|
common.hideMobileMenu();
|
|
}
|
|
if ($("#mobileLanguageMenu").hasClass("showing")) {
|
|
common.hideMobileLanguageMenu();
|
|
}
|
|
});
|
|
|
|
$("#mobileLanguageMenu a").on("click", function (e) {
|
|
e.preventDefault();
|
|
});
|
|
|
|
//show support form
|
|
$("a.linkSupport").on("click", function (e) {
|
|
e.preventDefault();
|
|
common.showForm("support");
|
|
});
|
|
|
|
//show contact form
|
|
$("a.linkContactUs").on("click", function (e) {
|
|
e.preventDefault();
|
|
common.showForm("contact");
|
|
});
|
|
|
|
$("#scrollToBoxes").on("click", function (e) {
|
|
e.preventDefault();
|
|
$.scrollToElement($("#pageBoxesContainer"));
|
|
});
|
|
|
|
|
|
$('.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();
|
|
});
|
|
|
|
$("#mobileMenu a").on("click", function (e) {
|
|
common.hideMobileMenu();
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
initForms() {
|
|
|
|
|
|
$(".btnQuitForm").on("click", function () {
|
|
$("#forms").hide();
|
|
$("#screenOverlay").hide();
|
|
$("#formContactContainer").hide();
|
|
$("#formSupportContainer").hide();
|
|
});
|
|
|
|
$("#formSupport").on("submit", function (e) {
|
|
e.preventDefault();
|
|
common.submitSupportForm($(this));
|
|
});
|
|
|
|
$("#formContact").on("submit", function (e) {
|
|
e.preventDefault();
|
|
common.submitContactForm($(this));
|
|
});
|
|
}
|
|
|
|
|
|
showForm(formName) {
|
|
|
|
$("#forms").show();
|
|
$("#screenOverlay").show();
|
|
|
|
$(".contactTable").show();
|
|
$(".formInputContainer").show();
|
|
$(".formResultContainer").hide();
|
|
|
|
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: ");
|
|
}
|
|
$("#formContactContainer").show();
|
|
} else if (formName === "support") {
|
|
$("#formSupportContainer").show();
|
|
}
|
|
|
|
scrollToTop();
|
|
|
|
}
|
|
|
|
|
|
submitSupportForm(form) {
|
|
|
|
$.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()
|
|
},
|
|
function (data) {
|
|
console.log(data);
|
|
}
|
|
);
|
|
|
|
$(".formInputContainer").hide();
|
|
$(".formResultContainer").show();
|
|
scrollToTop();
|
|
|
|
$("#supSubject").val("");
|
|
$("#supCompany").val("");
|
|
$("#supName").val("");
|
|
$("#supEmail").val("");
|
|
$("#supPhone").val("");
|
|
$("#supProduct").val("");
|
|
$("#supComments").val("");
|
|
}
|
|
|
|
|
|
submitContactForm(form) {
|
|
|
|
$.post("http://biz199.inmotionhosting.com/~rustyt6/pythagoras/php/submit_contact_form.php",
|
|
{
|
|
name: $("#conName").val(),
|
|
email: $("#conEmail").val(),
|
|
phone: $("#conPhone").val(),
|
|
comments: $("#conComments").val()
|
|
},
|
|
function (data) {
|
|
console.log(data);
|
|
}
|
|
);
|
|
|
|
$(".contactTable").hide();
|
|
$(".formResultContainer").show();
|
|
scrollToTop();
|
|
|
|
$("#conName").val("");
|
|
$("#conEmail").val("");
|
|
$("#conPhone").val("");
|
|
$("#conComments").val("");
|
|
}
|
|
|
|
|
|
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");
|
|
} 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");
|
|
}
|
|
}
|
|
|
|
showMobileMenu() {
|
|
$("#screenOverlayBehindHeader").show();
|
|
|
|
$("#mobileMenu").slideDown();
|
|
$("#mobileMenu").addClass("showing");
|
|
}
|
|
|
|
|
|
hideMobileMenu() {
|
|
$("#mobileMenu").slideUp(function () {
|
|
$("#screenOverlayBehindHeader").hide();
|
|
});
|
|
$("#mobileMenu").removeClass("showing");
|
|
}
|
|
|
|
showMobileLanguageMenu() {
|
|
$("#screenOverlayBehindHeader").show();
|
|
|
|
$("#mobileLanguageMenu").slideDown();
|
|
$("#mobileLanguageMenu").addClass("showing");
|
|
}
|
|
|
|
hideMobileLanguageMenu() {
|
|
$("#mobileLanguageMenu").slideUp(function () {
|
|
$("#screenOverlayBehindHeader").hide();
|
|
});
|
|
$("#mobileLanguageMenu").removeClass("showing");
|
|
}
|
|
|
|
scrollToTop() {
|
|
$("body,html").animate({ scrollTop: 0 }, "slow");
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
isPhone() {
|
|
var ua = navigator.userAgent;
|
|
var ipad = ua.match(/(iPad).*OS\s([\d_]+)/);
|
|
var isIphone = !ipad && ua.match(/(iPhone\sOS)\s([\d_]+)/);
|
|
return isIphone;
|
|
}
|
|
}
|
|
|
|
|
|
export const common = new Common();
|
|
|
|
|