Vue.component("ito-main-btn-menu", {
template: `
{{item.name}}
{{item.name}}
`,
props: ["type"],
data() {
return {
windowWidth: window.innerWidth,
activeClickTitle: "",
activeClickList: [],
mainButtonList: [
{
icon: "icon-main-01.png",
name: "Thyroid and Parathyroid Disorders",
// name: "甲状腺の病気",
url: "02_thyroid_disease/01_kikkake.html",
style: "margin-left: 1px;",
sub: [
{
name: "When to seek medical care",
url: "02_thyroid_disease/01_kikkake.html",
//来院のきっかけ
},
{
name: "The Role of the Thyroid Gland",
url: "./02_thyroid_disease/02_2function_of_thyroid.html",
//甲状腺の役割
},
{
name: "Disease Characteristics",
url: "./02_thyroid_disease/02_1thyroid_diseases.html",
//病気の特徴
},
{
name: "Hashimoto’s disease",
url: "./02_thyroid_disease/02_5_1about_hashimoto.html",
//橋本病
},
{
name: "Basedow’s Disease",
url: "./02_thyroid_disease/02_4_1about_basedow.html",
//バセドウ病
},
{
name: "Thyroid Tumors",
url: "02_thyroid_disease/02_7_1about_nodle.html",
//甲状腺腫瘍
},
{
name: "Subacute Thyroiditis",
url: "02_thyroid_disease/02_6subacute_thyroiditis.html",
//亜急性甲状腺炎
},
{
name: "Simple Diffuse Goiter",
url: "02_thyroid_disease/02_3diffuse_nontoxic_goiter.html",
//単純性びまん性甲状腺腫
},
{
name: "The Role and Diseases of the Parathyroid Glands",
url: "02_thyroid_disease/03_1parathyroid.html",
style: "font-size: 90%;"
//副甲状腺の役割と病気
},
],
},
{
icon: "icon-main-02.png",
name: "Consultation Information",
// name: "外来受診のご案内"
url: "05_guide/01_1outpatient_receipt.html",
// url: "05_guide/01_1outpatient_receipt.html",
sub: [
{
name: "Reception Hours & Clinic Days",
url: "05_guide/01_1outpatient_receipt.html",
//外来受付時間・診療日のご案内
},
{
name: "Information about medical interpreting",
url: "09_translate/translate.html",
//医療通訳
},
],
},
{
icon: "icon-main-05.png",
name: "Map & directions",
url: "14_traffic_guide/traffic_guide.html",
},
],
};
},
methods: {
handleResize() {
this.windowWidth = window.innerWidth;
},
btnClick(index, event, url, type) {
console.log("click", index, event, url, type);
if (index === 2 || index === 3 || index === 4) {
if (type === "main") {
window.location.href = url;
} else {
window.location.href = "../" + url;
}
}
if (this.windowWidth <= 767) {
if (index === 0) {
event.target.classList.add("active");
this.activeClickTitle = "Thyroid disease";
this.activeClickList = this.mainButtonList[0].sub;
this.openClickNav();
} else if (index === 1) {
event.target.classList.add("active");
this.activeClickTitle = "Consultation Information";
this.activeClickList = this.mainButtonList[1].sub;
this.openClickNav();
}
}
},
openClickNav() {
document.querySelector(".btn-main-sp-overlay-menu").style.display =
"block";
},
closeClickNav() {
document.querySelector(".btn-main-sp-overlay-menu").style.dislpay =
"none";
},
},
created() {
window.addEventListener("resize", this.handleResize);
this.handleResize();
},
destroyed() {
window.removeEventListener("resize", this.handleResize);
},
mounted() {
this.$nextTick(() => {
if (this.windowWidth > 767) {
var hoverBtn3 = document.querySelector(".btn-main-0");
var hoverBtn4 = document.querySelector(".btn-main-1");
hoverBtn3.addEventListener(
"mouseenter",
function (event) {
handler("3", event);
},
false
);
hoverBtn3.addEventListener("mouseleave", function (event) {
setTimeout(() => {
remover("3", event);
}, 100);
});
hoverBtn4.addEventListener(
"mouseenter",
function (event) {
handler("4", event);
},
false
);
hoverBtn4.addEventListener("mouseleave", function (event) {
setTimeout(() => {
remover("4", event);
}, 100);
});
function handler(type, event) {
if (window.innerWidth <= 767) {
return;
}
let dropdown;
let valueCheck = {
3: ".btn-main-0-dropdown",
4: ".btn-main-1-dropdown",
};
dropdown = document.querySelector(valueCheck[type]);
dropdown.classList.add("d-block");
event.target.classList.add("active");
dropdown.addEventListener("mouseenter", function (e) {
e.target.classList.add("d-block", "active");
event.target.classList.add("active");
});
dropdown.addEventListener("mouseleave", function (e) {
e.target.classList.remove("d-block", "active");
event.target.classList.remove("active");
});
}
function remover(type, event) {
let dropdown;
let valueCheck = {
3: ".btn-main-0-dropdown",
4: ".btn-main-1-dropdown",
};
dropdown = document.querySelector(valueCheck[type]);
if (dropdown.classList.contains("active") == false) {
dropdown.classList.remove("d-block");
event.target.classList.remove("active");
}
}
}
});
},
watch: {
windowWidth: function (val) {
if (val > 767) {
var hoverBtn3 = document.querySelector(".btn-main-0");
var hoverBtn4 = document.querySelector(".btn-main-1");
hoverBtn3.addEventListener(
"mouseenter",
function (event) {
handler("3", event);
},
false
);
hoverBtn3.addEventListener("mouseleave", function (event) {
setTimeout(() => {
remover("3", event);
}, 100);
});
hoverBtn4.addEventListener(
"mouseenter",
function (event) {
handler("4", event);
},
false
);
hoverBtn4.addEventListener("mouseleave", function (event) {
setTimeout(() => {
remover("4", event);
}, 100);
});
function handler(type, event) {
if (window.innerWidth <= 767) {
return;
}
let dropdown;
let valueCheck = {
3: ".btn-main-0-dropdown",
4: ".btn-main-1-dropdown",
};
dropdown = document.querySelector(valueCheck[type]);
dropdown.classList.add("d-block");
event.target.classList.add("active");
dropdown.addEventListener("mouseenter", function (e) {
e.target.classList.add("d-block", "active");
event.target.classList.add("active");
});
dropdown.addEventListener("mouseleave", function (e) {
e.target.classList.remove("d-block", "active");
event.target.classList.remove("active");
});
}
function remover(type, event) {
let dropdown;
let valueCheck = {
3: ".btn-main-0-dropdown",
4: ".btn-main-1-dropdown",
};
dropdown = document.querySelector(valueCheck[type]);
if (dropdown.classList.contains("active") == false) {
dropdown.classList.remove("d-block");
event.target.classList.remove("active");
}
}
}
},
},
});