// main slide 1
const tabList = [
[
{
id: 1,
text: "대화문",
description:
"내신 시험범위에 반드시 포함되는 대화문.
교과서 본문 학습 전, 탑재된 대화문을 먼저 익혀봅니다.",
},
{
id: 2,
text: "빈출 어휘",
description:
"중고등 교과서 내신시험 빈출 어휘를
이미지 연상 드릴학습으로 반복적으로 암기합니다.",
},
{
id: 3,
text: "본문 쉐도잉",
description:
"실제 교과서의 단원별 핵심 지문을
원어민 음성으로 통문장 본문 암기가 가능합니다.",
},
{
id: 4,
text: "스크램블",
description:
"영어 문장의 구조를 익히기 위해
어휘학습 이후 낱말 조합으로 문장을 완성합니다.",
},
{
id: 5,
text: "기출 문제",
description:
"실제 출제된 교과서 내신문제 기반
문법, 어법, 내용파악 등 쌍둥이 기출문제를 풀어봅니다.",
},
],
[
{
id: 1,
text: "문법강의",
description:
"초등~중등 내신 맞춤 영문법 동영상 강의,
총 9,000 여 개의 영문법 문제은행 무료 제공!",
},
{
id: 2,
text: "영어 도서관",
description:
"교과서 출제 가이드라인에 맞게 제작된
총 16단계 도서관 스토리북으로 독해력 상승!",
},
{
id: 3,
text: "주요 구문",
description:
"중고등 영어 교과서 본문 기반,
학년별 필수 구문으로 회화 응용력 완벽 대비!",
},
{
id: 4,
text: "빈출 단어",
description:
"초등 파닉스부터, 고난이도 어휘까지
단기속성 빈출 단어로 기본부터 탄탄하게!",
},
],
[
{
id: 1,
text: "AI 원어민",
description:
"국내 최초, AI 원어민 학습 기능 탑재!
듣고 보면서 직접 말해보는 소리영어를 시작하세요.",
},
{
id: 2,
text: "발음코칭",
description:
"영어교육형 최신 음성인식 엔진으로
억양, 발음까지 꼼꼼하게 발음 코칭이 가능합니다.",
},
{
id: 3,
text: "시험지 출력",
description:
"온라인 학습 효과를 두 배로!
나만의 맞춤 워크시트를 무제한으로 출력합니다.",
},
{
id: 4,
text: "성적분석",
description:
"실시간 자동채점으로 잔업을 줄이고,
학생별 취약유형 분석 기간 레포트를 제공합니다.",
},
],
];
// 학부모 페이지 / 학생 페이지 분기처리
const baseImgSrc =
location.pathname.includes("parent") || location.host.includes("home")
? "https://www.tabstudy.co.kr/src"
: "./src";
const slides = [
[
{
id: 1,
image: `${baseImgSrc}/imgs/index/new-main/slide/slide1/1_01.png`,
},
{
id: 2,
image: `${baseImgSrc}/imgs/index/new-main/slide/slide1/1_02.png`,
},
{
id: 3,
image: `${baseImgSrc}/imgs/index/new-main/slide/slide1/1_03.png`,
},
{
id: 4,
image: `${baseImgSrc}/imgs/index/new-main/slide/slide1/1_04.png`,
},
{
id: 5,
image: `${baseImgSrc}/imgs/index/new-main/slide/slide1/1_05.png`,
},
],
[
{
id: 1,
image: `${baseImgSrc}/imgs/index/new-main/slide/slide1/2_01.png`,
},
{
id: 2,
image: `${baseImgSrc}/imgs/index/new-main/slide/slide1/2_02.png`,
},
{
id: 3,
image: `${baseImgSrc}/imgs/index/new-main/slide/slide1/2_03.png`,
},
{
id: 4,
image: `${baseImgSrc}/imgs/index/new-main/slide/slide1/2_04.png`,
},
],
[
{
id: 1,
image: `${baseImgSrc}/imgs/index/new-main/slide/slide1/3_01.png`,
},
{
id: 2,
image: `${baseImgSrc}/imgs/index/new-main/slide/slide1/3_02.png`,
},
{
id: 3,
image: `${baseImgSrc}/imgs/index/new-main/slide/slide1/3_03.png`,
},
{
id: 4,
image: `${baseImgSrc}/imgs/index/new-main/slide/slide1/3_04.png`,
},
],
];
const createTabElement = (index, parentElementSelector) => {
const tabs = tabList[index];
for (let i = 0; i < tabs.length; i++) {
const tabElement = $("
").addClass("tab").text(tabs[i].text);
tabElement.on("click", () => {
changeSlide(index, tabs[i].id);
$(`${parentElementSelector} .tab`).removeClass(`select-tab-${index + 1}`);
$(`${parentElementSelector} .tab .book-icon-${index + 1}`).remove();
tabElement.addClass(`select-tab-${index + 1}`);
const bookIconElement = $("
").addClass(`book-icon-${index + 1}`);
const imgElement = $("
").attr(
"src",
`${baseImgSrc}/imgs/index/new-main/book-icon.png`
);
bookIconElement.append(imgElement);
tabElement.prepend(bookIconElement);
const descHtml = createDescHtml(tabs[i]);
$(`.desc-wrapper-${index + 1}`).html(descHtml);
});
$(parentElementSelector).append(tabElement);
}
};
const createSlideElement = (index, parentElementSelector) => {
slides[index].forEach((slide) => {
const swiperSlide = $("
").addClass("swiper-slide");
if (slide.image) {
const imageElement = $("
")
.attr("src", slide.image)
.attr("alt", "slide-img")
.addClass("slide-img");
swiperSlide.append(imageElement);
}
$(parentElementSelector).append(swiperSlide);
});
};
(() => {
for (let i = 1; i <= 3; i++) {
createTabElement(i - 1, `.tab-wrapper-${i}`);
createSlideElement(i - 1, `.swiper-wrapper-${i}`);
}
})();
const mainTabletSlide1 = new Swiper(".main-swiper-1", {
speed: 1000,
centeredSlides: true,
loop: true,
slidesPerView: 1,
touchMoveStopPropagation: true,
initialSlide: 0,
});
const mainTabletSlide2 = new Swiper(".main-swiper-2", {
speed: 1000,
centeredSlides: true,
loop: true,
slidesPerView: 1,
touchMoveStopPropagation: true,
initialSlide: 0,
});
const mainTabletSlide3 = new Swiper(".main-swiper-3", {
speed: 1000,
centeredSlides: true,
loop: true,
slidesPerView: 1,
touchMoveStopPropagation: true,
initialSlide: 0,
});
mainTabletSlide1.on("slideChange", function () {
updateActiveTab(0, this.realIndex);
});
mainTabletSlide2.on("slideChange", function () {
updateActiveTab(1, this.realIndex);
});
mainTabletSlide3.on("slideChange", function () {
updateActiveTab(2, this.realIndex);
});
// 스크롤 닿으면 autoplay
let options = {
root: null,
rootMargin: "0px",
threshold: 0,
};
let observer = new IntersectionObserver((entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
mainTabletSlide1.autoplay.start();
mainTabletSlide2.autoplay.start();
mainTabletSlide3.autoplay.start();
}
});
}, options);
let target = document.querySelector(".content-1");
observer.observe(target);
function updateActiveTab(swiperIndex, slideIndex) {
const parentElementSelector = `.tab-wrapper-${swiperIndex + 1}`;
const bookIconElement = $("
").addClass(`book-icon-${swiperIndex + 1}`);
const imgElement = $("
").attr(
"src",
`${baseImgSrc}/imgs/index/new-main/book-icon.png`
);
bookIconElement.append(imgElement);
$(`${parentElementSelector} .tab`).removeClass(
`select-tab-${swiperIndex + 1}`
);
$(`${parentElementSelector} .tab .book-icon-${swiperIndex + 1}`).remove();
$(`${parentElementSelector} .tab:eq(${slideIndex})`)
.addClass(`select-tab-${swiperIndex + 1}`)
.prepend(bookIconElement);
const tabs = tabList[swiperIndex];
const descHtml = createDescHtml(tabs[slideIndex]);
$(`.desc-wrapper-${swiperIndex + 1}`).html(descHtml);
}
function changeSlide(swiperIndex, slideIndex) {
if (swiperIndex === 0) {
mainTabletSlide1.slideTo(slideIndex);
} else if (swiperIndex === 1) {
mainTabletSlide2.slideTo(slideIndex);
} else {
mainTabletSlide3.slideTo(slideIndex);
}
}
(() => {
for (let i = 1; i <= 3; i++) {
$(`${`.tab-wrapper-${i}`} .tab`)
.first()
.click();
}
})();
function createDescHtml(tab) {
return `
STEP 0${tab.id}
${tab.text}
${tab.description}
`;
}
// main slide 2 (books)
const bookCategories = ["NE능률", "지학사", "다락원", "영문법", "도서관"];
$(document).ready(function () {
$(".book-tab").on("click", function () {
$(".book-tab").removeClass("select-tab");
$(this).addClass("select-tab");
const index = $(this).index();
$(".main-7-img").removeClass("active");
$(".main-7-img").eq(index).addClass("active");
});
});
// main slide 3 (AI)
var mainAiSwiper = new Swiper(".main-10-swiper", {
speed: 1000,
centeredSlides: true,
loop: true,
slidesPerView: 1,
touchMoveStopPropagation: true,
autoplay: {
delay: 3000,
disableOnInteraction: false,
},
pagination: {
el: ".swiper-pagination",
clickable: true,
},
navigation: {
nextEl: ".swiper-button-next",
prevEl: ".swiper-button-prev",
},
});
mainAiSwiper.on("slideChange", function () {
let currentIndex = mainAiSwiper.realIndex;
$(".main-10-text-img").removeClass("active");
$(".main-10-text-img").eq(currentIndex).addClass("active");
});