PageSourceSearch

https://jw-on.com/data/skin/front/dbook_20250527/js/gd_ui.js?ts=1780623858

js jw-on.com collected 2026-10-05 05:14:16 UTC 22,018 bytes, 647 lines download raw bytes

1$(function(){
2    if ($('#scroll_right, #scroll_left').length > 0) {
3        $('#scroll_right, #scroll_left').gb_quick_menu({
4            //HEADER_ID: '#header_warp'
5        });
6    }
7    // top으로 이동
8    $('.btn_scroll_top a').click(
9        function() {
10            $('html, body').stop().animate({scrollTop: $('body').offset().top}, 300);
11            return false;
12        }
13    );
14});
15
16$(function(){
17    var cateArray = new Array('','','','');
18    var arrayNum = 0;
19    var menupage = 0;
20    var total_width = $('.gnb_menu_box').innerWidth();
21    var gd_display_cate = function(){
22        var depth1 = 0;
23        $('.gnb_menu_box > ul > li').each(function(){
24            depth1 += $(this).innerWidth();
25            if(depth1 > total_width){
26                arrayNum++;
27                depth1 =0;
28                depth1 += $(this).innerWidth();
29                cateArray[arrayNum] += "<li>"+$(this).html()+"</li>";
30            }else{
31                cateArray[arrayNum] += "<li>"+$(this).html()+"</li>";
32            }
33        });
34        $('.gnb_menu_box > ul').html(cateArray[0]);
35        $('#header .gnb .depth0').css({
36            'overflow':'visible',
37            'height':'100%',
38        });
39    };
40    gd_display_cate();
41    /* 상단 메뉴 */
42    var gd_topmenu = function(){
43        $('.depth0 li').on({
44            'mouseover':function(){
45                $(this).find('> ul').stop(true,true).fadeIn('fast');
46                $(this).find('> a').addClass('active');
47                //console.log('open');
48            },
49            'mouseleave':function(){
50                $(this).find('> ul').stop(true,true).fadeOut('fast');
51                $(this).find('> a').removeClass('active');
52                //console.log('hide');
53            }
54        });
55    };
56    gd_topmenu();
57
58
59
60    /* 메뉴 우측 버튼 */
61    $('.gnb_right').on({
62        'click':function(){
63            if(arrayNum > menupage){
64                menupage++;
65                if(menupage == arrayNum) $(this).find('a').addClass('active');
66                $('.gnb_left').find('a').removeClass('active');
67                $('.gnb_menu_box > ul').html(cateArray[menupage]);
68                gd_topmenu();
69            }
70        }
71    });
72    /* 메뉴 좌측 버튼 */
73    $('.gnb_left').on({
74        'click':function(){
75            if(arrayNum >= menupage && menupage != 0){
76                menupage--;
77                if(menupage == 0) $(this).find('a').addClass('active');
78                $('.gnb_right').find('a').removeClass('active');
79                $('.gnb_menu_box > ul').html(cateArray[menupage]);
80                gd_topmenu();
81            }
82        }
83    });
84
85
86
87    /* 전체메뉴 버튼 */
88    /*
89     $('.gnb_all').on({
90     'click':function(){
91     if($('.gnb_allmenu').css('display') =='none') $('.gnb_allmenu').stop(true,true).slideDown('fast');
92     else $('.gnb_allmenu').slideUp('fast');
93
94     }
95     });
96     */
97
98    $ ( '.layer_type .sub_depth0 li'). on ({
99        'mouseover': function () {
100            $ (this) .find ( '> ul'). stop (true, true) .fadeIn ( 'fast');
101            $ (this) .find ( '> a'). addClass ( 'active');
102            //console.log('open ');
103        },
104        'mouseleave': function () {
105            $ (this) .find ( '> ul'). stop (true, true) .fadeOut ( 'fast');
106            $ (this) .find ( '> a'). removeClass ( 'active');
107            //console.log('hide ');
108        }
109    });
110
111    /* 해외몰 홈아이콘 타입 선택형(국기) */
112    $('.top_country_list1 .country_tit').on({
113        'click':function(){
114            if($(this).parent().find('ul').css('display') =='none'){
115                $(this).addClass('active');
116                $(this).parent().find('ul').slideDown('fast');
117            }else{
118                $(this).parent().find('ul').slideUp('fast');
119                $(this).removeClass('active');
120            }
121        }
122    });
123
124    /* 해외몰 홈아이콘 타입 선택형(국기,언어) */
125    $('.top_country_list2 .country_tit').on({
126        'click':function(){
127            if($(this).parent().find('ul').css('display') =='none'){
128                $(this).addClass('active');
129                $(this).parent().find('ul').slideDown('fast');
130            }else{
131                $(this).parent().find('ul').slideUp('fast');
132                $(this).removeClass('active');
133            }
134        }
135    });
136
137    /* location 경로 */
138    $('.location_select').on({
139        'mouseenter':function() {
140            if ($(this).find('ul').css('display') == 'none') {
141                $(this).find('.location_tit').addClass('active');
142                $(this).find('ul').slideDown('fast');
143            }
144        },
145        'mouseleave':function() {
146            $(this).find('ul').slideUp('fast');
147            $(this).find('.location_tit').removeClass('active');
148        }
149    });
150
151    /* 상단 마이페이지 레이어 */
152    $('.top_mypage_cont').on({
153        'mouseenter':function(){
154            if($(this).find('ul').css('display') =='none'){
155                $(this).find('.top_mypage_tit').addClass('active');
156                $(this).find('ul').show();
157            }
158        },
159        'mouseleave':function(){
160            $(this).find('ul').hide();
161            $(this).find('.top_mypage_tit').removeClass('active');
162        }
163    });
164
165    /* 상단 검색 */
166    $('.top_search_cont input[name="keyword"]').on({
167        'focus':function(){
168            if($("input[name=recentCount]").val() > 0) {
169                $(this).parents().find('.search_cont').show();
170            }
171        },
172        'blur':function(){
173            $('body').click(function(e){
174                if (!$('.search_cont').has(e.target).length && e.target.name != 'keyword') {
175                    $(this).parents().find('.search_cont').hide();
176                }
177            });
178            $('.btn_top_search_close').click(function(){
179                $(this).parents().find('.search_cont').hide();
180            });
181        }
182    });
183
184    /* 레이어, 추가 내용 */
185    $('.btn_common_box, .btn_layer').find('a').on({
186        'click':function(e){
187            var tg = $(this).attr('href');
188            if(tg.substr(0, 1) == '#'){
189                e.preventDefault();
190                if($(tg).css('display') == 'none'){
191                    $(tg).show();
192                    $(tg).find('.ly_close').attr('href',tg);
193                }else{
194                    $(tg).hide();
195                }
196            }
197        }
198    });
199    $('.ly_close').on({
200        click:function(){
201            var tg = $(this).attr('href');
202            if (tg.substr(0, 1) == '#') {
203                $(tg).hide();
204            }
205
206            if ($(this).parents('.js_password_layer').length) {
207                $('.js_password_layer').find('input[name="writerPw"]').val('');
208            }
209        }
210    });
211});
212
213
214function gd_btn_all_menu_close(){
215    $('.gnb_allmenu').slideUp('fast');
216}
217
218$(document).ready(function() {
219    /* 퀵검색 */
220    var qs_id = $('#quick_search');
221    var cname = qs_id.attr('class');
222    var position, position_m;
223
224    if(cname == 'q_left'){
225        position = qs_id.innerWidth();
226        qs_id.css('left','-'+position+'px');
227    }else if(cname == 'q_right'){
228        position = qs_id.innerWidth();
229        qs_id.css('right','-'+position+'px');
230    }else{
231        $(window).load(function(){
232            position = qs_id.innerHeight();
233            qs_id.css('top','-'+position+'px');
234        });
235    }
236    position_m = position;
237
238    function gd_quick_motion(){
239
240        if(cname == 'q_left'){
241            if(qs_id.css('left') == '0px') position_m = '-'+ position;
242            else position_m = 0;
243
244            qs_id.animate({
245                left : position_m
246            }, 500, function(){
247                //console.log(position_m);
248            });
249        }else if(cname =='q_right'){
250            if(qs_id.css('right') == '0px') position_m = '-'+ position;
251            else position_m = 0;
252
253            qs_id.animate({
254                right : position_m
255            }, 500, function(){
256                //console.log(position_m);
257            });
258        } else {
259            if(qs_id.css('top') == '0px') position_m = '-'+ position;
260            else position_m = 0;
261
262            qs_id.animate({
263                top : position_m
264            }, 500, function(){
265                //console.log(position_m);
266            });
267
268        }
269        if(position_m == 0) $('.quick_search_cont').addClass('on');
270        else $('.quick_search_cont').removeClass('on');
271    }
272    $('#quick_search .btn_quick_search_open, #quick_search .btn_quick_search_close').on({
273        'click':function(){
274            gd_quick_motion();
275        }
276    });
277
278    /* 퀵검색 컬러 & 혜택조건 */
279    $('.color_box span label, .benefit_box span label').on({
280        'click':function(){
281            if(!$(this).parent().find('input').is(':checked')) $(this).addClass('active');
282            else $(this).removeClass('active');
283        }
284    });
285
286    $('.btn_all_menu_open').on('click',function(){
287        gd_btn_all_menu_open();
288    });
289
290
291});
292
293
294
295
296// 레이어박스 센터정렬 플러그인 (최상단)
297jQuery.fn.center = function() {
298    var top = ($(window).height() - this.outerHeight()) / 2;
299    var left = ($(window).width() - this.outerWidth()) / 2;
300
301    this.css({
302        position:'absolute',
303        margin:0,
304        top: (top > 0 ? top : 0) + 'px',
305        left: (left > 0 ? left : 0) + 'px'
306    });
307
308    return this;
309};
310
311// 레이어박스 센터정렬 플러그인 (현재위치)
312jQuery.fn.currentCenter = function() {
313    this.css({
314        'position': 'fixed',
315        'left': '50%',
316        'top': '50%'
317    });
318
319    this.css({
320        'margin-left': -this.outerWidth() / 2 + 'px',
321        'margin-top': -this.outerHeight() / 2 + 'px'
322    });
323
324    return this;
325};
326
327/* 스크롤배너(오른쪽) */
328(function (){
329    $.fn.gb_quick_menu = function(options){
330        //초기값
331        var defaults = {
332            HEADER_ID: '.scroll_wrap',
333            FIXED_CLS: 'ban_fixed',
334            FIXED_SIZE :1450,
335            LEFT_QUICK_ID : '#scroll_left',
336            CONTENTS_WARP : '#wrap',
337        };
338        //초기값 옵션 배열 저장
339        var options = $.extend({}, defaults, options);
340        var el = $(this);
341        var scqTop = 0;
342        var quickTop = $(options.HEADER_ID).offset().top;
343        var qucik_left = $(options.LEFT_QUICK_ID).css('left');
344
345        $(window).on({
346            'resize':function(){
347
348            },
349            'scroll':function(){
350                var win_width = $(window).innerWidth();
351                scqTop = $(this).scrollTop();
352                if(scqTop <= quickTop){
353                    el.removeClass(options.FIXED_CLS).removeAttr('style');
354                }else{
355                    if(win_width > options.FIXED_SIZE){
356                        el.addClass(options.FIXED_CLS).removeAttr('style');
357                    }else{
358                        el.removeClass(options.FIXED_CLS).removeAttr('style');
359                        el.stop(true,true).css('top', (scqTop-quickTop+20));
360
361                    }
362                }
363            }
364        });
365        var gd_leftmove = function(){
366            var win_width = $(window).innerWidth();
367            if(win_width <= options.FIXED_SIZE){
368                gd_left_animate(qucik_left);
369            }else{
370                gd_left_animate(0);
371            }
372        };
373        var gd_left_animate = function(left_quick_position){
374            $('#wrap').stop(true,true).animate({
375                'marginLeft':left_quick_position,
376            },'5000',function(){
377
378            });
379        };
380        $(window).load(function(){
381
382        })
383    };
384})(jQuery);
385
386// 체크박스 처리 로직 초기화
387function gd_init_checkbox_ui() {
388    $(document).on('click', 'input[type=radio]', function(e){
389        $(this).parents('form:first').find("input[name='" + $(this).prop("name") + "']").each(function() {
390            if ($(this).prop("checked")) {
391                $("label[for=" + $(this).attr("id") + "]").addClass("on");
392            } else {
393                $("label[for=" + $(this).attr("id") + "]").removeClass("on");
394            }
395        });
396    });
397
398    $(document).on('click', 'input[type=checkbox]', function(e){
399        if($(this).prop('readonly') === false) {
400            if($(this).prop("checked")) {
401                $("label[for="+$(this).attr("id")+"]").addClass("on");
402            } else {
403                $("label[for="+$(this).attr("id")+"]").removeClass("on");
404            }
405        } else {
406            e.preventDefault();
407        }
408    });
409}
410
411// 라디오박스,체크박스 이미지화 스크립트
412function gd_trigger_checkbox_ui() {
413    var $input = $('input[type=radio], input[type=checkbox]');
414    // 템플릿에서 check 처리한 경우 예외처리 추가
415    if(!$input.find('label.on')){
416        $input.each(function(){
417            var $item = $("label[for="+$(this).attr("id")+"]");
418            if($(this).prop("checked")) {
419                $item.addClass("on");
420            } else {
421                $item.removeClass("on");
422            }
423        });
424    }
425}
426
427// 체크박스 전체 선택
428function gd_checkbox_all() {
429    // 체크박스 전체 선택 이벤트
430    if ($(':checkbox.gd_checkbox_all').length > 0) {
431        // 이벤트 중복 실행을 막아준다.
432        $(':checkbox.gd_checkbox_all').off('click');
433        $(':checkbox.gd_checkbox_all').click(function (e) {
434            var $target = $(e.target);
435            var targetName = $target.data('target-name');
436            var targetId = $target.data('target-id');
437            var targetFormName = $target.data('target-form');
438            if (typeof targetFormName == 'undefined') targetFormName = "";
439            if (_.isUndefined(targetId)) {
440                $(targetFormName + ' :checkbox[name="' + targetName + '"]').prop('checked', !$target.prop('checked')).trigger('click');
441            } else {
442                $(targetFormName + ' :checkbox[id*="' + targetId + '"]').prop('checked', !$target.prop('checked')).trigger('click');
443            }
444        });
445    }
446}
447
448// 레이어 박스 이벤트
449function gd_center_layer(){
450    //$('.btn_open_layer').off('click');
451    $(document).on('click', '.btn_open_layer', function() {
452        // @qnibus 레이어 안에 레이어가 있는 경우 종속된 보이지 않는 레이어가 이미 떠있는 레이어 기준으로 center 처리 되어 보여져 레이아웃이 깨짐
453        $('.layer_wrap').removeAttr('style');
454        var target = $(this).attr('href');
455        $(target).removeClass('dn');
456		if ( target != '#lyCouponDown'){
457			$('body').css('overflow','hidden');
458			$('#layerDim').removeClass('dn');
459		}
460        $(target).find('> div').center();
461
462        return false;
463    });
464
465    $(document).on('click', '.layer_wrap .layer_close, .btn_box .btn_cancel', function(){
466        $(this).closest('.layer_wrap').addClass('dn');
467        // 창이 2개 이상 떠있는 경우 Dim처리 안되게
468        if (!$('.layer_wrap').is(':visible')) {
469            $('#layerDim').addClass('dn');
470            $('body').removeAttr('style');
471        }
472        return false;
473    });
474}
475
476// 레이어 박스 창닫기 (현재 열려 있는 창만 닫는다)
477function gd_close_layer() {
478    if ($('.layer_wrap').is(':visible') || $('#layerDim').is(':visible')) {
479        if ($('.layer_wrap .layer_close, .btn_box .btn_cancel').length > 0) {
480            $('.layer_wrap .layer_close, .btn_box .btn_cancel').trigger('click');
481        } else {
482            // 딤만 떠있는 경우
483            $('.layer_wrap').addClass('dn');
484            $('#layerDim').addClass('dn');
485        }
486    }
487}
488
489// chosen 셀렉트 박스
490function gd_select_remodeling() {
491    var selector = '.chosen-select';
492    var config = {
493        disable_search_threshold: 10000,
494        no_results_text: __('검색결과가 없습니다.')
495    };
496
497    if ($(selector).length > 0) $(selector).chosen(config);
498}
499
500// 카트탭 레이어
501function gd_carttab_layer() {
502    $('.cart_tab_list li > a').on({
503        'click':function() {
504            if ($(this).hasClass('btn_alert_login') == false) {
505                $('.btn_shop_cart_box .btn_shop_cart_close').show();
506                $(this).parent().addClass('on').siblings().removeClass('on');
507                $('#shop_cart_wrap .shop_cart_cont > .cart_tab_box').eq($(this).index()).fadeIn('fast').siblings().removeClass('on').hide();
508                $('.shop_cart_cont').slideDown('fast');
509                gd_cart_tab_action($(this).attr('href'));
510            }
511        }
512    });
513
514    $('.btn_shop_cart_box .btn_shop_cart_open, .btn_shop_cart_box .btn_shop_cart_close').on({
515        'click':function() {
516            if ($('.shop_cart_cont').css('display') != 'none') {
517                $('.shop_cart_cont').slideUp('fast');
518                $('.btn_shop_cart_box .btn_shop_cart_close').hide();
519                $('.btn_shop_cart_box .btn_shop_cart_open').show();
520                $('.cart_tab_list li').removeClass('on');
521            } else {
522                $('.cart_tab_list li').eq(0).addClass('on');
523                $('.cart_tab_box').eq(0).addClass('on');
524                $('.shop_cart_cont').slideDown('fast');
525                $('.btn_shop_cart_box .btn_shop_cart_close').show();
526                $('.btn_shop_cart_box .btn_shop_cart_open').hide();
527                $('#shop_cart_wrap .shop_cart_cont > .cart_tab_box').hide().eq(0).fadeIn('fast');
528                gd_cart_tab_action('#cart_tab_today');
529            }
530
531            $('.chart_view_horizontal ul').slick('reinit');
532        }
533    });
534}
535
536// 파일첨부 꾸미기
537function gd_file_attach() {
538    $(document).on('change', '.file_upload_sec .file', function(){
539        var i = $(this).val();
540        $('label[for=' + $(this).attr('id') + ']').find('.file_text').val(i);
541    });
542}
543
544/*
545 카테고리/브랜드 카테고리 마우스 오버
546 */
547function gd_menu_over() {
548
549    $(document).on('mouseenter mouseleave', 'img.gd_menu_over', function (event) {
550        $(this).attr({
551            src: $(this).attr('data-other-src')
552            , 'data-other-src': $(this).attr('src')
553        });
554
555    });
556
557    $(document).on('mouseenter', 'span.gd_menu_over', function (event) {
558        var width = $(this).closest("strong").width();
559        var height = $(this).closest("strong").height() - 7;
560        $(this).html("<img src='" + $(this).data('other-src') + "' style='max-width:" + width + "px;max-height:" + height + "px'>");
561
562    });
563
564    $(document).on('mouseleave', 'span.gd_menu_over', function (event) {
565        $(this).html($(this).data('other-text'));
566    });
567}
568
569function gd_btn_all_menu_open(){
570
571    $.ajax({
572        method: "POST",
573        cache: false,
574        url: "/goods/goods_ps.php",
575        data: "mode=get_all_category",
576        success: function(data) {
577            var getData = $.parseJSON(data);
578            if(data =='false') {
579                $(".gnb_allmenu_box").html('');
580            }else{
581                var addHtml = '<div class="gnb_allmenu" style="display:none;"><div class="header-inner"><div class="gnb_allmenu_box"><div class="all-cate-box"><div>'/* dbook.fe 추가 */
582                $.each(getData, function (categoryKey, categoryVal) {
583                    $.each(categoryVal, function (key, val) {
584
585						if (val.cateCd === '041') { /* dbook.fe 추가 */
586
587							if(val.children) {
588								addHtml += '<ul class="all_depth1">';
589								$.each(val.children, function (key1, val1) {
590									addHtml += '<li><a href="../goods/goods_list.php?cateCd='+val1.cateCd+'">'+val1.cateNm+'</a>';
591									if(val1.children) {
592										addHtml += '<ul class="all_depth2">';
593										$.each(val1.children, function (key2, val2) {
594											addHtml += '<li><a href="../goods/goods_list.php?cateCd='+val2.cateCd+'">'+val2.cateNm+'</a>';
595											if(val2.children) {
596												addHtml += '<ul class="all_depth3">';
597												$.each(val2.children, function (key3, val3) {
598													addHtml += '<li><a href="../goods/goods_list.php?cateCd='+val3.cateCd+'">'+val3.cateNm+'</a></li>';
599												});
600												addHtml += '</ul>';
601											}
602											addHtml += '</li>';
603										});
604										addHtml += '</ul>';
605									}
606									addHtml += '</li>';
607								});
608								addHtml += '</ul>';
609							}
610						}
611                    });
612                });
613                addHtml += '</ul></div></div>'; /* dbook.fe 추가 */
614                addHtml += '<div class="allmenu-btm"><a href="../goods/goods_list.php?cateCd=013">전체상품</a></div>'
615                addHtml += '</div><span class="btn_all_menu_close" onClick="gd_btn_all_menu_close();">전체메뉴닫기</span></div></div>'
616                $(".gnb_allmenu_wrap").html(addHtml);
617				/* dbook.fe 메뉴 추가 
618				var $cateBD = $(".all-add-menu").html();
619				$(".gnb_allmenu_box").append($cateBD);
620				*/
621                $('.gnb_allmenu').stop(true,true).slideDown('fast');
622            }
623        },
624        error: function (data) {
625            alert(data.message);
626        }
627    });
628
629};
630
631// 함수 호출
632$(document).ready(function() {
633    gd_init_checkbox_ui();
634    gd_trigger_checkbox_ui();
635    gd_checkbox_all();
636    gd_center_layer();
637    gd_carttab_layer();
638    gd_select_remodeling();
639    gd_file_attach();
640    gd_menu_over();
641	
642	// dbook.fe 쿠폰다운
643	setTimeout(function(){
644		$('.item_detail_list .max-dc-price .btn_gray_list .btn_open_layer').trigger('click');
645	}, 400);
646
647});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.