퍼블 동기화
This commit is contained in:
@@ -2,6 +2,78 @@ etUI.utils.ready(function () {
|
||||
console.log('document ready');
|
||||
etUI.initUI();
|
||||
|
||||
// [공통] 헤더 스크롤 관련 기능
|
||||
etUI.pages.headerScroll = function () {
|
||||
const header = document.querySelector('.header');
|
||||
const modalFulls = document.querySelectorAll('.component-modal');
|
||||
|
||||
const updateHeaderClass = () => {
|
||||
if (!header) return;
|
||||
header.classList.toggle('scroll', window.scrollY > 0);
|
||||
};
|
||||
|
||||
const updateModalHeaderClass = () => {
|
||||
modalFulls.forEach(modalFull => {
|
||||
const modalContent = modalFull.querySelector('.modal-content');
|
||||
const modalHeader = modalFull.querySelector('.modal-header');
|
||||
if (modalContent && modalHeader) {
|
||||
const isScroll = modalContent.scrollTop > 0;
|
||||
modalHeader.classList.toggle('scroll', isScroll);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
etUI.hooks.useEventListener(window, 'scroll', updateHeaderClass);
|
||||
|
||||
modalFulls.forEach(modalFull => {
|
||||
const modalContent = modalFull.querySelector('.modal-content');
|
||||
if (modalContent) {
|
||||
modalContent.addEventListener('scroll', updateModalHeaderClass);
|
||||
}
|
||||
});
|
||||
|
||||
updateHeaderClass();
|
||||
};
|
||||
|
||||
// [공통] container 클래스 업데이트
|
||||
etUI.pages.updateContainerClassByLayout = function () {
|
||||
const container = document.getElementById('container');
|
||||
if (!container) return;
|
||||
|
||||
const hasFixedBtns = document.querySelector('.component-btns.fixed');
|
||||
const hasFooter = document.querySelector('footer');
|
||||
|
||||
// 조건에 맞게 클래스 추가/제거
|
||||
if (hasFixedBtns) {
|
||||
container.classList.add('btm-fixbtn');
|
||||
} else {
|
||||
container.classList.remove('btm-fixbtn');
|
||||
}
|
||||
|
||||
if (hasFooter) {
|
||||
container.classList.add('btm-footer');
|
||||
} else {
|
||||
container.classList.remove('btm-footer');
|
||||
}
|
||||
};
|
||||
|
||||
// [공통] 탭 버튼 활성화 토글
|
||||
etUI.pages.tabButtonToggle = function () {
|
||||
const tabGroups = document.querySelectorAll('.component-btns.type-tab');
|
||||
|
||||
tabGroups.forEach(group => {
|
||||
const buttons = group.querySelectorAll('.btn');
|
||||
|
||||
buttons.forEach(button => {
|
||||
button.addEventListener('click', () => {
|
||||
buttons.forEach(btn => btn.classList.remove('active'));
|
||||
|
||||
button.classList.add('active');
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
// [공통] 스위치 체크 스타일
|
||||
etUI.pages.initSwitchStyleToggle = function () {
|
||||
const switches = document.querySelectorAll('.switch-inner input[type="checkbox"]');
|
||||
@@ -111,47 +183,9 @@ etUI.utils.ready(function () {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// all(전체선택)
|
||||
document.querySelectorAll('.component-select .select-box.all').forEach(allBox => {
|
||||
allBox.addEventListener('click', function (e) {
|
||||
const selectBox = e.target.closest('.component-select').querySelector('.select-box');
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
// active 상태면 이벤트x
|
||||
if (this.classList.contains('active')) return;
|
||||
|
||||
// all 버튼 제외한 나머지 셀렉트박스 텍스트 초기화
|
||||
document.querySelectorAll('.component-select .select-box').forEach(activeBox => {
|
||||
if (allBox) {
|
||||
const selectTxt = activeBox.querySelector('.select-txt');
|
||||
if (selectTxt) {
|
||||
selectTxt.textContent = '';
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Selectbox.js의 removeAllActiveClass 함수 사용
|
||||
selectBoxComp.removeAllActiveClass(defaultTexts);
|
||||
|
||||
// all 버튼에 active 클래스 추가 (직접 구현)
|
||||
if (this) {
|
||||
this.classList.add('active');
|
||||
}
|
||||
activeSelectBox = this;
|
||||
|
||||
// all일 경우 옵션 숨기기
|
||||
const options = this.closest('.component-select').querySelector('.select-options');
|
||||
if (options) {
|
||||
options.style.display = 'none';
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
// [공통] 직접 입력 option 선택 시 input 표시
|
||||
// [공통] option 선택 시 매칭되는 input 표시
|
||||
etUI.pages.initDirectInputToggle = function () {
|
||||
const selectGroups = document.querySelectorAll('.select-group');
|
||||
|
||||
@@ -159,17 +193,18 @@ etUI.utils.ready(function () {
|
||||
const select = group.querySelector('.component-select');
|
||||
const selectBox = select.querySelector('.select-box');
|
||||
const options = select.querySelectorAll('.option');
|
||||
const directInput = group.querySelector('.component-input');
|
||||
const inputs = group.querySelectorAll('.component-input');
|
||||
|
||||
// 직접입력 input이 없다면 skip
|
||||
if (!directInput) return;
|
||||
|
||||
// 직접입력 input 기본 숨김
|
||||
directInput.style.display = 'none';
|
||||
// 모든 input 기본 숨김
|
||||
inputs.forEach(input => {
|
||||
input.style.display = 'none';
|
||||
});
|
||||
|
||||
const updateVisibility = (selectedText) => {
|
||||
const isDirect = selectedText === '직접 입력';
|
||||
directInput.style.display = isDirect ? '' : 'none';
|
||||
inputs.forEach(input => {
|
||||
const matchValue = input.getAttribute('data-option');
|
||||
input.style.display = matchValue === selectedText ? '' : 'none';
|
||||
});
|
||||
};
|
||||
|
||||
// 초기 상태 설정
|
||||
@@ -187,10 +222,41 @@ etUI.utils.ready(function () {
|
||||
});
|
||||
};
|
||||
|
||||
// [공통] appbar 아이콘 활성화
|
||||
etUI.pages.activeAppbarOnPath = function () {
|
||||
const appbar = document.querySelector('.footer-menu');
|
||||
const currentPath = window.location.pathname;
|
||||
|
||||
if (!appbar) return;
|
||||
|
||||
appbar.querySelectorAll('.active').forEach(el => el.classList.remove('active'));
|
||||
|
||||
// 경로와 클래스 매핑
|
||||
const pathMap = {
|
||||
'/pages/ACCO': 'menu-acco',
|
||||
'/pages/REGI': 'menu-regi',
|
||||
'/pages/STAT': 'menu-stat',
|
||||
'/pages/INFO': 'menu-info',
|
||||
};
|
||||
|
||||
// 경로에 해당하는 앱바 아이콘 활성화
|
||||
for (const [path, className] of Object.entries(pathMap)) {
|
||||
if (currentPath.includes(path)) {
|
||||
const targetElement = appbar.querySelector(`.${className}`);
|
||||
if (targetElement) targetElement.classList.add('active');
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
document.fonts.ready.then(() => {
|
||||
etUI.pages.initSwitchStyleToggle();
|
||||
etUI.pages.initPriceInputComma();
|
||||
etUI.pages.radioSelectbox();
|
||||
etUI.pages.initDirectInputToggle();
|
||||
etUI.pages.updateContainerClassByLayout();
|
||||
etUI.pages.activeAppbarOnPath();
|
||||
etUI.pages.headerScroll();
|
||||
etUI.pages.tabButtonToggle();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user