USP인트로 추가

This commit is contained in:
hyeonggil
2024-07-24 17:07:46 +09:00
parent cee833d7af
commit 95fd80f44d
9 changed files with 670 additions and 534 deletions

View File

@@ -536,6 +536,12 @@ function pdpInCarGameSwiperDtl() {
inCarGameSwiper.slideTo(0);
inCarGameSwiper2.slideTo(0);
});
// const videoEle = `
// <video muted="" playsinline poster="../assets/images/kia/pdp/in_car_game/theme1-1.png">
// <source src="/kr/assets/images/kia/pdp/in_car_game/theme1-1.mp4" type="video/mp4" class="themeVideo">
// </video>
// `;
// $(".inCarGameDtlThumb .swiper-slide").eq(0).html(videoEle);
},
},
});
@@ -595,7 +601,7 @@ $(document).on("click", ".inCarGame .dtthumb", function (e) {
`;
$(this).addClass(`${dtlImgPath}`);
console.log("videoEle===", videoEle);
beforeDtlImgPath = dtlImgPath;
$(this).html(videoEle);
@@ -690,13 +696,26 @@ function pdpIntro() {
if ($(".video_wrap video").length > 0) {
// .video_wrap 내 모든 비디오 요소 선택
const videoElements = document.querySelectorAll(".video_wrap video");
$(".displayTheme").addClass("playing");
let cookieVal;
$(".editorWarp").addClass("playing");
switch (true) {
case $(".displayTheme").length > 0:
cookieVal = "displayThemeIntro";
break;
case $(".inCarGame").length > 0:
cookieVal = "inCarGameIntro";
break;
case $(".srsPlus").length > 0:
cookieVal = "srsPlusIntro";
break;
}
$(".close-today").html(
`<span onclick="hideTodayIntroPopup()" style="cursor:pointer"><input type="checkbox"> 오늘 하루 재생하지 않기</span>`
`<span onclick="hideTodayIntroPopup('${cookieVal}')" style="cursor:pointer"><input type="checkbox"> 오늘 하루 재생하지 않기</span>`
);
if (getCookie("hideIntroPopup")) {
$(".displayTheme").removeClass("playing");
if (getCookie(cookieVal)) {
$(".editorWarp").removeClass("playing");
$(".close-today input").attr("checked", "checked");
videoElements[0].pause();
@@ -705,8 +724,8 @@ function pdpIntro() {
}
videoElements.forEach((video) => {
const videoWrap = $(".displayTheme .video_wrap");
const btnIntro = $(".displayTheme .btn-intro");
const videoWrap = $(".editorWarp .video_wrap");
const btnIntro = $(".editorWarp .btn-intro");
const btnClose = $(".video_wrap .btn-close");
const btnPlay = $(".video_wrap .btn-play");
// console.log("Intro 실행");
@@ -716,7 +735,7 @@ function pdpIntro() {
// 비디오 재생이 끝났을 때 이벤트 리스너 추가
video.addEventListener("ended", function () {
// console.log("addEventListener ended 실행");
$(".displayTheme").removeClass("playing");
$(".editorWarp").removeClass("playing");
video.currentTime = 0;
video.pause();
$(videoWrap).hide();
@@ -747,10 +766,10 @@ function pdpIntro() {
}
// .btn-intro 버튼 클릭 시 비디오 재생
$(document).on("click", ".displayTheme .btn-intro", function () {
$(document).on("click", ".editorWarp .btn-intro", function () {
// console.log('intro 다시 실행');
$(".displayTheme").addClass("playing");
if (getCookie("hideIntroPopup")) {
$(".editorWarp").addClass("playing");
if (getCookie(cookieVal)) {
$(".close-today input").attr("checked", "checked");
}
$(videoWrap).show();
@@ -763,7 +782,7 @@ function pdpIntro() {
// .btn-close 버튼 클릭 시 비디오 숨기기
$(document).on("click", ".video_wrap .btn-close", function () {
// console.log('btn close 실행');
$(".displayTheme").removeClass("playing");
$(".editorWarp").removeClass("playing");
$(videoWrap).hide();
if (video) {
video.currentTime = 0;
@@ -783,7 +802,7 @@ function pdpIntro() {
}
}
$(document).on("click", ".displayTheme .btn-play.play", function () {
$(document).on("click", ".video_wrap .btn-play.play", function () {
console.log("intro 플레이");
const btnPlay = $(".video_wrap .btn-play");
const videoElements = document.querySelectorAll(".video_wrap video");
@@ -794,7 +813,7 @@ $(document).on("click", ".displayTheme .btn-play.play", function () {
videoElements[0].play();
}
});
$(document).on("click", ".displayTheme .btn-play.pause", function () {
$(document).on("click", ".video_wrap .btn-play.pause", function () {
console.log("intro 정지");
const btnPlay = $(".video_wrap .btn-play");
const videoElements = document.querySelectorAll(".video_wrap video");
@@ -1088,11 +1107,15 @@ function getCookie(name) {
return null;
}
// 팝업을 숨기는 함수
function hideTodayIntroPopup() {
function hideTodayIntroPopup(target) {
const videoElements = document.querySelectorAll(".video_wrap video");
videoElements[0].pause();
videoElements[0].currentTime = 0;
$(".video_wrap").hide();
$(".displayTheme").removeClass("playing");
setCookie("hideIntroPopup", "true", 1);
$(".editorWarp").removeClass("playing");
if (target) {
setCookie(target, "true", 1);
} else {
setCookie("hideIntroPopup", "true", 1);
}
}