common_m.js 40 KB

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