no message
parent
b5ded3a57b
commit
eb401eaf64
@ -1,145 +0,0 @@
|
||||
/**************************************************************************
|
||||
* Global Variable
|
||||
***************************************************************************/
|
||||
const innerPageMap = {},
|
||||
openMax = 8;
|
||||
|
||||
function openMenu(obj, params) {
|
||||
|
||||
let menuUrl = $(obj)[0].dataset.url;
|
||||
if(menuUrl == "javascript:void(0);"){
|
||||
return;
|
||||
}
|
||||
|
||||
let menuNm = $(obj).find("div")[0].dataset.i18n;
|
||||
|
||||
let dataKey = $(obj).parent()[0].dataset.key;
|
||||
|
||||
|
||||
|
||||
const OPEN_TAB_CNT = $('div#tabsForInnerPage > ul > li').length;
|
||||
|
||||
if(innerPageMap[dataKey]){
|
||||
// 해당 tab 활성화
|
||||
$("#tabsForInnerPage").find("ul li button.nav-link").each((idx, data) => {
|
||||
if(data.dataset.bsTarget == ("#tab-"+dataKey)) {
|
||||
$(data).trigger("click");
|
||||
}
|
||||
});
|
||||
|
||||
let innerPageObj = document.getElementById("div"+dataKey);
|
||||
return innerPageObj;
|
||||
}
|
||||
if(OPEN_TAB_CNT === openMax){
|
||||
alert(`메뉴는 최대 ${openMax -1}까지만 열 수 있습니다.`)
|
||||
return null;
|
||||
}
|
||||
|
||||
const num_tabs = OPEN_TAB_CNT + 1;
|
||||
|
||||
|
||||
let liEl = '<li id="li-'+ dataKey +'" class="nav-item">';
|
||||
let linkClass = 'nav-link';
|
||||
if(dataKey != "main"){
|
||||
linkClass += ' nav-link-closeable';
|
||||
}
|
||||
liEl +='<button type="button" data-bs-toggle="tab" data-bs-target="#tab-'+ dataKey + '" class="' + linkClass + '">' + menuNm + '</button>';
|
||||
if(dataKey != "main"){
|
||||
liEl += '<button type="button" title="닫기" class="btn btn-close" onclick="closeTab('+ dataKey + ')"></button>'
|
||||
}
|
||||
liEl += '</li>';
|
||||
$('div#tabsForInnerPage ul').append(liEl);
|
||||
|
||||
$('div#ifrTabContents').append('<div id="tab-' + dataKey + '" class="tab-pane"></div>');
|
||||
|
||||
|
||||
if(params != null){
|
||||
menuUrl = menuUrl + params;
|
||||
}
|
||||
|
||||
let dynamicPage = document.createElement("div");
|
||||
dynamicPage.setAttribute("id","div"+dataKey);
|
||||
dynamicPage.setAttribute("name","div"+dataKey);
|
||||
dynamicPage.setAttribute("title",menuNm);
|
||||
|
||||
// .attr("frameborder" , "0")
|
||||
// .attr("scrolling" , "no")
|
||||
// .attr("width" , "100%")
|
||||
// .css("border" , "0")
|
||||
// .css("height" , "100%")
|
||||
// .css("min-height" , "800px")
|
||||
// .css("overflow" , "auto")
|
||||
// .css("overflow-x" , "no")
|
||||
;
|
||||
|
||||
$("#formForInnerPage").remove();
|
||||
|
||||
|
||||
$("#tab-" + dataKey)[0].appendChild(dynamicPage);
|
||||
|
||||
|
||||
innerPageMap[dataKey] = dynamicPage;
|
||||
|
||||
|
||||
ajax.request({
|
||||
type:"POST",
|
||||
url:menuUrl,
|
||||
data:{},
|
||||
success:resp => {
|
||||
|
||||
var cw = resp.split("<!-- Content wrapper -->")[1];
|
||||
var pb = cw.split("<!-- Page Body -->")[1];
|
||||
|
||||
var scriptAterTail1 = resp.split("<!-- script after tail1 -->")[1];
|
||||
var scriptAterTail2 = resp.split("//script after tail2")[1];
|
||||
$("#div"+dataKey).html(pb + " " + scriptAterTail1 + " " + "<script>"+ scriptAterTail2 + "</script>");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
$("div#tabsForInnerPage ul li button.nav-link").last().trigger("click");
|
||||
|
||||
}
|
||||
|
||||
function closeTab(menuId) {
|
||||
if(menuId === 'main' || menuId?.id === 'main') return;
|
||||
const num_tabs = $('div#tabsForInnerPage ul li').length;
|
||||
|
||||
// click한 tab
|
||||
const selIdx = id2Index("div#tabsForInnerPage","tab-"+menuId);
|
||||
|
||||
// active tab
|
||||
let activeTab = $('div#tabsForInnerPage ul li button.nav-link').filter(".active");
|
||||
|
||||
let activeIdx = $('div#tabsForInnerPage ul li button.nav-link').index(activeTab);
|
||||
|
||||
if(selIdx === activeIdx) {
|
||||
if (num_tabs - 1 > activeIdx) {
|
||||
$('div#tabsForInnerPage ul li button.nav-link').eq(activeIdx + 1).trigger("click");
|
||||
} else {
|
||||
$('div#tabsForInnerPage ul li button.nav-link').eq(activeIdx - 1).trigger("click");
|
||||
}
|
||||
}
|
||||
|
||||
document.getElementById("div"+menuId).remove();
|
||||
delete innerPageMap[menuId];
|
||||
|
||||
$("#tab-" + activeIdx).remove();
|
||||
$('#tabsForInnerPage').find('#li-'+menuId).remove();
|
||||
}
|
||||
|
||||
function id2Index(tabsId, srcId) {
|
||||
let index = -1;
|
||||
const nls = $(tabsId).find("li > button.nav-link");
|
||||
if(nls.length > 0) {
|
||||
|
||||
nls.each((idx, nl) => {
|
||||
if (nl.dataset.bsTarget.search(srcId) > 0) {
|
||||
index = idx;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
return index;
|
||||
}
|
Loading…
Reference in New Issue