mjon_git/src/main/webapp/publish/js/content.js

1886 lines
71 KiB
JavaScript

$(document).ready(function () {
// 문자작성 영역 클릭시 textarea 활성화
$('.put_left').on('click', function (e) {
$(this).find('textarea.put_text').focus();
});
/* gnb 마우스 오버시 열리거나 닫힘 */
$(".put_text").focusin(function () {
$(this).parents(".put_left").addClass("on");
});
$(".put_text").focusout(function () {
$(this).parents(".put_left").removeClass("on");
});
/* 문자샘플 , 회원가입 약관 동의, 전송내역, 팝업에 있는 table, 요금사용 내역 호버 컨텐츠, 예약관리 문자내용 상세보기 팝업, 메모 팝업, 주소록 불러오기 팝업, 주소록 관리 왼쪽, 견적서 스크롤바 꾸미기 */
if ($(".agree_text, .histroy_trans, .rev_popup, .history_hover, .rev_pop_txt .memo, .adr_pop_list, .estimate, .cashReceipt_popup02 .layer_in, .kakao_wrap .rev_pop_txt, .clause_version_popup .clause_wrap").length > 0) {
$(".agree_text, .histroy_trans, .rev_popup, .history_hover, .rev_pop_txt .memo, .adr_pop_list, .estimate, .cashReceipt_popup02 .layer_in, .kakao_wrap .rev_pop_txt, .clause_version_popup .clause_wrap").mCustomScrollbar({
axis: 'y',
scrollbarPosition: "outside",
theme: "dark",
autoHideScrollbar: false,
scrollInertia: 600,
mouseWheelPixels: 300
});
} else if ($(".kakao_template_wrap").length > 0) {
$(".kakao_template_wrap").mCustomScrollbar({
axis: 'y',
scrollbarPosition: "inside",
theme: "dark",
autoHideScrollbar: false,
scrollInertia: 600,
mouseWheelPixels: 300
});
}
//결제관리 - 견적내기 tbody 10줄 이상부터 스크롤 생김
var tbHieght = $('.tType3.payDetail .tType3_bd_wrap').height();
if (tbHieght > 399) {
$('.tType3.payDetail .tType3_bd_wrap').css("height", "400px");
$(".tType3.payDetail .tType3_bd_wrap").mCustomScrollbar({
axis: 'y',
scrollbarPosition: "outside",
theme: "dark",
autoHideScrollbar: false,
scrollInertia: 600,
mouseWheelPixels: 300
});
} else {}
/* 실시간 글 적용 */
/*var jbTxt = $("#textarea").text();
$(".realtime").text(jbTxt);*/
/*
$("#textarea, #smsTxtArea").on("change keyup paste", function () {
var crtTxt = $(this).val();
$(".realtime").text(crtTxt);
$(".none_txt").empty();
});
*/
$(".kakaotalksend_cont #textarea,.kakaotalkset_cont #textarea").on("change keyup paste", function () {
var crtTxt = $(this).val();
$(".template_text").text(crtTxt);
});
$(".template_side_text").on("change keyup paste", function () {
var sideText = $(this).val();
$(".kakaotalkset_cont .side_info_text").text(sideText);
});
/* 문자샘플 탭 선택 시 활성화 */
$(".tab_depth1:not(.security_tab) a").click(function () {
var tabText = $(this).text();
var tabPosi = $(this).position().left;
tabPosi -= 1;
var tabIdx = $(this).index();
// console.log(tabIdx);
if (tabIdx == 0) {
$(this).css("border-radius", "5px 0 0 5px")
} else if (tabIdx == 2) {
$(this).css("border-radius", "0 5px 5px 0");
} else {
$(this).css("border-radius", "0 0 0 0");
}
$(this).addClass("on");
$(this).siblings("a").removeClass("on");
//1depth 선택 시 2depth, 3depth 메뉴 첫번째로 이동
// $(".tab_depth2 a:first-child").addClass("on");
// $(".tab_depth2 a:first-child").siblings("a").removeClass("on");
// $(".tab_depth3 a:first-child").addClass("on");
// $(".tab_depth3 a:first-child").siblings("a").removeClass("on");
// $(".tab_depth4 a:first-child").addClass("on");
// $(".tab_depth4 a:first-child").siblings("a").removeClass("on");
});
$(".tab_depth2 a").click(function () {
$(this).addClass("on");
$(this).siblings("a").removeClass("on");
//2depth 선택 시 3depth 메뉴 첫번째로 이동
$(".tab_depth4 a:first-child").addClass("on");
$(".tab_depth4 a:first-child").siblings("a").removeClass("on");
$(".tab_depth4 a:first-child").addClass("on");
$(".tab_depth4 a:first-child").siblings("a").removeClass("on");
});
$(".tab_depth3 a").click(function () {
$(this).addClass("on");
$(this).siblings("a").removeClass("on");
});
$(".tab_depth4 a").click(function () {
$(this).addClass("on");
$(this).siblings("a").removeClass("on");
});
/* 단문문자, 포토문자 예시 */
if ($(".msg_photo").is(".active") == true) {
$(".btn_msg").css("display", "none");
} else {
$(".btn_photo").css("display", "block");
}
$(".tab_depth2 a:nth-child(1),.tab_depth2 a:nth-child(5)").click(function () {
$(".msg_photo").addClass("active");
$(".msg_text").removeClass("active");
$(".btn_photo").css("display", "block")
$(".btn_msg").css("display", "none")
})
$(".tab_depth2 a:nth-child(2),.tab_depth2 a:nth-child(3),.tab_depth2 a:nth-child(4)").click(function () {
$(".msg_text").addClass("active");
$(".msg_photo").removeClass("active");
$(".btn_msg").css("display", "block")
$(".btn_photo").css("display", "none")
})
//요금 사용내역 table안에 있는 내용 hover 시 컨텐츠 보임
$(".tb_tit").mouseover(function () {
$(this).find(".history_hover").css({
"top": "50%",
"left": "90%",
"display": "block"
})
})
//컨텐츠 사라짐
$(".tb_tit").mouseleave(function () {
$(this).find(".history_hover").css({
"top": 0,
"left": 0,
"display": "none"
})
})
/* 주소록 순서 변경 */
$(".list_switch").each(function (index, item) {
index += 1;
$(item).addClass("adr_0" + index); // 순서대로 클래스 추가
$(".adr_01").addClass("adr_first"); // 첫번째 그룹 클래스 추가
$(".list_switch").last().addClass("adr_last"); // 마지막 그룹 클래스 추가
});
/* 최상단으로 */
$(".btn_top").click(function () {
// 버튼 클릭 시 체크된 값 가져와야함.
var checkAdr = $(".list_switch").find("input[type='checkbox']:checked");
var checkAdrWrap = checkAdr.parent().parent();
if (checkAdrWrap.is(".adr_first") == true) {
// 첫번째가 선택됐을 때 첫번째는 고정이고 나머지만 움직이게
$(".adr_first").after(checkAdrWrap);
} else {
// 첫번째가 선택 안됐을 때 나머지들을 최상단으로
$(".adr_first").before(checkAdrWrap);
}
// 클래스 순서 다시 지정. 클래스 다 지우고 기본 클래스 추가
$(".list_switch").removeClass().addClass("list_switch adr_cb_wrap");
// 순서대로 다시 클래스 추가
$(".list_switch").each(function (index, item) {
$(item).removeClass("adr_0" + index);
index += 1;
if (index > 0) {
$(item).addClass("adr_0" + index);
$(".adr_01").addClass("adr_first");
$(".list_switch").last().addClass("adr_last");
}
});
})
/* 상단으로 */
$(".btn_up").click(function () {
// 버튼 클릭 시 체크된 값 가져와야함.
var checkAdr = $(".list_switch").find("input[type='checkbox']:checked");
var checkAdrWrap = checkAdr.parent().parent();
//$(checkAdrWrap).prev().before(checkAdrWrap);
$(checkAdrWrap).each(function (index, item) {
if ($(item).index() == 2) {
return false; //break
}
// 한칸씩 위로 이동
$(item).prev().before(item);
// 클래스 순서 다시 지정. 클래스 다 지우고 기본 클래스 추가
$(".list_switch").removeClass().addClass("list_switch adr_cb_wrap");
// 순서대로 다시 클래스 추가
$(".list_switch").each(function (index, item) {
$(item).removeClass("adr_0" + index);
index += 1;
if (index > 0) {
$(item).addClass("adr_0" + index);
$(".adr_01").addClass("adr_first");
$(".list_switch").last().addClass("adr_last");
}
});
});
//var checkAdr = $(".list_switch").find("input[type='checkbox']:checked");
//var checkAdrWrap = checkAdr.parent().parent();
//var adrLength = $(checkAdr).parents(".adr1_list").find(".adr_cb_wrap").eq;
//alert(adrLength);
//if($(checkAdr).is(":checked")){
// $(checkAdrWrap).length();
//}else{}
// // 버튼 클릭 시 체크된 값 가져와야함.
// var checkAdr = $(".list_switch").find("input[type='checkbox']:checked");
// var checkAdrWrap = checkAdr.parent().parent();
// var checkAdrWrap2 = checkAdrWrap.first().prev();
//
// if(checkAdrWrap2.is(".list_fixed") == false){
// $(checkAdrWrap2).before(checkAdrWrap);
// }else{}
//
// // 클래스 순서 다시 지정. 클래스 다 지우고 기본 클래스 추가
// $(".list_switch").removeClass().addClass("list_switch adr_cb_wrap");
//
// // 순서대로 다시 클래스 추가
// $(".list_switch").each(function(index, item){
// $(item).removeClass("adr_0"+index);
// index+=1;
// if(index > 0){
// $(item).addClass("adr_0"+index);
// $(".adr_01").addClass("adr_first");
// $(".list_switch").last().addClass("adr_last");
// }
// });
})
/* 하단으로 */
$(".btn_down").click(function () {
// 버튼 클릭 시 체크된 값 가져와야함.
var checkAdr = $(".list_switch").find("input[type='checkbox']:checked");
var checkAdrWrap = checkAdr.parent().parent();
//$(checkAdrWrap).next().after(checkAdrWrap);
$(checkAdrWrap.get().reverse()).each(function (index, item) {
if ($(item).index() == $(".list_switch").last().index()) {
return false; //break
}
// 한칸씩 아래로 이동
$(item).next().after(item);
// 클래스 순서 다시 지정. 클래스 다 지우고 기본 클래스 추가
$(".list_switch").removeClass().addClass("list_switch adr_cb_wrap");
// 순서대로 다시 클래스 추가
$(".list_switch").each(function (index, item) {
$(item).removeClass("adr_0" + index);
index += 1;
if (index > 0) {
$(item).addClass("adr_0" + index);
$(".adr_01").addClass("adr_first");
$(".list_switch").last().addClass("adr_last");
}
});
});
})
/* 최하단으로 */
$(".btn_botom").click(function () {
// 버튼 클릭 시 체크된 값 가져와야함.
var checkAdr = $(".list_switch").find("input[type='checkbox']:checked");
var checkAdrWrap = checkAdr.parent().parent();
if (checkAdrWrap.is(".adr_last") == true) {
// 첫번째가 선택됐을 때 첫번째는 고정이고 나머지만 움직이게
$(".adr_last").before(checkAdrWrap);
} else {
// 첫번째가 선택 안됐을 때 나머지들을 최하단으로
$(".adr_last").after(checkAdrWrap);
}
// 클래스 순서 다시 지정. 클래스 다 지우고 기본 클래스 추가
$(".list_switch").removeClass().addClass("list_switch adr_cb_wrap");
// 순서대로 다시 클래스 추가
$(".list_switch").each(function (index, item) {
$(item).removeClass("adr_0" + index);
index += 1;
if (index > 0) {
$(item).addClass("adr_0" + index);
$(".adr_01").addClass("adr_first");
$(".list_switch").last().addClass("adr_last");
}
});
})
/* //주소록 순서 변경 */
/* 그림문자 첨부파일 삭제 이벤트 */
$(".file_close, .file_close_on").click(function () {
$(this).parents(".put_left.photo li").css("display", "none");
})
// 퀵메뉴 버튼 클릭 시 컨텐츠와 푸터 열고 닫히고 버튼 이미지 변경됨
$(".adr_cb_wrap>p").off("click").on('click', function () {
// 전체
$(".check_group_all>p").find("img").attr("src", "/publish/images/content/close_folder.png");
$(".check_group_all>p").find("img").attr("alt", "폴더 닫힘");
// 주소록 그룹 열림, 닫힘 폴더이미지 초기화
$(".adr1_list div p").each(function (index, item) {
$(item).find("img").attr("src", "/publish/images/content/close_folder2.png");
$(item).find("img").attr("alt", "폴더 닫힘");
});
var foloerImg = $(this);
/*
//컨텐츠
$(this).toggleClass("open");
if ($(this).hasClass("open") === true) {
$(this).find("img").attr("src", "/publish/images/content/open_folder2.png");
$(this).find("img").attr("alt", "폴더 열림");
}
else {
$(this).find("img").attr("src", "/publish/images/content/close_folder2.png");
$(this).find("img").attr("alt", "폴더 닫힘");
}
*/
if ($(this).parent().hasClass("check_group_all") === true) {
$(this).find("img").attr("src", "/publish/images/content/open_folder.png");
$(this).find("img").attr("alt", "폴더 열림");
} else {
$(this).find("img").attr("src", "/publish/images/content/open_folder2.png");
$(this).find("img").attr("alt", "폴더 열림");
}
});
// //주소록 불러오기 팝업 textarea 대신 p태그로 글씨 먹인 영역 active 시 사라지게
// $(".req_area").click(function(){
// $(".req_area").addClass("active");
// });
// // 외부영역 클릭 시 textarea 사라짐
// $(document).mouseup(function (e){
// var LayerPopup = $(".req_area");
// if(LayerPopup.has(e.target).length === 0){
// LayerPopup.removeClass("active");
// }
// });
//선거문자 1명씩 선택 ? 호버 시 팝업
$(".btn_check_one .qmMark").mouseover(function () {
$(this).parents(".btnType").next(".send_hover_cont").addClass("on");
})
$(".btn_check_one .qmMark").mouseleave(function () {
$(this).parents(".btnType").next(".send_hover_cont").removeClass("on");
})
// 번호추가 ? 호버 시 팝업
$(".btn_add_number .qmMark").mouseover(function () {
$(this).parents(".btnType").siblings(".send_hover_cont").addClass("on");
})
$(".btn_add_number .qmMark").mouseleave(function () {
$(this).parents(".btnType").siblings(".send_hover_cont").removeClass("on");
})
//문자발송 오류검사 ? 호버 시 팝업
$(".test_qm").mouseover(function () {
$(this).parents(".btnType").find(".test_hover_cont").addClass("on");
})
$(".test_qm").mouseleave(function () {
$(this).parents(".btnType").find(".test_hover_cont").removeClass("on");
})
//문자발송 오류검사 ? 호버 시 팝업
$(".check_validity").mouseover(function () {
$(this).next(".error_hover_cont").addClass("on");
});
$(".check_validity").mouseleave(function () {
$(this).next(".error_hover_cont").removeClass("on");
});
//주소록 관리 - 수신거부 관리 결과전송 ?호버 시 팝업
$(".adr2_hover").mouseover(function () {
$(this).parents(".btnType").next(".adr2_hover_cont").addClass("on");
})
$(".adr2_hover").mouseleave(function () {
$(this).parents(".btnType").next(".adr2_hover_cont").removeClass("on");
})
//문자발송 오류검사 ? 호버 시 팝업
$(".adr_qm").mouseover(function () {
$(this).parents(".btnType").find(".adr_hover_cont").addClass("on");
})
$(".adr_qm").mouseleave(function () {
$(this).parents(".btnType").find(".adr_hover_cont").removeClass("on");
})
//발송결과 진행상황 호버 시 팝업
$(".check_validity").mouseover(function () {
$(this).next(".info_hover_cont").addClass("on");
});
$(".check_validity").mouseleave(function () {
$(this).next(".info_hover_cont").removeClass("on");
});
// 알림톡 템플릿 등록/관리 버튼 클릭 시 콘텐츠 바뀜
$(".btn_list").click(function () {
$(this).closest(".tab_content").find(".thumbnail_content").fadeOut(0);
$(this).closest(".tab_content").find(".list_content,.btn_thumbnail").show();
$(this).hide();
//템플릿 리스트화면에서 리스트 버튼 선택시 전체선택 버튼 숨김 처리
$('#btnAllChk').hide();
$('#formListType').val("list");
});
$(".btn_thumbnail").click(function () {
$(this).closest(".tab_content").find(".list_content").fadeOut(0);
$(this).closest(".tab_content").find(".thumbnail_content,.btn_list").show();
$(this).hide();
//템플릿 리스트화면에서 리스트 버튼 선택시 전체선택 버튼 숨김 처리 해제
$('#btnAllChk').show();
$('#formListType').val("thumbnail");
});
$(".send_fail_check").change(function () {
/*var ofsT=Math.round($(".send_top").find('.send_right').offset().top);
var pH=Math.round($(".send_top").find('.send_right .phone').outerHeight());*/
if ($(".send_fail_check").is(":checked")) {
$(".replace_send_wrap").slideDown(400);
/*var scrT=$(window).scrollTop();
var t=scrT+213;
var h=Math.round($('.send_top').find('.send_right').outerHeight());
if(t>ofsT && t-ofsT<h-pH){
$('.send_top .send_right .phone').css({'top':t-ofsT,'transition': 'none'});
}else if(t>ofsT){
$('.send_top .send_right .phone').css({'top':h-pH+213,'transition': 'top .4s linear'});
}else if(t<=ofsT){
$('.send_top .send_right .phone').attr('style','');
}*/
} else {
$(".replace_send_wrap").slideUp(400);
$('.send_top .send_right .phone').css({
'top': '0',
'transition': 'top .4s linear'
});
}
});
//강조유형 선택시 처리
$(".emphasis_select").change(function () {
if ($(this).val() == "NONE") {
//강조표기형 숨김처리 및 내용 초기화
$('.emphasis_title_text').hide();
$('.emphasis_side_text').hide();
$("#inputTemplateTitle").val("");
$("#inputTemplateSubTitle").val("");
$("#imgFile").val("");
$("#imgNm").val("");
//영역 제거하기
$(".emphasis_cont").removeClass("active");
} else if ($(this).val() == "IMAGE") {
$(".emphasis_image").addClass("active");
$(".emphasis_image").siblings(".emphasis_cont").removeClass("active");
} else if ($(this).val() == "TEXT") {
$(".emphasis_mark").addClass("active");
$(".emphasis_mark").siblings(".emphasis_cont").removeClass("active");
//첨부 이미지 정보가 있으면 지워준다.
$("#imgFile").val("");
$("#imgNm").val("");
} else {
$(".emphasis_cont").removeClass("active");
}
});
$(".kakaotalksend_cont .template_type_select").change(function () {
if ($(this).val() == "template_01") {
$(".receiver_wrap01").attr("style", "display: block !important;");
$(".receiver_wrap02").attr("style", "display: none !important;");
$(".variable_wrap").hide();
} else {
$(".receiver_wrap02").attr("style", "display: block !important;");
$(".receiver_wrap01").attr("style", "display: none !important;");
$(".variable_wrap").show();
}
});
$("input[name='img_file_add']").change(function () {
if ($("input[name='img_file_add']:checked").attr("id") == "img_file_1") {
$(".basic_img_add_wrap").show().siblings(".wide_img_add_wrap").hide();
//$(".img_file_add_wrap").show();
$(".kakao_image img").show().attr("src", "/publish/images/content/kakao_img_basic.jpg");
} else if ($("input[name='img_file_add']:checked").attr("id") == "img_file_2") {
$(".wide_img_add_wrap").show().siblings(".basic_img_add_wrap").hide();
$(".kakao_image img").show().attr("src", "/publish/images/content/kakao_img_wide.jpg");
//$(".img_file_add_wrap").show();
} else {
$(".img_add_info_wrap, .img_file_add_wrap").hide();
$(".kakao_image img").hide();
}
});
$(".friend_talk_wrap #ad_Y").click(function () {
if ($(this).is(":checked") == false) {
$(".ad_txt, .sub_ad_text p,.friend_talk_title,.kakao_block_text").hide();
$(".friend_talk_wrap .put_text_wrap .put_text").css({
"padding": "0",
"height": "calc(100% - 18px)"
});
if($(".friend_talk_wrap .replace_send_wrap .put_left").is(".short") == true){
$(".friend_talk_wrap .replace_send_wrap textarea").css({
"height": "calc(100% - 79px)"
});
}else{
$(".friend_talk_wrap .replace_send_wrap textarea").css({
"height": "calc(100% - 59px)"
});
}
} else {
$(".ad_txt, .sub_ad_text p,.friend_talk_title,.kakao_block_text").show();
$(".friend_talk_wrap .put_text_wrap .put_text").removeAttr("style");
$(".friend_talk_wrap .replace_send_wrap textarea").removeAttr("style");
}
})
/* 포토이미지 드래그 */
if ($('.thumb_wrap').length > 0) {
$('.thumb_wrap').sortable();
}
photoLayerView();
/* 카카오톡 소개 페이지 탭 */
$('.kakao_intro_cont .use ul.tabs li').click(function () {
var tab_id = $(this).attr('data-tab');
$('ul.tabs li').removeClass('current');
$('.tab-content').removeClass('current');
$(this).addClass('current');
$("#" + tab_id).addClass('current');
});
});
function photoLayerView() {
/* 그림문자 마우스 오버 시 이미지 확대 띄움 */
$(".photo_cont").mouseover(function () {
$(this).mousemove(function (e) {
//offset 사용한 이유 특정 div 영역 왼쪽상단(0,0)부터 마우스 포인터까지의 좌표 구해냄.
//+-숫자 한 이유는 포인터에 딱 붙어있어 흔들림 현상때문.
var xOffset = e.offsetX + 50;
var yOffset = e.offsetY - 150;
$(this).siblings(".hover_cont").css({
"top": yOffset,
"left": xOffset,
"display": "block"
})
})
})
//그림문자에서 마우스가 떠날 시 이미지 사라짐.
$(".photo_cont").mouseleave(function () {
$(this).siblings(".hover_cont").css({
"top": "0",
"left": "0",
"display": "none"
})
});
}
var currTabId = "";
/* tab 버튼 공통 - 단순 구조 일 때만 사용 */
function TabType(obj, tabId) {
var $tab = $(obj).closest("li");
console.log('$tab : ', $tab);
var popItem = $(obj).closest(".popup-com");
var popClass = popItem.attr("data-tooltip-con");
$tab.addClass("active");
$tab.find("button").attr("title", "선택됨");
$tab.siblings("li.tab").removeClass("active");
$tab.siblings("li.tab").find("button").removeAttr("title");
var tabCont = $tab.parent("ul").parent("div").children(".hascont");
tabId = tabId - 1;
tabCont.eq(tabId).addClass("current");
tabCont.eq(tabId).siblings("div").removeClass("current");
wrapWindowByMask(popClass);
}
/* 팝업 중앙정렬 */
function wrapWindowByMask(item) {
setTimeout(function () {
var width = $("." + item).width();
var height = $("." + item).height();
/*$("."+item).css({'left' : ($(window).width() - width) / 2, 'top' : ($(window).height() - height) / 2,'opacity':'1'});*/
$("." + item).css({
'left': ($(document).width() - width) / 2,
'top': ($(window).height() - height) / 2,
'opacity': '1'
});
}, 250);
}
// 문자보내기 tab 버튼 - send_top
function TabType1_advc(obj) {
var $tab = $(obj).closest("li");
$tab.addClass("active");
$tab.find("button").attr("title", "선택됨");
$tab.siblings("li.tab").removeClass("active");
$tab.siblings("li.tab").find("button").removeAttr("title");
}
// 문자보내기 tab 버튼 - send_top
function TabType1(obj, tabId) {
var $tab = $(obj).closest("li");
$tab.addClass("active");
$tab.find("button").attr("title", "선택됨");
$tab.siblings("li.tab").removeClass("active");
$tab.siblings("li.tab").find("button").removeAttr("title");
var $tabCn = $("#tab1_" + tabId);
$tabCn.fadeIn(0);
$tabCn.addClass("current");
// if($(".text_preview").is(".mCustomScrollbar") == true){
// $(".img_box").addClass("on_scroll_img");
// }else {$(".img_box").removeClass("on_scroll_img");}
$(".top_content").not($tabCn).removeClass("current");
$(".top_content").not($tabCn).fadeOut(0);
$(".alarm_cont").not($tabCn).removeClass("current");
$(".alarm_cont").not($tabCn).fadeOut(0);
$(".pay_cont").not($tabCn).removeClass("current");
$(".pay_cont").not($tabCn).fadeOut(0);
$(".fee_cont").not($tabCn).removeClass("current");
$(".fee_cont").not($tabCn).fadeOut(0);
currTabId = tabId;
}
// 문자보내기 tab 버튼 - send_bottom
function TabType2(obj, tabId) {
var $tab = $(obj).closest("li");
var $tabPrev = $(obj).closest("li").next("li");
$tab.addClass("active");
$tab.find("button").attr("title", "선택됨");
$tab.siblings("li.tab").removeClass("active");
$tab.siblings("li.btn_tab").removeClass("active");
$tab.siblings("li.tab").find("button").removeAttr("title");
$tab.siblings("li:not(li:first-child)").find("button").css("border-left", "1px solid #e5e5e5");
$tabPrev.find("button").css("border-left", "0");
var $tabCn = $("#tab2_" + tabId);
$tabCn.fadeIn(0);
$tabCn.addClass("current");
$(".bottom_content").not($tabCn).removeClass("current");
$(".bottom_content").not($tabCn).fadeOut(0);
$(".area_tabcont").not($tabCn).removeClass("on");
$(".area_tabcont").not($tabCn).fadeOut(0);
/*탭 이동 시 탭활성 초기화*/
/*단문, 장문문자*/
//상단 단문/장문 선택
$('.tDep1_letType a').eq(0).addClass('on');
$('.tDep1_letType a').eq(1).removeClass('on');
//하단 카테고리
$('.tab_depth3.tDep1_cateCode a').removeClass('on');
$('.tab_depth3.tDep1_cateCode a').eq(0).addClass('on');
//해시태그
$('.tab_depth4 .tDep1_hashTag a').removeClass('on');
$('.tab_depth4 .tDep1_hashTag a').eq(0).addClass('on');
/*그림문자*/
//하단 카테고리
$('.tab_depth3.tDep2_cateCode a').removeClass('on');
$('.tab_depth3.tDep2_cateCode a').eq(0).addClass('on');
//해시태그
$('.tab_depth4 .tDep2_hashTag a').removeClass('on');
$('.tab_depth4 .tDep2_hashTag a').eq(0).addClass('on');
$(".api_guide_con").not($tabCn).removeClass("current");
$(".api_guide_con").not($tabCn).fadeOut(0);
$(".api_guide_con").not($tabCn).removeClass("current");
$(".api_guide_con").not($tabCn).fadeOut(0);
currTabId = tabId;
}
// 맞춤제작 tab 버튼
function TabType4(obj, tabId) {
if (tabId == '3') {
// 비로그인인 경우 로그인하도록
if ($("#loginId").val() == null) {
//alert("로그인 후 사용이 가능합니다.");
location.href = "/web/user/login/login.do";
return false;
}
}
var $tab = $(obj).closest("li");
$tab.addClass("active");
$tab.find("button").attr("title", "선택됨");
$tab.siblings("li.tab").removeClass("active");
$tab.siblings("li.tab").find("button").removeAttr("title");
var $tabCn = $("#tab4_" + tabId);
$tabCn.fadeIn(0);
$tabCn.addClass("current");
$(".custom_content").not($tabCn).removeClass("current");
$(".custom_content").not($tabCn).fadeOut(0);
$(".adr_cont_depth2").not($tabCn).removeClass("current");
$(".adr_cont_depth2").not($tabCn).fadeOut(0);
currTabId = tabId;
}
// 마이페이지 tab 버튼
function TabType5(obj, tabId) {
var $tab = $(obj).closest("li");
$tab.addClass("active");
$tab.find("button").attr("title", "선택됨");
$tab.siblings("li.tab").removeClass("active");
$tab.siblings("li.tab").find("button").removeAttr("title");
var $tabCn = $("#tab5_" + tabId);
$tabCn.fadeIn(0);
$tabCn.addClass("current");
$(".mypage_content").not($tabCn).removeClass("current");
$(".mypage_content").not($tabCn).fadeOut(0);
$(".charg_cont").not($tabCn).removeClass("current");
$(".charg_cont").not($tabCn).fadeOut(0);
$(".adr_cont").not($tabCn).removeClass("current");
$(".adr_cont").not($tabCn).fadeOut(0);
$(".adr_cont").not($tabCn).removeClass("current");
$(".adr_cont").not($tabCn).fadeOut(0);
$(".rev_content").not($tabCn).removeClass("current");
$(".rev_content").not($tabCn).fadeOut(0);
$(".api_guide").not($tabCn).removeClass("current");
$(".api_guide").not($tabCn).fadeOut(0);
currTabId = tabId;
}
// 주소록 등록(옮기기) tab 버튼
function TabType6(obj, tabId) {
var $tab = $(obj).closest("li");
var $tabPrev = $(obj).closest("li").prev("li");
$tab.addClass("active");
$tab.find("button").attr("title", "선택됨");
$tab.siblings("li.tab").removeClass("active");
$tab.siblings("li.tab").find("button").removeAttr("title");
var $tabCn = $("#tab6_" + tabId);
$tabCn.fadeIn(0);
$tabCn.addClass("current");
$tab.siblings("li:not(li:last-child)").find("button").css("border-right", "1px solid #e5e5e5");
$tabPrev.find("button").css("border-right", "0");
$(".enroll_cont").not($tabCn).removeClass("current");
$(".enroll_cont").not($tabCn).fadeOut(0);
$(".pay_refund_cont").not($tabCn).removeClass("current");
$(".pay_refund_cont").not($tabCn).fadeOut(0);
//폰 주소록 detph2 클릭 시 depth3 첫번 째 탭으로 감
$(".enroll_cont").find(".adr_depth3").find("li").removeClass("active");
$(".enroll_cont").find(".adr_depth3").find("li").first().addClass("active");
$(".enroll_cont").find(".eleType_cont").removeClass("current");
$(".enroll_cont").find("#listTab_1").addClass("current");
currTabId = tabId;
}
// list tab 버튼
function listTab(obj, tabId) {
var $tab = $(obj).closest("li");
var $tabPrev = $(obj).closest("li").prev("li");
$tab.addClass("active");
$tab.find("button").attr("title", "선택됨");
$tab.siblings("li.tab").removeClass("active");
$tab.siblings("li.tab").find("button").removeAttr("title");
var $tabCn = $("#listTab_" + tabId);
$tabCn.fadeIn(0);
$tabCn.addClass("current");
$(".list_cont").not($tabCn).removeClass("current");
$(".list_cont").not($tabCn).fadeOut(0);
$(".eleType_cont").not($tabCn).removeClass("current");
$(".eleType_cont").not($tabCn).fadeOut(0);
currTabId = tabId;
}
// list tab2 버튼
function listTab2(obj, tabId) {
var $tab = $(obj).closest("li");
var $tabPrev = $(obj).closest("li").prev("li");
$tab.addClass("active");
$tab.find("button").attr("title", "선택됨");
$tab.siblings("li.tab").removeClass("active");
$tab.siblings("li.tab").find("button").removeAttr("title");
$tab.siblings("li:not(li:last-child)").find("button").css("border-right", "1px solid #e5e5e5");
$tabPrev.find("button").css("border-right", "0");
var $tabCn = $("#listTab2_" + tabId);
$tabCn.fadeIn(0);
$tabCn.addClass("current");
$(".price_history_cont").not($tabCn).not('.price_history_cont').removeClass("current");
$(".price_history_cont").not($tabCn).not('.price_history_cont').fadeOut(0);
$(".adpop_cont").not($tabCn).not('.price_history_cont').removeClass("current");
$(".adpop_cont").not($tabCn).not('.price_history_cont').fadeOut(0);
$(".cdpop_cont").not($tabCn).not('.price_history_cont').removeClass("current");
$(".cdpop_cont").not($tabCn).not('.price_history_cont').fadeOut(0);
currTabId = tabId;
}
// list tab3 버튼
function listTab3(obj, tabId) {
var $tab = $(obj).closest("li");
$tab.addClass("active");
$tab.find("button").attr("title", "선택됨");
$tab.siblings("li.tab").removeClass("active");
$tab.siblings("li.tab").find("button").removeAttr("title");
var $tabCn = $("#listTab3_" + tabId);
$tabCn.fadeIn(0);
$tabCn.addClass("current");
$(".download_cont").not($tabCn).removeClass("current");
$(".download_cont").not($tabCn).fadeOut(0);
currTabId = tabId;
}
// 주소록 관리 팝업
function popupTab(obj, tabId) {
var $tab = $(obj).closest("li");
var $tabPrev = $(obj).closest("li").prev("li");
$tab.addClass("active");
$tab.find("button").attr("title", "선택됨");
$tab.siblings("li.tab").removeClass("active");
$tab.siblings("li.btn_tab").removeClass("active");
$tab.siblings("li.tab").find("button").removeAttr("title");
var $tabCn = $("#popCont_" + tabId);
$tabCn.fadeIn(0);
$tabCn.addClass("current");
$tab.siblings("li:not(li:last-child)").find("button").css("border-right", "1px solid #e5e5e5");
$tabPrev.find("button").css("border-right", "0");
$(".popCont").not($tabCn).removeClass("current");
$(".popCont").not($tabCn).fadeOut(0);
currTabId = tabId;
}
// 테이블에 분류하는 tab
function tableTab(obj, tabId) {
var $tab = $(obj).closest("li");
$tab.addClass("active");
$tab.find("button").attr("title", "선택됨");
$tab.siblings("li.tab").removeClass("active");
$tab.siblings("li.btn_tab").removeClass("active");
$tab.siblings("li.tab").find("button").removeAttr("title");
var $tabCn = $("#tableCont_" + tabId);
$tabCn.fadeIn(0);
$tabCn.addClass("current");
$(".table_cont").not($tabCn).removeClass("current");
$(".table_cont").not($tabCn).fadeOut(0);
currTabId = tabId;
}
//콘텐츠 tab
function contentTab(obj, tabId) {
var $tab = $(obj).closest("li");
$tab.addClass("active");
$tab.find("button").attr("title", "선택됨");
$tab.siblings("li.tab").removeClass("active");
$tab.siblings("li.btn_tab").removeClass("active");
$tab.siblings("li.tab").find("button").removeAttr("title");
var $tabCn = $("#tab_content_" + tabId);
$tabCn.fadeIn(0);
$tabCn.addClass("current");
$(".tab_content").not($tabCn).removeClass("current");
$(".tab_content").not($tabCn).fadeOut(0);
currTabId = tabId;
}
//콘텐츠 - 발송결과 미리보기 tab
function phoneTab(obj, tabId) {
var $tab = $(obj).closest("li");
$tab.addClass("active");
$tab.find("button").attr("title", "선택됨");
$tab.siblings("li.tab").removeClass("active");
$tab.siblings("li.btn_tab").removeClass("active");
$tab.siblings("li.tab").find("button").removeAttr("title");
var $tabCn = $("#tab_phone_" + tabId);
$tabCn.fadeIn(0);
$tabCn.addClass("current");
$(".tab_phone").not($tabCn).removeClass("current");
$(".tab_phone").not($tabCn).fadeOut(0);
currTabId = tabId;
}
/* 회원가입 약관동의 list */
function clause_list(obj) {
var listBody = $(obj).parents(".clause_list_head").siblings(".clause_list_body");
if (listBody.is(":visible")) {
listBody.slideUp(250);
listBody.parents(".list_open").removeClass("on");
} else {
listBody.slideDown(250);
listBody.parents(".list_open").addClass("on");
//listBody.parents(".list_open").siblings(".list_open").find(".clause_list_body").slideUp(250);
//listBody.parents(".list_open").siblings(".list_open").removeClass("on");
}
}
/* 자주하는 질문 list */
function qnaList(item) {
var qnaAnswer = $(item).parent("li").find(".qna_answer");
if (qnaAnswer.is(":visible")) {
qnaAnswer.slideUp(450);
qnaAnswer.parent("li").removeClass("open")
qnaAnswer.prev("button").attr("title", "닫힘");
} else {
qnaAnswer.slideDown(450);
qnaAnswer.parent("li").addClass("open");
qnaAnswer.prev("button").attr("title", "열림");
qnaAnswer.parent("li.open").siblings("li").find("button").attr("title", "닫힘");
qnaAnswer.parent("li.open").siblings("li").removeClass("open")
qnaAnswer.parent("li.open").siblings("li").find(".qna_answer").slideUp(450);
}
}
/* 포토 preview 버튼 누르면 클릭한 번호로 위치 이동 */
function imgClick(num) {
//20220628추가
for (var i = 0; i <= num; i++) {
var h = $(".preiew_img .img_box").outerHeight() + 10;
h = h * num;
$(".text_preview").animate({
scrollTop: h
}, 300);
}
/*var posiTop = $(".preiew_img .img_box").eq(num).position().top;
$(".text_preview").mCustomScrollbar("scrollTo",posiTop,{
scrollInertia:300
});*/
}
/* 인쇄미리보기 클릭 시 견적서 새창 팝업 오픈 */
function showEstimate() {
//만들려는 팝업의 크기
var popup_wid = '820';
var popup_ht = '900';
//중앙 정렬을 위해 윈도우 스크린의 width,height 구하는 변수 만듦
var popup_left = (window.screen.width / 2) - (popup_wid / 2);
var popup_top = (window.screen.height / 2) - (popup_ht / 2);
window.open('estimate.html', 'a', 'width=' + popup_wid + ', height=' + popup_ht + ', left=' + popup_left + ', top=' + popup_top);
}
/* 사용내역서 클릭 시 내역서 새창 팝업 오픈 */
function showEstimate2() {
//만들려는 팝업의 크기
var popup_wid = '840';
var popup_ht = '900';
var popup_left = (window.screen.width / 2) - (popup_wid / 2);
var popup_top = (window.screen.height / 2) - (popup_ht / 2);
window.open('estimate2.html', 'a', 'width=' + popup_wid + ', height=' + popup_ht + ', left=' + popup_left + ', top=' + popup_top);
}
/* 간이영수증 클릭 시 내역서 새창 팝업 오픈 */
function showEstimate3() {
//만들려는 팝업의 크기
var popup_wid = '400';
var popup_ht = '800';
var popup_left = (window.screen.width / 2) - (popup_wid / 2);
var popup_top = (window.screen.height / 2) - (popup_ht / 2);
window.open('estimate3.html', 'a', 'width=' + popup_wid + ', height=' + popup_ht + ', left=' + popup_left + ', top=' + popup_top);
}
/* 주소록 인쇄 미리보기 팝업 */
function previewList1() {
//만들려는 팝업의 크기
var popup_wid = '870';
var popup_ht = '680';
var popup_left = (window.screen.width / 2) - (popup_wid / 2);
var popup_top = (window.screen.height / 2) - (popup_ht / 2);
window.open('previewList1.html', 'a', 'width=' + popup_wid + ', height=' + popup_ht + ', left=' + popup_left + ', top=' + popup_top);
}
/* 주소록 내보내기 인쇄 미리보기 팝업 */
function previewList2() {
//만들려는 팝업의 크기
var popup_wid = '870';
var popup_ht = '700';
var popup_left = (window.screen.width / 2) - (popup_wid / 2);
var popup_top = (window.screen.height / 2) - (popup_ht / 2);
window.open('previewList2.html', 'a', 'width=' + popup_wid + ', height=' + popup_ht + ', left=' + popup_left + ', top=' + popup_top);
}
$(function () {
if ($('.calendar').length > 0) {
calendarSetting();
}
});
function calendarSetting() {
var $input = $('.calendar02').pickadate({
format: "yyyy/mm/dd", //인풋에 표기되는 값
formatSubmit: "yyyymmdd", //전송하는 값
labelMonthNext: '다음 달 보기',
labelMonthPrev: '이전 달 보기',
min: true,
max: 365,
onOpen: function () {
// 윈도우 height 값 기준으로 달력 height 보다 위에있을 경우 팝업이 아래로 아래 있을 경우 팝업이 위로 열림
var thisCal = $(this.$holder);
if ($(window).scrollTop() + ($(window).outerHeight() / 2) > thisCal.closest('.calendar_wrap').offset().top) {
thisCal.attr('style', '').css("top", "5px");
} else {
thisCal.attr('style', '').css("bottom", "35px");
}
if (thisCal.offset().left + thisCal.outerWidth() < $(window).outerWidth()) {
var ll = thisCal.closest('.picker').prev().position().left;
thisCal.css({
'left': ll,
'right': 'initial'
});
} else {
thisCal.css({
'left': 'initial',
'right': 0
});
}
thisCal.css("display", "block");
}
});
var $input = $('.calendar').pickadate({
format: "yyyy/mm/dd", //인풋에 표기되는 값
formatSubmit: "yyyymmdd", //전송하는 값
labelMonthNext: '다음 달 보기',
labelMonthPrev: '이전 달 보기',
onOpen: function () {
// 윈도우 height 값 기준으로 달력 height 보다 위에있을 경우 팝업이 아래로 아래 있을 경우 팝업이 위로 열림
var thisCal = $(this.$holder);
if ($(window).scrollTop() + ($(window).outerHeight() / 2) > thisCal.closest('.calendar_wrap').offset().top) {
thisCal.attr('style', '').css("top", "5px");
} else {
thisCal.attr('style', '').css("bottom", "35px");
}
if (thisCal.offset().left + thisCal.outerWidth() < $(window).outerWidth()) {
var ll = thisCal.closest('.picker').prev().position().left;
thisCal.css({
'left': ll,
'right': 'initial'
});
} else {
thisCal.css({
'left': 'initial',
'right': 0
});
}
thisCal.css("display", "block");
}
});
// 달력으로 기간 정해서 검색할 경우
if ($(".startDate").length != 0) {
var $startinput = $('.startDate').pickadate({
format: "yyyy/mm/dd", //인풋에 표기되는 값
formatSubmit: "yyyymmdd", //전송하는 값
labelMonthNext: '다음 달 보기',
labelMonthPrev: '이전 달 보기',
min: false,
max: false,
onOpen: function () {
// 윈도우 height 값 기준으로 달력 height 보다 위에있을 경우 팝업이 아래로 아래 있을 경우 팝업이 위로 열림
var thisCal = $(this.$holder);
if ($(window).scrollTop() + ($(window).outerHeight() / 2) > thisCal.closest('.calendar_wrap').offset().top) {
thisCal.attr('style', '').css("top", "5px");
} else {
thisCal.attr('style', '').css("bottom", "35px");
}
if (thisCal.offset().left + thisCal.outerWidth() < $(window).outerWidth()) {
var ll = thisCal.closest('.picker').prev().position().left;
thisCal.css({
'left': ll,
'right': 'initial'
});
} else {
thisCal.css({
'left': 'initial',
'right': 0
});
}
thisCal.css("display", "block");
}
});
var startpicker = $startinput.pickadate('picker');
startpicker.on({
open: function () {
var calDate = $(this.$node).val();
var yearText = calDate.substr(0, 4);
var monthText = calDate.substr(5, 2);
var dayText = calDate.substr(8, 2);
if ($(this.$node).val() != '') {
monthText = monthText - 1;
startpicker.set("view", new Date(yearText, monthText, dayText));
startpicker.set("highlight", new Date(yearText, monthText, dayText));
} else {}
},
close: function () {
var startVal = $(".startDate").val();
var endVal = $(".endDate").val();
console.log(startVal, endVal);
endVal = endVal.replace(/[.]/gi, '');
startVal = startVal.replace(/[.]/gi, '');
if (startVal > endVal && endVal != "") {
startpicker.clear();
alert("시작일이 종료일보다 클 수 없습니다.");
} else {}
}
});
var $endinput = $('.endDate').pickadate({
format: "yyyy/mm/dd", //인풋에 표기되는 값
formatSubmit: "yyyymmdd", //전송하는 값
labelMonthNext: '다음 달 보기1111',
labelMonthPrev: '이전 달 보기',
onOpen: function () {
// 윈도우 height 값 기준으로 달력 height 보다 위에있을 경우 팝업이 아래로 아래 있을 경우 팝업이 위로 열림
var thisCal = $(this.$holder);
if ($(window).scrollTop() + ($(window).outerHeight() / 2) > thisCal.closest('.calendar_wrap').offset().top) {
thisCal.attr('style', '').css("top", "5px");
} else {
thisCal.attr('style', '').css("bottom", "35px");
}
if (thisCal.offset().left + thisCal.outerWidth() < $(window).outerWidth()) {
var ll = thisCal.closest('.picker').prev().position().left;
thisCal.css({
'left': ll,
'right': 'initial'
});
} else {
thisCal.css({
'left': 'initial',
'right': 0
});
}
thisCal.css("display", "block");
}
});
var endpicker = $endinput.pickadate('picker');
endpicker.on({
open: function () {
var calDate = $(this.$node).val();
var yearText = calDate.substr(0, 4);
var monthText = calDate.substr(5, 2);
var dayText = calDate.substr(8, 2);
if ($(this.$node).val() != '') {
monthText = monthText - 1;
endpicker.set("view", new Date(yearText, monthText, dayText));
endpicker.set("highlight", new Date(yearText, monthText, dayText));
} else {}
},
close: function () {
var startVal = $(".startDate").val();
var endVal = $(".endDate").val();
console.log(startVal, endVal);
endVal = endVal.replace(/[.]/gi, '');
startVal = startVal.replace(/[.]/gi, '');
if (endVal < startVal && startVal != "" && endVal != "") {
endpicker.clear();
alert("종료일이 시작일보다 작을 수 없습니다.");
} else {}
}
});
}
}
function fnSetDynamicCalendar() {
$(':text.startDate,:text.endDate,:text.date').each(function (i) {
$this = $(this);
if ($this.attr("data-dateControl") == undefined) {
$this.attr("data-dateControl", true);
switch ($this[0].className) {
case "startDate":
sText = "시작";
break;
case "endDate":
sText = "종료";
break;
case "date":
sText = "";
break;
default:
sText = "";
}
var sobjId = $this.attr("id");
if (!sobjId) {
$this.attr("id", $this.attr("name"));
sobjId = $this.attr("name");
}
var innerhtml = "<div class='calendarPop' id='calendarName_" + sobjId + "'>" +
"<input type='button' value='" + sText + "날짜 달력에서 선택'" +
"onclick=\"return calendarOpen('" + sobjId + "-lry','" + sText + "',this)\"/>" +
"</div>";
$this.after(innerhtml);
}
});
}
$(function () {
fnSetDynamicCalendar();
jQuery(".rv a").bind('mouseover keyup', function () {
imgOn(jQuery(this))
})
jQuery(".rv a").bind('mouseout blur', function () {
imgOff(jQuery(this))
})
})
/* //calendar */
/* 신규 script 작성 */
$(function () {
recomChecked();
tableAllChk();
});
/* 추천인 ID */
function recomChecked() {
$('td.check_num input[type=radio]').each(function () {
if ($(this).is(':checked') && $(this).next('label').text() == '없음') {
$(this).closest('td.check_num').find('>div input[type=text]').prop('disabled', true);
}
$(this).on('change', function () {
var t = $(this).next('label').text();
if (t == '없음') {
$(this).closest('td.check_num').find('>div input[type=text]').prop('disabled', true);
} else {
$(this).closest('td.check_num').find('>div input[type=text]').prop('disabled', false);
}
});
});
}
/* 테이블 전체 체크 */
function tableAllChk() {
$('.tType4').each(function () {
var target = $(this);
var thChk = target.find('thead tr th:first-child input[type=checkbox]');
var tbChk = target.find('tbody tr td:first-child input[type=checkbox]');
var len = tbChk.length;
thChk.on('change', function () {
if ($(this).is(':checked')) {
if (tbChk.attr('disabled') == false) {
tbChk.prop('checked', true);
}
} else {
tbChk.prop('checked', false);
}
});
tbChk.on('change', function () {
var chkLen = target.find('tbody tr td:first-child input[type=checkbox]:checked').length;
var chkDisLen = target.find('tbody tr td:first-child input[type=checkbox]:disabled').length;
if ((len - chkDisLen) == chkLen) {
thChk.prop('checked', true);
} else {
thChk.prop('checked', false);
}
});
});
}
/* 문자전송 핸드폰 상단 고정 */
$(window).on('load', function () {
setTimeout(function () {
if ($('.send_top .send_right .phone').length > 0) {
if (!$('.top_content').hasClass('contentExcelArea')) {
sendPhoneFixed();
}
}
}, 800);
});
function sendPhoneFixed() {
$('.send_top').each(function () {
var ofsT = Math.round($(this).find('.send_right').offset().top);
if ($(".kakaotalkset_cont .kakao_wrap").length == 1) {
var pH = Math.round($(this).find('.send_right .phone').outerHeight());
} else {
var pH = Math.round($(this).find('.send_right .phone').outerHeight() + 240);
}
var sendRightOft = Math.round($(this).find('.send_right:visible').offset().top);
$(window).on('scroll', function () {
var scrT = $(this).scrollTop();
var t = scrT + 213;
var h = Math.round($('.send_top').find('.send_right').outerHeight());
var revT = $('.send_rev').length ? Math.round($('.send_rev:visible').offset().top) : null;
if ($(".cont").find(".tabType1 .tab.active").text().trim() == "대량문자(광고문자)") {
if (t > ofsT && scrT !== 0) {
// send_rev 영역에 도달한 경우 멈춤
if (scrT + pH > revT) {
$('.send_top .send_right .phone:visible').css({
'top': revT - pH - sendRightOft + 470,
'transition': 'all 0.2s'
});
}
// 스크롤 위치에 맞춰 부드럽게 이동
else {
$('.send_top .send_right .phone:visible').css({
'top': t - sendRightOft,
'transition': 'all 0.2s'
});
}
}
// send_right 상단에 도달하면 스타일 제거
else {
$('.send_top .send_right .phone:visible').css({
'top': '0',
'transition': 'all 0.2s'
});
}
} else if ($(".cont").find(".tabType4 .tab.active").text().trim() == "알림톡") {
if (t > ofsT && t - ofsT < h - pH) {
$('.send_top .send_right .phone').css({
'top': t - ofsT,
'transition': 'all 0.2s'
});
} else if (t > ofsT) {
$('.send_top .send_right .phone').css({
'top': h - pH + 30,
'transition': 'all 0.2s'
});
} else if (t <= ofsT) {
$('.send_top .send_right .phone').css({
'top': '0',
'transition': 'all 0.2s'
});
}
} else {
if (t > ofsT && t - ofsT < h - pH) {
$('.send_top .send_right .phone').css({
'top': t - ofsT,
'transition': 'all 0.2s'
});
} else if (t > ofsT) {
$('.send_top .send_right .phone').css({
'top': h - pH,
'transition': 'all 0.2s'
});
} else if (t <= ofsT) {
$('.send_top .send_right .phone').css({
'top': '0',
'transition': 'all 0.2s'
});
}
}
});
});
}
/* 스팸팝업 내용 보기 버튼 */
function popContentBoxView(obj) {
var target = $(obj);
if (target.hasClass('active')) {
target.removeClass('active');
target.closest('.title_box').next('.content_box').stop().slideDown('200');
} else {
target.addClass('active');
target.closest('.title_box').next('.content_box').stop().slideUp('200');
}
}
/* 문자전송, 선거문자 제목 사용여부 체크 */
function titleStatus(obj) {
var v = $(obj).val();
if (v == 'Y') {
$(obj).closest('.title_wrap').find('.textbox').addClass('active');
} else {
$(obj).closest('.title_wrap').find('.textbox input:text').val('');
$(obj).closest('.title_wrap').find('.textbox').removeClass('active');
}
}
//카카오톡 알림톡 템플릿 등록 - 템플릿 유형 선택
function templateTypeSelect(type) {
var templateType = $(type).val();
var channelwrap = '<dl class="button_type_wrap template_channel_add"><dt>채널추가</dt><dd class="button_type_input"><input type="hidden" id="channelLikeType" name="channelLikeType" value="AC" readonly/><input type="text" id="btnChannelNm" name="btnChannelNm" value="채널 추가" readonly></dd></dl>';
var channelButton = '<p class="channel_info_text">채널 추가하고 이 채널의 광고와 마케팅 메시지 받기</p><button type="button" class="btn_kakao_channel"><img src="/publish/images/content/icon_kakao_channel_plus.png" alt=""> 채널추가</button>'
var sideText = '<p class="side_info_text">부가정보내용</p>';
if (templateType == "EX") {
//부가정보형
$(".template_type_cont.type1").show();
$(".template_type_cont.type1").siblings(".template_type_cont").hide();
$(".channel_info_text,.btn_kakao_channel").hide();
$(".template_channel_add").remove();
if ($(".side_info_text").length == 0) {
$(".template_text").after(sideText);
$(".template_side_text").val("");
} else {}
} else if (templateType == "AD") {
//채널추가형
$(".template_type_cont.type2,.channel_info_text,.btn_kakao_channel").show();
$(".template_type_cont.type2").siblings(".template_type_cont").hide();
$(".side_info_text").remove();
if ($(".button_add_wrap").find(".template_channel_add").length == 0) {
$(".button_add_wrap").prepend(channelwrap);
} else {}
if ($(".btn_kakao_channel").length == 0) {
$(".allimtalk_content").append(channelButton);
} else {}
} else if (templateType == "MI") {
//복합형
$(".template_type_cont.type1,.template_type_cont.type2").show();
$(".btn_kakao_channel").css("display", "block");
if ($(".side_info_text").length == 0) {
$(".template_text").after(sideText);
$(".template_side_text").val("");
} else {}
if ($(".button_add_wrap").find(".template_channel_add").length == 0) {
$(".button_add_wrap").prepend(channelwrap);
} else {}
if ($(".btn_kakao_channel").length == 0) {
$(".allimtalk_content").append(channelButton);
} else {}
} else {
//기본
$(".template_type_cont.type1,.template_type_cont.type2").hide();
$(".template_channel_add,.side_info_text,.btn_kakao_channel,.channel_info_text").remove();
$(".template_side_text").val("");
}
}
// 카카오톡 알림톡 템플릿 등록 - 버튼 추가
function templateButtonAdd() {
var buttonType = $(".template_button_select").val();
var buttonCnt = $(".button_type_wrap").length;
//버튼갯수 체크
if (buttonCnt >= 5) {
alert("버튼은 최대 5개까지만 등록가능합니다.");
return false;
}
var buttonText;
var buttonView;
//템플릿 버튼은 buttonVO의 buttonVOList 변수에 셋팅해서 넘겨주게 만들었음
if (buttonType == "button_type_0") {
alert("버튼 타입을 선택해 주세요");
return false;
}
if (buttonType == "button_type_1") {
buttonText = '<dl class="button_type_wrap type1"><dt>배송조회</dt><dd class="button_type_input"><input type="hidden" id="buttonLikeTypeDeliv" name="buttonVOList[' + buttonCnt + '].linkType" value="DS"/><input type="text" id="btnNmDeliv" name="buttonVOList[' + buttonCnt + '].name" value="배송조회" placeholder="버튼명 입력(최대 14자)" readonly><p class="cf_text">*이용가능 택배사 : KG로지스, 우체국택배,일양로지스, GTX로지스, FedEx, 경동택배, 합동택배, 롯데택배</p></dd><dd><button type="button" class="btn_del" onclick="buttonTypeDel(this);"><img src="/publish/images/btn_delete.png" alt=""></button></dd></dl>';
buttonView = '<button type="button" class="btn_kakao_type btnEmpty" id="btnViewDS">배송조회</button>';
} else if (buttonType == "button_type_2") {
buttonText = '<dl class="button_type_wrap type2"><dt>웹링크</dt><dd class="button_type_input"><ul><li><input type="hidden" id="buttonLikeTypeWeb" name="buttonVOList[' + buttonCnt + '].linkType" value="WL"/><input type="text" id="btnNmWeb" name="buttonVOList[' + buttonCnt + '].name" value="" placeholder="버튼명 입력(최대 14자)"></li><li><input type="text" id="buttonLinkMo" name="buttonVOList[' + buttonCnt + '].linkMo" value="" placeholder="모바일 링크 입력"></li><li><input type="text" id="buttonLinkPc" name="buttonVOList[' + buttonCnt + '].linkPc" value="" placeholder="PC 링크 입력"></li></ul></dd><dd><button type="button" class="btn_del" onclick="buttonTypeDel(this);"><img src="/publish/images/btn_delete.png" alt=""></button></dd></dl>';
buttonView = '<button type="button" class="btn_kakao_type btnEmpty" id="btnViewWL">웹링크</button>';
} else if (buttonType == "button_type_3") {
buttonText = '<dl class="button_type_wrap type3"><dt>앱링크</dt><dd class="button_type_input"><ul><li><input type="hidden" id="buttonLikeTypeApp" name="buttonVOList[' + buttonCnt + '].linkType" value="AL"/><input type="text" id="btnNmApp" name="buttonVOList[' + buttonCnt + '].name" value="" placeholder="버튼명 입력(최대 14자)"></li><li><input type="text" id="buttonLinkAnd" name="buttonVOList[' + buttonCnt + '].linkAnd" value="" placeholder="Android 링크 입력"></li><li><input type="text" id="buttonLinkIos" name="buttonVOList[' + buttonCnt + '].linkIos" value="" placeholder="IOS 링크 입력"></li></ul></dd><dd><button type="button" class="btn_del" onclick="buttonTypeDel(this);"><img src="/publish/images/btn_delete.png" alt=""></button></dd></dl>';
buttonView = '<button type="button" class="btn_kakao_type btnEmpty" id="btnViewAL">앱링크</button>';
} else if (buttonType == "button_type_4") {
buttonText = '<dl class="button_type_wrap type4"><dt>봇키워드</dt><dd class="button_type_input"><input type="hidden" id="buttonLikeTypeBot" name="buttonVOList[' + buttonCnt + '].linkType" value="BK"/><input type="text" id="btnNmBot" name="buttonVOList[' + buttonCnt + '].name" value="" placeholder="버튼명 입력(최대 14자)"></dd><dd><button type="button" class="btn_del" onclick="buttonTypeDel(this);"><img src="/publish/images/btn_delete.png" alt=""></button></dd></dl>';
buttonView = '<button type="button" class="btn_kakao_type btnEmpty" id="btnViewBK">봇키워드</button>';
} else if (buttonType == "button_type_5") {
buttonText = '<dl class="button_type_wrap type5"><dt>메시지전달</dt><dd class="button_type_input"><input type="hidden" id="buttonLikeTypeMsg" name="buttonVOList[' + buttonCnt + '].linkType" value="MD"/><input type="text" id="btnNmMsg" name="buttonVOList[' + buttonCnt + '].name" value="" placeholder="버튼명 입력(최대 14자)"></dd><dd><button type="button" class="btn_del" onclick="buttonTypeDel(this);"><img src="/publish/images/btn_delete.png" alt=""></button></dd></dl>';
buttonView = '<button type="button" class="btn_kakao_type btnEmpty" id="btnViewMD">메시지전달</button>';
} else if (buttonType == "button_type_6") {
buttonText = '<dl class="button_type_wrap type6"><dt>상담톡전환</dt><dd class="button_type_input"><input type="hidden" id="buttonLikeTypeCons" name="buttonVOList[' + buttonCnt + '].linkType" value="BC"/><input type="text" id="btnNmCons" name="buttonVOList[' + buttonCnt + '].name" value="" placeholder="버튼명 입력(최대 14자)"></dd><dd><button type="button" class="btn_del" onclick="buttonTypeDel(this);"><img src="/publish/images/btn_delete.png" alt=""></button></dd></dl>';
buttonView = '<button type="button" class="btn_kakao_type btnEmpty" id="btnViewBC">상담톡전환</button>';
} else if (buttonType == "button_type_7") {
buttonText = '<dl class="button_type_wrap type7"><dt>챗봇전환</dt><dd class="button_type_input"><input type="hidden" id="buttonLikeTypeBotChg" name="buttonVOList[' + buttonCnt + '].linkType" value="BT"/><input type="text" id="btnNmBotChg" name="buttonVOList[' + buttonCnt + '].name" value="" placeholder="버튼명 입력(최대 14자)"></dd><dd><button type="button" class="btn_del" onclick="buttonTypeDel(this);"><img src="/publish/images/btn_delete.png" alt=""></button></dd></dl>';
buttonView = '<button type="button" class="btn_kakao_type btnEmpty" id="btnViewBT">챗봇전환</button>';
} else {}
$(".button_add_wrap").prepend(buttonText);
$(".btnViewArea").prepend(buttonView);
}
//카카오톡 친구톡 템플릿 등록 - 버튼 추가
function friendTemplateButtonAdd() {
var buttonType = $(".template_button_select").val();
var buttonCnt = $(".button_type_wrap").length;
var imageType = $("input[name=img_file_add]:checked").val();
if (imageType == 'W') {
if (buttonCnt > 0) { //처음것 하나 추가할때는 갯수가 0으로 넘어옴.
alert("와이드 이미지 첨부시 버튼은 1개만 등록 가능합니다.");
return false;
}
}
//버튼갯수 체크
if (buttonCnt >= 5) {
alert("버튼은 최대 5개까지만 등록가능합니다.");
return false;
}
var buttonText;
var buttonView;
//템플릿 버튼은 buttonVO의 buttonVOList 변수에 셋팅해서 넘겨주게 만들었음
if (buttonType == "button_type_1") {
buttonText = '<dl class="button_type_wrap type1"><dt>배송조회</dt><dd class="button_type_input"><input type="hidden" id="buttonLikeTypeDeliv" name="buttonVOList[' + buttonCnt + '].linkType" value="DS"/><input type="text" id="btnNmDeliv" name="buttonVOList[' + buttonCnt + '].name" value="배송조회" placeholder="버튼명 입력(최대 14자)" readonly><p class="cf_text">*이용가능 택배사 : KG로지스, 우체국택배,일양로지스, GTX로지스, FedEx, 경동택배, 합동택배, 롯데택배</p></dd><dd><button type="button" class="btn_del" onclick="buttonTypeDel(this);"><img src="/publish/images/btn_delete.png" alt=""></button></dd></dl>';
buttonView = '<button type="button" class="btn_kakao_type btnEmpty" id="btnViewDS">배송조회</button>';
} else if (buttonType == "button_type_2") {
buttonText = '<dl class="button_type_wrap type2"><dt>웹링크</dt><dd class="button_type_input"><ul><li><input type="hidden" id="buttonLikeTypeWeb" name="buttonVOList[' + buttonCnt + '].linkType" value="WL"/><input type="text" id="btnNmWeb" name="buttonVOList[' + buttonCnt + '].name" value="" placeholder="버튼명 입력(최대 14자)"></li><li><input type="text" id="buttonLinkMo" name="buttonVOList[' + buttonCnt + '].linkMo" value="" placeholder="모바일 링크 입력"></li><li><input type="text" id="buttonLinkPc" name="buttonVOList[' + buttonCnt + '].linkPc" value="" placeholder="PC 링크 입력"></li></ul></dd><dd><button type="button" class="btn_del" onclick="buttonTypeDel(this);"><img src="/publish/images/btn_delete.png" alt=""></button></dd></dl>';
buttonView = '<button type="button" class="btn_kakao_type btnEmpty" id="btnViewWL">웹링크</button>';
} else if (buttonType == "button_type_3") {
buttonText = '<dl class="button_type_wrap type3"><dt>앱링크</dt><dd class="button_type_input"><ul><li><input type="hidden" id="buttonLikeTypeApp" name="buttonVOList[' + buttonCnt + '].linkType" value="AL"/><input type="text" id="btnNmApp" name="buttonVOList[' + buttonCnt + '].name" value="" placeholder="버튼명 입력(최대 14자)"></li><li><input type="text" id="buttonLinkAnd" name="buttonVOList[' + buttonCnt + '].linkAnd" value="" placeholder="Android 링크 입력"></li><li><input type="text" id="buttonLinkIos" name="buttonVOList[' + buttonCnt + '].linkIos" value="" placeholder="IOS 링크 입력"></li></ul></dd><dd><button type="button" class="btn_del" onclick="buttonTypeDel(this);"><img src="/publish/images/btn_delete.png" alt=""></button></dd></dl>';
buttonView = '<button type="button" class="btn_kakao_type btnEmpty" id="btnViewAL">앱링크</button>';
} else if (buttonType == "button_type_4") {
buttonText = '<dl class="button_type_wrap type4"><dt>봇키워드</dt><dd class="button_type_input"><input type="hidden" id="buttonLikeTypeBot" name="buttonVOList[' + buttonCnt + '].linkType" value="BK"/><input type="text" id="btnNmBot" name="buttonVOList[' + buttonCnt + '].name" value="" placeholder="버튼명 입력(최대 14자)"></dd><dd><button type="button" class="btn_del" onclick="buttonTypeDel(this);"><img src="/publish/images/btn_delete.png" alt=""></button></dd></dl>';
buttonView = '<button type="button" class="btn_kakao_type btnEmpty" id="btnViewBK">봇키워드</button>';
} else if (buttonType == "button_type_5") {
buttonText = '<dl class="button_type_wrap type5"><dt>메시지전달</dt><dd class="button_type_input"><input type="hidden" id="buttonLikeTypeMsg" name="buttonVOList[' + buttonCnt + '].linkType" value="MD"/><input type="text" id="btnNmMsg" name="buttonVOList[' + buttonCnt + '].name" value="" placeholder="버튼명 입력(최대 14자)"></dd><dd><button type="button" class="btn_del" onclick="buttonTypeDel(this);"><img src="/publish/images/btn_delete.png" alt=""></button></dd></dl>';
buttonView = '<button type="button" class="btn_kakao_type btnEmpty" id="btnViewMD">메시지전달</button>';
} else if (buttonType == "button_type_6") {
buttonText = '<dl class="button_type_wrap type6"><dt>상담톡전환</dt><dd class="button_type_input"><input type="hidden" id="buttonLikeTypeCons" name="buttonVOList[' + buttonCnt + '].linkType" value="BC"/><input type="text" id="btnNmCons" name="buttonVOList[' + buttonCnt + '].name" value="" placeholder="버튼명 입력(최대 14자)"></dd><dd><button type="button" class="btn_del" onclick="buttonTypeDel(this);"><img src="/publish/images/btn_delete.png" alt=""></button></dd></dl>';
buttonView = '<button type="button" class="btn_kakao_type btnEmpty" id="btnViewBC">상담톡전환</button>';
} else if (buttonType == "button_type_7") {
buttonText = '<dl class="button_type_wrap type7"><dt>챗봇전환</dt><dd class="button_type_input"><input type="hidden" id="buttonLikeTypeBotChg" name="buttonVOList[' + buttonCnt + '].linkType" value="BT"/><input type="text" id="btnNmBotChg" name="buttonVOList[' + buttonCnt + '].name" value="" placeholder="버튼명 입력(최대 14자)"></dd><dd><button type="button" class="btn_del" onclick="buttonTypeDel(this);"><img src="/publish/images/btn_delete.png" alt=""></button></dd></dl>';
buttonView = '<button type="button" class="btn_kakao_type btnEmpty" id="btnViewBT">챗봇전환</button>';
} else {}
$(".button_add_wrap").prepend(buttonText);
$(".btnViewArea").prepend(buttonView);
}
//관리자 카카오톡 알림톡 샘플 템플릿 등록 - 버튼 추가
function SampleTemplateButtonAdd() {
var buttonType = $(".template_button_select").val();
var buttonCnt = $(".button_type_wrap").length;
//버튼갯수 체크
if (buttonCnt >= 5) {
alert("버튼은 최대 5개까지만 등록가능합니다.");
return false;
}
var buttonText;
//템플릿 버튼은 buttonVO의 buttonVOList 변수에 셋팅해서 넘겨주게 만들었음
if (buttonType == "button_type_1") {
buttonText = '<dl class="button_type_wrap type1"><dt>배송조회</dt><dd class="button_type_input"><input type="hidden" id="buttonLikeTypeDeliv" name="buttonVOList[' + buttonCnt + '].buttonLinktype" value="DS"/><input type="text" id="btnNmDeliv" name="buttonVOList[' + buttonCnt + '].buttonName" value="" placeholder="버튼명 입력(최대 14자)"><p class="cf_text">*이용가능 택배사 : KG로지스, 우체국택배,일양로지스, GTX로지스, FedEx, 경동택배, 합동택배, 롯데택배</p></dd><dd><button type="button" class="btn_del" onclick="buttonTypeDel(this);"><img src="/publish/images/btn_delete.png" alt=""></button></dd></dl>';
} else if (buttonType == "button_type_2") {
buttonText = '<dl class="button_type_wrap type2"><dt>웹링크</dt><dd class="button_type_input"><ul><li><input type="hidden" id="buttonLikeTypeWeb" name="buttonVOList[' + buttonCnt + '].buttonLinktype" value="WL"/><input type="text" id="btnNmWeb" name="buttonVOList[' + buttonCnt + '].buttonName" value="" placeholder="버튼명 입력(최대 14자)"></li><li><input type="text" id="buttonLinkMo" name="buttonVOList[' + buttonCnt + '].buttonLinkmo" value="" placeholder="모바일 링크 입력"></li><li><input type="text" id="buttonLinkPc" name="buttonVOList[' + buttonCnt + '].buttonLinkpc" value="" placeholder="PC 링크 입력"></li></ul></dd><dd><button type="button" class="btn_del" onclick="buttonTypeDel(this);"><img src="/publish/images/btn_delete.png" alt=""></button></dd></dl>';
} else if (buttonType == "button_type_3") {
buttonText = '<dl class="button_type_wrap type3"><dt>앱링크</dt><dd class="button_type_input"><ul><li><input type="hidden" id="buttonLikeTypeApp" name="buttonVOList[' + buttonCnt + '].buttonLinktype" value="AL"/><input type="text" id="btnNmApp" name="buttonVOList[' + buttonCnt + '].buttonName" value="" placeholder="버튼명 입력(최대 14자)"></li><li><input type="text" id="buttonLinkAnd" name="buttonVOList[' + buttonCnt + '].buttonLinkand" value="" placeholder="Android 링크 입력"></li><li><input type="text" id="buttonLinkIos" name="buttonVOList[' + buttonCnt + '].buttonLinkios" value="" placeholder="IOS 링크 입력"></li></ul></dd><dd><button type="button" class="btn_del" onclick="buttonTypeDel(this);"><img src="/publish/images/btn_delete.png" alt=""></button></dd></dl>';
} else if (buttonType == "button_type_4") {
buttonText = '<dl class="button_type_wrap type4"><dt>봇키워드</dt><dd class="button_type_input"><input type="hidden" id="buttonLikeTypeBot" name="buttonVOList[' + buttonCnt + '].buttonLinktype" value="BK"/><input type="text" id="btnNmBot" name="buttonVOList[' + buttonCnt + '].buttonName" value="" placeholder="버튼명 입력(최대 14자)"></dd><dd><button type="button" class="btn_del" onclick="buttonTypeDel(this);"><img src="/publish/images/btn_delete.png" alt=""></button></dd></dl>';
} else if (buttonType == "button_type_5") {
buttonText = '<dl class="button_type_wrap type5"><dt>메시지전달</dt><dd class="button_type_input"><input type="hidden" id="buttonLikeTypeMsg" name="buttonVOList[' + buttonCnt + '].buttonLinktype" value="MD"/><input type="text" id="btnNmMsg" name="buttonVOList[' + buttonCnt + '].buttonName" value="" placeholder="버튼명 입력(최대 14자)"></dd><dd><button type="button" class="btn_del" onclick="buttonTypeDel(this);"><img src="/publish/images/btn_delete.png" alt=""></button></dd></dl>';
} else if (buttonType == "button_type_6") {
buttonText = '<dl class="button_type_wrap type6"><dt>상담톡전환</dt><dd class="button_type_input"><input type="hidden" id="buttonLikeTypeCons" name="buttonVOList[' + buttonCnt + '].buttonLinktype" value="BC"/><input type="text" id="btnNmCons" name="buttonVOList[' + buttonCnt + '].buttonName" value="" placeholder="버튼명 입력(최대 14자)"></dd><dd><button type="button" class="btn_del" onclick="buttonTypeDel(this);"><img src="/publish/images/btn_delete.png" alt=""></button></dd></dl>';
} else if (buttonType == "button_type_7") {
buttonText = '<dl class="button_type_wrap type7"><dt>챗봇전환</dt><dd class="button_type_input"><input type="hidden" id="buttonLikeTypeBotChg" name="buttonVOList[' + buttonCnt + '].buttonLinktype" value="BT"/><input type="text" id="btnNmBotChg" name="buttonVOList[' + buttonCnt + '].buttonName" value="" placeholder="버튼명 입력(최대 14자)"></dd><dd><button type="button" class="btn_del" onclick="buttonTypeDel(this);"><img src="/publish/images/btn_delete.png" alt=""></button></dd></dl>';
} else {}
$(".button_add_wrap").prepend(buttonText);
}
function buttonTypeDel(btn) {
var btnIndex = $(btn).closest(".button_type_wrap").index(); //선택한 삭제 버튼의 Index값 받아오기
//추가된 버튼 영역 삭제해주기
$(btn).closest(".button_type_wrap").remove();
//미리보기 추가된 버튼 정보 삭제처리하기
$('.btnEmpty').eq(btnIndex).remove();
}
function fn_loadAddActive() {
$('.loading_layer').addClass('active');
}
function fn_loadRemoveActive() {
$('.loading_layer').removeClass('active');
}
function fn_excelLoadAddActive() {
$('.loading_execl_layer').addClass('active');
}
function fn_excelLoadRemoveActive() {
$('.loading_execl_layer').removeClass('active');
}
// 프로그레스바
var start, change;
var progressInterval = null; // 전역 변수로 타이머 ID 관리
function progressStart(time) {
// 기존 타이머 정지 및 초기화
if (progressInterval !== null) {
clearInterval(progressInterval); // 이전 타이머 정지
progressInterval = null; // 타이머 ID 초기화
}
resetProgressBar(); // 프로그레스바 초기화
// 프로그레스바 보이기
$(".progress_bar_wrap").css("display", "flex");
// 프로그레스바 요소 가져오기
var timeText = document.querySelector(".time_text");
var bar = document.querySelector(".change_bar");
// 초기 상태 설정
var width = 1;
var totalTime = time * 1000; // 총 실행 시간 (밀리초)
var cmpWid = totalTime / 100; // width 증가 간격 (밀리초)
// 새 타이머 시작
progressInterval = setInterval(changeWidth, cmpWid);
function changeWidth() {
if (width >= 100) {
// 프로그레스바 100% 도달
clearInterval(progressInterval); // 타이머 종료
progressInterval = null; // 타이머 ID 초기화
timeText.innerHTML = "100%";
setTimeout(function () {
// 100% 표시 후 "잠시만 기다려주세요" 변경
timeText.innerHTML = "잠시만 기다려주세요...";
$(".time_text").addClass("animation");
}, 1000);
} else {
// 프로그레스바 진행
width++;
bar.style.width = width + "%";
timeText.innerHTML = width + "%";
}
}
}
// 프로그레스바 초기화 함수
function resetProgressBar() {
$(".time_text").text("0%");
$(".change_bar").css("width", "0%");
$(".time_text").removeClass("animation");
$(".progress_bar_wrap").hide();
}
// 프로그레스바 완료
function progressComplete() {
// var width = parseInt($(".time_text").text().replace('%', '')) || 0; // 현재 width 가져오기
$(".progress_bar_wrap").hide();
/*
var widthText = $(".change_bar").attr("style");
var width = widthText.replace(/[width:%;overfloen]/ig, ""); // width 값 퍼센트로 가져오기
var currentText = $(".time_text").text().trim(); // 현재 텍스트 가져오기
console.log('width : ', width, 'currentText : ', currentText);
// 이미 "100%" 상태이고 "잠시만 기다려주세요" 메시지가 표시된 경우 즉시 종료
if (width >= 100 && currentText === "잠시만 기다려주세요...") {
console.log("이미 완료 상태입니다. 즉시 종료합니다.");
$(".progress_bar_wrap").hide();
return;
}
// 진행 중인 경우
change = setInterval(() => {
if (width >= 100) {
console.log('width : ', width);
$(".time_text").text("100%");
$(".change_bar").css("width", "100%");
setTimeout(function () {
clearInterval(change); // 인터벌 종료
setTimeout(() => {
// $(".time_text").text("잠시만 기다려주세요...");
// $(".time_text").addClass("animation");
$(".progress_bar_wrap").hide();
}, 10); // "잠시만 기다려주세요..." 1초 후 숨기기
}, 1000); // "100%" 표시 후 1초 대기
} else {
// width 증가 및 text 변경
width++;
$(".time_text").text(width + "%");
$(".change_bar").css("width", width + "%");
}
}, 10); // DOM 업데이트 간격 (10ms)*/
}
/*// 프로그레스바 완료
function progressComplete() {
change = setInterval(changeText);
var width = 1;
function changeText() {
// var widthText = $(".change_bar").attr("style");
// widthText = widthText.replace(/[width:%;overfloen]/ig, ""); // width 값 퍼센트로 가져오기
if (width >= 100) {
console.log('width : ', width);
$(".time_text").text("100%");
// if(backtime>=time){
// 예상시간보다 먼저 처리됐을 경우
setTimeout(function () {
$(".time_text").text("잠시만 기다려주세요...");
$(".time_text").addClass("animation");
}, 1000)
// }else{}
$(".progress_bar_wrap").hide();
setTimeout(function () {
clearInterval(change);
}, 0);
} else {
// width 증가 및 text 변경
width++;
$(".time_text").text(width + "%");
$(".change_bar").css("width", width + "%");
}
}
clearInterval(start); // 프로그레스바 시작 멈추기
}*/