init
This commit is contained in:
381
src/static/common.js
Normal file
381
src/static/common.js
Normal file
@@ -0,0 +1,381 @@
|
||||
var isMobile = null;
|
||||
var wasMobile = isMobile;
|
||||
var isMiniHeader = false;
|
||||
|
||||
import $ from 'jquery'
|
||||
|
||||
class Common {
|
||||
constructor(name, age) {
|
||||
this.name = name;
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
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');
|
||||
}, 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();
|
||||
|
||||
if (!this.isMobile()) {
|
||||
$(".mobileContent").hide();
|
||||
}
|
||||
|
||||
if (isMobile) wasMobile = 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() {
|
||||
|
||||
if ($("#mobileMenu").hasClass("showing")) {
|
||||
$("#mobileMenu").hide();
|
||||
$("#mobileMenu").removeClass("showing");
|
||||
}
|
||||
|
||||
if (!$("#mobileLanguageMenu").hasClass("showing")) {
|
||||
common.showMobileLanguageMenu();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
$("#screenOverlayBehindHeader, .linkGoBack").on("click", function() {
|
||||
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() {
|
||||
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();
|
||||
}
|
||||
|
||||
common.scrollToTop();
|
||||
|
||||
}
|
||||
|
||||
|
||||
submitSupportForm() {
|
||||
|
||||
$.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();
|
||||
common.scrollToTop();
|
||||
|
||||
$("#supSubject").val("");
|
||||
$("#supCompany").val("");
|
||||
$("#supName").val("");
|
||||
$("#supEmail").val("");
|
||||
$("#supPhone").val("");
|
||||
$("#supProduct").val("");
|
||||
$("#supComments").val("");
|
||||
}
|
||||
|
||||
|
||||
submitContactForm() {
|
||||
|
||||
$.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();
|
||||
common.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();
|
||||
57
src/static/config.js
Normal file
57
src/static/config.js
Normal file
@@ -0,0 +1,57 @@
|
||||
window.config = {
|
||||
menus: [{
|
||||
name: "首页",
|
||||
url: "/index",
|
||||
child: []
|
||||
},
|
||||
{
|
||||
name: "我们的方案",
|
||||
url: "/ourPlan",
|
||||
child: [{
|
||||
name: "三维展示",
|
||||
url: "/ourPlan/reaEstate",
|
||||
},
|
||||
{
|
||||
name: "房地产和物业管理",
|
||||
url: "/ourPlan/estateManagement",
|
||||
},
|
||||
{
|
||||
name: "物联网(iot)",
|
||||
url: "/ourPlan/iot",
|
||||
},
|
||||
{
|
||||
name: "技术和集成",
|
||||
url: "/ourPlan/technologyIntegration",
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "前沿",
|
||||
url: "/fulEdge",
|
||||
child: [{
|
||||
name: "移动解决方案",
|
||||
url: "/fulEdge/mobileSolution",
|
||||
},
|
||||
{
|
||||
name: "其他",
|
||||
url: "/fulEdge/other",
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "关于我们",
|
||||
url: "/aboutUs",
|
||||
child: [{
|
||||
name: "与我们合作",
|
||||
url: "/aboutUs/cooperateWithUs",
|
||||
},
|
||||
{
|
||||
name: "丙维科技",
|
||||
url: "/aboutUs/propystTechnology",
|
||||
},
|
||||
]
|
||||
},
|
||||
|
||||
]
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user