common_m.js 40 KB

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