This commit is contained in:
2018-11-04 16:29:30 +08:00
parent d16a2fabcf
commit 05f2fc36bc
5 changed files with 100 additions and 148 deletions

View File

@@ -1,6 +1,6 @@
var isMobile = null;
var isPhone = null;
var isPhoneWidth = null;
var wasMobile = isMobile;
var wasDesktop = !isMobile;
@@ -18,10 +18,10 @@ class Common {
init() {
var self=this;
var self = this;
isMobile = common.isMobileWidth();
isPhone = common.isPhoneWidth();
isMobile = common.isMobile();
isPhoneWidth = common.isPhone();
//create trigger to resizeEnd event, called after event is finished
$(window).resize(function () {
@@ -40,7 +40,7 @@ class Common {
$(window).scroll(function () {
if ($(window).scrollTop() > 200) {
if (isMiniHeader === false && !self.isMobileWidth()) {
if (isMiniHeader === false && !self.isMobile()) {
$('.header').addClass('mini');
isMiniHeader = true;
}
@@ -73,21 +73,16 @@ class Common {
adjustElementsForScreen() {
isMobile = this.isMobileWidth();
isPhone = this.isPhoneWidth();
isMobile = this.isMobile();
isPhoneWidth = this.isPhone();
if (!this.isMobileWidth()) {
if (!this.isMobile()) {
$(".mobileContent").hide();
}
if (isMobile) wasMobile = true;
if (!isMobile) wasDesktop = true;
if (wasDesktop && isMobile) {
if (location.pathname.indexOf("index.php") === -1 && location.pathname.indexOf(".php") > -1) {
handleActivePage();
}
}
if (wasMobile && !isMobile) location.reload();
if (isMobile && isMiniHeader === true) {
@@ -95,17 +90,7 @@ class Common {
isMiniHeader = false;
}
//adjust 'find us' Google Maps links as user location not always located accurately on desktop
if (isMobile) {
$(".findUsSweden").attr("href", "https://www.google.com/maps/dir/?api=1&destination=Pythagoras+AB,+S%C3%B6der+M%C3%A4larstrand+27+B,+118+25+Stockholm");
$(".findUsUK").attr("href", "https://www.google.com/maps/dir/?api=1&destination=180+Piccadilly,+St.+James's,+London+W1J+9HF,+UK");
$(".findUsNorway").attr("href", "https://www.google.com/maps/dir/?api=1&destination=Skogliveien+4a,+3047+Drammen,+Norway");
} else {
$(".findUsSweden").attr("href", "https://www.google.com/maps/dir//Pythagoras+AB,+S%C3%B6der+M%C3%A4larstrand+27+B,+118+25+Stockholm");
$(".findUsUK").attr("href", "https://www.google.com/maps/dir//180+Piccadilly,+St.+James's,+London+W1J+9HF,+UK");
$(".findUsNorway").attr("href", "https://www.google.com/maps/dir//Skogliveien+4a,+3047+Drammen,+Norway");
}
this.adjustContentBannersForScreen();
}
@@ -116,8 +101,8 @@ class Common {
//go to main page if not there on logo click
$(".logoCell .logo").on("click", function () {
if (window.location.href.indexOf("index.php") === -1) {
window.location.href = "index.php";
if (window.location.href.indexOf("index") === -1) {
window.location.href = "#/index";
}
});
@@ -137,41 +122,11 @@ class Common {
$("table.mainMenu > tbody > tr > td.selected").css("box-shadow", "0 -3px 0 #ff0000 inset");
});
this.highlightHeaderCategory();
}
highlightHeaderCategory() {
var myLocation = location.pathname;
//console.log("My location: " + myLocation);
if (myLocation.indexOf("index.php") !== -1) {
$("#mainMenuGroup0").addClass("selected");
} else if (
myLocation.indexOf("/fm-") !== -1 ||
myLocation.indexOf("/prs-") !== -1 ||
myLocation.indexOf("/lvh-") !== -1 ||
myLocation.indexOf("/fas-") !== -1 ||
myLocation.indexOf("/sb-") !== -1 ||
myLocation.indexOf("/tek-") !== -1) {
$("#mainMenuGroup1").addClass("selected");
} else if (
myLocation.indexOf("/mobila-losningar.php") !== -1 ||
myLocation.indexOf("/ifrs16.php") !== -1 ||
myLocation.indexOf("/gdpr.php") !== -1) {
$("#mainMenuGroup2").addClass("selected");
} else if (
myLocation.indexOf("/det-har-ar-pythagoras.php") !== -1 ||
myLocation.indexOf("/kontakta-oss.php") !== -1 ||
myLocation.indexOf("/jobba-hos-oss.php") !== -1) {
$("#mainMenuGroup3").addClass("selected");
} else if (myLocation.indexOf(".php") === -1) {
$("#mainMenuGroup0").addClass("selected");
}
}
initListeners() {
@@ -183,9 +138,9 @@ class Common {
}
if ($("#mobileMenu").hasClass("showing")) {
hideMobileMenu();
common.hideMobileMenu();
} else {
showMobileMenu();
common.showMobileMenu();
}
});
@@ -199,7 +154,7 @@ class Common {
if ($("#mobileLanguageMenu").hasClass("showing")) {
hideMobileLanguageMenu();
} else {
showMobileLanguageMenu();
common.showMobileLanguageMenu();
}
});
@@ -207,10 +162,10 @@ class Common {
$("#screenOverlayBehindHeader, .linkGoBack").on("click", function (e) {
if ($("#mobileMenu").hasClass("showing")) {
hideMobileMenu();
common.hideMobileMenu();
}
if ($("#mobileLanguageMenu").hasClass("showing")) {
hideMobileLanguageMenu();
common.hideMobileLanguageMenu();
}
});
@@ -221,13 +176,13 @@ class Common {
//show support form
$("a.linkSupport").on("click", function (e) {
e.preventDefault();
showForm("support");
common.showForm("support");
});
//show contact form
$("a.linkContactUs").on("click", function (e) {
e.preventDefault();
showForm("contact");
common.showForm("contact");
});
$("#scrollToBoxes").on("click", function (e) {
@@ -243,20 +198,21 @@ class Common {
}
initMobileMenu() {
$("#mobileMenu a").on("click", function (e) {
if ($(this).hasClass("hasSubmenu")) {
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();
} else {
hideMobileMenu();
}
$("#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();
});
}
@@ -272,12 +228,12 @@ class Common {
$("#formSupport").on("submit", function (e) {
e.preventDefault();
submitSupportForm($(this));
common.submitSupportForm($(this));
});
$("#formContact").on("submit", function (e) {
e.preventDefault();
submitContactForm($(this));
common.submitContactForm($(this));
});
}
@@ -293,7 +249,7 @@ class Common {
if (formName === "contact") {
var $conCommentsTitle = $("label[for='conComments']");
console.log($(".contentTableRight").find("[data-contact-link]").data("contact-link"));
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") + ": *");
@@ -368,7 +324,7 @@ class Common {
adjustContentBannersForScreen() {
if (this.isMobileWidth()) {
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");
@@ -412,12 +368,25 @@ class Common {
$("body,html").animate({ scrollTop: 0 }, "slow");
}
isMobileWidth() {
return $('#mobile_indicator').is(':visible');
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;
}
isPhoneWidth() {
return $('#phone_indicator').is(':visible');
isPhone() {
var ua = navigator.userAgent;
var ipad = ua.match(/(iPad).*OS\s([\d_]+)/);
var isIphone = !ipad && ua.match(/(iPhone\sOS)\s([\d_]+)/);
return isIphone;
}
}