From 05f2fc36bca59be32e6b45e4a7b13483c374e229 Mon Sep 17 00:00:00 2001 From: LightZhang <978854603@qq.com> Date: Sun, 4 Nov 2018 16:29:30 +0800 Subject: [PATCH] ss --- src/assets/static/common.js | 139 ++++++++++---------------- src/assets/static/config.js | 2 +- src/components/ihead.vue | 10 +- src/components/leftMenu.vue | 92 +++++++---------- src/views/aboutUs/cooperateWithUs.vue | 5 +- 5 files changed, 100 insertions(+), 148 deletions(-) diff --git a/src/assets/static/common.js b/src/assets/static/common.js index 0051622..930f857 100644 --- a/src/assets/static/common.js +++ b/src/assets/static/common.js @@ -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; } } diff --git a/src/assets/static/config.js b/src/assets/static/config.js index b8b215d..513ca3f 100644 --- a/src/assets/static/config.js +++ b/src/assets/static/config.js @@ -31,7 +31,7 @@ window.config = { }, { name: "前沿", - url: "/fulEdge/mobileSolution", + url: "/fulEdge", child: [{ name: "移动解决方案", url: "/fulEdge/mobileSolution", diff --git a/src/components/ihead.vue b/src/components/ihead.vue index bd27e9c..2ed07f3 100644 --- a/src/components/ihead.vue +++ b/src/components/ihead.vue @@ -65,7 +65,8 @@
diff --git a/src/components/leftMenu.vue b/src/components/leftMenu.vue index 64e5ed5..b3d5cff 100644 --- a/src/components/leftMenu.vue +++ b/src/components/leftMenu.vue @@ -1,76 +1,56 @@ - diff --git a/src/views/aboutUs/cooperateWithUs.vue b/src/views/aboutUs/cooperateWithUs.vue index 73f8c4e..1c9d81e 100644 --- a/src/views/aboutUs/cooperateWithUs.vue +++ b/src/views/aboutUs/cooperateWithUs.vue @@ -18,12 +18,15 @@