110 lines
2.8 KiB
JavaScript
110 lines
2.8 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();
|
|
|
|
var popWid = showTarget.width();
|
|
var popHei = showTarget.height();
|
|
|
|
var nLeft = (($(window).outerWidth() - popWid) / 2);
|
|
var nTop = (($(window).outerHeight() - popHei) / 2);
|
|
|
|
showTarget.css({
|
|
"left": "50%",
|
|
"top": "50%",
|
|
"transform": "translate(-50%, -50%)"
|
|
});
|
|
showTarget.find('.tooltip-close').data('activeTarget', t);
|
|
|
|
|
|
$(".mask").show();
|
|
$("body").css("overflow", "hidden");
|
|
|
|
}
|
|
|
|
function close(t) {
|
|
var activeTarget = $('[data-tooltip-con="' + t + '"]');
|
|
activeTarget.hide();
|
|
$('[data-tooltip="' + t + '"]').focus();
|
|
$(".mask").hide();
|
|
$("body").css("overflow", "inherit");
|
|
|
|
// 뉴스레터 신청 후 팝업 닫기 버튼 클릭 시
|
|
if (t == "apl_after_popup") {
|
|
close("apl_popup");
|
|
} else if (t == "cancel_after_popup") {
|
|
close("cancel_popup")
|
|
}
|
|
}
|
|
|
|
$(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;
|
|
}
|
|
|
|
e.preventDefault();
|
|
open(getTarget(e.target));
|
|
/* wrapWindowByMask(popName); */
|
|
|
|
}).on('click', closeBtn, function (e) {
|
|
e.preventDefault();
|
|
close($(this).data('activeTarget'));
|
|
})
|
|
}
|
|
|
|
$(document).ready(function () {
|
|
tooltip();
|
|
accessibilityFocus();
|
|
})
|
|
|
|
// $(window).resize(function(){
|
|
// var showTarget = $('.popup_wrap');
|
|
// var popWid = showTarget.width();
|
|
// var popHei = showTarget.height();
|
|
|
|
// var nLeft = (($(window).outerWidth() - popWid)/2);
|
|
// var nTop = (($(window).outerHeight() - popHei)/2);
|
|
|
|
// showTarget.css({
|
|
// "left": nLeft,
|
|
// "top": nTop
|
|
// });
|
|
// })
|