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

304 lines
8.9 KiB
JavaScript

// 접근성 관련 포커스 강제 이동
function accessibilityFocus() {
$(document).on('keydown', '[data-focus-prev], [data-focus-next]', function (e) {
var next = $(e.target).attr('data-focus-next'),
prev = $(e.target).attr('data-focus-prev'),
target = next || prev || false;
if (!target || e.keyCode != 9) {
return;
}
if ((!e.shiftKey && !!next) || (e.shiftKey && !!prev)) {
//setTimeout(function () {
$('[data-focus="' + target + '"]').focus();
//}, 0);
}
});
}
function tooltip() {
var openBtn = '[data-tooltip]',
closeBtn = '.tooltip-close';
function getTarget(t) {
if($(t).is('[data-tooltip]') == true){
return $(t).attr('data-tooltip');
}
else if($(t).is('[data-tooltip]') == false){
return $(t).closest("[data-tooltip]").attr('data-tooltip');
}
}
function open(t) {
var showTarget = $('[data-tooltip-con="' + t + '"]');
showTarget.show().focus();
showTarget.find('.tooltip-close').data('activeTarget', t);
}
function close(t) {
var activeTarget = $('[data-tooltip-con="' + t + '"]');
activeTarget.hide().css('opacity','0');
if (t != "rev_popup01") {
$('[data-tooltip="' + t + '"]').focus();
}
}
$(document)
.on('click', openBtn, function (e) {
// 팝업 클릭 시 data-tooltip 속성 불러오기
var popName;
if($(this).attr("type","button") == true){
popName = e.target.dataset.tooltip;
}else{
popName = e.currentTarget.dataset.tooltip;
}
if($(this).is(".tab1") == true ){
$(".history_layer .tabType6 li").eq(0).addClass("active");
$(".history_layer .tabType6 li").eq(1).removeClass("active");
$("#latestMsgArea").parent(".history_cont").addClass("current");
$("#bookMarkMsgArea").parent(".history_cont").removeClass("current");
$('.popupJunk .list_tab li').removeClass('active').eq(0).addClass('active');
$('.popupJunk .adpop_cont').removeClass('current').eq(0).addClass('current');
}else if($(this).is(".tab2") == true ){
$(".history_layer .tabType6 li").eq(1).addClass("active");
$(".history_layer .tabType6 li").eq(0).removeClass("active");
$(".history_layer .tabType6 li").eq(0).removeClass("active");
$("#bookMarkMsgArea").parent(".history_cont").addClass("current");
$("#latestMsgArea").parent(".history_cont").removeClass("current");
$('.popupJunk .list_tab li').removeClass('active').eq(1).addClass('active');
$('.popupJunk .adpop_cont').removeClass('current').eq(1).addClass('current');
}
if($(this).attr("data-tooltip") == "chat_02"){
$(".chat_01").hide();
}else{}
// // 비로그인인 경우 로그인하도록
// if(popName == "popup01"){
// // 비로그인인 경우 로그인하도록
// if($("#loginId").val() == null){
// return alert("로그인후 이용 가능합니다.");
// }
// var tabIndex = $('.tabType4').find('.active').index();
// var customId = "";
// if(tabIndex == '0'){
// $("#customPopupType").val("insert");
// $("#customType04").css("display","none");
// $("#customType05").css("display","none");
// $("input:radio[name='customType']:radio[value='01']").attr('checked', true);
// customId = "customPay01";
// }else if(tabIndex == '2'){
// $("#customPopupType").val("update");
// $("#customType01").css("display","none");
// $("#customType02").css("display","none");
// $("input:radio[name='customType']:radio[value='05']").attr('checked', true);
// customId = "customPay05";
// }
// selectPayCalculation(customId);
// }
e.preventDefault();
open(getTarget(e.target));
$("body").find(".mask").addClass("on");
$("body").css("overflow","hidden");
wrapWindowByMask(popName);
if($(e.target).closest(".popup-com").is(".popup-com") == true){
$(".mask").attr("style","z-index:101;");
$("."+popName).closest(".tooltip-wrap").attr("style","z-index:105;");
}
// 엑셀 불러오기 > 주소록 상세결과 팝업 마스크 오류 예외처리
if($("[data-tooltip-con="+popName+"]").is(".adr_detail_result")){
$(".mask").removeClass("on");
$(".adr_detail_result").before('<div class="mask on"></div>');
$("body").css("overflow","hidden");
$(".adr_detail_result").closest(".tooltip-wrap").attr("style","z-index:120;");
}
/* 주소록 대량등록, 주소롟 불러오기 팝업에 있는 테이블 스크롤바 꾸미기 */
$(".adr_pop_list2 .adr_bd_wrap").mCustomScrollbar({
axis: 'y',
scrollbarPosition: "outside",
theme: "dark",
autoHideScrollbar: false,
scrollInertia: 600,
mouseWheelPixels: 300
});
})
.on('click', closeBtn, function (e) {
e.preventDefault();
close($(this).data('activeTarget'));
//$("body").find(".mask").removeClass("on");
$("body").css("overflow","inherit");
wrapWindowByMask();
/* 맞춤문자 제작요청 팝업 재생성 이벤트 */
if($(".popup01").length != 0 && $(".add_profile_popup01").length == 0){
//카톡 채널 ID 등록 페이지에 .popup01이 있어 마스크 오류.
// 조건 추가
$("#customPopup").empty();
customPopup();
}else{}
/* 상세보기 버튼 클릭 시 레이어팝업*/
// 팝업이 보이고 있으면 마스크 노출/미노출
// 레이어 팝업 2개 뜰 경우
if($(".popup-com:visible").length < 1){
$(".mask").removeClass("on");
}else{
$(".mask").attr("style","z-index:99;");
$(".mask").addClass("on");
$("body").css("overflow","hidden");
}
if($(this).closest(".adr_layer").is(".adr_popup14") == true){
$(".mask").addClass("on");
$("body").css("overflow","hidden");
}else{}
// 결과상세에서 레이어팝업 2개 뜰 경우
if($(this).closest(".adr_layer").is(".rev_popup02") == true && $(this).closest(".adr_layer").is(".add_adr_popup") == false){
$(".mask").addClass("on");
$("body").css("overflow","hidden");
}
else{}
// 엑셀 불러오기 > 주소록 상세결과 팝업 마스크 오류 예외처리
if($(this).closest(".adr_layer").is(".adr_detail_result")){
$(".mask").removeClass("off");
$(".adr_detail_result").siblings(".mask").remove();
}
})
}
$(document).ready(function () {
tooltip();
accessibilityFocus();
/* 포토에디터 스크롤바 꾸미기 */
scrollbar();
/* 특수문자 */
//$('.tab_character a').click(function(){
$(document).on('click', '.tab_character a', function(){
var tabNum = $(this).index();
$(this).addClass("on");
$(this).siblings().removeClass("on");
$(".cnt_character").eq(tabNum).addClass("on");
$(".cnt_character").eq(tabNum).siblings().removeClass("on");
// 특수문자
$(".cnt_character").mCustomScrollbar({
axis: 'y',
scrollbarPosition: "outside",
theme: "dark",
autoHideScrollbar: false,
scrollInertia: 600,
});
});
// 메인 팝업
$(".popup_close").click(function(){
var btnNum = $(".popup_close").index(this);
//console.log(a);
$(".layer_popup").eq(btnNum).hide();
if($(".layer_popup:visible").length == 0){
$(".layer_popup_wrap").hide();
}else{}
});
});
function scrollbar(){
if($(".contWrap_scroll").length>0){
$(".contWrap_scroll").mCustomScrollbar({
axis: 'y',
scrollbarPosition: "outside",
theme: "dark",
autoHideScrollbar: false,
scrollInertia: 600,
callbacks: {
//스크롤이 생길 때
onOverflowY: function () {
$(".contWrap").addClass("on_scroll");
},
//스크롤이 없어질 때
onOverflowYNone: function () {
$(".contWrap").removeClass("on_scroll");
}
}
});
}
if($(".cnt_character").length>0){
// 특수문자
$(".cnt_character").mCustomScrollbar({
axis: 'y',
scrollbarPosition: "outside",
theme: "dark",
autoHideScrollbar: false,
scrollInertia: 600,
});
}
}
/* 문자발송 미니팝업 */
function miniPopup(item){
$(item).next("div").toggleClass("on");
$(item).parents(".btn_popup_wrap").siblings(".btn_popup_wrap").find("div").removeClass("on");
scrollbar();
if($(item).next("div").is(".spc_character") == true){
$(".cnt_character").first().addClass("on");
// $(item).next().css("z-index","9999999")
// $(item).next("div").find(".tab_character").children("a").removeClass("on");
// $(item).next("div").find(".tab_character").children("a:first-child").addClass("on");
}
if($(item).is(".btn_close") == true){
$(item).parent("div").removeClass("on");
$(item).parent("div").find("a").removeClass("on");
$(item).parent("div").find("a:first-child").addClass("on");
$(item).parent("div").find(".cnt_character").removeClass("on");
console.log($(item).parent("div"));
}
}
/* 문자발송 미니팝업 */
/*function miniPopup(item){
$(item).next(".send_miniPop").toggleClass("on");
$(item).parents(".btn_popup_wrap").siblings(".btn_popup_wrap").find("div").removeClass("on");
scrollbar();
// 특수문자 팝업 안닫힘 수정
if($(item).is(".btn_close") == true){
$(item).parent(".spc_character, .convers").removeClass("on");
}
}*/