common_m.js 39 KB

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