common_m.js 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843
  1. /* * * * * * * * * * * * * * * * * * * * * * *
  2. 1. Init (초기설정)
  3. * * * * * * * * * * * * * * * * * * * * * */
  4. window.addEventListener('load', function(){
  5. setTimeout(scrollTo, 0, 0, 1);
  6. }, false);
  7. // 210819_ touch, scroll event
  8. var xScrStart, yScrStart = 0;
  9. document.addEventListener('touchstart', function(e) {
  10. xScrStart = e.touches[0].scrareaX;
  11. yScrStart = e.touches[0].scrareaY;
  12. });
  13. document.addEventListener('touchmove', function(e) {
  14. var xMovement = Math.abs(e.touches[0].scrareaX - xScrStart);
  15. var yMovement = Math.abs(e.touches[0].scrareaY - yScrStart);
  16. if((yMovement * 3) > xMovement) {
  17. e.preventDefault();
  18. }
  19. });
  20. $(document).ready(function() {
  21. // 웹페이지가 브라우징된 후 주소창 제거
  22. window.addEventListener("load", function () {
  23. setTimeout(scrollTo, 0, 0, 1);
  24. }, false);
  25. //210608_히스토리백 스크립트
  26. $(".btn_back").on("click", function () {
  27. history.back();
  28. });
  29. //210819_상품상세 히스토리백(팝업닫기) 스크립트
  30. $(".pd+.btn_back").on("click", function () {
  31. $("[class*='_pop']").not("[class*='popup_wrap']").not("[class*='_pop_container']").css('display', 'none');
  32. });
  33. //1.쿠키세팅
  34. function setCookie(cookieName, value, exdays){
  35. var exdate = new Date();
  36. exdate.setDate(exdate.getDate() + exdays);
  37. var cookieValue = escape(value) + ((exdays==null) ? "" : "; expires=" + exdate.toGMTString());
  38. document.cookie = cookieName + "=" + cookieValue;
  39. }
  40. function deleteCookie(cookieName){
  41. var expireDate = new Date();
  42. expireDate.setDate(expireDate.getDate() - 1);
  43. document.cookie = cookieName + "= " + "; expires=" + expireDate.toGMTString();
  44. }
  45. function getCookie(cookieName) {
  46. cookieName = cookieName + '=';
  47. var cookieData = document.cookie;
  48. var start = cookieData.indexOf(cookieName);
  49. var cookieValue = '';
  50. if(start != -1){
  51. start += cookieName.length;
  52. var end = cookieData.indexOf(';', start);
  53. if(end == -1)end = cookieData.length;
  54. cookieValue = cookieData.substring(start, end);
  55. }
  56. return unescape(cookieValue);
  57. }
  58. //2. 쿠키설정
  59. var category = getCookie("category"); //setCookie("category")로 세팅한 category 변수 명
  60. var scrollPoint = getCookie("scrollPoint"); //setCookie("scrollPoint")로 세팅한 스크롤 위치
  61. var currentCategory = "mainScrollPoint"; //이벤트 발생 후 새로 로드된 현재 페이지의 카테고리 지정
  62. //3.스크롤 값 가져오기
  63. $('a').on("click", function(){
  64. if($(this).attr('href').indexOf('html') !== -1){
  65. var scrollPoint = (document.documentElement && document.documentElement.scrollTop) || document.body.scrollTop;
  66. setCookie("category", "mainScrollPoint"); // 쿠키에서 사용할 category에 사용자 정의 카테고리명 세팅
  67. setCookie("scrollPoint", scrollPoint); // 쿠키에 스크롤 위치 세팅
  68. }
  69. });
  70. //4. 뒤로가기 시 이전페이지 스크롤 이동
  71. window.onpageshow = function(event) {
  72. if ( event.persisted || (window.performance && window.performance.navigation.type == 2)) {
  73. // Back Forward Cache로 브라우저가 로딩될 경우 혹은 브라우저 뒤로가기 했을 경우
  74. if (category != "" && category != 'undefined'
  75. && category == currentCategory && scrollPoint != "" && scrollPoint != 'undefined') {
  76. $('html').animate({scrollTop : scrollPoint}, 400);
  77. }
  78. setCookie("category", "");
  79. setCookie("scrollPoint", "");
  80. }
  81. };
  82. // goTop, header (스크롤 인식)
  83. $(".btn_top").click(function () {
  84. $("html, body").animate({
  85. "scrollTop": 0
  86. }, 50);
  87. $("[class*='pop']").animate({
  88. "scrollTop": 0
  89. }, 50);
  90. });
  91. $(window).scroll(function (event) {
  92. if ($(window).scrollTop() > $("header").height()) {
  93. $(".btn_top").animate({
  94. "opacity": 1
  95. }, 50);
  96. $("footer .btn_back").animate({
  97. "opacity": 1
  98. }, 50);
  99. } else {
  100. $(".btn_top").animate({
  101. "opacity": 0
  102. }, 50);
  103. $("footer .btn_back").animate({
  104. "opacity": 0
  105. }, 50);
  106. }
  107. });
  108. // items like on/off
  109. $(document).on('click','.itemLike',function(){
  110. $(this).toggleClass("likeit");
  111. });
  112. });
  113. /* * * * * * * * * * * * * * * * * * * * * * *
  114. 2. Utility (유틸리티)
  115. * * * * * * * * * * * * * * * * * * * * * */
  116. // FORM
  117. // input-File-Add
  118. $(document).ready(function() {
  119. if (window.File && window.FileList && window.FileReader) {
  120. $("#fileAdd").on("change", function(e) {
  121. var files = e.target.files,
  122. filesLength = files.length;
  123. console.log(filesLength);
  124. var cmtLa = $('.form_field .imgUpload label');
  125. var cmtIn = $('.form_field .imgUpload input');
  126. var myrvLa = $('.form_field .imgUpload label');
  127. var myrvIn = $('.form_field .imgUpload input');
  128. for (var i = 0; i < filesLength; i++) {
  129. var f = files[i]
  130. var fileReader = new FileReader();
  131. fileReader.onload = (function(e) {
  132. var file = e.target;
  133. console.log(file);
  134. $("<span class=\"pics\">" +
  135. "<img class=\"picsThumbs\" src=\"" + e.target.result + "\" title=\"" + file.name + "\"/>" +
  136. "<br/><span class=\"removes\">Removes image</span>" +
  137. "</span>").insertBefore(".fileAdd");
  138. $(".removes").click(function(){
  139. $(this).parent(".pics").closest(".imgUpload").children("input").val("");
  140. $(this).parent(".pics").remove();
  141. cmtLa.css('display', 'block');
  142. cmtIn.css('display', 'block');
  143. myrvLa.css('display', 'block');
  144. myrvIn.css('display', 'block');
  145. $('#fileAdd').removeAttr("disabled");
  146. });
  147. });
  148. fileReader.readAsDataURL(f);
  149. var maxFileLength = 10; /* 최대 파일 갯수를 입력해 주세요 */
  150. var imgFiles=$('.imgUpload .pics');
  151. if (imgFiles.length >= maxFileLength-1) {
  152. $('#fileAdd').attr("disabled",true);
  153. cmtLa.css('display', 'none');
  154. cmtIn.css('display', 'none');
  155. myrvLa.css('display', 'none');
  156. myrvIn.css('display', 'none');
  157. } else if(imgFiles.length < maxFileLength){
  158. $('#fileAdd').removeAttr("disabled");
  159. }
  160. }
  161. });
  162. } else {
  163. alert("브라우저가 File API를 지원하지 않습니다.")
  164. }
  165. });
  166. //210514_ 수정 : 파일첨부가 최대 2개일 경우 스크립트 수정.
  167. // input-File-Adds
  168. $(document).ready(function() {
  169. if (window.File && window.FileList && window.FileReader) {
  170. $("#fileAdds").on("change", function(e) {
  171. var files = e.target.files,
  172. filesLength = files.length;
  173. var cmtLa = $('.form_field .imgUpload label');
  174. for (var i = 0; i < filesLength; i++) {
  175. var f = files[i]
  176. var fileReader = new FileReader();
  177. fileReader.onload = (function(e) {
  178. var file = e.target;
  179. $("<span class=\"pics\">" +
  180. "<img class=\"picsThumbs\" src=\"" + e.target.result + "\" title=\"" + file.name + "\"/>" +
  181. "<br/><span class=\"removes\">Removes image</span>" +
  182. "</span>").insertBefore(".fileAdd");
  183. $(".removes").click(function(){
  184. cmtLa.css('display', 'block');
  185. $(this).parent(".pics").closest(".imgUpload").children("input").val("");
  186. $(this).parent(".pics").remove();
  187. $('#fileAdds').removeAttr("disabled");
  188. });
  189. });
  190. fileReader.readAsDataURL(f);
  191. var maxFileLength = 2; /* 최대 파일 갯수를 입력해 주세요 */
  192. var imgFiles=$('.imgUpload .pics');
  193. if (imgFiles.length >= maxFileLength-1) {
  194. $('#fileAdds').attr("disabled",true);
  195. cmtLa.css('display', 'none');
  196. } else if(imgFiles.length < maxFileLength){
  197. $('#fileAdds').removeAttr("disabled");
  198. }
  199. }
  200. });
  201. } else {
  202. alert("브라우저가 File API를 지원하지 않습니다.")
  203. }
  204. });
  205. // check-All
  206. $( document ).ready(function() {
  207. var $chkAll = $('.check-all');
  208. $chkAll.change(function () {
  209. var checked = $(this).prop('checked');
  210. $('input[name="dd"]').prop('checked', checked);
  211. });
  212. var ddChk = $('input[name="dd"]');
  213. ddChk.change(function () {
  214. var ddChkLength = ddChk.length;
  215. var checkedLength = $('input[name="dd"]:checked').length;
  216. var selectAll = (ddChkLength == checkedLength);
  217. $chkAll.prop('checked', selectAll);
  218. });
  219. });
  220. // Select-Combo-Custom
  221. function sCombo(selector){
  222. this.$selectBox = null,
  223. this.$select = null,
  224. this.$list = null,
  225. this.$listLi = null;
  226. sCombo.prototype.init = function(selector){
  227. this.$selectBox = $(selector);
  228. this.$select = this.$selectBox.find('.combo .select');
  229. this.$list = this.$selectBox.find('.combo .list');
  230. this.$listLi = this.$list.children('li');
  231. }
  232. sCombo.prototype.initEvent = function(e){
  233. var that = this;
  234. this.$select.on('click', function(e){
  235. that.listOn();
  236. });
  237. this.$listLi.on('click', function(e){
  238. that.listSelect($(this));
  239. });
  240. $(document).on('click', function(e){
  241. that.listOff($(e.target));
  242. });
  243. }
  244. sCombo.prototype.listOn = function(){
  245. this.$selectBox.toggleClass('on');
  246. if(this.$selectBox.hasClass('on')){
  247. this.$list.css('display', 'block');
  248. }else{
  249. this.$list.css('display', 'none');
  250. };
  251. }
  252. sCombo.prototype.listSelect = function($target){
  253. $target.addClass('selected').siblings('li').removeClass('selected');
  254. this.$selectBox.removeClass('on');
  255. this.$select.html($target.html());
  256. this.$list.css('display', 'none');
  257. }
  258. sCombo.prototype.listOff = function($target){
  259. if(!$target.is(this.$select) && this.$selectBox.hasClass('on')){
  260. this.$selectBox.removeClass('on');
  261. this.$list.css('display', 'none');
  262. };
  263. }
  264. this.init(selector);
  265. this.initEvent();
  266. };
  267. // selectBrand on/off
  268. $( document ).ready( function() {
  269. $("#selectBrand .brandbox input").on("click", function() {
  270. $("#selectBrand .brandbox input").removeClass("on");
  271. $(this).addClass("on");
  272. });
  273. });
  274. /* alert */
  275. $(function(){
  276. $('.alertCls').click(function(){
  277. setTimeout(function(){
  278. $('.alert').css('animation', 'none');
  279. $('.alert').css('display', 'none');
  280. $('.once').css('display', 'none');
  281. }, 300);
  282. // uifn_currCallback();
  283. });
  284. });
  285. /* * * * * * * * * * * * * * * * * * * * * * *
  286. 2. Page Setting (페이지세팅)
  287. * * * * * * * * * * * * * * * * * * * * * */
  288. $(document).ready(function () {
  289. //210525_마우스 휠을 스크롤 이벤트로 변경 및 3가지 경우의 수 헤더 정리
  290. var lastScrollTop = 0;
  291. $(window).scroll(function (event) {
  292. //경우1 : only htopMain
  293. if($('section').is('#htopMain') === true && $('div').is('#gnb') === false){
  294. var commonSt = $(this).scrollTop();
  295. if (commonSt > lastScrollTop) {
  296. $("header").css('display', 'none');
  297. $("header").css('position', 'fixed');
  298. $(".tabbar").removeClass("fixed");
  299. } else {
  300. $("header").css('display', 'block');
  301. $("header").css('position', 'fixed');
  302. $(".tabbar").addClass("fixed");
  303. }
  304. lastScrollTop = commonSt;
  305. //경우2 : htopMian + gnb
  306. } else if($('section').is('#htopMain') === true && $('div').is('#gnb') === true) {
  307. var commonSt = $(this).scrollTop();
  308. if (commonSt > lastScrollTop) {
  309. $("header").css('display', 'none');
  310. $("header").css('position', 'fixed');
  311. $("#gnb").css('display', 'block');
  312. $("#gnb").css('position', 'fixed');
  313. $("#gnb").css('top', '0');
  314. $(".tabbar").removeClass("fixed");
  315. $("section.content, section.main, .bnrtype_banner").addClass('scr');
  316. } else {
  317. $("header").css('display', 'block');
  318. $("header").css('position', 'fixed');
  319. $("#gnb").css('display', 'block');
  320. $("#gnb").css('position', 'fixed');
  321. $("#gnb").css('top', '55px');
  322. $(".tabbar").addClass("fixed");
  323. $("section.content, section.main, .bnrtype_banner").removeClass('scr');
  324. }
  325. if(commonSt < 170){
  326. $("header").css('display', 'block');
  327. $("header").css('position', 'fixed');
  328. $("#gnb").css('display', 'block');
  329. $("#gnb").css('position', 'fixed');
  330. $("#gnb").css('top', '55px');
  331. $(".tabbar").addClass("fixed");
  332. $("section.content, section.main, .bnrtype_banner").removeClass('scr');
  333. }
  334. lastScrollTop = commonSt;
  335. //경우3 : only htopSub
  336. } else {
  337. var commonSt = $(this).scrollTop();
  338. $("header").css('display', 'block');
  339. $("header").css('position', 'fixed');
  340. if (commonSt > lastScrollTop) {
  341. $(".tabbar").removeClass("fixed");
  342. } else {
  343. $(".tabbar").addClass("fixed");
  344. }
  345. if(commonSt < 10){
  346. $(".tabbar").addClass("fixed");
  347. }
  348. lastScrollTop = commonSt;
  349. }
  350. //210701_ 추가 : 전시 리스트 일정 스크롤 이동시, 분류 고정.
  351. if($(".dp .dp_list .list_content").length){
  352. var winScrollTop= $(window).scrollTop();
  353. var dpListTop = $(".dp .dp_list .list_content").offset().top - 55;
  354. if (winScrollTop > dpListTop){
  355. $('.dp .count_wrap').addClass('fixed');
  356. $('.dp .dp_list .list_content').css({'paddingTop':'5.6rem'});
  357. } else {
  358. $('.dp .count_wrap').removeClass('fixed');
  359. $('.dp .dp_list .list_content').css({'paddingTop':'0'});
  360. }
  361. };
  362. // 210813_ 추가 : 검색 결과 스크롤 이동 시, 필터 고정
  363. if($(".sch .sch_result .count_wrap").length){
  364. // var winScrollTop2= ;
  365. var schListTop = $(".sch .sch_result .count_wrap").offset().top - 60;
  366. if ($(window).scrollTop() > schListTop){
  367. $('.sch .sch_result .count_wrap').addClass('fixed');
  368. } else {
  369. $('.sch .sch_result .count_wrap').removeClass('fixed');
  370. }
  371. };
  372. })
  373. window.onload = function() {
  374. setTimeout (function () {
  375. scrollTo(0,0);
  376. },1);
  377. }
  378. // GNB
  379. $(".btn_gnb").on("click", function () {
  380. $(this).toggleClass("on");
  381. $(".hmenu").toggleClass("on");
  382. $("body").toggleClass("gnb_on");
  383. });
  384. // GNB
  385. $(".btn_gnbs").on("click", function () {
  386. $(this).toggleClass("on");
  387. $(".hmenus").toggleClass("on");
  388. $("body").toggleClass("gnb_on");
  389. });
  390. $(".gnb .d1 > .folder > a").on("click", function () {
  391. var d2_H = $(this).siblings(".d2").children("li").length * 39;
  392. if ( $(this).parent().hasClass("on") ) {
  393. $(this).siblings(".d2").animate({
  394. "height": 0, "padding-top": 0, "padding-bottom": 0
  395. }, 500 , function() {
  396. $(this).siblings(".d2").hide();
  397. $(this).parent().removeClass("on");
  398. });
  399. } else {
  400. $(this).parent().addClass("on");
  401. $(this).siblings(".d2").show().animate({
  402. "height": d2_H+"px", "padding-top": "20px", "padding-bottom": "20px"
  403. }, 500);
  404. }
  405. });
  406. $(".gnb .d2 > .folder > a").on("click", function () {
  407. var d3_H = $(this).siblings(".d3").children("li").length * 36;
  408. if ( $(this).parent().hasClass("on") ) {
  409. $(this).siblings(".d3").animate({
  410. "height": 0, "padding-bottom": 0
  411. }, 500 , function() {
  412. $(this).siblings(".d3").hide();
  413. $(this).parent().removeClass("on");
  414. });
  415. } else {
  416. $(this).parent().addClass("on");
  417. $(this).siblings(".d3").show().animate({
  418. "height": d3_H+"px", "padding-bottom": "10px"
  419. }, 500);
  420. $(this).parent().parent(".d2").css({"height":"auto"})
  421. }
  422. });
  423. // CNB (Media)
  424. $(".cnb .btn_cnb").on("click", function () {
  425. var cate_H = $(this).siblings("ul").height()+70;
  426. if ( $(this).parent(".cnb").hasClass("on") ) {
  427. $(this).parent(".cnb").animate({
  428. "height": "50px"
  429. }, 500);
  430. $(this).parent().removeClass("on");
  431. } else {
  432. $(this).parent().addClass("on");
  433. $(this).parent(".cnb").animate({
  434. "height": cate_H+"px"
  435. }, 500);
  436. }
  437. });
  438. $(".cnb .list_cate button").on("click", function () {
  439. if ( $(this).hasClass("btn_all") ) {
  440. $(".list_cate button").removeClass("on");
  441. $(this).addClass("on");
  442. } else {
  443. $(".list_cate .btn_all").removeClass("on");
  444. $(this).toggleClass("on");
  445. }
  446. });
  447. // infos
  448. $(".btn_infos").click(function () {
  449. $(this).toggleClass("on");
  450. $(".infos").toggleClass("on");
  451. });
  452. // slide main
  453. var swiper_m1 = new Swiper(".m1 .slide", {
  454. loop: true,
  455. autoplay: {
  456. delay: 3500,
  457. disableOnInteraction: false,
  458. },
  459. pagination: {
  460. el: ".swiper-pagination-m1",
  461. clickable: true,
  462. renderBullet: function (index, className) {
  463. return '<i class="' + className + '"> 0' + (index + 1) + '</i>';
  464. },
  465. },
  466. });
  467. $(".swiper-button-pause").click(function () {
  468. swiper_m1.autoplay.stop();
  469. $(this).hide();
  470. $(this).siblings(".swiper-button-play").show();
  471. });
  472. $(".swiper-button-play").click(function () {
  473. swiper_m1.autoplay.start();
  474. $(this).hide();
  475. $(this).siblings(".swiper-button-pause").show();
  476. });
  477. // slide sub
  478. var swiper_lnbNav = new Swiper(".lnb", {
  479. slidesPerView: "auto",
  480. spaceBetween: 20,
  481. autoHeight: true,
  482. preventClicks: true,
  483. preventClicksPropagation: false,
  484. observer: true,
  485. observeParents: true
  486. });
  487. var $lnbItem = $('.lnb .swiper-wrapper .swiper-slide a');
  488. $lnbItem.click(function(){
  489. var target = $(this).parent();
  490. $lnbItem.parent().removeClass('on')
  491. target.addClass('on');
  492. muCenter(target);
  493. })
  494. function muCenter(target){
  495. var snbwrap = $('.lnb .swiper-wrapper');
  496. var targetPos = target.position();
  497. var box = $('.lnb');
  498. var boxHarf = box.width()/2;
  499. var pos;
  500. var listWidth=0;
  501. snbwrap.find('.swiper-slide').each(function(){ listWidth += $(this).outerWidth(); })
  502. var selectTargetPos = targetPos.left + target.outerWidth()/2;
  503. if (selectTargetPos <= boxHarf) { // left
  504. pos = 0;
  505. }else if ((listWidth - selectTargetPos) <= boxHarf) { //right
  506. pos = listWidth-box.width();
  507. }else {
  508. pos = selectTargetPos - boxHarf;
  509. }
  510. setTimeout(function(){snbwrap.css({
  511. "transform": "translate3d("+ (pos*-2) +"px, 0, 0)",
  512. "transition-duration": "500ms"
  513. })}, 200);
  514. }
  515. var swiper_subTab = new Swiper(".slideWrap", {
  516. autoHeight: true,
  517. thumbs: {
  518. swiper: swiper_lnbNav,
  519. },
  520. });
  521. var swiper_me1 = new Swiper(".me1_pop .slide", {
  522. loop: false,
  523. slidesPerView: "auto",
  524. centeredSlides: true,
  525. spaceBetween: 20,
  526. pagination: {
  527. el: ".swiper-pagination-me1",
  528. type: "progressbar",
  529. },
  530. });
  531. var swiper_b1 = new Swiper(".b1 .slide", {
  532. loop: true,
  533. autoplay: {
  534. delay: 3500,
  535. disableOnInteraction: false,
  536. },
  537. pagination: {
  538. el: ".swiper-pagination-b1",
  539. type: 'fraction',
  540. },
  541. });
  542. $(".swiper-button-pause-b1").click(function () {
  543. swiper_b1.autoplay.stop();
  544. $(this).hide();
  545. $(this).siblings(".swiper-button-play-b1").show();
  546. });
  547. $(".swiper-button-play-b1").click(function () {
  548. swiper_b1.autoplay.start();
  549. $(this).hide();
  550. $(this).siblings(".swiper-button-pause-b1").show();
  551. });
  552. // toggleBox (윤리경영)
  553. $(".list_cate > li dl dt > button").on("click", function () {
  554. var li = $(this).parent().parent().parent("li").index();
  555. if ($(this).parent().parent().parent("li").hasClass("on")) {
  556. $(this).parent().parent().parent("li").removeClass("on");
  557. $(this).parent().parent().parent().parent().siblings(".cate").children("li").eq(li).find("button").removeClass("on");
  558. } else {
  559. $(this).parent().parent().parent("li").siblings().removeClass("on");
  560. $(this).parent().parent().parent("li").addClass("on");
  561. $(this).parent().parent().parent().parent().siblings(".cate").children("li").find("button").removeClass("on");
  562. $(this).parent().parent().parent().parent().siblings(".cate").children("li").eq(li).find("button").addClass("on");
  563. }
  564. });
  565. // media play
  566. $(".btn_play").on("click", function(e) {
  567. e.stopPropagation();
  568. });
  569. // 구매하기팝업
  570. // pop open
  571. function popOpenScroll(){
  572. $('html, body').css({'overflow': 'hidden', 'height': '100%'});
  573. $('#element').on('scroll touchmove mousewheel', function(event) { // 터치무브, 휠 스크롤 방지
  574. event.preventDefault();
  575. event.stopPropagation();
  576. return false;
  577. });
  578. }
  579. // pop close
  580. function popClsScroll(){
  581. $('html, body').css({'overflow': 'auto', 'height': '100%'}); //n 해제
  582. $('#element').off('scroll touchmove mousewheel'); // 터치무브, 휠 스크롤 가능
  583. return false;
  584. }
  585. // popup (media)
  586. $(".btn_popOpen").on("click", function(e) {
  587. popOpenScroll();
  588. $(".popup").fadeIn();
  589. swiper_me1.update();
  590. return false;
  591. });
  592. $(".popup .btn_popClose").on("click", function(e) {
  593. popClsScroll();
  594. $(".popup").fadeOut();
  595. return false;
  596. });
  597. $(".btn_popOpen_mov, .btn_popOpen_mov .btn_play").on("click", function(e) {
  598. $(".me1_popMov").fadeIn();
  599. return false;
  600. });
  601. $(".me1_popMov .btn_popClose").on("click", function(e) {
  602. $(".me1_popMov").fadeOut();
  603. return false;
  604. });
  605. var appHeight = document.documentElement.clientHeight; // 디바이스의 클라이언트 높이값
  606. let headresult = document.querySelector('.btPop_head');
  607. let result = document.querySelector('.btPop_body');
  608. // btPop_full
  609. $('.btPop_full_click').click(function(){
  610. popOpenScroll();
  611. $('.container').addClass('btPop_full_open');
  612. return false;
  613. });
  614. $('.btPop_full_close').click(function(){
  615. popClsScroll();
  616. $('.container').removeClass('btPop_full_open');
  617. return false;
  618. });
  619. // btPopAuto
  620. $('.btPop_close').click(function(){
  621. popClsScroll();
  622. $('.container').removeClass('btPop_open');
  623. autome.style.top = 100 + "%";
  624. return false;
  625. });
  626. // 쇼핑백팝업
  627. $("#btn_shoppingBag_pop").click(function() {
  628. popClsScroll();
  629. $('.container').removeClass('btPop_open');
  630. autome.style.top = 100 + "%";
  631. $("html, body").animate({"scrollTop": 0}, 0);
  632. $("#shoppingBagModal").fadeIn();
  633. setTimeout(function(){
  634. $("#shoppingBagModal").fadeOut(500);
  635. },2000);
  636. return false;
  637. });
  638. let autome = document.querySelector('.btPopAuto');
  639. $('.btPop_auto').click(function(){
  640. popOpenScroll();
  641. $('.container').addClass('btPop_open');
  642. return false;
  643. });
  644. // 210405_사이즈 선택시 구매하기 팝업 추가
  645. $('.opt_size .form_field div input').click(function(){
  646. popOpenScroll();
  647. console.log();
  648. $('.container').addClass('btPop_open');
  649. return false;
  650. });
  651. });
  652. /* branch */
  653. $( document ).ready( function() {
  654. /* 주문결제_Header Style */
  655. if($('main').children("section").hasClass("shopping_bag")){
  656. $('.htop .home').css({"display": "inline-block"});
  657. $('.htop .search').css({"display": "none"});
  658. $('.htop .store').css({"display": "none"});
  659. }else if($('main').children("section").hasClass("od_gift")){
  660. $('.htop .home').css({"display": "none"});
  661. $('.htop .search').css({"display": "inline-block"});
  662. $('.htop .store').css({"display": "inline-block"});
  663. }else if($('main').children("section").hasClass("od_extra")){ //추가결제(특수결제)
  664. $('.htop .home').css({"display": "none"});
  665. $('.htop .search').css({"display": "none"});
  666. $('.htop .store').css({"display": "none"});
  667. }else if($('main').children("section").hasClass("odPayment")){ //회원,비회원주문
  668. $('.htop .home').css({"display": "none"});
  669. $('.htop .search').css({"display": "none"});
  670. $('.htop .store').css({"display": "none"});
  671. }else if($('main').children("section").hasClass("nonMBorder")){ //비회원주문-로그인
  672. $('.htop .home').css({"display": "none"});
  673. $('.htop .search').css({"display": "none"});
  674. $('.htop .store').css({"display": "none"});
  675. };
  676. /* 상품상세_Header Style */
  677. let pdPage = document.getElementsByClassName('pd');
  678. if($(pdPage).children("section").hasClass("pd_detail")){
  679. $('.htop').css({"background": "transparent","position":"absolute","width":"100%"});
  680. $('.htop h1').css({"border-bottom": "none"});
  681. $('.htop h1').css({"display": "none"});
  682. $('.htop .home').css({"display": "inline-block"});
  683. };
  684. /* 마이페이지_Header Style */
  685. let container = document.getElementsByClassName('container');
  686. if($(container).hasClass('my')){
  687. $('.htop').css({"border-bottom": "1px solid rgba(0, 0, 0, 0.1)"});
  688. };
  689. /* 마이페이지_비회원_Header Style */
  690. let myPage = document.getElementsByClassName('my');
  691. if($(myPage).children("nav").hasClass("pnb")){
  692. $('.htop .home').css({"display": "none"});
  693. $('.htop .search').css({"display": "none"});
  694. $('.htop .store').css({"display": "none"});
  695. };
  696. /* 210805_ 추가 : 고객센터_Header Style */
  697. /* 210813_ 제거 : 고객센터 '.htop .home').css({"display": "inline-block"}) */
  698. /* 검색_Header Style */
  699. let schPage = document.getElementsByClassName('sch');
  700. if($(schPage).children("section").hasClass("sch_result")){
  701. $('.htop h1').css({"display": "none"});
  702. $('.htop .search').css({"display": "none"});
  703. };
  704. /* 210428_수정 : 아코디언 */
  705. $(document).on('click','.cs .foldGroup .fold_head, .my .foldGroup .fold_head',function(e){
  706. $(this).toggleClass('on');
  707. $(this).siblings('.fold_cont').slideToggle(100);
  708. $(this).parents('li').siblings('li').find('.fold_head').removeClass('on');
  709. $(this).parents('li').siblings('li').find('.fold_cont').slideUp(100);
  710. });
  711. /* //210428_수정 : 아코디언 */
  712. /* 검색 인풋 클리어 버튼 */
  713. /* 210819 */
  714. $('.search_wrap').each(function(){
  715. $(this).find('.cs_search_input').on('keyup focus', function(){
  716. $(this).siblings('.btn_x').attr('style', 'visibility: visible');
  717. if($(this).val().length == 0){
  718. $(this).siblings('.btn_x').attr('style', 'visibility: hidden');
  719. } else {
  720. $(this).siblings('.btn_x').attr('style', 'visibility: visible');
  721. }
  722. });
  723. $(this).find('.cs_search_input').on('blur', function(){
  724. $(this).siblings('.btn_x').attr('style', 'visibility: hidden');
  725. });
  726. $(this).find('.btn_x').on('click touchstart', function(){
  727. $(this).closest('.search_wrap').find('.cs_search_input').val('');
  728. $(this).closest('.search_wrap').find('.btn_x').attr('style', 'visibility: hidden');
  729. return false;
  730. });
  731. });
  732. /* 주문결제_accordion */
  733. /* 210428_수정 : 아코디언 */
  734. $(document).on('click','.od .foldGroup .fold_head .fold_tit',function(e){
  735. $(this).parents('.foldGroup li').find('.fold_cont').slideToggle(100);
  736. $(this).parents('.fold_head').toggleClass('on');
  737. $(this).parents('.inner').siblings('.inner').find('.fold_head').removeClass('on');
  738. $(this).parents('.inner').siblings('.inner').find('.fold_cont').slideUp(100);
  739. // 210617_ 추가 : 선택 된 폴드그룹 포커스 이동
  740. if($('.od .foldGroup .fold_head').hasClass('on') === true){
  741. var odoffset = $('.od .foldGroup .fold_head').offset();
  742. $('html').animate({scrollTop : odoffset.top - 40}, 400);
  743. }
  744. return false;
  745. });
  746. /* 210428_수정 : 아코디언 */
  747. /* 상품문의_accordion */
  748. $(document).on('click','.pd_qnalist .foldGroup .fold_head',function(e){
  749. if($(this).parent().hasClass('secret_qna')){
  750. mcxDialog.alert("비밀글은 열람하실 수 없습니다.", {
  751. sureBtnText: "확인",
  752. });
  753. } else {
  754. $('.fold_head').removeClass('on');
  755. $('.fold_cont').slideUp(100);
  756. if(!$(this).parents('.foldGroup li').find('.fold_cont').is(":visible")){
  757. $(this).parents('.foldGroup li').find('.fold_cont').slideDown(100);
  758. $(this).parents('.fold_head').toggleClass('on');
  759. }
  760. }
  761. return false;
  762. });
  763. //210604_하단 고정버튼 있을 시 tabbar 제거
  764. //210813_$('div').hasClass('cs_contactUs_my_footer') || 제거
  765. if($('div').hasClass('product_floormenu') || $('div').hasClass('od_calc_wrap')){
  766. $('.tabbar').css('display', 'none');
  767. $('footer .btn_back').css('bottom', 'clac(constant(safe-area-inset-bottom) + 6.5rem)');
  768. $('footer .btn_back').css('bottom', 'calc(env(safe-area-inset-bottom) + 6.5rem)');
  769. $('footer .btn_top').css('bottom', 'clac(constant(safe-area-inset-bottom) + 6.5rem);');
  770. $('footer .btn_top').css('bottom', 'calc(env(safe-area-inset-bottom) + 6.5rem)');
  771. }
  772. });