PageSourceSearch

https://l2c.co.kr/js/module/ModalPlugin.1791261834.js

js l2c.co.kr collected 2026-10-07 06:57:17 UTC 2,149,931 bytes, 35,418 lines download raw bytes

1var fileUpdateCnt = 0; 
2var loadFile = 0;
3var closeProductNumber = 0;
4var $thisUploadCheck = '', taxUse = '', CANCEL = false, ABORT = false;
5var uadmin = '';
6(function (jQuery) {
7
8    jQuery.modalON = function (text,bgcolor) {
9        var checkSetBgcolor = (typeof bgcolor != 'undefined' && bgcolor) ? true : false;
10
11        bgcolor = (checkSetBgcolor) ? bgcolor : '#fff';
12        var msg = (text) ? text : '';
13        
14        if ($('.ModalPlugin').length < 1) {
15            $('body').prepend('<div class="ModalPlugin"><svg version="1.1" xmlns="http://www.w3.org/svg/2000" viewBox="0 0 30 30" width="60"><circle cy="15" cx="15" r="14" /></svg><p>' + msg + '</p></div>');
16        }
17
18        $('.ModalPlugin').css({
19            "display": "inherit",
20            "position": "fixed",
21            "z-index": "99999999",
22            "top": "0",
23            "left": "0",
24            "right": "0",
25            "bottom": "0",
26            "background": bgcolor,
27            "width": "100%",
28            "text-align": "center",
29            "height": "100%"
30        });
31        if(!checkSetBgcolor) $('.ModalPlugin p').css('color','#3f3f3f');
32        $('.ModalPlugin').show();
33        $(document)
34            .off('click','.ModalPlugin')
35            .on ('click','.ModalPlugin', function(e) {
36                e.preventDefault();
37            });
38    }
39
40    jQuery.modalOFF = function () {
41        $('.ModalPlugin').remove();
42    }
43
44    jQuery.uploadON = function (text) {
45        UPLOAD = 0;
46        UPLOADED = 0;
47        PROGRESS = 0;
48        var msg = (text) ? text : 'Uploading images...';
49        if ($('.uploadModal').length < 1) {
50            $('body').prepend('<div class="uploadModal"></div>');
51            $('.uploadModal').append('<button class="cl-mobile-btn upload-close close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><polygon points="16 1 15 0 8 7 1 0 0 1 7 8 0 15 1 16 8 9 15 16 16 15 9 8 "></polygon></svg></span></button>');
52            $('.uploadModal').append('<div class="upload-wrap"></div>');
53            $('.uploadModal .upload-wrap').append('<div class="upload-header"></div>');
54            $('.uploadModal .upload-wrap').append('<div class="upload-content"></div>');
55
56            $('.uploadModal .upload-header').append('<h1>' + $.lang[LANG]['editor.upload.title.1'] + '</h1>');
57            $('.uploadModal .upload-header').append('<button type="" class="upload-close close"><span><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path d="M8.71 8l7.15-7.15c0.2-0.2 0.2-0.51 0-0.71s-0.51-0.2-0.71 0L8 7.29 0.85 0.15c-0.2-0.2-0.51-0.2-0.71 0s-0.2 0.51 0 0.71L7.29 8l-7.15 7.15c-0.2 0.2-0.2 0.51 0 0.71C0.24 15.95 0.37 16 0.5 16s0.26-0.05 0.35-0.15L8 8.71l7.15 7.15c0.1 0.1 0.23 0.15 0.35 0.15s0.26-0.05 0.35-0.15c0.2-0.2 0.2-0.51 0-0.71L8.71 8z"></path></svg></span></button>');
58            $('.uploadModal .upload-content').append('<div class="upload-cancel"><div class="btn btn-default">' + $.lang[LANG]['config.close'] + '</div></div>');
59        }
60        $('.uploadModal .upload-content').find('.file').remove();
61
62        $progress = $('<div id="file-upload-progress" class="file-upload-progress"></div>');
63        $bar = $('<div class="progress-bar"></div>');
64        $progress.css({
65            'height': '2px',
66            'background-color':'#d1d3d5',
67            'overflow' : 'hidden',
68        });
69        $progress.append($bar);
70        if($('.uploadModal #file-upload-progress').length==0) {
71            $('.uploadModal .upload-header').append($progress);
72            $('.uploadModal .upload-header').append('<div class="info1"></div>');
73            $('.uploadModal .upload-header').append('<div class="info2"></div>');
74        }
75        // $('.uploadModal').show();
76    }
77
78    jQuery.uploadOFF = function () {
79        $('.uploadModal').fadeOut(500, function(){
80            $(this).remove();
81        });
82    }
83
84    jQuery.upload_add = function(e,data,upload_type) {
85        $('.uploadModal').show();
86        var submit = true, err = '';
87
88        var checkPlan = false,
89            checkPlanType = '',
90            filesize = data.files[0].size,
91            maxsize = 10485760; //10MB == 10485760Byte
92
93        if(typeof PAGE_MODE != 'undefined') {
94            if (PAGE_MODE == 'c') {
95                checkPlan = VALIDPLAN;
96                checkPlanType = VALIDTYPE;
97            } else if(typeof property != 'undefined' && property) {
98                checkPlan = property.VALIDPLAN;
99                checkPlanType = property.VALIDTYPE;
100            }
101        }
102        if(upload_type == 'flink' && checkPlan && $.inArray(checkPlanType,['BN','SM']) > -1) maxsize = 104857600; //100MB == 104857600Byte
103        if(upload_type == 'forum_file' && VALIDPLAN && $.inArray(VALIDTYPE,['BN','SM']) > -1) maxsize = 104857600; //100MB == 104857600Byte
104        if(upload_type == 'register_flink' && typeof property != 'undefined' && property && property.VALIDPLAN && $.inArray(property.VALIDTYPE,['BN','SM']) > -1 ||
105           upload_type == 'register_flink' && typeof VALIDTYPE != 'undefined' && VALIDTYPE && $.inArray(VALIDTYPE,['BUSNESS','SHOPPING']) > -1 
106            ) maxsize = 104857600; //100MB == 104857600Byte
107
108        console.log(maxsize);
109        if( filesize > maxsize) {
110            filesize = (filesize/1024/1024).toFixed(1);
111            if(maxsize == 104857600) err = $.lang[LANG]['editor.upload.max.100'] + $.lang[LANG]['editor.upload.max.2'];
112            else err = $.lang[LANG]['editor.upload.max.1'] + $.lang[LANG]['editor.upload.max.2'];
113            submit = false;
114        }
115
116        var image_types = 'jpg|jpeg|png|bmp|ico|gif|psd|ai|icns|webp',
117            text_types = 'txt|hwp|hwpx|hwt|doc|docx|docm|pdf|xls|xlsx|ppt|pps|ppsm|ppsx|pptx|pptm|potx|rtf|csv',
118            audio_types = 'mp3|wma|wav|ogg',
119            video_types = 'mp4|avi|wmv|mpg|mpeg',
120            etc_types = 'zip|7z|rar|ttf|otf',
121            allowed_types = '';
122
123        var filename = data.files[0].name;
124        var search = /%/g,
125            match = filename.match(search);
126
127        if(match===null) {
128            var uploadErrors = [];
129            if(upload_type == 'flink' || upload_type == 'forum_file' || upload_type == 'register_flink') {
130                allowed_types = image_types + '|' + text_types + '|' + audio_types + '|' + video_types + '|' + etc_types;
131                var validFileAllTypes = allowed_types.split('|'),
132                    alltypeAry = data.files[0]['name'].toLowerCase().split('.');
133                if (validFileAllTypes.indexOf(alltypeAry[alltypeAry.length - 1]) == -1) {
134                    console.log(data.files[0]['name'] + ' => ' + data.files[0]['type']);
135
136                    err = $.lang[LANG]['editor.upload.error.flink'];
137                    submit = false;
138                }
139            } else {
140                var validImageTypes = ['jpg', 'jpeg', 'png', 'gif', 'webp'];
141                var imgtypeAry = data.files[0]['name'].toLowerCase().split('.');
142                if (validImageTypes.indexOf(imgtypeAry[imgtypeAry.length - 1]) == -1) {
143                    err = $.lang[LANG]['editor.upload.error.ext'];
144                    submit = false;
145                }
146            }
147
148        } else {
149            err = $.lang[LANG]['editor.upload.filename'];
150            submit = false;
151        }
152
153        var fileSize = (data.files[0].size/1024/1024).toFixed(1) + 'MB';
154        var tpl = '<div class="file">\
155            <div class="progress"><div class="progress-bar"></div></div>\
156            <div class="progress-info"><span class="file-name">' + data.files[0].name + '</span><span class="file-size">' + fileSize + '</span><span class="ing">' + $.lang[LANG]['editor.upload.response'] + '</span></div>\
157            <div class="preview"></div>\
158            </div>';
159        data.context = $(tpl).insertBefore($('.uploadModal .upload-content .upload-cancel'));
160
161        if(upload_type == 'all') {
162            data.context.find('.preview').addClass('not_image');
163        } else {
164            if(data.files[0].type.match('image.*')) {
165                if (data.files && data.files[0]) {
166                    var reader = new FileReader();
167                    reader.onload = function(e) {
168                        // data.context.find('.preview').append('<img src="' + e.target.result + '">');
169                        if(e.target.result != '') {
170                            data.context.find('.preview').css('background-image', 'url(' + e.target.result + ')');
171                        }
172                        else {
173                            data.context.find('.preview').addClass('no_preview');
174                        }
175                    }
176                    reader.readAsDataURL(data.files[0]);
177                }
178            } else data.context.find('.preview').addClass('not_image');
179        }
180
181        return {
182            submit : submit,
183            err : err
184        }
185    }
186
187    jQuery.upload_progress = function(e,data) {
188        var rate = (data.bitrate/1024).toFixed(1) + 'kbps';
189        var progress = parseInt((data.loaded / data.total) * 100, 10);
190        if(typeof data.context != 'undefined') {
191            data.context.find('.res').text(data.bitrate);
192            data.context.find('.progress-bar').css('width',progress + '%');
193            data.context.find('.ing').text(progress + '%');
194            data.context.find('.rate').text(rate);
195            if(progress == 100) {
196                data.context.find('.ing').text($.lang[LANG]['editor.upload.response']);
197            }
198        }
199    }
200
201    jQuery.upload_done = function(e,data) {
202        data.context.addClass('done');
203        data.context.find('i').removeClass("fa-circle-o-notch fa-spin fa-3x fa-fw").addClass("fa-check");
204        data.context.find('.ing').text($.lang[LANG]['editor.upload.done']);
205        data.context.find('.rate').fadeOut();
206
207        if(typeof data.result.error != 'undefined') {
208            data.context.find('.loading').html('<i class="fa fa-times error"></i>');
209            data.context.find('.ing').addClass('error').text(data.result.error);
210        }
211    }
212
213    jQuery.upload_progressall = function(e,data) {
214        var total = (data.total/1024/1024).toFixed(1) + 'MB';
215        $('.uploadModal .info1').text($.lang[LANG]['editor.upload.size.total'] + total);
216        $('.uploadModal .info2').html('<span>' + (UPLOADED+1) + '</span>/' + UPLOAD.toString());
217        var progress = parseInt((data.loaded / data.total) * 100, 10);
218        $('.file-upload-progress .progress-bar').css('width',progress + '%');
219    }
220
221    jQuery.upload_start = function(e,data) {
222        $('.uploadModal .upload-header h1').text($.lang[LANG]['editor.upload.title.2']);
223        $('.uploadModal .upload-content .upload-cancel .btn-default').text($.lang[LANG]['config.cancel']);
224    }
225
226    jQuery.progressON = function(text,sub,delay,cancel_off) {
227        CANCEL = false;
228        var msg = (typeof text !='undefined') ? text : $.lang[LANG]['editor.delete.title.2'];
229        if ($('.progressModal').length < 1) {
230            $('body').prepend('<div class="progressModal"></div>');
231            if( (typeof text !='undefined' && text == '이미지를 업로드 중입니다.') || (typeof text != 'undefined' && text == 'Uploading...')) {
232                $('.progressModal').append("<div class='progress-wrap btn-bottom-wrap-bgcolor'></div>");
233            } else {
234                $('.progressModal').append("<div class='progress-wrap'></div>");
235            }
236            $('.progressModal .progress-wrap').append("<div class='progress-header'></div>");
237            $('.progressModal .progress-wrap').append("<div class='progress-content'></div>");
238
239            $('.progressModal .progress-header').append('<h1>' + msg + '</h1>');
240            // $('.progressModal .progress-header').append('<div class="close"></div>');
241            
242            if(typeof cancel_off != 'undefined' && cancel_off === true) {
243            } else {
244                if(typeof delay == 'undefined') {
245                    $('.progressModal .progress-content').append('<div class="progress-cancel"><div class="btn btn-default">' + $.lang[LANG]['config.cancel'] + '</div></div>');
246                } else {
247                    setTimeout(function() {
248                        $('.progressModal .progress-content').append('<div class="progress-cancel"><div class="btn btn-default">' + $.lang[LANG]['config.cancel'] + '</div></div>');
249                    },delay);
250                }
251            }
252            $progress = $('<div id="file-upload-progress" class="file-upload-progress"></div>');
253            $bar = $('<div class="progress-bar progress-bar-success"></div>');
254            $progress.css({
255                'height': '5px',
256                'background-color':'#f5f5f5',
257                'overflow' : 'hidden',
258            });
259            $progress.append($bar);
260            $progress = $('<div id="file-upload-progress" class="file-upload-progress"></div>');
261            $bar = $('<div class="progress-bar"></div>');
262            $progress.css({
263                'height': '2px',
264                'background-color':'#f5f5f5',
265                'overflow' : 'hidden',
266            });
267            $progress.append($bar);
268            if($('.progressModal #file-upload-progress').length==0) {
269                $('.progressModal .progress-header').append($progress);
270                $('.progressModal .progress-header').append('<div class="info1"></div>');
271                $('.progressModal .progress-header').append('<div class="info2"></div>');
272                $('.progressModal .progress-header').append('<p>&nbsp;</p>');
273            }            
274        }
275        if(typeof sub != 'undefined') {
276            $('.progressModal .progress-header .info1').html('<i class="fa fa-circle-o-notch fa-spin fa-3x fa-fw"></i> ' + sub);
277        }
278
279        $('body').addClass('overflow-hidden');
280
281        $(document).on('click','.progress-cancel',function(e) {
282            CANCEL = true; ABORT = true;
283            $.progressOFF();
284        });
285        $('.progressModal').show();
286    }
287
288    jQuery.progressOFF = function() {
289        $('body').removeClass('overflow-hidden');
290        $('.progressModal').fadeOut().remove();
291    }
292
293    jQuery.processON = function(text,bg) {
294        var msg = (text) ? text : '';
295        bg = (bg) ? bg : 'rgba(0,0,0,0.75)';
296        if ($('.processModal').length < 1) {
297            if($('.reorderModal').length) {
298                $('.reorderModal').after('<div class="processModal"><svg version="1.1" xmlns="http://www.w3.org/svg/2000" viewBox="0 0 30 30" width="60"><circle cy="15" cx="15" r="14" /></svg><p>' + msg + '</p></div>');
299            } else {
300                $('body').prepend('<div class="processModal">
300<svg version="1.1" xmlns="http://www.w3.org/svg/2000" viewBox="0 0 30 30" width="60"><circle cy="15" cx="15" r="14" /></svg><p>' + msg + '</p></div>');
301            }
302        } else {
303            $('.processModal').find('p').html(text);
304        }
305
306        $('.processModal').css({
307            'display': 'inherit',
308            'position': 'fixed',
309            'z-index': '9999999999',
310            'top': '0',
311            'left': '0',
312            'width': '100%',
313            'text-align': 'center',
314            'height': '100%',
315            'background-color' : bg
316        });
317        $('.processModal').fadeIn();
318    }
319
320    jQuery.processOFF = function() {
321        $('.processModal').fadeOut().remove();
322    }
323
324    jQuery.loadingOn = function(selector,txt) {
325        if(typeof txt == 'undefined') txt = '';
326        selector.prepend('<div class="loadingModal"><svg class="spin_svg" version="1.1" xmlns="http://www.w3.org/svg/2000" viewBox="0 0 30 30" width="60"><circle cy="15" cx="15" r="14" /></svg><p>' + txt + '</p></div>');        $('.loadingModal').css({
327            'display': 'inherit',
328            'position': 'absolute',
329            'z-index': '9999999999',
330            'top': '0',
331            'left': '0',
332            'width': '100%',
333            'text-align': 'center',
334            'height': '100%',
335            'background-color' : ''
336        });
337        $('.loadingModal').fadeIn();
338    }
339
340    jQuery.loadingOFF = function() {
341        $('.loadingModal').fadeOut().remove();
342    }
343
344    jQuery.guideON = function(step) {
345        hideElementListPanel();
346        var $guide = $('<div class="guideModal"></div>');
347
348        if ($('.guideModal').length < 1) {
349            $('body').prepend($guide);
350            $('.guideModal').append('<div class="content"></div>')
351            $('.guideModal').css({
352                'display': 'inherit',
353                'position': 'fixed',
354                'z-index': '99999999',
355                'top': '0',
356                'left': '0',
357                'width': '100%',
358                'text-align': 'center',
359                'background-color' : 'transparent',
360                'height': '100%',
361            });
362            $('.guideModal .content').css({
363                'width' : '100%',
364                'height' : '100%',
365                'background-color' : 'rgba(0,0,0,0.6)',
366                'margin-top' : '35px'
367            });
368            $('.guideModal').fadeIn();
369        }
370
371        $('.guideModal').find('.popover').fadeOut().remove();
372        $('.cleditor-btn.edit-menu').removeClass('active');
373        $('.cleditor-btn.edit-site').removeClass('active');
374        $('.el_0_ctrl .config-element').css('z-index','4');
375        $('.addElementButton').css('z-index','1');
376        $('.config-image-edit').hide();
377        $('.config-element').removeClass('disabled');
378        $('.add-block').removeClass('disabled');
379
380        switch(step) {
381            case 1 : 
382                $('.cleditor-btn.edit-menu').addClass('active');
383                var str = '\
384                <div class="popover bottom">\
385                    <div class="arrow"></div>\
386                    <div class="popover-content" style="padding:15px 15px 10px;font-weight:600;">\
387                        <p>' + $.lang[LANG]["editor.guide.steps.1"] + '</p>\
388                    </div>\
389                    <h3 style="padding:5px;overflow:auto;" class="popover-title" id="popover-bottom">\
390                        <div class="pull-left"><span class="btn btn-default btn-sm" onclick="$.guideON();">' + $.lang[LANG]['config.close'] + '</span></div>\
391                        <div class="pull-right"><span style="padding-right:5px;"> <b>1</b> / 7 </span><span class="btn btn-primary btn-sm" onclick="$.guideON(2);">' + $.lang[LANG]['editor.guide.next'] + '</span></div>\
392                    </h3>\
393                </div>\
394                ';
395                $step1 = $(str);
396                $('.guideModal').find('.content').append($step1);
397                $step1.css({
398                    'top' : $('.editor-navbar').outerHeight()+2,
399                    'left' : '0px'
400                });
401
402                $('.dsgn-body').scrollTop(0);
403                $step1.fadeIn();
404                break;
405
406            case 2 :
407                $('.cleditor-btn.edit-site').addClass('active');
408                var str = '\
409                <div class="popover bottom">\
410                    <div class="arrow"></div>\
411                    <div class="popover-content" style="padding:15px 15px 10px;font-weight:600;">\
412                        <p>' + $.lang[LANG]["editor.guide.steps.2"] + '</p>\
413                    </div>\
414                    <h3 style="padding:5px;overflow:auto;" class="popover-title" id="popover-bottom">\
415                        <div class="pull-left"><button class="btn btn-default btn-sm" onclick="$.guideON()">' + $.lang[LANG]['config.close'] + '</button></div>\
416                        <div class="pull-right"><span style="padding-right:5px;"> <b>2</b> / 7 </span><span class="btn btn-primary btn-sm" onclick="$.guideON(3);">' + $.lang[LANG]['editor.guide.next'] + '</span></div>\
417                    </h3>\
418                </div>\
419                ';
420                $step2 = $(str);
421                $('.guideModal').find('.content').append($step2);
422                $step2.css({
423                    'top' : $('.editor-navbar').outerHeight()+2,
424                    'left' : '332px'
425                });
426                $step2.fadeIn();
427                break;
428
429            case 3:
430                $('.cleditor-btn.edit-site').removeClass('active');
431                $('.element').removeClass('active');
432                if($('.el_0').length<1) {
433                    $.guideON(13);
434                    return false;
435                }
436                $('.el_0_ctrl').hide();
437                $('.el_0').addClass('active');
438                $('.config-element-section').first().show().addClass('active');
439                //$('.el_0_ctrl').show();
440
441                var popover_direction = ($('header').hasClass('sidebar') || $('header').is('[data-layout="sidenav"]')) ? 'right' : 'left',
442                    arrow_style = (popover_direction == 'right') ? 'style="left:-5px; margin-top: -8px; border-right: none;"' : '';
443                var str = '\
444                <div class="popover '+popover_direction+'">\
445                    <div class="arrow" '+arrow_style+'></div>\
446                    <div class="popover-content" style="padding:15px 15px 10px;font-weight:600;">\
447                        <p>' + $.lang[LANG]["editor.guide.steps.3"] + '</p>\
448                    </div>\
449                    <h3 style="padding:5px;overflow:auto;" class="popover-title" id="popover-bottom">\
450                        <div class="pull-left"><button class="btn btn-default btn-sm" onclick="$.guideON()">' + $.lang[LANG]['config.close'] + '</button></div>\
451                        <div class="pull-right"><span style="padding-right:5px;"> <b>3</b> / 7 </span><span class="btn btn-primary btn-sm" onclick="$.guideON(4);">' + $.lang[LANG]['editor.guide.next'] + '</span></div>\
452                    </h3>\
453                </div>\
454                ';
455                $step3 = $(str);
456                $('.guideModal').find('.content').append($step3);
457                var right = ($('header').hasClass('sidebar') || $('header').is('[data-layout="sidenav"]')) ? 'inherit' : '80px',
458                    left = ($('header').hasClass('sidebar') || $('header').is('[data-layout="sidenav"]')) ?  '270px' : 'inherit';
459                $step3.css({
460                    'left' : left,
461                    'top'  : 0,
462                    'right' : right
463                });
464                $step3.fadeIn();
465                $('.el-menu_ctrl').show().css('z-index','99999999');
466                addElementButtonDisplay('el_0');
467                break;
468
469            case 4:
470                $('.el-menu_ctrl').hide();
471                var winHeight = $('.dsgn-body').height(),
472                    elOffsetTop = $('.addel_0').offset().top;
473
474                var arrow = (winHeight>elOffsetTop) ? 'bottom' : 'top';
475                $('.addElementButton').css('z-index','99999999');
476                $('.add-block').removeClass('disabled').css('z-index','99999999');
477                $('.addel_0 li .add-block').show().css('z-index','99999999');
478
479                var str = '\
480                <div class="popover ' + arrow + '">\
481                    <div class="arrow"></div>\
482                    <div class="popover-content" style="padding:15px 15px 10px;font-weight:600;">\
483                        <p>' + $.lang[LANG]["editor.guide.steps.4"] + '</p>\
484                    </div>\
485                    <h3 style="padding:5px;overflow:auto;" class="popover-title" id="popover-bottom">\
486                        <div class="pull-left"><button class="btn btn-default btn-sm" onclick="$.guideON()">' + $.lang[LANG]['config.close'] + '</button></div>\
487                        <div class="pull-right"><span style="padding-right:5px;"> <b>4</b> / 7 </span><span class="btn btn-primary btn-sm" onclick="$.guideON(5);">' + $.lang[LANG]['editor.guide.next'] + '</span></div>\
488                    </h3>\
489                </div>\
490                ';
491                $step4 = $(str);
492                $('.guideModal').find('.content').append($step4);
493
494                var left = ($('.dsgn-body').width()/2) - ($step4.width()/2) - 10;
495                if($('header').hasClass('sidebar') || $('header').is('[data-layout="sidenav"]')) left = left + 260;
496
497                if(elOffsetTop>winHeight) {
498                    $('.dsgn-body').animate({scrollTop:elOffsetTop-($('.dsgn-body').height()/2)},'500','swing', function() {
499                        var top = $('.addel_0').offset().top - 150;
500                        $step4.css({
501                            'top' : top + 'px',
502                            'left' : left + 'px'
503                        });
504                        $step4.fadeIn();
505                    });
506                } else {
507                    if(winHeight/2 > elOffsetTop) {
508                        $step4.removeClass(arrow).addClass('bottom');
509                        var top = elOffsetTop + 40;
510                        $step4.css({
511                            'top' : top + 'px',
512                            'left' : left + 'px'
513                        });
514                        $step4.fadeIn();
515                    } else {
516                        $step4.removeClass(arrow).addClass('top');
517                        var top = elOffsetTop -150;
518                        $step4.css({
519                            'top' : top + 'px',
520                            'left' : left + 'px'
521                        });
522                        $step4.fadeIn();
523                    }
524                }
525                break;
526
527            case 5: 
528                showElList();
529
530                var str = '\
531                <div class="popover right">\
532                    <div class="arrow" style="left:-5px; margin-top: -8px;
532 border-right: none;"></div>\
533                    <div class="popover-content" style="padding:15px 15px 10px;font-weight:600;">\
534                        <p>' + $.lang[LANG]["editor.guide.steps.5"] + '</p>\
535                    </div>\
536                    <h3 style="padding:5px;overflow:auto;" class="popover-title" id="popover-bottom">\
537                        <div class="pull-left"><button class="btn btn-default btn-sm" onclick="$.guideON()">' + $.lang[LANG]['config.close'] + '</button></div>\
538                        <div class="pull-right"><span style="padding-right:5px;"> <b>5</b> / 7 </span><span class="btn btn-primary btn-sm" onclick="$.guideON(6);">' + $.lang[LANG]['editor.guide.next'] + '</span></div>\
539                    </h3>\
540                </div>\
541                ';
542                $step5 = $(str);
543                $('.guideModal').find('.content').append($step5);
544                var top = ($('.guideModal').height()/2) - ($step5.height()/2);
545                $step5.css({
546                    'top' : top + 'px',
547                    'left' : '175px'
548                });
549                $step5.fadeIn(function() {
550                    $('.guideModal .content').css('margin-top','0px');
551                    $('.guideModal .content').css('margin-left','170px');
552                });
553                break;
554
555            case 6:
556                $('.guideModal .content').css('margin-top','35px');
557                $('.guideModal .content').css('margin-left','0px');
558                hideElementListPanel();
559                var str = '\
560                <div class="popover bottom">\
561                    <div class="arrow"></div>\
562                    <div class="popover-content" style="padding:15px 15px 10px;font-weight:600;">\
563                        <p>' + $.lang[LANG]["editor.guide.steps.6"] + '</p>\
564                    </div>\
565                    <h3 style="padding:5px;overflow:auto;" class="popover-title" id="popover-bottom">\
566                        <div class="pull-left"><button class="btn btn-default btn-sm" onclick="$.guideON();">' + $.lang[LANG]['config.close'] + '</button></div>\
567                        <div class="pull-right"><span style="padding-right:5px;"> <b>6</b> / 7 </span><span class="btn btn-primary btn-sm" onclick="$.guideON(7);">' + $.lang[LANG]['editor.guide.next'] + '</span></div>\
568                    </h3>\
569                </div>\
570                ';
571                $step6 = $(str);
572                $('.guideModal').find('.content').append($step6);
573                var left = $('#change-mode').offset().left - ($step6.width()/2) + ($('#change-mode').width()/2);
574                $step6.css({
575                    'top' : $('.editor-navbar').outerHeight()+2,
576                    'left' : left + 'px'
577                });
578                $step6.fadeIn();
579
580                break;
581
582            case 7:
583                $('.guideModal .content').css('margin-left','0px');
584                hideElementListPanel();
585                var str = '\
586                <div class="popover bottom">\
587                    <div class="arrow"></div>\
588                    <div class="popover-content" style="padding:15px 15px 10px;font-weight:600;">\
589                        <p>' + $.lang[LANG]["editor.guide.steps.7"] + '</p>\
590                    </div>\
591                    <h3 style="padding:5px;text-align:right;" class="popover-title" id="popover-bottom"><span style="padding-right:5px;"> <b>7</b> / 7 </span><span class="btn btn-primary btn-sm" onclick="$.guideON();">' + $.lang[LANG]['editor.guide.start'] + '</span></h3>\
592                </div>\
593                ';
594                $step7 = $(str);
595                $('.guideModal').find('.content').append($step7);
596                var left = $('#config-publishing').offset().left - ($step7.width()/2) + ($('#config-publishing').width()/2);
597                $step7.css({
598                    'top' : $('.editor-navbar').outerHeight()+2,
599                    'left' : left + 'px'
600                });
601                $step7.fadeIn();
602
603                break;
604            case 13:
605                $('.el-menu').addClass('active');
606                $('.config-element-section').hide();
607                $('.el-menu_ctrl').show();
608
609                var str = '\
610                <div class="popover left">\
611                    <div class="arrow"></div>\
612                    <div class="popover-content" style="padding:15px 15px 10px;font-weight:600;">\
613                        <p>메뉴변경, 이미지 업로드, 배경색, 여백 조절 등 블럭의 세부사항을 설정할 수 있습니다.</p>\
614                    </div>\
615                    <h3 style="padding:5px;overflow:auto;" class="popover-title" id="popover-bottom">\
616                        <div class="pull-left"><button class="btn btn-default btn-sm" onclick="$.guideON()">' + $.lang[LANG]['config.close'] + '</button></div>\
617                        <div class="pull-right"><span style="padding-right:5px;"> <b>3</b> / 7 </span><span class="btn btn-primary btn-sm" onclick="$.guideON(14);">' + $.lang[LANG]['editor.guide.next'] + '</span></div>\
618                    </h3>\
619                </div>\
620                ';
621                $step3 = $(str);
622                $('.guideModal').find('.content').append($step3);
623                var top = $('.el-menu_ctrl').offset().top - ($step3.height()/2)+27;
624                $step3.css({
625                    'top' : top + 'px',
626                    'left' : 'inherit',
627                    'right' : '80px'
628                });
629                $step3.fadeIn();
630                $('.config-element').addClass('disabled');
631                $('.el-menu_ctrl .config-element').css('z-index','99999999');
632                //addElementButtonDisplay('el_0');
633
634                break;
635
636            case 14:
637                $('.el-menu_ctrl .config-element').hide();
638                var str = '\
639                <div class="popover right">\
640                    <div class="arrow"></div>\
641                    <div class="popover-content" style="padding:15px 15px 10px;font-weight:600;">\
642                        <p>현재 선택된 위치에 블럭을 추가하여 사이트를 만들 수 있습니다.</p>\
643                    </div>\
644                    <h3 style="padding:5px;overflow:auto;" class="popover-title" id="popover-bottom">\
645                        <div class="pull-left"><button class="btn btn-default btn-sm" onclick="$.guideON()">' + $.lang[LANG]['config.close'] + '</button></div>\
646                        <div class="pull-right"><span style="padding-right:5px;"> <b>4</b> / 7 </span><span class="btn btn-primary btn-sm" onclick="$.guideON(5);">' + $.lang[LANG]['editor.guide.next'] + '</span></div>\
647                    </h3>\
648                </div>\
649                ';
650                $step4 = $(str);
651                var top = $('.addEL-wrap').offset().top + ($('.addEL-wrap').height()/2) - 90;
652                $step4.css({
653                    'top' : top + 'px',
654                    'left': '50%',
655                    'margin-left' : '100px'
656                });
657                $('.guideModal').find('.content').append($step4);
658                $step4.fadeIn();
659                break;
660            default : 
661                var settings = {
662                    'showGuide' : 'none'
663                };
664                $.post('/template/settings',{ sid : SID, settings : JSON.stringify(settings), el : 'site_settings' }, function(data) {
665                    checkError(data);
666                },'json');
667
668                $('.guideModal').find('.popover').fadeOut().remove();
669                $('.cleditor-btn.edit-menu').removeClass('active');
670                $('.cleditor-btn.edit-site').removeClass('active');
671                $('.el_0_ctrl .config-element').css('z-index','4');
672                $('.addElementButton').css('z-index','1').hide();
673                $('.config-image-edit').hide();
674                $('.config-element').removeClass('disabled');
675                $('.add-block').removeClass('disabled');
676                $('.config-element-section.active').removeClass('active').fadeOut();
677                $('.guideModal').fadeOut().remove();
678                //$.quickON(0);
679                $.guideVideoON();
680                break;
681        }
682    }
683
684    jQuery.quickON = function(menu) {
685        hideElementListPanel();
686        var $quick = $('<div class="quickModal"></div>'),
687            $content = $('<div class="content"></div>');
688
689        if ($('.quickModal').length < 1) {
690            $('body').prepend($quick);
691            /*$content.on('click',function() {
692                $.quickOFF();
693            });*/
694            $content.css({
695                'width' : '100%',
696                'height' : '100%',
697                'background-color' : 'rgba(0,0,0,0.6)',
698                'display' : 'none'
699            });
700
701            $quick.append($content);
702            $quick.css({
703                'display': 'inherit',
704                'position': 'fixed',
705                'z-index': '99999999',
706                'top': '0',
707                'left': '0',
708                'width': '100%',
709                'height': '100%',
710                'text-align': 'center',
711                'background-color' : 'transparent'
712            });
713            $quick.fadeIn();
714
715            var hostAry = HOST.split('.');
716
717            if (hostAry.length >= 3) {
718                HOST = hostAry[1]+'.'+hostAry[2];
719            }
720            var supportUrl = (LANG == 'ko') ? 'https://supportcenter.creatorlink.net/creatorlink/' : 'https://supportcenter.creatorlink.net/creatorlink-support-center/';
721            var chkgcp = window.location.hostname;
722            if(typeof chkgcp !== 'undefined' && chkgcp.indexOf('creatorlink.co.kr') > -1) {
723                supportUrl = 'https://supportcenter.creatorlink.net/migration/';
724            }
725                
726            var $guide = $('<div class="guide">'),
727                $close = $('<div class="close"><img src="https://storage.googleapis.com/i.addblock.net/fa-close-modal.png" alt="close" /></div>'),
728                $header = $('<div class="header"><h2>' + $.lang[LANG]["editor.guide-title"] + '</h2></div>'),
729                $linksWrap = $('<div class="links-wrap"></div>'),
730                $mainguide = $('<span class="mainguide"><i class="fa fa-plus-circle"></i>' + $.lang[LANG]["editor.guide.walkthrough"] + '</sort-page-linen>'),
731                $supportLink = $('</div><span class="support-link-wrap"><a class="support-link" href="' + supportUrl + '" target="_blank"><i class="fa fa-plus-circle"></i>' + $.lang[LANG]["editor.guide.support-center"] + '</a></span>'),
732                $body = $('<div class="body"></div>'),
733                $sidebar = $('<div class="sidebar"></div>'),
734                nav = new Array( $.lang[LANG]["editor.guide.tutorial-video"], $.lang[LANG]["editor.menu-config"], $.lang[LANG]["editor.site-config"], $.lang[LANG]["config.element-config"], $.lang[LANG]["editor.guide.add-blocks"], $.lang[LANG]["editor.image.add-change"], $.lang[LANG]["editor.guide.edit-text"], $.lang[LANG]["editor.guide.gallery"], $.lang[LANG]["editor.guide.preview-publish"]),
735                $nav = $('<ul class="nav"></ul>'),
736                $bottom = $('<div class="bottom"></div>');
737
738            $mainguide.on('click', function() {
739                $.quickOFF();
740                $.guideON(1);
741            });
742
743            $close.on('click',function() { $.quickOFF(); });
744
745            // 임시 - 한국어 동영상이 완료될 때까지 만 
746            if (LANG != 'en') {
747               nav.shift();
748            }
749
750            $.each(nav, function(i,v){
751                $li = $('<li class="'+i+'">'+v+'<img src="https://storage.googleapis.com/i.addblock.net/config/fa_thin_right_w.png" alt="" /></li>');
752                $nav.append($li);
753            });
754            $navli = $nav.children();
755            $navli.on('click',function() {
756                var classtext = $(this).attr('class');
757                $.quickON(Number(classtext.substring(0,1)));
758            });
759            $sidebar.append($nav).append($bottom);
760
761            var $contentbox = $('<div class="contentbox"></div>');
762
763            $body.append($sidebar).append($contentbox);
764            $linksWrap.append($mainguide, $supportLink);
765            $header.append($linksWrap);
766            $guide.append($header).append($close).append($body);
767            $content.append($guide);
768            $content.fadeIn();
769
770        }
771
772        var $thisContent = $('.quickModal .contentbox'),
773            $thisMenu = $('.quickModal .sidebar .nav li');
774        $thisMenu.removeClass('active');
775        $thisMenu.eq(menu).addClass('active');
776
777        var lang;
778
779        if (LANG == 'en') {
780            lang = '_' + LANG;
781
782            // 제임스: 임시로 여기로 옮겼음 (나중에 한 switch으로 할 예정)
783            switch(menu) {
784                case 0 :  /* 가이드 동영상 */
785
786                    var str = '\
787                    <ul>\
788                        <li><h4>' + $.lang[LANG]["editor.guide.tutorial-video"] + '</h4></li>\
789                        <li><p>' + $.lang[LANG]["editor.guide.tutorial-video.text"] + '</p></li>\
790                    </ul>\
791                    ';
792
793                    var $quickVideoWrap = $('<li></li>'),
794                        $tutorialVideo = $('<div class="tutorial-video"></div>'),
795                        $videoWrap = $('<div class="video-wrap guideVideo-stopPlay"><div id="quick-guide-video-overlay"></div></div>');
796
797                    $menu0 = $(str);
798                    $tutorialVideo.append( $videoWrap ); 
799                    $quickVideoWrap.append( $tutorialVideo );
800                    $menu0.append( $quickVideoWrap );
801
802                    $thisContent.empty();
803                    $thisContent.append($menu0);
804                    $menu0.fadeIn();
805
806                    $videoWrap.on('click', function() {
807
808                        $(this).toggleClass('guideVideo-stopPlay');
809
810                        if(!$(this).hasClass('guideVideo-stopPlay')) {
811                            if ( LANG == 'en' )
812                                var link = 'https://www.youtube.com/embed/p6fyIMl2BcI';
813
814                            var html = '<iframe class="video embed-responsive-item" width="765" height="380" src="' + link + '?enablejsapi=1&rel=0&vq=large&wmode=
814opaque&showinfo=0&controls=1&autoplay=0&loop=0;playlist=Fn0Mpyh3xto;" frameborder="0" allowfullscreen></iframe>';
815                            $(this).html(html);
816                        }
817                    });   
818
819                    break;
820                case 1 :  /*메뉴 설정*/
821                    var str = '\
822                    <ul>\
823                        <li><h4>' + $.lang[LANG]["editor.menu-config"] + '</h4></li>\
824                        <li><p>' + $.lang[LANG]["editor.guide.menu-config.text.1"] + '</p></li>\
825                        <li><img src="https://storage.googleapis.com/i.addblock.net/config/quickguid_0_1' + lang + '.png " alt="" /></li>\
826                    </ul>\
827                    ';
828                    $menu1 = $(str);
829
830                    $thisContent.empty();
831                    $thisContent.append($menu1);
832                    $menu1.fadeIn();
833                    break;
834                case 2 :  /*사이트 설정*/
835                    var str = '\
836                    <ul>\
837                        <li><h4>' + $.lang[LANG]["editor.site-config"] + '</h4></li>\
838                        <li><p>' + $.lang[LANG]["editor.guide.site-config.text.1"] + '</p></li>\
839                        <li><img src="https://storage.googleapis.com/i.addblock.net/config/quickguid_1_1' + lang + '.png" alt="" /></li>\
840                    </ul>\
841                    ';
842                    $menu2 = $(str);
843                    $thisContent.empty();
844                    $thisContent.append($menu2);
845                    $menu2.fadeIn();
846                    break;
847                case 3 :  /*블럭 설정*/
848                    var str = '\
849                    <ul>\
850                        <li><h4>' + $.lang[LANG]["config.element-config"] + '</h4></li>\
851                        <li><p>' + $.lang[LANG]["editor.guide.element-config.text.1"] + '</p></li>\
852                        <li><h6><img src="https://storage.googleapis.com/i.addblock.net/config/fa_exclamation.png" alt="" class="fa"/> ' + $.lang[LANG]["editor.guide.element-config.text.note"] + '</h6></li>\
853                        <li><img src="https://storage.googleapis.com/i.addblock.net/config/quickguid_2_1' + lang + '.png" alt="" /></li>\
854                    </ul>\
855                    ';
856                    $menu3 = $(str);
857                    $thisContent.empty();
858                    $thisContent.append($menu3);
859                    $menu3.fadeIn();
860                    break;
861                case 4 :  /*블럭 추가*/
862                    var str = '\
863                    <ul>\
864                        <li><h4>' + $.lang[LANG]["editor.guide.add-blocks"] + '</h4></li>\
865                        <li><p>' + $.lang[LANG]["editor.guide.add-block.text.1"] + '</p></li>\
866                        <li><img src="https://storage.googleapis.com/i.addblock.net/config/quickguid_3_1' + lang + '.png" alt="" /></li>\
867                    </ul>\
868                    ';
869                    $menu4 = $(str);
870                    $thisContent.empty();
871                    $thisContent.append($menu4);
872                    $menu4.fadeIn();
873                    break;
874                case 5 :  /*이미지 추가/변경*/
875                    var str = '\
876                    <ul>\
877                        <li><h4>' + $.lang[LANG]["editor.image.add-change"] + '</h4></li>\
878                        <li><p>' + $.lang[LANG]["editor.guide.add-change-images.text.1"] + '</p></li>\
879                        <li><h6><img src="https://storage.googleapis.com/i.addblock.net/config/fa_exclamation.png" alt="" class="fa"/>' + $.lang[LANG]["editor.guide.add-change-images.text.note"] + '</h6></li>\
880                        <li><img src="https://storage.googleapis.com/i.addblock.net/config/quickguid_4_1.png" alt="" /></li>\
881                    </ul>\
882                    ';
883                    $menu5 = $(str);
884                    $thisContent.empty();
885                    $thisContent.append($menu5);
886                    $menu5.fadeIn();
887                    break;
888                case 6 :  /*텍스트*/
889                    var str = '\
890                    <ul>\
891                        <li><h4>' + $.lang[LANG]["config.text"] + '</h4></li>\
892                        <li><p>' + $.lang[LANG]["editor.guide.edit-text.text.1"] + '</p></li>\
893                        <li><img src="https://storage.googleapis.com/i.addblock.net/config/quickguid_5_1' + lang + '.png" alt="" /></li>\
894                    </ul>\
895                    ';
896                    $menu6 = $(str);
897                    $thisContent.empty();
898                    $thisContent.append($menu6);
899                    $menu6.fadeIn();
900                    break;
901                case 7 :  /*갤러리*/
902                    var str = '\
903                    <ul>\
904                        <li><h4>' + $.lang[LANG]["editor.block.gallery"] + '</h4></li>\
905                        <li><p>' + $.lang[LANG]["editor.guide.gallery.text.1"] + '</p></li>\
906                        <li><img src="https://storage.googleapis.com/i.addblock.net/config/quickguid_6_1.png" alt="" /></li>\
907                        <li><hr /></li>\
908                        <li><p>' + $.lang[LANG]["editor.guide.gallery.text.2"] + '</p></li>\
909                        <li><img src="https://storage.googleapis.com/i.addblock.net/config/quickguid_6_2' + lang + '.png" alt="" /></li>\
910                        <li><h6><img src="https://storage.googleapis.com/i.addblock.net/config/fa_exclamation.png" alt="" class="fa"/> ' + $.lang[LANG]["editor.guide.gallery.text.note"] + '</h6></li>\
911                    </ul>\
912                    ';
913                    $menu7 = $(str);
914                    $thisContent.empty();
915                    $thisContent.append($menu7);
916                    $menu7.fadeIn();
917                    break;
918                case 8 :  /*저장/게시*/
919                    var str = '\
920                    <ul>\
921                        <li><h4>' + $.lang[LANG]["editor.guide.preview-publish"] + '</h4></li>\
922                        <li><img src="https://storage.googleapis.com/i.addblock.net/config/quickguid_7_1' + lang + '.png" alt="" style="margin-top: 0"/></li>\
923                        <li><p>' + $.lang[LANG]["editor.guide.preview-publish.text.1"] + '</p></li>\
924                        <li><h6><img src="https://storage.googleapis.com/i.addblock.net/config/fa_exclamation.png" alt="" class="fa"/> ' + $.lang[LANG]["editor.guide.preview-publish.text.note"] + '</h6></li>\
925                    </ul>\
926                    ';
927                    $menu8 = $(str);
928                    $thisContent.empty();
929                    $thisContent.append($menu8);
930                    $menu8.fadeIn();
931                    break;
932                default : 
933                    $.quickOFF();
934                    break;
935            }
936        }
937        else {
938            lang = '';
939
940            // 제임스: 임시로 여기로 옮겼음 (나중에 한 switch으로 할 예정)
941            switch(menu) {
942                case 0 :  /*메뉴 설정*/
943                    var str = '\
944                    <ul>\
945                        <li><h4>' + $.lang[LANG]["editor.menu-config"] + '</h4></li>\
946                        <li><p>' + $.lang[LANG]["editor.guide.menu-config.text.1"] + '</p></li>\
947                        <li><img src="https://storage.googleapis.com/i.addblock.net/config/quickguid_0_1' + lang + '.png " alt="" /></li>\
948                    </ul>\
949                    ';
950                    $menu0 = $(str);
951
952                    $thisContent.empty();
953                    $thisContent.append($menu0);
954                    $menu0.fadeIn();
955                    break;
956                case 1 :  /*사이트 설정*/
957                    var str = '\
958                    <ul>\
959                        <li><h4>' + $.lang[LANG]["editor.site-config"] + '</h4></li>\
960                        <li><p>' + $.lang[LANG]["editor.guide.site-config.text.1"] + '</p></li>\
961                        <li><img src="https://storage.googleapis.com/i.addblock.net/config/quickguid_1_1' + lang + '.png" alt="" /></li>\
962                    </ul>\
963                    ';
964                    $menu1 = $(str);
965                    $thisContent.empty();
966                    $thisContent.append($menu1);
967                    $menu1.fadeIn();
968                    break;
969                case 2 :  /*블럭 설정*/
970                    var str = '\
971                    <ul>\
972                        <li><h4>' + $.lang[LANG]["config.element-config"] + '</h4></li>\
973                        <li><p>' + $.lang[LANG]["editor.guide.element-config.text.1"] + '</p></li>\
974                        <li><h6><img src="https://storage.googleapis.com/i.addblock.net/config/fa_exclamation.png" alt="" class="fa"/> ' + $.lang[LANG]["editor.guide.element-config.text.note"] + '</h6></li>\
975                        <li><img src="https://storage.googleapis.com/i.addblock.net/config/quickguid_2_1' + lang + '.png" alt="" /></li>\
976                    </ul>\
977                    ';
978                    $menu2 = $(str);
979                    $thisContent.empty();
980                    $thisContent.append($menu2);
981                    $menu2.fadeIn();
982                    break;
983                case 3 :  /*블럭 추가*/
984                    var str = '\
985                    <ul>\
986                        <li><h4>' + $.lang[LANG]["editor.guide.add-blocks"] + '</h4></li>\
987                        <li><p>' + $.lang[LANG]["editor.guide.add-block.text.1"] + '</p></li>\
988                        <li><img src="https://storage.googleapis.com/i.addblock.net/config/quickguid_3_1' + lang + '.png" alt="" /></li>\
989                    </ul>\
990                    ';
991                    $menu3 = $(str);
992                    $thisContent.empty();
993                    $thisContent.append($menu3);
994                    $menu3.fadeIn();
995                    break;
996                case 4 :  /*이미지 추가/변경*/
997                    var str = '\
998                    <ul>\
999                        <li><h4>' + $.lang[LANG]["editor.image.add-change"] + '</h4></li>\
1000                        <li><p>' + $.lang[LANG]["editor.guide.add-change-images.text.1"] + '</p></li>\
1001                        <li><h6><img src="https://storage.googleapis.com/i.addblock.net/config/fa_exclamation.png" alt="" class="fa"/>' + $.lang[LANG]["editor.guide.add-change-images.text.note"] + '</h6></li>\
1002                        <li><img src="https://storage.googleapis.com/i.addblock.net/config/quickguid_4_1.png" alt="" /></li>\
1003                    </ul>\
1004                    ';
1005                    $menu4 = $(str);
1006                    $thisContent.empty();
1007                    $thisContent.append($menu4);
1008                    $menu4.fadeIn();
1009                    break;
1010                case 5 :  /*텍스트*/
1011                    var str = '\
1012                    <ul>\
1013                        <li><h4>' + $.lang[LANG]["config.text"] + '</h4></li>\
1014                        <li><p>' + $.lang[LANG]["editor.guide.edit-text.text.1"] + '</p></li>\
1015                        <li><img src="https://storage.googleapis.com/i.addblock.net/config/quickguid_5_1' + lang + '.png" alt="" /></li>\
1016                    </ul>\
1017                    ';
1018                    $menu5 = $(str);
1019                    $thisContent.empty();
1020                    $thisContent.append($menu5);
1021                    $menu5.fadeIn();
1022                    break;
1023                case 6 :  /*갤러리*/
1024                    var str = '\
1025                    <ul>\
1026                        <li><h4>' + $.lang[LANG]["editor.block.gallery"] + '</h4></li>\
1027                        <li><p>' + $.lang[LANG]["editor.guide.gallery.text.1"] + '</p></li>\
1028                        <li><img src="https://storage.googleapis.com/i.addblock.net/config/quickguid_6_1.png" alt="" /></li>\
1029                        <li><hr /></li>\
1030                        <li><p>' + $.lang[LANG]["editor.guide.gallery.text.2"] + '</p></li>\
1031                        <li><img src="https://storage.googleapis.com/i.addblock.net/config/quickguid_6_2' + lang + '.png" alt="" /></li>\
1032                        <li><h6><img src="https://storage.googleapis.com/i.addblock.net/config/fa_exclamation.png" alt="" class="fa"/> ' + $.lang[LANG]["editor.guide.gallery.text.note"] + '</h6></li>\
1033                    </ul>\
1034                    ';
1035                    $menu6 = $(str);
1036                    $thisContent.empty();
1037                    $thisContent.append($menu6);
1038                    $menu6.fadeIn();
1039                    break;
1040                case 7 :  /*저장/게시*/
1041                    var str = '\
1042                    <ul>\
1043                        <li><h4>' + $.lang[LANG]["editor.guide.preview-publish"] + '</h4></li>\
1044                        <li><img src="https://storage.googleapis.com/i.addblock.net/config/quickguid_7_1' + lang + '.png" alt="" style="margin-top: 0"/></li>\
1045                        <li><p>' + $.lang[LANG]["editor.guide.preview-publish.text.1"] + '</p></li>\
1046                        <li><h6><img src="https://storage.googleapis.com/i.addblock.net/config/fa_exclamation.png" alt="" class="fa"/> ' + $.lang[LANG]["editor.guide.preview-publish.text.note"] + '</h6></li>\
1047                    </ul>\
1048                    ';
1049                    $menu7 = $(str);
1050                    $thisContent.empty();
1051                    $thisContent.append($menu7);
1052                    $menu7.fadeIn();
1053                    break;
1054                default : 
1055                    $.quickOFF();
1056                    break;
1057            }
1058        }
1059
1060    }
1061
1062    jQuery.quickOFF = function() {
1063        $('.quickModal').fadeOut(function() {
1064            $(this).remove();  
1065        });
1066    }
1067
1068    $('.quickModal').live({
1069        click: function(e) {
1070            if($(e.target).parents('.guide').length < 1) $.quickOFF();
1071        }
1072    });
1073
1074    $.fn.addSvgClass = function(cls) {
1075        return this.each(function() {
1076            var $t = $(this);
1077
1078            if ($t[0] instanceof SVGElement) {
1079                if (!$t[0].classList.contains(cls)) {
1080                    $t[0].classList.add(cls);
1081                }
1082            } else {
1083                $t.addClass(cls);
1084            }
1085        });
1086    };
1087
1088    $.fn.removeSvgClass = function(cls) {
1089        return this.each(function() {
1090            var $t = $(this);
1091
1092            if ($t[0] instanceof SVGElement) {
1093                if ($t[0].classList.contains(cls)) {
1094                    $t[0].classList.remove(cls);
1095                }
1096            } else {
1097                $t.removeClass(cls);
1098            }
1099        });
1100    };
1101
1102    jQuery.setAloneBlockError = function(centerArea,return_v) {
1103        if(typeof return_v != 'boolean') return_v = false;
1104
1105        var onoff = false;
1106        if(typeof centerArea == 'undefined' || $(centerArea).length === 0) {
1107            if(return_v) return onoff;
1108        } else {
1109            var center_b = $(centerArea).find('.reorderBlock').length,
1110                center_lb = $(centerArea).find('.reorderBlock[data-mode="shopping"]').length,
1111                center_fb = $(centerArea).find('.reorderBlock[data-feature*="fixedscroll"]').length,
1112                check_lux = (LUX && (center_lb > 1)) ? true : false,
1113                check_fixedscroll = (center_fb > 1 || (center_fb == 1 && center_b > 1)) ? true : false;
1114            onoff = (check_lux || check_fixedscroll) ? true : false;
1115
1116            if(onoff) {
1117                var error_str = (check_lux) ? $.lang[LANG]['config.lux.shopping.not-supported.reorder'] : $.lang[LANG]['config.premium.gallery.fixedscroll.not-supported.reorder'];
1118                $('.reorderModal').addClass('aloneBlockError');
1119                if($('.reorderModal .alone_b_error').length === 0) $('.reorderModal').append('<div class="alone_b_error">' + error_str + '</div>');
1120                $('.reorderModal .alone_b_error').slideDown(200);
1121            } else {
1122                $('.reorderModal .alone_b_error').slideUp(200, function() {
1123                    $('.reorderModal').removeClass('aloneBlockError');    
1124                });
1125            }
1126
1127            if(return_v) return onoff;
1128        }
1129    }
1130
1131    jQuery.reorderON = function(pageMenuStr) {
1132        $.processON('Loading blocks ...');
1133        if(pageMenuStr == 'index') pageMenuStr = '';
1134        if(prevPAGE == 'index') prevPAGE = '';
1135        if(prevONE) prevPAGE = ORG_PAGES[selectID];
1136        window.currentPageMenu = pageMenuStr ? pageMenuStr.toString() : prevPAGE;
1137        window.currentPageMenuIdx = -1;
1138        window.copy_menu_list = MENULIST;
1139        // if(copy_menu_list[0] == 'INTRO') copy_menu_list.splice(0, 1);
1140
1141        var enable = true;
1142        if(!window.basketBlockHtml)
1143            window.basketBlockHtml = '';
1144
1145        if(!window.pageListChangeFlag) window.pageListChangeFlag = [];
1146
1147        if($('.ctrl-reorder').hasClass('disabled')) return;
1148        
1149        // var el = [], idx = 0;
1150        // var toolbar = ($('.editor-navbar').css('display')=='none') ? 0 : 35;
1151        // var sidebar = ($('header').hasClass('sidebar')) ? true : false;
1152        var el_fixed = (reorderFIXED) ? reorderFIXED.split(':') : [];
1153
1154        // $.each($('.element'),function(i,v) {
1155        //     if( $(v).data('el') == 'el-menu' || 
1156        //         $(v).data('el') == 'el-footer' || 
1157        //         $(v).hasClass('add-footer-information') ||
1158        //         $(v).hasClass('cl-s-product-review') ||
1159        //         $(v).hasClass('cl-s-product-qna')
1160        //     ) return true;
1161
1162        //     if(reorderFIXED) {
1163        //         if($(v).hasClass('el-fixedblock')) {
1164        //             if($(v).attr('data-posby') != el_fixed[2]) return true;
1165        //         } else return true;
1166        //     } else {
1167        //         if($(v).hasClass('el-fixedblock')) return true;
1168        //     }
1169
1170        //     el[idx] = $(v).attr('data-el') + '|' + ($(v).offset().top - toolbar) + '-' + $(v).outerHeight();    
1171        //     idx++;
1172        // });
1173        // eloffSet = el.toString();
1174
1175        var $reorder = $('<div class="reorderModal"></div>');
1176        if($('.reorderModal').length < 1) {
1177            $('body').prepend($reorder);
1178            $reorder.css({
1179                'position' : 'fixed',
1180                'width' : '100%',
1181                'height' : '100%',
1182                'background' : '#eef0f4',
1183                'z-index' : '1049',
1184                'display' : 'none',
1185                'overflow' : 'auto'
1186            });
1187        } else {
1188            // $('.reorderModal').empty();
1189            $reorder = $(".reorderModal");
1190        }
1191                           //<div class="scale" style="margin-top: 0; height: 100%; width: calc(388px * 5); margin-left: calc((-388px * 5) /2 + 50%); ">\
1192        var reorder_title = (reorderFIXED) ? $.lang[LANG]['editor.reorder-blocks.title.'+el_fixed[2]] : $.lang[LANG]['editor.reorder-blocks.title'],
1193        $content = $('<div class="content" style="display: flex;"></div>'),
1194        $left_area = $('<div class="left-area ' + (VIEW ? ' view-exist ' : '')  + '" style="flex: 1 1 40%; max-width: calc(48% - 155px);">\
1195                            <div style="display: flex; -webkit-box-pack: end; -ms-flex-pack: end; justify-content: flex-end;">\
1196                                <div class="" style="max-width: 385px; height: 100%; background-color: #fff; position: fixed; width: calc(48% - 155px);">\
1197                                    <div class="" style="text-align: center; padding-top: 30px; padding-bottom: 53px;"><h4 style="margin-top: 10px;">' + $.lang[LANG]['config.blockmove.moveblock'] + '</h4></div>\
1198                                    <div class="scale" style="margin-top: 0; width: calc(100% / 0.166); height: calc(100% / 0.166 - (124px / 0.166)) !important; overflow-y: auto; overflow-x: hidden; transform: scale(.166);">\
1199                                        <div class="el-sortable">\
1200                                            <div class="sort-empty guide-text">' + $.lang[LANG]['config.blockmove.movehere'] + '</div>\
1201                                        </div>\
1202                                    </div>\
1203                                </div>\
1204                            </div>\
1205                        </div>'),
1206        $center_area = $('<div class="center-area ' + (VIEW ? ' view-exist ' : '') + ' " style="flex: 1 1 40%; max-width: calc(47% - 155px);"><div class="block-area" style="max-width: 400px; margin: 0 auto;"><div class="page-list-area"><div class="btn-group"></div></div></div></div>'),
1207        $right_area = $('<div class="right-area" style="flex: 1 1 30%; padding: 30px 40px 0 0; position: fixed; right: 0; z-index: 4;"></div>'),
1208        // $scale = $('<div class="scale" style="width: calc(388px * 5); margin-left: calc((-388px * 5) /2 + 50%);"></div>');
1209        $scale = $('<div class="scale" style="width: 500%;"></div>'),
1210        $save = $('<span class="btn btn-primary btn-flat btn-sm pull-right">' + $.lang[LANG]['config.save'] + '</span>'),
1211        $close = $('<span class="btn btn-default btn-flat btn-sm pull-right">' + $.lang[LANG]['config.cancel'] + '</span>').css('margin-right','10px');
1212
1213        $close.on('click',function() {
1214            $.processON('','#fff');
1215            $.reorderOFF();
1216
1217            setConfigLogs('block.reorder','cancel',{'seq':selectID},PAGE);
1218
1219            if(!VIEW && (prevPAGE || PAGE)) {
1220                var refer = prevPAGE ? prevPAGE.replace(',','/view/') : PAGE.replace(',','/view/');
1221                location.replace('/'+CONFIG_URL+'config/page/' + refer);
1222            } else {
1223                location.reload();
1224                $.processOFF();
1225            }
1226        });
1227
1228        $save.on('click',function() {
1229            if(basketBlockHtml != '') {
1230                alert($.lang[LANG]['config.blockmove.blockleft']);
1231                return false;
1232            }
1233
1234            var checkAloneBlock = $.setAloneBlockError($center_area,true);
1235            if(checkAloneBlock) {
1236                console.log('error');
1237                return false;
1238            }
1239
1240
1241            $.processON($.lang[LANG]['config.reorder.loading']);
1242
1243            // var rPage = '';
1244            // $.each($('.el-sortable').children(), function(i,v) {
1245            //     var page_name = $(v).attr('data-result-page');
1246            //     if(typeof page_name !='undefined' && page_name && $(v).hasClass('sort-empty')) {
1247            //         rPage = $(v).attr('data-result-page');
1248            //         return true;
1249            //     }
1250
1251            //     $(v).attr('data-reorder-page',rPage);
1252            // });
1253            var r = [];
1254            // $.each($('.center-area .reorderBlock'), function(i,v) {
1255            //     tmp = $(this).attr('data-reorder-page') + ':' + $(this).attr('data-id');
1256            //     if(reorderFIXED) tmp += ':' + el_fixed[2];
1257            //     r.push(tmp);
1258            // });
1259
1260            var clog_more_obj = {};
1261            $(pageList).each(function(idx) {
1262                var loopPage = this;
1263                if(!ONE && typeof pageListChangeFlag[idx] == 'undefined') return true;
1264                if(typeof pageList[idx] == 'undefined') return true;
1265
1266                var loop_pagename = (!VIEW) ? window.copy_menu_list[idx] : currentPageMenu;
1267                clog_more_obj[loop_pagename] = {
1268                    'before': clogPageList[idx],
1269                    'after' : loopPage,
1270                };
1271
1272                $(loopPage).each(function() {
1273                    var tmp = loop_pagename + ':' + this;
1274                    if(reorderFIXED) tmp += ':' + el_fixed[2];
1275                    r.push(tmp);
1276                });
1277            });
1278
1279            setConfigLogs('block.reorder','save.click',{'seq':selectID, 'more_obj':clog_more_obj},PAGE);
1280            var view_page = (reorderFIXED) ? el_fixed[1] : currentPageMenu;
1281            $.ajax({
1282                type: 'POST',
1283                url: '/template/update/type/block-reorder',
1284                data: { s: JSON.stringify(r), id: SID, page: view_page, onepage : ONE},
1285                async:true,
1286                cache: false,
1287                success: function (data) {
1288                    var type = getElementType();
1289                    setLogs(type,'block.reorder','block-sort','','product-manager','el');
1290                    $('.element').removeClass('active').removeClass('el-active');
1291                    $('#el-property').hide();
1292
1293
1294                    setConfigLogs('block.reorder','save.end',{'seq':selectID},PAGE);
1295                    if(!VIEW && (prevPAGE || PAGE)) {
1296                        var refer = prevPAGE ? prevPAGE.replace(',','/view/') : PAGE.replace(',','/view/');
1297                        location.replace('/'+CONFIG_URL+'config/page/' + refer);
1298                    } else {
1299                        location.reload();
1300                    }
1301                    $.processOFF();
1302                    $.reorderOFF();
1303                    checkError(data);
1304                }
1305            });
1306            /*
1307            var ids = [];
1308            $.each($('.render'), function(i,v) {
1309                if(typeof $(v).attr('data-id') != 'undefined') ids.push($(v).attr('data-id').trim());
1310            });
1311
1312            $.post('/template/update/type/block-reorder',{ id : SID, page : PAGE, s:ids.join(',')}, function(data) {
1313                checkError(data);
1314            },'json');
1315            return false;
1316            */
1317        });
1318
1319        $content.append($left_area);
1320
1321        if(window.basketBlockHtml && window.basketBlockHtml != '') {
1322            $left_area.find(".el-sortable").append(window.basketBlockHtml);
1323            $left_area.find(".sort-empty").hide();
1324            $left_area.find(".reorderBlock").removeClass("active");
1325        }
1326
1327        $right_area.append($save);
1328        $right_area.append($close);
1329        $content.append($center_area);
1330        $content.append($right_area);
1331        $center_area.find(".block-area").append($scale);
1332        $reorder.html($content);
1333
1334        var $sort = $('<div class="el-sortable"></div>');
1335        $sort.css('color',$('.dsgn-body').css('color'));
1336
1337        if(!$(".new-dsgn-body").length) {
1338            var temp_dsgn_body = $('<div class="new-dsgn-body"><div class="elements"></div></div>');
1339            $("body").append(temp_dsgn_body);
1340        } else {
1341            var temp_dsgn_body = $(".reorderModal .new-dsgn-body");
1342            // temp_dsgn_body.empty();
1343        }
1344
1345        $reorder.fadeIn();
1346
1347        //var $scale = $('<div class="scale"></div>');
1348        //$scale.css('color',$('.dsgn-body').css('color'));
1349        var elIndex = 0;
1350
1351        window.pageMenu = [];
1352        // if(PAGE == 'index') {
1353        //     $.each(MENULINK,function(i,v) {
1354        //     //$.each(SMENU,function(i,v) {
1355        //         pageMenu.push(v.replace(/ /g,'-'));
1356        //         //if(v.display == 'on') pageMenu.push(v.name);
1357        //     });
1358        // } else {
1359        var view_page = (reorderFIXED) ? el_fixed[1] : PAGE;
1360        pageMenu.push(view_page);
1361        // }
1362
1363        var pageMenuSelect = '';
1364
1365        if(!VIEW) {
1366            if(!window.currentPageMenu || window.currentPageMenu == '') window.currentPageMenu = copy_menu_list[0];
1367
1368            var reorderMenuSeparator = (typeof MENU_ROUTE_SEPARATOR != 'undefined') ? MENU_ROUTE_SEPARATOR : '~';
1369            var escapeReorderHtml = (typeof escapeMenuDisplayHtml == 'function') ? escapeMenuDisplayHtml : function(value) {
1370                return String(value == null ? '' : value)
1371                    .replace(/&/g, '&amp;')
1372                    .replace(/</g, '&lt;')
1373                    .replace(/>/g, '&gt;');
1374            };
1375            var escapeReorderAttr = (typeof escapeMenuDisplayAttr == 'function') ? escapeMenuDisplayAttr : function(value) {
1376                return escapeReorderHtml(value)
1377                    .replace(/"/g, '&quot;')
1378                    .replace(/'/g, '&#39;');
1379            };
1380            var getReorderDisplayName = (typeof getMenuDisplayNameText == 'function') ? getMenuDisplayNameText : function(value) {
1381                return String(value == null ? '' : value).replace(/-/g, ' ');
1382            };
1383            var getReorderPathHtml = function($item, pageName) {
1384                if ($item && $item.length > 0 && typeof getMenuDisplayPathHtmlFromLi == 'function') return getMenuDisplayPathHtmlFromLi($item);
1385                if (typeof getMenuDisplayPathHtml == 'function') return getMenuDisplayPathHtml(pageName);
1386                return escapeReorderHtml(String(pageName || '').split(reorderMenuSeparator).join(' > ').replace(/-/g, ' '));
1387            };
1388            var getReorderPageLabel = function(pageName) {
1389                pageName = String(pageName || '');
1390                return (pageName.indexOf(reorderMenuSeparator) > -1) ? pageName.split(reorderMenuSeparator).pop() : pageName;
1391            };
1392            var getReorderMenuItem = function(pageName) {
1393                var $matched = $();
1394                $("#nestable").find(".dd-first, .dd-item:not(.dd-dummy)").each(function () {
1395                    var $item = $(this);
1396                    var itemPage = (typeof getMenuPageFromLi == 'function') ? getMenuPageFromLi($item) : ($item.attr("data-page") || $item.attr("data-id") || '').replace(/ /g, '-');
1397                    if(itemPage == pageName) {
1398                        $matched = $item;
1399                        return false;
1400                    }
1401                });
1402                return $matched;
1403            };
1404            var $currentPageMenuItem = getReorderMenuItem(currentPageMenu);
1405            var currentPageMenuLabelHtml = getReorderPathHtml($currentPageMenuItem, currentPageMenu);
1406
1407            pageMenuSelect += '\
1408                <button type="button" class="btn btn-sm fsm dropdown-toggle" data-toggle="dropdown">\
1409                    <span>' + currentPageMenuLabelHtml + '</span> ' + ($currentPageMenuItem.children(".menu-ctrl").find(".menu-visible").hasClass('invisible') ? ' <svg viewBox="0 0 14 12" width="14" height="14"><path d="M12.29 0l-1.88 1.88C9.39 1.32 8.23 1 7 1 3.83 1 1.12 3.07 0 6c0.56 1.46 1.53 2.68 2.73 3.56L1 11.29 1.71 12 13 0.71 12.29 0zM1.09 6C2.15 3.64 4.4 2 7 2c0.95 0 1.86 0.23 2.67 0.62L8.73 3.56C8.24 3.21 7.65 3 7 3 5.34 3 4 4.34 4 6c0 0.65 0.21 1.24 0.56 1.73L3.44 8.85C2.44 8.15 1.62 7.17 1.09 6zM5 6c0-1.1 0.9-2 2-2 0.37 0 0.71 0.11 1.01 0.28L5.28 7.01C5.11 6.71 5 6.37 5 6z"></path><path d="M12.05 3.06l-0.71 0.71C11.99 4.4 12.53 5.15 12.91 6c-1.05 2.36-3.3 4-5.91 4 -0.57 0-1.12-0.09-1.65-0.24l-0.8 0.8C5.32 10.84 6.14 11 7 11c3.17 0 5.88-2.07 7-5C13.57 4.87 12.89 3.87 12.05 3.06z"></path></svg> ' : '') + ' <span class="caret"></span>\
1410                </button>\
1411                <ul class="dropdown-menu" role="menu">\
1412            ';
1413            $(copy_menu_list).each(function(idx) {
1414                var active_cls = '';
1415                var depth_cls = '';
1416                var visible_cls = '';
1417                var visible_svg = '';
1418
1419                var menu_str = String(this || '');
1420                var menu_label = getReorderDisplayName(getReorderPageLabel(menu_str));
1421                if(menu_str == '전체상품') return true;
1422                if(currentPageMenu == this) {
1423                    currentPageMenuIdx = idx;
1424                    active_cls = ' active ';
1425                }
1426
1427                var $menuItem = getReorderMenuItem(menu_str);
1428                if($menuItem.length > 0) {
1429                    if($menuItem.parents(".dd-item").length) depth_cls = ' indent ';
1430
1431                    if($menuItem.children(".menu-ctrl").find(".menu-visible").hasClass("invisible")) {
1432                        visible_cls = ' visibleoff ';
1433                        visible_svg = ' <svg viewBox="0 0 14 12" width="14" height="14"><path d="M12.29 0l-1.88 1.88C9.39 1.32 8.23 1 7 1 3.83 1 1.12 3.07 0 6c0.56 1.46 1.53 2.68 2.73 3.56L1 11.29 1.71 12 13 0.71 12.29 0zM1.09 6C2.15 3.64 4.4 2 7 2c0.95 0 1.86 0.23 2.67 0.62L8.73 3.56C8.24 3.21 7.65 3 7 3 5.34 3 4 4.34 4 6c0 0.65 0.21 1.24 0.56 1.73L3.44 8.85C2.44 8.15 1.62 7.17 1.09 6zM5 6c0-1.1 0.9-2 2-2 0.37 0 0.71 0.11 1.01 0.28L5.28 7.01C5.11 6.71 5 6.37 5 6z"></path><path d="M12.05 3.06l-0.71 0.71C11.99 4.4 12.53 5.15 12.91 6c-1.05 2.36-3.3 4-5.91 4 -0.57 0-1.12-0.09-1.65-0.24l-0.8 0.8C5.32 10.84 6.14 11 7 11c3.17 0 5.88-2.07 7-5C13.57 4.87 12.89 3.87 12.05 3.06z"></path></svg> ';
1434                    }
1435                }
1436
1437                
1438
1439                // pageMenuSelect += '<option value="' + this + '" ' + (currentPageMenu == this ? ' selected ' : '') + '>' + this + '</option>';
1440                if(menu_str.indexOf(reorderMenuSeparator) > -1) depth_cls = ' indent ';
1441                pageMenuSelect += '<li class="gallery-name ' + active_cls + depth_cls + visible_cls +' " data-page="' + escapeReorderAttr(menu_str) + '">' + '<span>' + escapeReorderHtml(menu_label) + '</span>' +  visible_svg + '</li>';
1442            });
1443            pageMenuSelect += '</ul>';
1444            $center_area.find(".page-list-area .btn-group").append(pageMenuSelect);
1445        } else {
1446            currentPageMenuIdx = 0;
1447        }
1448
1449        if(reorderFIXED) {
1450            if(el_fixed[2] == 't') {
1451                $center_area.find(".page-list-area .btn-group").html('<h4>' + $.lang[LANG]['config.blockmove.fixedtopblock'] + '</h4><span class="sub">' + $.lang[LANG]['config.blockmove.dragblock'] + '</span>');
1452            } else if(el_fixed[2] == 'b') {
1453                $center_area.find(".page-list-area .btn-group").html('<h4>' + $.lang[LANG]['config.blockmove.fixedbottomblock'] + '</h4><span class="sub">' + $.lang[LANG]['config.blockmove.dragblock'] + '</span>');
1454            }
1455        } else if(VIEW) {
1456            $center_area.find(".page-list-area .btn-group").html('<h4>' + $.lang[LANG]['config.blockmove.title'] + '</h4><span class="sub">' + $.lang[LANG]['config.blockmove.dragblock'] + '</span>');
1457        }
1458
1459        setTimeout(function() {
1460
1461            if(typeof pageList[currentPageMenuIdx] == 'undefined' || typeof pageListChangeFlag[currentPageMenuIdx] == 'undefined') {
1462               
1463                $('.new-dsgn-body .contents[data-page="' + currentPageMenu + '"]').remove();
1464                var pageIndex = 0;
1465                PAGE = currentPageMenu.toString();
1466                var dsgn_body_clone = $('.dsgn-body').clone().empty().addClass('contents');
1467                $('.dsgn-body').removeClass('dsgn-body').addClass('prev-dsgn-body');
1468                $('.new-dsgn-body .elements').append(dsgn_body_clone);
1469                
1470                showPageCallback(showPage); 
1471                
1472                $('.new-dsgn-body .contents.dsgn-body').removeClass('dsgn-body').attr('data-page', currentPageMenu);
1473                $('.prev-dsgn-body').removeClass('prev-dsgn-body').addClass('dsgn-body');
1474                PAGE = prevPAGE ? prevPAGE.toString() : '';
1475             
1476                pageList[currentPageMenuIdx] = [];
1477                $.each($('.new-dsgn-body .contents[data-page="' + currentPageMenu + '"] .element'),function(i,v) {
1478                    if($(v).is('[data-type="tabmenu"], .tabmenu-auto-block')) {
1479                        var $tabmenuUnit = $(v).closest('.elem');
1480                        ($tabmenuUnit.length ? $tabmenuUnit : $(v)).hide();
1481                        return true;
1482                    }
1483
1484                    if( $(v).hasClass('el-menu') || 
1485                        $(v).hasClass('el-footer') || 
1486                        $(v).hasClass('add-footer-information') ||
1487                        $(v).hasClass('cl-s-product-detail') ||
1488                        $(v).hasClass('cl-s-product-review') ||
1489                        $(v).hasClass('cl-s-product-qna') || 
1490                        $(v).hasClass('cl-s-product-info-notice') ||
1491                        $(v).hasClass('el-fixedcontact')
1492                    ) {
1493                        return true;
1494                    }
1495
1496                    if(reorderFIXED) {
1497                        if($(v).hasClass('el-fixedblock')) {
1498                            if($(v).attr('data-posby') != el_fixed[2]) return true;
1499                        } else return true;
1500                    } else {
1501                        if($(v).hasClass('el-fixedblock')) return true;
1502                    }
1503                    
1504                    if ($(v).hasClass('addEL-wrap')) {
1505                        return true;
1506                    } 
1507                    
1508                    pageList[currentPageMenuIdx][pageIndex] = (LUX && $(v).is('.lux-product-block')) ? 'lux-product-block' : $(v).data('id');
1509
1510                    $(v).find('.hideBlockWrap .blockOn').hide();
1511                    if($(v).find('.hideBlockWrap').length > 0) $(v).addClass('block_checkOnOff');
1512                    pageIndex++;
1513                });
1514                pageListChangeFlag[currentPageMenuIdx] = true;
1515            }
1516
1517            PAGE = prevPAGE ? prevPAGE.toString() : '';
1518
1519            var $empty = $('<div class="render sort-empty" data-result-page="' + currentPageMenu + '">&nbsp;</div>'),
1520                $pageLine = $('<div class="sort-page-line"></div>'),
1521                pageName = currentPageMenu.replace(/,/,'/'),
1522                menulist_index = $.inArray(pageName,MENULIST),
1523                pageNameOrg = pageName=='INTRO' ? pageName : $('#nestable').find('.dd-item').eq(menulist_index-1).attr('data-id'),
1524                $pageInfo = $('<div class="sort-page-info">' + pageNameOrg + '</div>'),
1525                isLink = pageName=='INTRO' || menulist_index == -1 ? false : $('#nestable').find('.dd-item').eq(menulist_index-1).find('.menu-link').first().hasClass('active');
1526                
1527            if(pageName.indexOf('/')>-1 || reorderFIXED) $pageInfo.addClass('hide');
1528
1529            // $empty.append($pageLine);
1530            // $empty.append($pageInfo);
1531
1532            $empty = (isLink) ? $empty.addClass('use-link') : $empty;
1533                // if(!isLink) $sort.append($empty);
1534
1535            pageList[currentPageMenuIdx] = $.grep(pageList[currentPageMenuIdx] || [], function(blockId) {
1536                return String(blockId) != 'tabmenu';
1537            });
1538
1539            $(pageList[currentPageMenuIdx]).each(function(i,v) {
1540                if(v == 'lux-product-block') {
1541                    var element_selector = ($('.new-dsgn-body .lux-product-block').hasClass('reorderBlock')) ? 'reorderBlock' : 'element',
1542                        $ndb_el = $('.new-dsgn-body .lux-product-block.' + element_selector);
1543                } else {
1544                    var element_selector = ($('.new-dsgn-body [data-id="'+v + '"][data-type]').hasClass('reorderBlock')) ? 'reorderBlock' : 'element',
1545                        $ndb_el = $('.new-dsgn-body .' + element_selector + '[data-id="'+v + '"]');
1546                }
1547
1548                $ndb_el.removeClass('element')
1549                        .removeClass('el-active')
1550                        .removeClass('active')
1551                        .removeClass('emptyGallery')
1552                        .removeClass('el-fixedblock')
1553                        .removeAttr('data-parallax')
1554                        .addClass('render')
1555                        .addClass('reorderBlock')
1556                        .attr('data-reorder-page',currentPageMenu);
1557
1558                var $el = $ndb_el.clone();
1559                var isLink = $('#nestable .dd-item[data-id="'+pageNameOrg+'"] > span > .menu-link').hasClass('active');
1560                if($el.is('[data-parallax="true"]')) {
1561                    $el.css('background-attachment','inherit');
1562                }
1563
1564                if(elIndex==0) {
1565                    $el.css('margin','0px');
1566                    if(VIEW && ($el.attr('data-type')=='project' || $el.attr('data-type')=='product')) return true;//$el.addClass('unsort').hide();
1567                }
1568                if($el.attr('data-msny')=='true' && $el.find('.container').hasClass('full-width')) {
1569                    $el.css('padding-left',$('header.sidebar').width()+'px');
1570                }
1571
1572                if($ndb_el.css('background-color')=='rgba(0, 0, 0, 0)' || $ndb_el.css('background-color')=='transparent') {
1573                    $el.css('background-color', '#fff');
1574                }
1575
1576                $el.find('[data-edit="true"]').removeAttr('data-edit');
1577                $el.css('position','relative');
1578                $el.css('min-height','0px');
1579                $el.css('margin-bottom','120px');
1580
1581                if($el.attr('data-layout')=="true") $el.css('overflow','');
1582
1583                if(v == 'lux-product-block') {
1584                    $el.html('<div class="lux-product-sample"><h1>본사 상품 상세 정보 블럭</h1></div>');
1585                }
1586                if(!isLink) $sort.append($el);
1587                elIndex++;
1588
1589            });
1590            var $last = $('<div class="sort-empty guide-text" style="display: none;">' + $.lang[LANG]['config.blockmove.movehere'] + '</div>');
1591            if(pageList[currentPageMenuIdx].length == 0 || typeof pageList[currentPageMenuIdx] == 'undefined') $last.show();
1592            $sort.append($last);
1593            $scale.append($sort);
1594
1595            $scale.css('height', 'auto');
1596
1597            var target_contents = $('.new-dsgn-body .elements .contents[data-page="' + currentPageMenu + '"]');
1598            var setting_height = target_contents.height() / 5 + $(".page-list-area").outerHeight() + 120;
1599
1600            $scale.height(setting_height);
1601            $center_area.height(setting_height);
1602
1603            $center_area.find('.reorderBlock[data-msny="true"]').each(function() {
1604                var cnt = 0;
1605                var total = $(this).find(".row").data("view");
1606                var target = this;
1607                $(target).imagesLoaded().progress(function(imgload, image) {
1608                    cnt ++;
1609                    if(total == cnt || cnt == $(target).find(".row .gallery-item").length) {
1610                        setTimeout(function() {
1611                            $(target).find(".row").masonry();    
1612                        }, 1)
1613                    }
1614                });
1615            });
1616
1617            if($center_area.find('[data-map_kind="kakao"]').length && (typeof kakao == 'undefined' || typeof kakao.maps == 'undefined' || 
1617kakao.maps == null || VALIDPLAN == '')) {
1618                $center_area.find('[data-map_kind="kakao"]').html('지도연결해제됨. Javascript키 확인');
1619                    $center_area.find('[data-map_kind="kakao"]').html('<iframe class="google-map" src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3165.5659473821083!2d127.0282496015659!3d37.494568!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x357ca1598c361b2b%3A0xdbf9af292beff3c!2z6rCV64Ko!5e0!3m2!1sko!2skr!4v1637303748377!5m2!1sko!2skr" width="600" height="450" style="border:0;" allowfullscreen="" loading="lazy"></iframe>');
1620            } else {
1621                $center_area.find('[data-map_kind="kakao"]').each(function() {
1622                    var container = this;
1623                    var lat = $(this).data("lat");
1624                    var lng = $(this).data("lng");
1625                    var options = { center: new kakao.maps.LatLng(lat, lng), level: 3};
1626                    var c_map = new kakao.maps.Map(container, options);
1627                    var marker = new kakao.maps.Marker({ position: new kakao.maps.LatLng(lat, lng), map: c_map});
1628                    var zoomInOut = $(this).data("zoominout");
1629                    var mapTitle = $(this).data("maptitle");
1630                    var mapContent = $(this).data("mapcontent");
1631                    var useTitle = $(this).data("usetitle");
1632                    var useContent = $(this).data("usecontent");
1633                    if(typeof zoomInOut == 'undefined' || !zoomInOut) zoomInOut = false;
1634                    if(typeof mapTitle == 'undefined' || !mapTitle) mapTitle = '';
1635                    if(typeof mapContent == 'undefined' || !mapContent) mapContent = '';
1636                    if(typeof useTitle == 'undefined' || !useTitle) useTitle = false;
1637                    if(typeof useContent == 'undefined' || !useContent) useContent = false;
1638
1639                    if(zoomInOut == true) {
1640                        // var mapTypeControl = new kakao.maps.MapTypeControl();
1641                        // c_map.addControl(mapTypeControl, kakao.maps.ControlPosition.TOPRIGHT);
1642                        // var zoomControl = new kakao.maps.ZoomControl();
1643                        // c_map.addControl(zoomControl, kakao.maps.ControlPosition.RIGHT);
1644                        var zoomControlHtml = '';
1645                        zoomControlHtml += '\
1646                            <div class="zoom-control" style="margin-top: 8px; margin-right: 8px; right: 0; width: 30px; position: absolute; background-color: #fff; z-index: 1; border-radius: 3px; box-shadow: 0 2px 3px 0 rgba(0, 0, 0, 0.16);">\
1647                                <div class="btn-zoom-control" data-inout="I" style="cursor: pointer; width: 30px; height: 30px;">\
1648                                    <svg style="fill: #6b6b6b; margin: 3px;" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path d="M17 11h-4V7c0-.55-.45-1-1-1s-1 .45-1 1v4H7c-.55 0-1 .45-1 1s.45 1 1 1h4v4c0 .55.45 1 1 1s1-.45 1-1v-4h4c.55 0 1-.45 1-1s-.45-1-1-1z"/></svg>\
1649                                </div>\
1650                                <div class="slider-wrap-container" style="height: 130px;">\
1651                                    <div class="slider-wrap small" style="text-align: center; height: 100%;">\
1652                                        <div style="max-height: 100%;" class="zoom-control-slider"></div>\
1653                                    </div>\
1654                                </div>\
1655                                <div class="btn-zoom-control" data-inout="O" style="cursor: pointer; width: 30px; height: 30px;">\
1656                                    <svg style="fill: #6b6b6b; margin: 3px;" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path d="M17 13H7c-.55 0-1-.45-1-1s.45-1 1-1h10c.55 0 1 .45 1 1s-.45 1-1 1z"/></svg>\
1657                                </div>\
1658                            </div>\
1659                        ';
1660                        var $zoomController = $(zoomControlHtml);
1661                        $(container).append($zoomController);
1662                        var zoom_slider = $zoomController.find('.zoom-control-slider').slider({
1663                            'orientation': 'vertical',
1664                            'min' : 1,
1665                            'max' : 14,
1666                            'step' : 1,
1667                            'value' : 3,
1668                            'handle' : 'square',
1669                            // 'reversed' : true,
1670                            'tooltip' : 'hide',
1671                        }).on('slide', function(data) {
1672                            c_map.setLevel(data.value);
1673                            c_map.setCenter(marker.getPosition());
1674                        }).on('slideStop', function(data) {
1675                            c_map.setLevel(data.value);
1676                            c_map.setCenter(marker.getPosition());
1677                        });
1678
1679                        $zoomController.find('.btn-zoom-control').on('click', function() {
1680                            if($(this).data('inout') == 'I') {
1681                                c_map.setLevel(c_map.getLevel() - 1);
1682                                zoom_slider.slider('setValue', c_map.getLevel());
1683                            } else if($(this).data('inout' == 'O')) {
1684                                c_map.setLevel(c_map.getLevel() + 1);
1685                                zoom_slider.slider('setValue', c_map.getLevel());
1686                            }
1687                        });
1688
1689                        kakao.maps.event.addListener(c_map, 'zoom_changed', function() {
1690                            zoom_slider.slider('setValue', c_map.getLevel());
1691                        });
1692                    }
1693                        
1694                    if((useTitle == true || useContent == true) && (mapTitle || mapContent)) {
1695                        var iwContent = '';
1696                        if(useTitle == true && mapTitle) {
1697                            iwContent = '<div class="title">' + mapTitle + '</div>';
1698                        }
1699                        if(useContent == true && mapContent) {
1700                            iwContent += '<div class="content">' + mapContent + '</div>';
1701                        }
1702
1703                        if(iwContent) {
1704                            iwContent = '<div class="contact-map-info-window"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path d="M8 0C4.69 0 2 2.69 2 6s1 4 6 10c5-6 6-6.69 6-10s-2.69-6-6-6zm0 8.3a2.3 2.3 0 1 1 0-4.6 2.3 2.3 0 0 1 0 4.6z"/></svg>
1704' + iwContent + '</div>';
1705                            var infoWindow = $(iwContent);
1706                            $(container).append(infoWindow);
1707                            // infoWindow.css('bottom', 'calc(-100% + ' + (infoWindow.outerHeight() + 36) + 'px)');  
1708                        }
1709                    }
1710
1711                    $(window).on("resize", function() {
1712                        c_map.setCenter(marker.getPosition());
1713                    });
1714                });
1715            }
1716    
1717            if($center_area.find('[data-map_kind="naver"]').length && (typeof naver == 'undefined' || typeof naver.maps == 'undefined' || naver.maps == null || VALIDPLAN == '')) {
1718                $center_area.find('[data-map_kind="naver"]').html('지도연결해제됨. Client ID 확인');
1719                    $center_area.find('[data-map_kind="naver"]').html('<iframe class="google-map" src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3165.5659473821083!2d127.0282496015659!3d37.494568!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x357ca1598c361b2b%3A0xdbf9af292beff3c!2z6rCV64Ko!5e0!3m2!1sko!2skr!4v1637303748377!5m2!1sko!2skr" width="600" height="450" style="border:0;" allowfullscreen="" loading="lazy"></iframe>');
1720            } else {
1721                $center_area.find('[data-map_kind="naver"]').each(function() {
1722                    var container = this;
1723                    var lat = $(this).data("lat");
1724                    var lng = $(this).data("lng");
1725                    var options = { center: new naver.maps.LatLng(lat, lng), zoom: 17};
1726                    var zoomInOut = $(this).data("zoominout");
1727                    var mapTitle = $(this).data("maptitle");
1728                    var mapContent = $(this).data("mapcontent");
1729                    var useTitle = $(this).data("usetitle");
1730                    var useContent = $(this).data("usecontent");
1731                    if(typeof zoomInOut == 'undefined' || !zoomInOut) zoomInOut = false;
1732                    if(typeof mapTitle == 'undefined' || !mapTitle) mapTitle = '';
1733                    if(typeof mapContent == 'undefined' || !mapContent) mapContent = '';
1734                    if(typeof useTitle == 'undefined' || !useTitle) useTitle = false;
1735                    if(typeof useContent == 'undefined' || !useContent) useContent = false;
1736
1737                    var c_map = new naver.maps.Map(container, options);
1738                    var marker = new naver.maps.Marker({ position: new naver.maps.LatLng(lat, lng), map: c_map});
1739
1740                    if(zoomInOut == true) {
1741                        // options.zoomControl = true;
1742                        // options.zoomControlOptions = {
1743                        //     position: naver.maps.Position.RIGHT_CENTER
1744                        // };
1745
1746                        var zoomControlHtml = '';
1747                        zoomControlHtml += '\
1748                            <div class="zoom-control" style="margin-top: 8px; margin-right: 8px; right: 0; width: 30px; position: absolute; background-color: #fff; z-index: 1; border-radius: 3px; box-shadow: 0 2px 3px 0 rgba(0, 0, 0, 0.16);">\
1749                                <div class="btn-zoom-control" data-inout="I" style="cursor: pointer; width: 30px; height: 30px;">\
1750                                    <svg style="fill: #6b6b6b; margin: 3px;" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path d="M17 11h-4V7c0-.55-.45-1-1-1s-1 .45-1 1v4H7c-.55 0-1 .45-1 1s.45 1 1 1h4v4c0 .55.45 1 1 1s1-.45 1-1v-4h4c.55 0 1-.45 1-1s-.45-1-1-1z"/></svg>\
1751                                </div>\
1752                                <div class="slider-wrap-container" style="height: 130px;">\
1753                                    <div class="slider-wrap small" style="text-align: center; height: 100%;">\
1754                                        <div style="max-height: 100%;" class="zoom-control-slider"></div>\
1755                                    </div>\
1756                                </div>\
1757                                <div class="btn-zoom-control" data-inout="O" style="cursor: pointer; width: 30px; height: 30px;">\
1758                                    <svg style="fill: #6b6b6b; margin: 3px;" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">
1758<path d="M17 13H7c-.55 0-1-.45-1-1s.45-1 1-1h10c.55 0 1 .45 1 1s-.45 1-1 1z"/></svg>\
1759                                </div>\
1760                            </div>\
1761                        ';
1762                        var $zoomController = $(zoomControlHtml);
1763                        $(container).append($zoomController);
1764                        var zoom_slider = $zoomController.find('.zoom-control-slider').slider({
1765                            'orientation': 'vertical',
1766                            'min' : 6,
1767                            'max' : 21,
1768                            'step' : 1,
1769                            'value' : 17,
1770                            'handle' : 'square',
1771                            'reversed' : true,
1772                            'tooltip' : 'hide',
1773                        }).on('slide', function(data) {
1774                            c_map.setZoom(data.value);
1775                            c_map.setCenter(marker.getPosition());
1776                        }).on('slideStop', function(data) {
1777                            c_map.setZoom(data.value);
1778                            c_map.setCenter(marker.getPosition());
1779                        });
1780                        $zoomController.find('.btn-zoom-control').on('click', function() {
1781                            if($(this).data('inout') == 'I') {
1782                                c_map.setZoom(c_map.getZoom() + 1);
1783                                zoom_slider.slider('setValue', c_map.getZoom());
1784                            } else if($(this).data('inout' == 'O')) {
1785                                c_map.setZoom(c_map.getZoom() - 1);
1786                                zoom_slider.slider('setValue', c_map.getZoom());
1787                            }
1788                        });
1789
1790                        naver.maps.Event.addListener(c_map, 'zoom_changed', function(zoom) {
1791                            zoom_slider.slider('setValue', c_map.getZoom());
1792                        });
1793                    }
1794
1795                    if((useTitle == true || useContent == true) && (mapTitle || mapContent)) {
1796                        var iwContent = '';
1797                        if(useTitle == true && mapTitle) {
1798                            iwContent = '<div class="title">' + mapTitle + '</div>';
1799                        }
1800                        if(useContent == true && mapContent) {
1801                            iwContent += '<div class="content">' + mapContent + '</div>';
1802                        }
1803
1804                        if(iwContent) {
1805                            iwContent = '<div class="contact-map-info-window"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path d="M8 0C4.69 0 2 2.69 2 6s1 4 6 10c5-6 6-6.69 6-10s-2.69-6-6-6zm0 8.3a2.3 2.3 0 1 1 0-4.6 2.3 2.3 0 0 1 0 4.6z"/></svg>' + iwContent + '</div>';
1806                            var infoWindow = $(iwContent);
1807                            $(container).append(infoWindow);
1808                            // infoWindow.css('bottom', 'calc(-100% + ' + (infoWindow.outerHeight() + 36) + 'px)');  
1809                        }
1810                    }
1811                    $(window).on("resize", function() {
1812                        c_map.setCenter(marker.getPosition());
1813                    });
1814
1815                    c_map.setSize(new naver.maps.Size($(container).outerWidth(), $(container).outerHeight()));
1816                });
1817            }
1818
1819            // $.each($('.sort-empty'),function(i,v) {
1820            //     if($(this).next().hasClass('sort-empty') && !$(this).next().hasClass('page')) {
1821            //         var $empty = $('<div class="sort-empty page">PAGE EMPTY</div>');
1822            //         //var $empty = ($(this).hasClass('use-link')) ?  $('<div class="sort-empty page">PAGE LINKED</div>') :  $('<div class="sort-empty page">PAGE EMPTY</div>');
1823            //         if(!$(this).hasClass('page')) $(this).after($empty);
1824            //     }
1825            // });
1826
1827            // $('.reorderModal').scrollTo('.reorderBlock[data-id="' + selectID + '"]',{offset:-200});
1828            // $('.reorderBlock[data-id="' + selectID + '"]').addClass('active');
1829
1830            // reorder page click
1831            $center_area.find(".page-list-area .gallery-name").on("click", function() {
1832                $.reorderON($(this).data('page'));
1833            });
1834            $center_area.find('.video-gallery-url').attr('data-gallery','');
1835            
1836            // reorder gallery gjs setting
1837            $('.reorderModal .center-area .reorderBlock[data-type="gallery"] input.gjs').parents('.element[data-type="gallery"]').each(function() {
1838                setGalleryJS('reorder-block',$(this));
1839            });
1840
1841            blockSortable();
1842            $.processOFF();
1843        });
1844    }
1845
1846    jQuery.reorderOFF = function() {
1847        window.basketBlockHtml = '';
1848        window.pageList = [];
1849        window.pageListChangeFlag = [];
1850        $(".new-dsgn-body").remove();
1851        $('.reorderModal').fadeOut(function() {
1852            $(this).remove();
1853            reorderFIXED = '';
1854        });
1855    }
1856
1857    jQuery.viewON = function() {
1858        var $view = $('<div class="viewModal"></div>');
1859
1860        if ($('.viewModal').length < 1) {
1861            $view.css({
1862                'position' : 'fixed',
1863                'width' : '100%',
1864                'height' : '100%',
1865                'background' : '#FFF url(https://storage.googleapis.com/i.addblock.net/preloader2.gif) center center no-repeat',
1866                'z-index' : '10000000000',
1867                'display' : 'none',
1868                'overflow' : 'auto'
1869            });
1870            $('body').prepend($view);
1871            var $content = $('<div class="content"></div>'),
1872                $h1 = $('<h1></h1>').css({
1873                    'position' : 'absolute',
1874                    'z-index' : '100001',
1875                    'right' : '0px'
1876                }),
1877                $close = $('<div class="pull-right"><i class="fa fa-times"></i></div>').css({
1878                    'margin-right' : '18px',
1879                    'margin-top' : '-16px',
1880                    'background-color': '#556273',
1881                    'color': '#fff',
1882                    'font-size': '18px',
1883                    'padding': '6px 9px',
1884                    'cursor': 'pointer',
1885                    'border-radius' : '20px'
1886                }),
1887                $iframe = $('<iframe src="http://' + SID + '.' + HOST + '/render/' + PAGE + '"></iframe>');
1888
1889            $iframe.css({
1890                'position' : 'absolute',
1891                'top' : '0',
1892                'left' : '0',
1893                'width' : '100%',
1894                'height' : '100%',
1895                'z-index' : '100000',
1896                'border' : 'none'
1897            });
1898
1899
1900            $close.on('click',function() {
1901                $.viewOFF();
1902            });
1903            $content.append($h1).append($iframe);
1904            $h1.append($close);
1905            $view.append($content);
1906            $view.fadeIn();
1907        }
1908    }
1909
1910    jQuery.viewOFF = function() {
1911        $('.viewModal').fadeOut(function() {
1912            $(this).remove();  
1913        });
1914    }
1915
1916    jQuery.historyON = function() {
1917        viewmode('view');
1918    }
1919
1920    $.fn.showUpgradePlanModal = function(sid, plan, upgrade_plan, fn) {
1921        if($('.site-upgrade-wrap').length > 0 || typeof checkUpgradeModal != "undefined" && checkUpgradeModal) return false;
1922        var checkUpgradeModal = true;
1923
1924        var check_plan = (!plan || plan == 'FR' || plan == 'FREE') ? false : true,
1925            log_fn = (!fn) ? '' : '.' + fn,
1926            log_plan = (!upgrade_plan) ? '' : '.' + upgrade_plan,
1927            upgrade_plan = (!upgrade_plan) ? '' : '/plan/' + upgrade_plan,
1928            upgrade_url = (!upgrade_plan) ? '/upgrade' : ((check_plan) ? '/upgrade/change/site/' + sid + upgrade_plan : '/upgrade/buy/site/' + sid + upgrade_plan),
1929            modal_title = $.lang[LANG]['config.upgrade-plan' + log_plan + log_fn + '.title'],
1930            modal_description =  $.lang[LANG]['config.upgrade-plan' + log_plan + log_fn + '.description'],
1931            str = '\
1932                <div class="site-upgrade-wrap">\
1933                    <p class="description">' + modal_description + '</p>\
1934                    <div class="btn-box">\
1935                        <a href="' + upgrade_url + '"><i class="fa fa-level-up"></i>'+$.lang[LANG]['config.upgrade-plan.btn']+'</a>\
1936                    </div>\
1937                </div>\
1938            '; 
1939
1940        var modal = $(this).showModalFlat(modal_title, str, false, false, '', '', '', '', '', '', '', function() {
1941            checkUpgradeModal = false;
1942        });
1943    }
1944
1945    $.fn.showModal = function (header, content, footer, cancel, confirm, callback, backdrop) {
1946        $('.editor-navbar').css('z-index','1030');
1947        var HTML = '<div class="modal modal-default fade" id="generic-modal">' +
1948            '   <div class="modal-dialog" style="padding-top:5%;">' +
1949            '       <div class="modal-content">' +
1950            '           <button type="" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true"><img src="https://storage.googleapis.com/i.addblock.net/fa-close-modal.png" alt="close"></span></button>' +
1951            '           <div class="modal-body">' +
1952            '               <h3 class="modal-title">' + header +
1953            '               </h3>' + content +
1954            '           </div>';
1955            if(footer==true) { 
1956                HTML = HTML + '<div class="modal-footer">';
1957                if(cancel == true) {
1958                    HTML = HTML + '<button type="button" class="btn btn-default btn-sm" data-dismiss="modal">취소</button>';
1959                } else if(confirm == true) {
1960                    HTML = HTML + '<button type="button" class="btn btn-primary btn-sm ok-button-dialog">확인1</button>';
1961                }
1962                HTML = HTML +
1963                '       </div>';
1964            }
1965            HTML = HTML +
1966            '       </div>' +
1967            '   </div>' +
1968            '</div>';
1969
1970        var container = $('<div class="generic-modal"></div>').html(HTML);
1971        $('body').append(container);
1972        var newInstance = jQuery.extend(true, {}, container);
1973        newInstance.find('.ok-button-dialog').bind('click', function () {
1974            callback();
1975        });
1976        var modalElement = newInstance.find('#generic-modal');
1977        if(backdrop) modalElement.modal({ backdrop : 'static', keboard : false});
1978        else modalElement.modal();
1979
1980        modalElement.on('hidden.bs.modal', function(e) {
1981            // $('.editor-navbar').css('z-index','1040');
1982            $('.generic-modal').remove();
1983            $('.modal-backdrop').remove();
1984        });
1985
1986        return modalElement;
1987    }
1988
1989
1990    $.fn.showModalFlat = function (header, content, footer, confirm, callback, closetext, oktext, size, backdrop, closecallback, showcallback, hidecallback, buttontop) {
1991    /**
1992     * @param header
1993     * @param content
1994     * @param footer
1995     * @param confirm
1996     * @param callback
1997     * @param closetext
1998     * @param oktext
1999     * @param size
2000     * @param backdrop
2001     * @param closecallback
2002     * @param showcallback
2003     * @param hidecallback
2004     * */
2005        // if($('#flat-modal.event').length) return;
2006
2007        size = (typeof size == 'undefined') ? '' : size;
2008        var focusBeforeOpen = document.activeElement;
2009
2010        var buttontop = (typeof buttontop != 'undefined' && buttontop) ? buttontop : false;
2011        var reg_zindex = /\bzindex(\d+)\b/;
2012        var matches = size.match(reg_zindex);
2013        var zindex = (matches) ? matches[1] * 1 : -1;
2014
2015        if(!matches && $('.bc-modal.open').length > 0)  zindex = 1043;
2016
2017        if(size.indexOf(',') > -1) {
2018            var modal_name = size.split(',');
2019            var modal_class = '';
2020
2021            size = modal_name[0];
2022            modal_class = modal_name[1];
2023        }
2024
2025        var noBackdrop = (typeof backdrop != 'undefined' && backdrop === 'none') ? true : false;
2026        backdrop = (typeof backdrop != 'undefined' && backdrop === true) ? true : false;
2027
2028        // $('.editor-navbar').css('z-index','1030');
2029
2030        var checkCLBtnMode = (size.indexOf('cl-s-btn') > -1) ? true : false,
2031            close_btn = $.lang[LANG]['config.close'],
2032            close_btn_class = 'btn-default',
2033            ok_btn = $.lang[LANG]['config.ok'],
2034            ok_btn_class = 'btn-primary',
2035            btn_html = '';
2036
2037        if( closetext == 'cancel') {
2038            close_btn = $.lang[LANG]['config.cancel'];
2039        } else if( closetext == 'close' ) {
2040            close_btn = $.lang[LANG]['config.close'];
2041        } else if( closetext == 'ok' || closetext == 'notice.ok' ) {
2042            close_btn = $.lang[LANG]['config.'+closetext];
2043            close_btn_class = 'btn-primary ok-button-dialog';
2044        } else if( closetext == 'move.cancel' ) {
2045            close_btn = $.lang[LANG]['config.'+closetext];
2046            close_btn_class = 'closemodal';
2047        } else if ( typeof closetext != 'undefined') {
2048            if( closetext.match(/\./g) !== null ) close_btn = $.lang[LANG][closetext];
2049            else if(closetext.length > 0) close_btn = closetext;
2050        }
2051        
2052        if( oktext == 'save' ) {
2053            ok_btn = $.lang[LANG]['config.save'];
2054        } else if( oktext == 'send' ) {
2055            ok_btn = $.lang[LANG]['config.send'];
2056        } else if( oktext == 'ok' ) {
2057            ok_btn = $.lang[LANG]['config.ok'];
2058        } else if( oktext == 'move.ok' ) {
2059            ok_btn = $.lang[LANG]['config.'+oktext];
2060            ok_btn_class = 'btn-primary ok-button-dialog movetocreatorlink';
2061        } else if( oktext == 'move.ok2' ) {
2062            ok_btn = $.lang[LANG]['config.'+oktext];
2063            ok_btn_class = 'btn-primary ok-button-dialog movetocreatorlink';
2064        } else if( oktext == 'move.domain' ) {
2065            ok_btn = $.lang[LANG]['config.'+oktext];
2066            ok_btn_class = 'btn-primary ok-button-dialog movedomain';
2067        } else if ( typeof oktext != 'undefined') {
2068            if( oktext.match(/\./g) !== null ) ok_btn = $.lang[LANG][oktext];
2069            else if(oktext.length > 0) ok_btn = oktext;
2070        } 
2071        var flat_modal_cnt = $('.modal-default').length,
2072            flat_modal_id = (flat_modal_cnt == 0) ? 'flat-modal': 'flat-modal'+flat_modal_cnt,
2073            btn_html_close = '<button type="button" class="btn '+ close_btn_class +' btn-sm close-button-dialog" data-dismiss="modal">' + close_btn + '</button>';             
2074
2075        if(confirm == true) {
2076            if(checkCLBtnMode) {
2077                var btn_html_ok = '<button type="button" class="btn '+ ok_btn_class +' btn-sm ok-button-dialog">' + ok_btn + '</button>';                
2078                btn_html_ok = (buttontop && (oktext == '')) ? '' : btn_html_ok;
2079                btn_html = btn_html_ok + btn_html_close;
2080            } else {
2081                btn_html = btn_html_close + '<button type="button" class="btn '+ ok_btn_class +' btn-sm ok-button-dialog">' + ok_btn + '</button>';
2082            }
2083        } else btn_html = btn_html_close;
2084
2085        var HTML = '<div class="modal modal-default fade" id="'+flat_modal_id+'">' +
2086            '   <div class="modal-dialog '+size+'">' +
2087            '       <div class="modal-content" data-buttontop="'+buttontop+'">' +
2088            '           <button type="" class="close close-button-dialog" data-dismiss="modal" aria-label="Close"><span aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path d="M8.71 8l7.15-7.15c0.2-0.2 0.2-0.51 0-0.71s-0.51-0.2-0.71 0L8 7.29 0.85 0.15c-0.2-0.2-0.51-0.2-0.71 0s-0.2 0.51 0 0.71L7.29 8l-7.15 7.15c-0.2 0.2
2088-0.2 0.51 0 0.71C0.24 15.95 0.37 16 0.5 16s0.26-0.05 0.35-0.15L8 8.71l7.15 7.15c0.1 0.1 0.23 0.15 0.35 0.15s0.26-0.05 0.35-0.15c0.2-0.2 0.2-0.51 0-0.71L8.71 8z"/></svg></span></button>' +
2089            '           <div class="modal-body">';
2090            HTML += (buttontop) ? '\
2091                            <div class="modal-top">\
2092                                <div class="modal-title-wrap">\
2093                                    <h3 class="modal-title">' + header + '</h3>\
2094                                </div>\
2095                                <div class="modal-title-button">' + btn_html_close + btn_html_ok + '</div>\
2096                            </div>' : '<h3 class="modal-title">' + header + '</h3>';
2097            HTML += content +'\
2098                        </div>';
2099            if(footer==true) {
2100                HTML = HTML + 
2101                '      <div class="modal-footer">';
2102                HTML = HTML + btn_html + 
2103                '      </div>';
2104            }
2105            HTML = HTML +
2106            '       </div>' +
2107            '   </div>' +
2108            '</div>';
2109
2110        var time = new Date().getTime();
2111        var container = $('<div class="flat-modal"></div>').html(HTML);
2112        
2113        if(typeof modal_class != "undefined" && modal_class) container.addClass(modal_class);
2114        if(size && size.indexOf('cl-modal') > 0 || (size && size.indexOf('cl-cmmodal') > -1)) {
2115            var mobile_close_btn = '\
2116                    <button class="cl-mobile-btn close" data-dismiss="modal" aria-label="Close">\
2117                        <span aria-hidden="true">\
2118                            <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\
2119                                <polygon points="16 1 15 0 8 7 1 0 0 1 7 8 0 15 1 16 8 9 15 16 16 15 9 8 "/>\
2120                            </svg>\
2121                        </span>\
2122                    </button>\
2123                    ';
2124
2125            container.find('.modal').prepend(mobile_close_btn);
2126            
2127            if(confirm==false && (closetext=='close' || closetext=='cancel')) container.find('.close-button-dialog').addClass('clostbtnfalse'); //닫기 버튼 하나일 경우 공통 class
2128            if(footer==true && container.find('.cl-cmmodal').hasClass('fullcover-modal-scroll') && container.find('.modal-footer').find('button').length==1) container.find('.cl-cmmodal').addClass('single-btn'); // fullcover 버튼 하나일경우
2129
2130            if(size.indexOf('cl-modal') > -1) container.addClass('cl-flat-modal');
2131            else if(size.indexOf('cl-cmmodal') > -1) container.addClass('cl-common-modal');
2132            if(size.indexOf('cl-alert') > -1) container.addClass('cl-alert-modal');
2133
2134            if(size.indexOf('confirm-resource-folder-delete') && size.indexOf('modal-over-1') > -1) container.addClass('modal-over-1');
2135
2136            if(size.indexOf('pg-modal') > -1) container.addClass('pg-modal-wrap'); 
2137            else if(size.indexOf('cl-common-notice') > -1) {  //공통 notice icon 추가
2138                var svg = '\
2139                    <svg xmlns="http://www.w3.org/2000/svg" class="cl-notice-icon" viewBox="0 0 90 90" width="90" height="90"><path d="M45 4c22.61 0 41 18.39 41 41S67.61 86 45 86 4 67.61 4 45 22.39 4 45 4M45 0C20.15 0 0 20.15 0 45s20.15 45 45 45 45-20.15 45-45S69.85 0 45 0L45 0z"/>\
2140                        <path d="M45 20L45 20c1.1 0 2 0.9 2 2v32c0 1.1-0.9 2-2 2h0c-1.1 0-2-0.9-2-2V22C43 20.9 43.9 20 45 20z"/><circle cx="45" cy="67" r="3"/>\
2141                    </svg>\
2142                    ';
2143                container.find('.modal-title').before(svg);
2144                if(size.indexOf('modal-over-1') > -1) container.addClass('modal-over-1');
2145            } else if(size.indexOf('guidePopup') > -1) {
2146                container.find('.modal-title').not('.guidetitle').remove();
2147                container.addClass('guidePopup-wrap');
2148            } else if(size.indexOf('modal-product-badge') > -1) {
2149                container.addClass('modal-product-badge-wrap');
2150                if(size.indexOf('cl-change-badge-design') > -1) {
2151                    container.addClass('modal-change-badge-design-wrap');
2152                }
2153            } else if(size.indexOf('cl-delete-badge-image') > -1) {
2154                container.addClass('modal-delete-badge-image');
2155            } else if(size.indexOf('modal-addFranchiseBar') > -1) {
2156                container.addClass('modal-addFranchiseBar-wrap');
2157            }
2158        }
2159
2160        $('body').append(container);
2161        var newInstance = jQuery.extend(true, {}, container);
2162        var modalElement = newInstance.find('#'+flat_modal_id);
2163        if(noBackdrop) modalElement.modal({ backdrop : false});
2164        else if(backdrop) modalElement.modal({ backdrop : 'static'});
2165        else modalElement.modal();
2166
2167        if(zindex > -1) {
2168            modalElement.css('z-index', zindex);
2169            modalElement.closest('.flat-modal').next('.modal-backdrop').attr('style','z-index: '+(zindex-1)+'!important;');
2170        }
2171
2172        newInstance.find('.ok-button-dialog').bind('click', function () {
2173            if(typeof callback == 'function')
2174                callback();
2175        });
2176
2177        newInstance.find('.close-button-dialog').bind('click', function () {
2178            if(typeof closecallback == 'function') {
2179                closecallback();
2180            }
2181        });
2182
2183        modalElement.on('shown.bs.modal', function(e) {
2184            if($('#ch-plugin').length > 0) $('#ch-plugin').attr('style','z-index: 1 !important; pointer-events: none !important;');
2185            var modal = document.querySelector('.modal');
2186            // modal.style.position = 'absolute';
2187            // setTimeout(function() {
2188                modal.style.position = 'fixed';
2189            // },0);
2190            if(typeof showcallback == 'function') showcallback();
2191        });
2192
2193        modalElement.on('hide.bs.modal', function(e) {
2194            if($(this).find('input:focus').length > 0) {
2195                e.preventDefault();
2196                return false;
2197            }
2198
2199            var activeElement = document.activeElement;
2200            if(activeElement && this.contains(activeElement) && typeof activeElement.blur == 'function') {
2201                activeElement.blur();
2202            }
2203        });
2204        
2205        modalElement.on('hidden.bs.modal', function(e) {
2206            if(typeof isEDIT != 'undefined' && isEDIT === false) editEL = '';
2207            if(typeof hidecallback == 'function') hidecallback();
2208            var flat_modal_id = $(this).attr('id');
2209            // $('.editor-navbar').css('z-index','1040');
2210            var this_modal = $('#'+flat_modal_id).closest('.flat-modal');
2211            this_modal.next('.modal-backdrop').remove();
2212            this_modal.remove();
2213
2214            if($('.modal-backdrop').length) {
2215                setTimeout(function() {
2216                    $('body').addClass('modal-open');    
2217                },10);                
2218            }
2219            $('body').removeClass('no-fixed');
2220            if($('#ch-plugin').length > 0) $('#ch-plugin').attr('style','z-index: 10000000 !important; pointer-events: auto !important;');
2221
2222            if(focusBeforeOpen
2223                && focusBeforeOpen !== document.body
2224                && document.documentElement.contains(focusBeforeOpen)
2225                && typeof focusBeforeOpen.focus == 'function'
2226            ) {
2227                try {
2228                    focusBeforeOpen.focus({preventScroll: true});
2229                } catch(focusError) {
2230                    focusBeforeOpen.focus();
2231                }
2232            }
2233        });
2234
2235        return modalElement;
2236    }
2237
2238    $.fn.showPopupModal = function (data,sid) {
2239        // console.log('showPopupModal');
2240        
2241        var img_count = data.length,
2242            img_w = new Array(), 
2243            img_h = new Array(), 
2244            counter = 0,
2245            sid = (typeof sid != 'undefined') ? sid : SID,
2246            popup_data = new Array();
2247
2248        $('#el-empty').html('');
2249        $.each(data,function(i,v) {
2250            var check_img = v.popupimg + '?' + new Date().getTime();
2251            var $img = $('<img/>').attr('src',check_img);
2252            $img.error(function() {
2253                data[i]['popupimg'] = '//storage.googleapis.com/i.addblock.net/img_broken_fill_500.png';
2254                $(this).attr('src', '//storage.googleapis.com/i.addblock.net/img_broken_fill_500.png');
2255            });
2256            $('#el-empty').append($img);
2257        });
2258
2259        var $imgs = $('#el-empty img');
2260        $.each($imgs,function(i,v) {
2261            $(this).one('load',function() {
2262                counter++;
2263                img_w[i] = this.width;
2264                img_h[i] = this.height;
2265                if(counter == img_count) getPopupFunction();
2266            });
2267            if(this.complete) $(this).load();
2268        });
2269
2270        function getPopupFunction() {
2271            $('#el-empty').html('');
2272            var html = '',
2273                display = new Array();
2274
2275            $.each(data, function(i,o) {
2276                var isCookie = ($.cookie(sid + 'Popup' + i)) ? 'style= display:none;' : '';
2277                display.push(isCookie);
2278
2279                var plink = (typeof o.popuplink != 'undefined' && o.popuplink != 'javascript:;' && o.popuplink.length > 0) ? o.popuplink : 'javascript:;',
2280                    plink_target = (typeof o.popuplink_target != 'undefined' && o.popuplink_target === true) ? 'target="_blank"' : '',
2281                    link_option = '';
2282
2283                if(typeof o.popuplink == 'undefined') o.popuplink = '';
2284                if(typeof o.popuplink_target == 'undefined') o.popuplink_target = '';
2285                if(typeof o.popuptime == 'undefined') o.popuptime = '';
2286
2287                if(plink != '' && plink != 'javascript:;') {
2288                    if(checkBase64Encode(plink)) plink = Base64.decode(plink);
2289                    var _menuList = (PAGE_MODE == 'c') ? MENULIST : property.MENULIST;
2290                    
2291                    if(plink.match(/^\@/g) !== null) {                                                  // link-type: link-bookmark ==> a[attr-bookmark]
2292                        var _settings = (PAGE_MODE == 'c') ? SETTINGS : property.SETTINGS,
2293                            bookmark_seq = plink.replace(/^\@/g,'');
2294                            
2295                        if(typeof _settings == 'undefined' || typeof _settings.blockBookmarkList == 'undefined' || _settings.blockBookmarkList['bookmark' + bookmark_seq] == 'undefined') {
2296                            plink = '';
2297                            link_option = '';
2298                        } else {
2299                            link_option = 'attr-bookmark="' + bookmark_seq + '"';
2300                        }
2301                    } else if(plink.match(/^flink\@[0-9]/gi) !== null) {                                // link-type: link-file     ==> a[attr-flink]
2302                        link_option = 'attr-flink="' + plink.replace(/^flink\@/gi,'') + '"';
2303                        plink_target = '';
2304                    } else if(_menuList.indexOf(plink.replace(/^\//g,"").replace(/ /g,"-")) > -1) {     // link-type: link-menu     ==> a[data-user-link]
2305                        link_option = 'data-user-link="' + plink + '"';
2306                    } else {                                                                            // link-type: link-out      ==> a[attr-link]
2307                        link_option = 'attr-link="' + plink + '"';
2308                    }
2309
2310                    plink = (PAGE_MODE == 'c') ? makeLinkUrl(plink, ONE, VIEW) : makeLinkUrl(plink, property.ONE, property.VIEW);
2311                }
2312
2313                html = html + '<div class="modal-popup" id="' + sid + 'Popup' + i + '" data-link="' + plink + '" data-target="' + o.popuplink_target + '" data-time="' + o.popuptime + '" data-idx="' + i + '" ' + display[i] + '>' + 
2314                '   <div class="popup-content">' +
2315                '       <div class="popup-header">' +
2316                '           <button type="button" class="close popup-close"><span aria-hidden="true"><svg viewBox="0 0 12 12" width="12" height="12"><path d="M6.71 6l5.15-5.15c0.2-0.2 0.2-0.51 0-0.71s-0.51-0.2-0.71 0L6 5.29 0.85 0.15c-0.2-0.2-0.51-0.2-0.71 0s-0.2 0.51 0 0.71L5.29 6l-5.15 5.15c-0.2 0.2-0.2 0.51 0 0.71C0.24 11.95 0.37 12 0.5 12s0.26-0.05 0.35-0.15L6 6.71l5.15 5.15c0.1 0.1 0.23 0.15 0.35 0.15s0.26-0.05 0.35-0.15c0.2-0.2 0.2-0.51 0-0.71L6.71 6z"/></svg></span></button>' +
2317                '       </div>' +
2318                '       <div class="popup-body">' +
2319                '          <a href="' + plink + '" ' + plink_target  + ' ' + link_option + '>' +
2320                '             <div class="img-wrap">' +
2321                '               <img src="' + o.popupimg + '" alt="" class="img-responsive img-popup" />' +
2322                '             </div>' +
2323                '          </a>' +
2324                '       </div>' +
2325                '       <div class="popup-footer clearfix">' +
2326                '           <ul class="text-center">' +
2327                '               <li class="sitePopupTodayHide">' +
2328                '                   <input type="checkbox" value="" class="hide">' +
2329                '                   ' + $.lang[LANG]['editor.popup.close-24hours'] + 
2330                '               </li>' +
2331                '               <li class="sitePopupClose">' + $.lang[LANG]['config.close'] + '</li>' +
2332                '           </ul>' +
2333                '       </div>' +
2334                '   </div>' +
2335                '</div>';
2336                if(data.length == (i+1) )  setPopupFunction(html,display);
2337            });
2338
2339        }
2340
2341        function setPopupFunction(html, display) {
2342
2343            var container = $('<div class="popup"></div>').html('<div class="popup-modal">' + html + '</div>');
2344            if($('.dsgn-body').find('.popup').length > 0 )  { 
2345                $('.dsgn-body').find('.popup').replaceWith(container);
2346            } else { 
2347                $('.dsgn-body').append(container); 
2348            }
2349
2350            var newInstance = jQuery.extend(true, {}, container);
2351            var sitePopupElement  = newInstance.find('.popup-modal');
2352
2353            var total_w = 0,
2354                add_w = 0, 
2355                d_top = $('.header.el-menu > header').outerHeight() + 15, 
2356                d_left = 0,
2357                x = 0, y = 0, y_r = 0;
2358
2359            var checkDsgnDodyW = $('.dsgn-body').width() + $('.dsgn-body').css('padding-left').replace('px','') * 1;
2360            if($('.header.el-menu').hasClass('sidebar') && checkDsgnDodyW > 752 ) d_top = 15;
2361
2362            for(i=0; i<img_w.length; i++) {
2363                if(parseInt(img_w[i]) > $('.dsgn-body').width()-30 ) {
2364                    img_w[i] = $('.dsgn-body').width()-30;
2365                }
2366                if(display[i]) { 
2367                    continue;
2368                } else {
2369                    total_w = total_w + parseInt(img_w[i]) + 30;
2370                }
2371            }
2372           
2373            var isOverflow = ($('.dsgn-body').width() < total_w) ? true : false,
2374                display_i = -1;
2375            
2376            if(isOverflow) { sitePopupElement.addClass('popupimg-overflow-y');
2377            } else { sitePopupElement.removeClass('popupimg-overflow-y'); }
2378
2379            $.each(img_w, function(i,v) {
2380                if(display[i]) {
2381                    return true;
2382                } else {
2383                    display_i++;
2384                }
2385
2386                if(isOverflow) {
2387                    x = (display_i==0) ? d_top : d_top + (display_i*30);
2388                    y = d_left + ((display_i+1)*30);
2389                    y_r = 120 - y;
2390
2391                    img_w[i] = 'auto';
2392                } else {
2393                    d_left = ($('.dsgn-body').width() - total_w)/2;
2394
2395                    x = d_top;
2396                    y = d_left + add_w + (i*15);
2397                }
2398                add_w = add_w + v;
2399
2400                var css_val = (isOverflow) ? {'top': x +'px', 'left': y+'px', 'right': y_r+'px', 'margin-left': '0px', 'width': img_w[i], 'max-width': v} : {'top': x +'px', 'left': y+'px' , 'width': img_w[i]};
2401                sitePopupElement.find('#'+sid +'Popup'+ i).css(css_val);
2402            });
2403            return sitePopupElement;
2404        }
2405    }
2406
2407    jQuery.guideVideoON = function() {
2408        // 편집 모드를 처음으로 보는 경우가 아니면 ( 주요기능을 이미 둘려봤으면 )
2409        if( LANG == 'ko' || typeof SETTINGS.showGuide != 'undefined')
2410            return false;
2411
2412        hideElementListPanel();
2413        var $guideVideoModal = $('<div class="guideVideoModal config-modal"></div>'),
2414            $content = $('<div class="content"></div>');
2415
2416        if ($('.guideVideoModal').length < 1) {
2417            $('body').prepend($guideVideoModal);
2418            $content.css({
2419                "width" : "100%",
2420                "height" : "100%",
2421                "background-color" : "rgba(0,0,0,0.6)",
2422                "display" : "none"
2423            });
2424
2425            $guideVideoModal.append($content);
2426            $guideVideoModal.css({
2427                "display": "inherit",
2428                "position": "fixed",
2429                "z-index": "99999999",
2430                "top": "0",
2431                "left": "0",
2432                "width": "100%",
2433                "height": "100%",
2434                "text-align": "center",
2435                "background-color" : "transparent"
2436            });
2437            $guideVideoModal.fadeIn();
2438
2439            var $guideVideo = $('<div class="guideVideo">'),
2440                $close = $('<div class="close"><img src="https://storage.googleapis.com/i.addblock.net/fa-close-modal.png" alt="close" /></div>'),
2441                $close2 = $('<button type="button" class="btn btn-primary btn-sm ok-button-dialog">' + $.lang[LANG]['config.ok'] + '</button>');
2442                $header = $('<div class="header"><h2>' + $.lang[LANG]["editor.guide.tutorial-video"] + '</h2></div>'),
2443                $body = $('<div class="body"></div>'),
2444                $contentbox = $('<div class="contentbox"></div>'),
2445                $tutorialVideo = $('<div class="tutorial-video"></div>'),
2446                $videoWrap = $('<div class="video-wrap guideVideo-stopPlay"><div id="guide-video-modal-video-overlay"></div></div>'),
2447                $watchAgainNote = $('<span class="watch-again-note">' + $.lang[LANG]['tutorial-video.watch-again-note'] + '</span>'),
2448                $bottom = $('<div class="bottom"></div>');
2449
2450            $close.on('click',function() { $.guideVideoOFF(); });
2451            $close2.on('click',function() { $.guideVideoOFF(); });
2452
2453            $videoWrap.on('click', function() {
2454
2455                $(this).toggleClass('guideVideo-stopPlay');
2456
2457                if(!$(this).hasClass('guideVideo-stopPlay')) {
2458                    if ( LANG == 'en' )
2459                        var link = "https://www.youtube.com/embed/p6fyIMl2BcI";
2460
2461                    var html = '<iframe class="video embed-responsive-item" width="765" height="380" src="' + link + '?enablejsapi=1&rel=0&vq=large&wmode=opaque&showinfo=0&controls=1&autoplay=0&loop=0;playlist=Fn0Mpyh3xto;" frameborder="0" allowfullscreen></iframe>';
2462
2463                    $(this).html(html);
2464
2465                }
2466            });
2467
2468            $tutorialVideo.append( $videoWrap );
2469            $contentbox.append( $tutorialVideo );
2470
2471            $bottom.append($close2).append($watchAgainNote);
2472            $body.append($contentbox).append($bottom);
2473            $guideVideo.append($header).append($close).append($body);
2474            $content.append($guideVideo);
2475            $content.fadeIn();
2476
2477        }
2478
2479        var $thisContent = $('.guideVideoModal .contentbox');
2480        
2481    }
2482
2483    jQuery.guideVideoOFF = function() {
2484        $('.guideVideoModal').fadeOut(function() {
2485            $(this).remove();  
2486        });
2487    }
2488
2489
2490
2491
2492    $.fn.siteDelete = function(sid, code, options) {
2493        // isDelLangSite : 특정 다국어 삭제시 ( 사이트 삭제에서의 다국어 삭제는 false 임 )
2494        var isDelLangSite = (code) ? true : false;
2495        options = options || {};
2496
2497        var sdOrgSid = sid,
2498            sdSid = (isDelLangSite) ? sid + '__' + code : sid,
2499            sdMore = [''],
2500            sdResource = [],
2501            sdResourceIdx = -1,
2502            sdResourceTotal = 0,
2503            sdIdx = -1,
2504            p_w = 0, p_max = 100, p_unit = 1,
2505            p_step_max = 100, p_step_unit = 1, p_step_plus = 1,
2506            block_view = { 'gallery':1, 'forum':2, 'form':2 };
2507
2508        $.sd = {
2509            initVal: function() {
2510                p_step_max = 100;
2511                p_step_unit = 1;
2512                p_step_plus = 1;
2513
2514                sdIdx++;
2515
2516                if(!isDelLangSite) {
2517                    code = sdMore[sdIdx];
2518                    sdSid = (code) ? sid + '__' + code : sid;
2519                }
2520            },
2521            strProcess: function(step) {
2522                // console.log('step: ' + step + '');
2523                // console.log('p_w: '+ p_w + ', p_unit: ' + p_unit);
2524                var str = '', cnt = '';
2525
2526                switch(step) {
2527                    case 'init':
2528                        p_max = (isDelLangSite) ? 100 : 100/sdMore.length;
2529                        p_unit = p_max / 100;
2530
2531                        str = $.lang[LANG]['site.delete.process.init'];
2532                        break;
2533
2534                    case '1':
2535                        p_w += p_unit * 5;
2536
2537                        str = $.lang[LANG]['site.delete.process.step1'];
2538                        break;
2539
2540                    case 'end':
2541                        p_w = p_max * (sdIdx+1);
2542
2543                        var checkEnd = (sdMore.length > sdIdx+1) ? false : true;
2544
2545                        str = $.lang[LANG]['site.delete.process.step14'];
2546                        cnt = (checkEnd) ? '' : '<br>' + $.lang[LANG]['site.delete.process.more'];
2547
2548                        if(checkEnd) {
2549
2550                            if(isDelLangSite) {
2551                                var slog_lang = $('.language-contents .settings-language .selected-languages li[data-code="' + code + '"] .language-name').text();
2552                                setSiteLogs('settings.language','delete',{'lang':slog_lang,'code':code},'settings.language');
2553                            }
2554
2555                            setTimeout(function() {
2556                                $.progressOFF();
2557                            }, 500);
2558                        }
2559                        break;
2560
2561                    default:
2562                        if(step == '2') {
2563                            p_step_max = p_unit * 90;
2564                            p_step_unit = p_step_max / 13;
2565                        }
2566
2567                        if($.inArray(step,['3','4'])>-1) str = $.lang[LANG]['site.delete.process.step3'];
2568                        else if($.inArray(step,['5','6','7','8','8-more','9'])>-1) str = $.lang[LANG]['site.delete.process.step5'];
2569                        else str = $.lang[LANG]['site.delete.process.step'+step];
2570
2571                        if(step == '13-more') {
2572                            if(sdResource.length == 0) return false;
2573                            str += '( ' + (sdResourceIdx+1) + ' / ' + sdResource.length + ' )';
2574                        }
2575
2576                        if(p_step_plus > 0) p_w += p_step_unit;
2577                        break;
2578                }
2579
2580
2581                if(step == 'init' && sdIdx == 0) {
2582                    $.progressON(str,'','',true);
2583                } else {
2584                    $('.progressModal .progress-header h1').html(str);
2585                    $('.progressModal .progress-bar').css('width',p_w+'%');
2586                }
2587
2588                // console.log('p_w: '+ p_w + ', p_unit: ' + p_unit);
2589            },
2590            step0: function() {
2591                if(sdIdx == 0) $('#loading').addClass('hide');
2592
2593                var sdStep1 = $.sd.step1();
2594                sdStep1.done(function() {
2595                    $.sd.stepMultiCall('2');
2596                }).fail(function(sdStep1_msg){
2597                    console.log(sdStep1_msg);
2598
2599                    $.sd.stepEnd();
2600                    if(sdStep1_msg) $(this).showModalFlat('ERROR', sdStep1_msg, false, false,'', 'ok','','cl-cmmodal cl-s-btn w560 cl-p130 cl-p0');
2601                });
2602            },
2603            step1: function() { // [del] ln_select
2604                var step1_deferred = $.Deferred();
2605
2606                $.post('/template/siteDelete', { step:'1', sid:sdOrgSid, code:code, isDelLangSite:isDelLangSite }, function(r1) {
2607                    if(typeof r1.error != 'undefiend' && r1.error) {
2608                        console.log('step1 reject');
2609                        step1_deferred.reject(r1.error);
2610                    }
2611                    $.sd.strProcess('1');
2612
2613                    setTimeout(function() {
2614                        step1_deferred.resolve();
2615                    }, 200);
2616                }, 'json');
2617                
2618                return step1_deferred.promise();
2619            },
2620            stepMultiCall: function(call_step) {
2621                if(call_step == '2') $.sd.strProcess('2');
2622
2623                if(call_step == '13-more') {
2624                    var sdStep3 = $.sd.step3();
2625                    sdStep3.done(function(next_step) {
2626                        if(next_step) $.sd.stepMultiCall(next_step);
2627                        else $.sd.stepEnd();
2628                    }).fail(function(sdStep3_msg) {
2629                        console.log(sdStep3_msg);
2630
2631                        $.sd.stepMultiCall('14');
2632                        if(sdStep3_msg) $(this).showModalFlat('ERROR', sdStep3_msg, false, false,'', 'ok','','cl-cmmodal cl-s-btn w560 cl-p130 cl-p0');
2633                    });
2634                } else {
2635                    var sdStepMulti = $.sd.stepMulti(call_step);
2636                    sdStepMulti.done(function(next_step) {
2637                        if(next_step) $.sd.stepMultiCall(next_step);
2638                        else $.sd.stepEnd();
2639                    }).fail(function(sdStepMulti_msg){
2640                        console.log(sdStepMulti_msg);
2641
2642                        var jump_step = (call_step.indexOf('-more') > -1) ? Number(call_step.replace('-more', ''))+1 : Number(call_step)+1;
2643                        if(jump_step >= 15) $.sd.stepEnd();
2644                        else $.sd.stepMultiCall(jump_step.toString());
2645                        
2646                        console.log(call_step);
2647                        console.log('->');
2648                        console.log(jump_step.toString());
2649
2650                        if(sdStepMulti_msg) $(this).showModalFlat('ERROR', sdStepMulti_msg, false, false,'', 'ok','','cl-cmmodal cl-s-btn w560 cl-p130 cl-p0');
2651                    });
2652                }
2653            },
2654            stepMulti: function(sd_step) {
2655                var stepMulti_deferred = $.Deferred();
2656
2657                $.post('/template/siteDelete', { step:sd_step, sid:sdOrgSid, code:code }, function(r) {
2658                    if(typeof r.error != 'undefiend' && r.error) {
2659                        console.log('stepMulti reject');
2660                        stepMulti_deferred.reject(r.error);
2661                    }
2662                    if(sd_step == '13') {
2663                        sdResource = (typeof r.r_list != 'undefiend') ? r.r_list : [];
2664                        sdResourceTotal = (typeof r.r_total != 'undefiend') ? r.r_total : 0;
2665                    }
2666
2667                    p_step_plus = (r.next_step=='' || r.next_step.indexOf('-more') > -1) ? 0 : 1;
2668                    if(r.next_step) $.sd.strProcess(r.next_step);
2669
2670                    setTimeout(function() {
2671                        stepMulti_deferred.resolve(r.next_step);
2672                    }, 100);
2673                }, 'json');
2674
2675                return stepMulti_deferred.promise();
2676            },
2677            step3: function() {
2678                var step3_deferred = $.Deferred();
2679
2680                sdResourceIdx++;
2681                var r_seq = sdResource[sdResourceIdx];
2682                if(typeof r_seq != 'undefiend' && r_seq) {
2683                    $.post('/template/siteDelete', { step:'13-more', sid:sdOrgSid, code:code, r_seq:r_seq }, function(r3) {
2684                        if(typeof r3.error != 'undefiend' && r3.error) {
2685                            console.log('step3 reject');
2686                            step3_deferred.reject(r3.error);
2687                        }
2688                        p_step_plus = 0;
2689                        if(r3.next_step) $.sd.strProcess(r3.next_step);
2690
2691                        setTimeout(function() {
2692                            step3_deferred.resolve(r3.next_step);
2693                        }, 50);
2694                    }, 'json');
2695                } else {
2696                    step3_deferred.resolve('14');
2697                }
2698
2699                return step3_deferred.promise();
2700            },
2701            stepEnd: function() {
2702                $.sd.strProcess('end');
2703
2704                var checkEnd = (sdMore.length > sdIdx+1) ? false : true;
2705                if(checkEnd) {
2706                    $('#loading').removeClass('hide');
2707
2708                    var completed = false,
2709                        completeDelete = function() {
2710                            if (completed) return;
2711                            completed = true;
2712                            $('.modal.modal-default.fade.in').css('zIndex','');
2713                            if (typeof options.onComplete == 'function') options.onComplete();
2714                            if (options.noRedirect) return;
2715
2716                            location.href='/';
2717                        };
2718
2719                    var deleted_modal = $(this).showModalFlat($.lang[LANG]['site.delete.process.end.title'], $.lang[LANG]['site.delete.process.end.description'], true, false, function() {
2720                        completeDelete();
2721                    }, 'ok','','cl-cmmodal cl-s-btn w560 cl-p130 cl-p0','','','',function() {
2722                        completeDelete();
2723                    });
2724                } else {
2725                    $.sd.initVal();
2726                    setTimeout(function() {
2727                        $.sd.step0();
2728                    }, 300);
2729                }
2730            }
2731        }
2732
2733
2734
2735        if(isDelLangSite) {
2736            $.sd.initVal();
2737            $.sd.strProcess('init');
2738            setTimeout(function() {
2739                $.sd.step0();
2740            }, 300);
2741        } else {
2742            $.post('/template/siteDelete', { step:'check', sid:sdOrgSid, code:code }, function(r1) {
2743                if(typeof r1.error != 'undefiend' && r1.error) {
2744                    alert(r1.error);
2745                    location.reload();
2746                    return false;
2747                }
2748                sdMore = r1.more_code;
2749
2750                $.sd.initVal();
2751                $.sd.strProcess('init');
2752
2753                setTimeout(function() {
2754                    $.sd.step0();
2755                }, 300);
2756            }, 'json');
2757        }
2758    }
2759
2760
2761    $.fn.siteClone = function(sid, dest_sid, isAddLangSite) {
2762        var scIdx = -1,
2763            scSid = [sid],
2764            scDest = [dest_sid],
2765            scCheck = { 'popup':false, 'music':false, 'gallery':false, 'forum':false },
2766            scOrgData = [],
2767            scDestData = [],
2768            scTempData = [];
2769
2770        var p_w = 0, p_max = 100, p_unit = 1,
2771            p_step_max = 100, p_step_unit = 1, p_step_plus = 1,
2772            block_view = { 'gallery':1, 'forum':2, 'form':2, 'contact':2 };
2773
2774        $.sc = {
2775            initVal: function() {
2776                p_step_max = 100;
2777                p_step_unit = 1;
2778                p_step_plus = 1;
2779              
2780                scIdx++;
2781                if(scIdx == 0) {
2782                    if(isAddLangSite) scCheck = { 'popup':true, 'music':true, 'gallery':true, 'forum':true };
2783                    else scCheck = { 'popup':false, 'music':false, 'gallery':false, 'forum':false };
2784                } else if(scIdx > 0) {
2785                    scDest.push(scSid[scIdx].replace(scSid[0],scDest[0])
2785);
2786                }
2787
2788                scOrgData.push({ 'total':0, 'normal_total':0, 'gallery' : { 'total':0 }, 'forum' : { 'total':0 }, 'form' : { 'total':0 }, 'contact' : { 'total':0 } });
2789                scDestData.push({ 'total':0, 'normal_total':0, 'gallery' : { 'total':0 }, 'forum' : { 'total':0 }, 'form' : { 'total':0 }, 'contact' : { 'total':0 } });
2790                scTempData.push({ 'gallery':false, 'forum':false, 'form':false, 'contact':false });
2791            },
2792            strCheck: function() {
2793                var checkbox = clSVG('checkbox',16,16,false,'');
2794
2795                return '\
2796                <div class="check-wrap">\
2797                    <div class="box">\
2798                        <div class="newcheckbox hand checkbox">\
2799                            <label>\
2800                                <input type="checkbox" class="check-popup" name="check-popup">\
2801                                ' + checkbox + '\
2802                            </label>\
2803                            <span>' + $.lang[LANG]['site.clone.check.popup'] + '</span>\
2804                        </div>\
2805                        <div class="newcheckbox hand checkbox">\
2806                            <label>\
2807                                <input type="checkbox" class="check-music" name="check-music">\
2808                                ' + checkbox + '\
2809                            </label>\
2810                            <span>' + $.lang[LANG]['site.clone.check.music'] + '</span>\
2811                        </div>\
2812                        <div class="newcheckbox hand checkbox">\
2813                            <label>\
2814                                <input type="checkbox" class="check-gallery" name="check-gallery">\
2815                                ' + checkbox + '\
2816                            </label>\
2817                            <span>' + $.lang[LANG]['site.clone.check.gallery'] + '</span>\
2818                        </div>\
2819                        <div class="newcheckbox hand checkbox">\
2820                            <label>\
2821                                <input type="checkbox" class="check-forum" name="check-forum">\
2822                                ' + checkbox + '\
2823                            </label>\
2824                            <span>' + $.lang[LANG]['site.clone.check.forum'] + '</span>\
2825                        </div>\
2826                    </div>\
2827                    <p><span class="error">' + $.lang[LANG]['site.clone.check.info.1'] + '\
2828                    <svg class="cm-popover-info" viewBox="0 0 13 13"  width="13" height="13" tabindex="0" data-toggle="popover" data-trigger="hover" data-html="true" data-placement="top" data-content="' + $.lang[LANG]['site.clone.check.info.3'] + '">\
2829                        <path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM7 10H6V9h1V10zM7.67 6.75C7.04 7.37 7 7.66 6.99 8H6c0.02-0.63 0.21-1.03 0.88-1.69 0.46-0.47 0.75-0.86 0.76-1.34 0-0.58-0.39-0.95-1.02-0.95 -0.56 0-1 0.14-1.08 0.76C5.53 4.85 5.52 4.93 5.52 5H4.5c-0.01-0.08 0-0.14 0-0.2 0.08-1.3 1.11-1.79 2.17-1.79 1.22 0 2.04 0.84 2.04 1.87C8.7 5.68 8.17 6.27 7.67 6.75z"/>\
2830                    </svg>' + $.lang[LANG]['site.clone.check.info.2'] + '</span></p>\
2831                </div>\
2832                ';
2833            },
2834            strProcess: function(step) {
2835                // console.log('step: ' + step + '');
2836                // console.log('p_w: '+ p_w + ', p_unit: ' + p_unit);
2837
2838                var str = '',
2839                    cnt = '';
2840
2841                switch(step) {
2842                    case 'init': // 0%
2843                        str = $.lang[LANG]['site.clone.process.init'];
2844                        break;
2845
2846                    case '1': // 5%
2847                        if(scIdx == 0) {
2848                            p_max = 100 / scSid.length;
2849                            p_unit = p_max / 100;
2850                        }
2851
2852                        p_w += p_unit * 5;
2853
2854                        str = $.lang[LANG]['site.clone.process.step1'];
2855                        if(!isAddLangSite) {
2856                            if(!scCheck['popup'] && !scCheck['music']) str = $.lang[LANG]['site.clone.process.step1.1'];
2857                            else if (scCheck['popup'] && !scCheck['music']) str = $.lang[LANG]['site.clone.process.step1.2'];
2858                            else if (!scCheck['popup'] && scCheck['music']) str = $.lang[LANG]['site.clone.process.step1.3'];
2859                        }
2860                        break;
2861
2862                    case '2': // 0%
2863                        str = $.lang[LANG]['site.clone.process.step2'];
2864                        break;
2865
2866                    case '2-ok':                        
2867                        str = $.lang[LANG]['site.clone.process.step2'];
2868                        cnt = '(0/' + scOrgData[scIdx]['total'] + ')';
2869
2870                        // step3,4 init
2871                        p_step_max = p_unit * 60;
2872                        p_step_unit = p_step_max / scOrgData[scIdx]['total'];
2873                        break;
2874
2875                    case '3': // 30%
2876                        str = $.lang[LANG]['site.clone.process.step3'];
2877                        cnt = '(' + scDestData[scIdx]['total'] + '/' + scOrgData[scIdx]['total'] + ')';
2878                        break;
2879
2880                    case '3-ok':
2881                        p_w += p_step_unit * p_step_plus;
2882
2883                        str = $.lang[LANG]['site.clone.process.step3'];
2884                        cnt = '(' + scDestData[scIdx]['total'] + '/' + scOrgData[scIdx]['total'] + ')';
2885                        break;
2886
2887                    case '4': // 5%
2888                        p_w += p_unit * 5;
2889
2890                        str = $.lang[LANG]['site.clone.process.step4'];
2891                        cnt = '(' + scDestData[scIdx]['total'] + '/' + scOrgData[scIdx]['total'] + ')';
2892                        break;
2893
2894                    case '5': // 30%
2895                        p_w += p_step_unit * p_step_plus;
2896
2897                        str = $.lang[LANG]['site.clone.process.step5'];
2898                        cnt = '(' + scDestData[scIdx]['total'] + '/' + scOrgData[scIdx]['total'] + ')';
2899                        break;
2900
2901                    case '6': // 5%
2902                        p_w += p_unit * 5;
2903
2904                        str = $.lang[LANG]['site.clone.process.step6'];
2905                        cnt = '(' + scDestData[scIdx]['resource']['total'] + '/' + scOrgData[scIdx]['resource']['total'] + ')';
2906
2907                        // step7 init
2908                        p_step_max = p_unit * 20;
2909                        p_step_unit = p_step_max / scOrgData[scIdx]['resource']['total'];
2910                        break;
2911
2912                    case '7': // 20%
2913                        p_w += p_step_unit;
2914
2915                        str = $.lang[LANG]['site.clone.process.step7'];
2916                        cnt = '(' + scDestData[scIdx]['resource']['total'] + '/' + scOrgData[scIdx]['resource']['total'] + ')';
2917                        break;
2918
2919                    case '8': // 5%
2920                        p_w = p_max * (scIdx+1);
2921
2922                        var checkEnd = (scSid.length > 1 && scSid.length > scIdx+1) ? false : true;
2923
2924                        str = $.lang[LANG]['site.clone.process.step8'];
2925                        cnt = (checkEnd) ? '' : '<br>' + $.lang[LANG]['site.clone.process.step8.more'];
2926
2927                        if(checkEnd) {
2928                            setTimeout(function() {
2929                                $.progressOFF();
2930                            }, 500);
2931                        }
2932                        break;
2933
2934                    default:
2935                        break;
2936                }
2937
2938
2939                if(step == 'init' && scIdx == 0) {
2940                    $.progressON(str,'','',true);
2941                } else {
2942                    $('.progressModal .progress-header h1').html(str + cnt);
2943                    $('.progressModal .progress-bar').css('width',p_w+'%');
2944                }
2945
2946                // console.log('p_w: '+ p_w + ', p_unit: ' + p_unit);
2947            },
2948            step0: function() {
2949
2950                var scStep1 = $.sc.step1();
2951                scStep1.done(function() {
2952                    var scStep2 = $.sc.step2();
2953                    scStep2.done(function() {
2954                        $.sc.step3Call(1);
2955                    }).fail(function(scStep2_msg) {
2956                        console.log('scStep2 fail');
2957                        console.log(scStep2_msg);
2958
2959                        $.sc.step8();
2960                        if(scStep2_msg) $(this).showModalFlat('<?=$this->lang->line("lang.delete.modal.title")?>', scStep2_msg, false, false,'', 'ok','','cl-cmmodal cl-s-btn w560 cl-p130 cl-p0');
2961                    });
2962                }).fail(function(scStep1_msg){
2963                    console.log(scStep1_msg);
2964
2965                    $.sc.step8();
2966                    if(scStep1_msg) $(this).showModalFlat('<?=$this->lang->line("lang.delete.modal.title")?>', scStep1_msg, false, false,'', 'ok','','cl-cmmodal cl-s-btn w560 cl-p130 cl-p0');
2967                });
2968            },
2969            step1: function() { // [clone] pf_site | [get] org pf_site 
2970                var step1_deferred = $.Deferred();
2971
2972                $.post('/template/siteClone', { step:'1', sid:scSid[scIdx], dest_sid:scDest[scIdx], check:scCheck, isAddLangSite:isAddLangSite }, function(r1) {
2973                    if(typeof r1.error != 'undefiend' && r1.error) {
2974                        console.log('step1 error: ' + r1.error);
2975
2976                        var error_msg = (r1.error == 'already_dest') ? '복제가 정상적으로 안되었으니 삭제 후 다시 시도해주세요.' : 'Site Clone Step1 Error';
2977                        step1_deferred.reject(error_msg);
2978                    }
2979
2980                    scOrgData[scIdx]['pfsite'] = r1.org_site;
2981                    if(scIdx == 0 && r1.site_langs !== null) scSid = r1.site_langs;
2982                    $.sc.strProcess('1');
2983
2984                    setTimeout(function() {
2985                        step1_deferred.resolve();
2986                    }, 300);
2987                }, 'json');
2988                
2989                return step1_deferred.promise();
2990            },
2991            step2: function() { // [get] block total
2992                var step2_deferred = $.Deferred();
2993                $.sc.strProcess('2');
2994
2995                $.post('/template/siteClone', { step:'2', sid:scSid[scIdx], check:scCheck }, function(r2) {
2996                    if(typeof r2.error != 'undefiend' && r2.error) {
2997                        console.log('step2 reject');
2998                        step2_deferred.reject(r2.error);
2999                    }
3000
3001                    scOrgData[scIdx]['total'] = r2.data.total;
3002                    scOrgData[scIdx]['normal_total'] = r2.data.normal_total;
3003                    $.sc.strProcess('2-ok');
3004
3005                    setTimeout(function() {
3006                        step2_deferred.resolve();
3007                    }, 300);
3008                }, 'json');
3009                
3010                return step2_deferred.promise();
3011            },
3012            step3Call: function(page) {
3013
3014                var view = 100,
3015                    checkNextStep = (Math.ceil(scOrgData[scIdx]['normal_total']/view) < page) ? true : false;
3016
3017                if(checkNextStep) {
3018                    var scStep4 = $.sc.step4();
3019                    scStep4.done(function(data4) {
3020                        $('.progress-content').append('\
3021                            <div class="clone-section" data-sid="' + scSid[scIdx] + '" data-sid="' + scDest[scIdx] + '">\
3022                                <ul class="clone-block-list"></ul>\
3023                                <ul class="clone-resource-list"></ul>\
3024                            </div>\
3025                        ');
3026                        $.each(data4, function(key,total) {
3027                            // if(key == 'gallery_items') return true;
3028                            if(key == 'total') return true;
3029                            if(total > 0) {
3030                                var view = block_view[key],
3031                                    total_page = (total > view) ? Math.ceil(total/view) : 1,
3032                                    view_start = 1,
3033                                    view_end = (total > view) ? view : total;
3034
3035                                for(var idx=1; idx<=total_page; idx++) {
3036                                    if(idx > 1) {
3037                                        view_start = view_end + 1;
3038                                        view_end = (total > (view*idx)) ? view*idx : total;
3039                                    }
3040
3041                                    var btn_target = (view === 1 || view_end == 1) ? '' : '(' + view_start + '~' + view_end + ')',
3042                                    btn_str = key + ' ' + idx + btn_target,
3043                                    btn_html = '<button type="button" class="btn btn-primary site-clone-step5" data-start="'+view_start+'" data-end="'+view_end+'">'+btn_str+'</button>';
3044                                    $('.progress-content .clone-section[data-sid="' + scSid[scIdx] + '"] .clone-block-list').append('<li class="'+ key +'">' + btn_html + '</li>');
3045                                }
3046                            }
3047                        });
3048
3049                        $.sc.step5Call(0);
3050
3051                    }).fail(function(scStep4_msg){
3052                        console.log(scStep4_msg);
3053
3054                        $.sc.step8();
3055                        if(scStep4_msg) $(this).showModalFlat('<?=$this->lang->line("lang.delete.modal.title")?>', scStep4_msg, false, false,'', 'ok','','cl-cmmodal cl-s-btn w560 cl-p130 cl-p0');
3056                    });
3057
3058                    return false;
3059                }
3060
3061                var scStep3 = $.sc.step3(page);
3062                scStep3.done(function() {
3063                    $.sc.step3Call(page+1);
3064                }).fail(function(scStep3_msg){
3065                    console.log(scStep3_msg);
3066
3067                    $.sc.step8();
3068                    if(scStep3_msg) $(this).showModalFlat('<?=$this->lang->line("lang.delete.modal.title")?>', scStep3_msg, false, false,'', 'ok','','cl-cmmodal cl-s-btn w560 cl-p130 cl-p0');
3069                });
3070
3071            },
3072            step3: function(page) { // [clone] pf_page > normal block
3073                var step3_deferred = $.Deferred();
3074
3075                $.sc.strProcess('3');
3076                $.post('/template/siteClone', { step:'3', sid:scSid[scIdx], dest_sid:scDest[scIdx], check:scCheck, page:page, isAddLangSite:isAddLangSite }, function(r3) {
3077                    if(typeof r3.error != 'undefiend' && r3.error) {
3078                        console.log('step3 reject');
3079                        step3_deferred.reject(r3.error);
3080                    }
3081
3082                    p_step_plus = r3.data.insert_total;
3083                    scDestData[scIdx]['total'] += r3.data.insert_total;
3084                    $.sc.strProcess('3-ok');
3085
3086                    setTimeout(function() {
3087                        step3_deferred.resolve();
3088                    }, 200);
3089                }, 'json');
3090                
3091                return step3_deferred.promise();
3092            },
3093            step4: function() { // [get] (gallery / form / forum) block total
3094                var step4_deferred = $.Deferred();
3095
3096                $.post('/template/siteClone', { step:'4', sid:scSid[scIdx], check:scCheck }, function(r4) {
3097                    if(typeof r4.error != 'undefiend' && r4.error) {
3098                        console.log('step4 reject');
3099                        step4_deferred.reject(r4.error);
3100                    }
3101
3102                    scOrgData[scIdx]['gallery']['total'] = r4.data.gallery;
3103                    scOrgData[scIdx]['forum']['total'] = r4.data.forum;
3104                    scOrgData[scIdx]['form']['total'] = r4.data.form;
3105                    scOrgData[scIdx]['contact']['total'] = r4.data.contact;
3106                    $.sc.strProcess('4');
3107
3108                    setTimeout(function() {
3109                        step4_deferred.resolve(r4.data);
3110                    }, 300);
3111                }, 'json');
3112                
3113                return step4_deferred.promise();
3114            },
3115            step5Call: function(cnt) {
3116                var cloneBlock = $('.progress-content .clone-section[data-sid="' + scSid[scIdx] + '"] .clone-block-list li').eq(cnt);
3117                if(cloneBlock.length == 0) {
3118                    $.sc.step6();
3119                    return false;
3120                }
3121
3122                var cloneBlockBtn = cloneBlock.find('button'),
3123                    key = cloneBlock.attr('class'),
3124                    start = cloneBlockBtn.attr('data-start'),
3125                    end = cloneBlockBtn.attr('data-end'),
3126                    more = (typeof cloneBlockBtn.attr('data-more') != 'undefined' && cloneBlockBtn.attr('data-more')) ? cloneBlockBtn.attr('data-more') : '';
3127
3128                var scStep5 = $.sc.step5(key,cnt,start,end,more);
3129                scStep5.done(function(checkMore) {
3130                    if(checkMore) $.sc.step5Call(cnt);
3131                    else $.sc.step5Call(cnt+1);
3132                }).fail(function() {
3133                    console.log('scStep5 fail');
3134                });
3135            },
3136            step5: function(key,cnt,start,end,more) { // [clone] pf_page > (gallery / form / forum) block
3137                var step5_deferred = $.Deferred();
3138
3139                var cloneBlock = $('.progress-content .clone-section[data-sid="' + scSid[scIdx] + '"] .clone-block-list li').eq(cnt),
3140                    cloneBlockBtn = cloneBlock.find('button'),
3141                    block_insert_data = scTempData[scIdx][key];
3142
3143                $.post('/template/siteClone', { step:'5', sid:scSid[scIdx], dest_sid:scDest[scIdx], check:scCheck, insert_data:block_insert_data, btype:key, bstart:start, bend:end, more:more }, function(r5) {
3144
3145                    if(typeof r5.error != 'undefined' && r5.error) {
3146                        console.log('step5 reject');
3147                        console.log('Gallery / form / forum Clone error::' + scSid[scIdx] + ', ' + r5.error);
3148                        $('.progress-content .clone-section[data-sid="' + scSid[scIdx] + '"] .clone-block-list li').eq(cnt).append('<span class="error">
3148'+r5.error+'</span>');
3149                        step5_deferred.reject();
3150
3151                    } else $('.progress-content .clone-section[data-sid="' + scSid[scIdx] + '"] .clone-block-list .error').remove();
3152
3153                    scDestData[scIdx]['total'] = scDestData[scIdx]['total'] + r5.data.total;
3154                    scTempData[scIdx][key] = Object.assign(block_insert_data, r5.data.insert_data);
3155
3156                    var check_more = false;
3157                    if(typeof r5.data.more != 'undefiend' && r5.data.more) {
3158                        check_more = true;
3159                        
3160                        var more_str = r5.data.more,
3161                            more_arr = more_str.split(','),
3162                            more_btn_str = more_arr[2]+'/'+more_arr[3];
3163                        cloneBlockBtn.attr('data-more',r5.data.more);
3164                        if(cloneBlockBtn.find('.next').length > 0) cloneBlockBtn.find('.next').text(more_btn_str);
3165                        else cloneBlockBtn.append('<span class="next">('+more_btn_str+')</span>');
3166                    } else {
3167                        p_step_plus = r5.data.total;
3168                        $.sc.strProcess('5');
3169                        cloneBlockBtn.attr('disabled',true);
3170                    }
3171
3172                    setTimeout(function() {
3173                        step5_deferred.resolve(check_more);
3174                    }, 200);
3175                }, 'json');
3176
3177
3178                return step5_deferred.promise();
3179            },
3180            step6: function() { // [get] pf_resource seq & total
3181                console.log(scSid[scIdx]);
3182
3183                $.post('/template/siteClone', { step:'6', sid:scSid[scIdx], dest_sid:scDest[scIdx] }, function(r6) {
3184
3185                    var cloneSection = $('.progress-content .clone-section[data-sid="' + scSid[scIdx] + '"] .clone-resource-list');
3186                    if(typeof r6.error != 'undefined' && r6.error) {
3187                        console.log('step6 reject');
3188                        console.log('Resorce Clone error::' + scSid[scIdx] + ', ' + r6.error);
3189                        cloneSection.before('<span class="error">'+r6.error+'</span>');
3190                        return false;
3191                    } else $('.error').remove();
3192
3193                    var r_view = 30,
3194                        r_total = r6.count,
3195                        r_add = 0;
3196                    
3197                    scOrgData[scIdx]['resource'] = {
3198                        'total' : r_total,
3199                        'list' : r6.list
3200                    };
3201                    scDestData[scIdx]['resource'] = {
3202                        'total' : 0,
3203                        'list' : new Array()
3204                    };
3205                    $.sc.strProcess('6');
3206
3207                    if(r_total == 0) {
3208                        $.sc.step8();
3209                        return false;
3210                    }
3211
3212                    $.each(r6.list, function(rs_i,rs_v) {
3213                        r_add++;
3214                        var mod = r_add%r_view;
3215                        if(mod === 1) cloneSection.append('<li></li>');
3216                        cloneSection.find('li:last-child').append('<span>' + rs_v.seq + '</span>');
3217
3218                        if(r_add == r_total) {
3219                            $.sc.step7Call(0,0);
3220                        }
3221                    });
3222                }, 'json');
3223            },
3224            step7Call: function(rs_eq1,rs_eq2) {
3225                var cloneResource = $('.progress-content .clone-section[data-sid="' + scSid[scIdx] + '"] .clone-resource-list');
3226                    rs_li_total = cloneResource.find('li').length;
3227                if(rs_eq1 >= rs_li_total) {
3228                    $.sc.step8();
3229                    return false;
3230                }
3231
3232                var cloneResourceli = cloneResource.find('li').eq(rs_eq1),
3233                    rs_span_total = cloneResourceli.find('span').length;
3234                if(rs_eq2 >= rs_span_total) {
3235                    $.sc.step7Call(rs_eq1+1,0);
3236                    return false;
3237                }
3238
3239                var cloneResourceSpan = cloneResourceli.find('span').eq(rs_eq2),
3240                    rs_seq = cloneResourceSpan.text();
3241                if(rs_seq == '') {
3242                    $.sc.step8();
3243                    return false;
3244                }
3245
3246                var scStep7 = $.sc.step7(rs_seq);
3247                scStep7.done(function() {
3248                    if(rs_eq2+1 < rs_span_total) $.sc.step7Call(rs_eq1,rs_eq2+1);
3249                    else $.sc.step7Call(rs_eq1+1,0);
3250                }).fail(function() {
3251                    console.log('scStep7 fail');
3252                });
3253            },
3254            step7: function(rs_seq) { // [clone] pf_resource
3255                var step7_deferred = $.Deferred();
3256
3257                $.post('/template/siteClone', { step:'7', sid:scSid[scIdx], dest_sid:scDest[scIdx], r_seq:rs_seq }, function(r7) {
3258
3259                    if(typeof r7.error != 'undefined' && r7.error) {
3260                        console.log('step7 reject');
3261                        console.log('Resorce Clone error::' + rs_seq + ', ' + r7.error);
3262                        $('.progress-content .clone-section[data-sid="' + scSid[scIdx] + '"] .clone-resource-list li span[data-seq="' + rs_seq + '"]').addClass('error');
3263                        step7_deferred.reject();
3264
3265                    } else $('.progress-content .clone-section[data-sid="' + scSid[scIdx] + '"] .clone-resource-list li .error').remove();
3266
3267                    scDestData[scIdx]['resource']['total'] = scDestData[scIdx]['resource']['total'] + 1;
3268                    scDestData[scIdx]['resource']['list'].push(rs_seq);
3269                    $.sc.strProcess('7');
3270
3271                    setTimeout(function() {
3272                        step7_deferred.resolve();
3273                    }, 100);
3274                }, 'json');
3275
3276                return step7_deferred.promise();
3277            },
3278            step8: function() { // check other site(language site)
3279                $.sc.strProcess('8');
3280
3281                if(isAddLangSite || scIdx+1 == scSid.length) {
3282                    location.reload();
3283                } else {
3284                    $.sc.initVal();
3285                    setTimeout(function() {
3286                        $.sc.step0();
3287                    }, 500);
3288                }
3289            }
3290        }
3291
3292
3293        $.sc.initVal();
3294        if(isAddLangSite) {
3295            $.sc.strProcess('init');
3296            setTimeout(function() {
3297                $.sc.step0();
3298            }, 600);
3299        } else {
3300            var scCheckModal = $(this).showModalFlat($.lang[LANG]['site.clone.check.title'], $.sc.strCheck(), true, true, function() {
3301                $.sc.strProcess('init');
3302
3303                scCheck.popup = $('.check-popup').prop('checked');
3304                scCheck.music = $('.check-music').prop('checked');
3305                scCheck.gallery = $('.check-gallery').prop('checked');
3306                scCheck.forum = $('.check-forum').prop('checked');
3307                
3308                setTimeout(function() {
3309                    $.sc.step0();
3310                    scCheckModal.modal('hide');
3311                }, 600);
3312            },'cancel','','cl-siteclone cl-cmmodal cl-s-btn w560 cl-p70 cl-p0','','',function() { $('[data-toggle="popover"]').popover(); });
3313        }
3314    }
3315
3316    $.fn.sitePublishVer01 = function(sid,onoff,endCallback) {
3317
3318        var strTitle = (onoff==1) ? $.lang[LANG]['loading.publishing'] : $.lang[LANG]['loading.publishing.off'];
3319        $.progressON(strTitle,'',0,true);
3320        
3321        var pbSiteCall = function(slist,sidx) {
3322            if(typeof slist == 'undefined' || typeof slist[sidx] == 'undefined') {
3323                pbEndCall(false);
3324                return false;
3325            }
3326
3327            var s_obj = slist[sidx],
3328                s_orgsid = s_obj['sid'],
3329                s_code = (typeof s_obj['code'] != 'undefined' && s_obj['code']) ? s_obj['code'] : '',
3330                s_sid = (s_code) ? s_orgsid+'__'+s_code : s_orgsid;
3331
3332            $.progressON('', s_orgsid + ((s_code) ? $.lang[LANG]['editor.publish.step2.1'] + ' (' + s_code + ')' : '') + $.lang[LANG]['editor.publish.step2.2'],0,true);
3333            var pbSite_r = pbSite(s_sid,onoff);
3334            pbSite_r.done(function(r2) {
3335                $.progressON('', s_orgsid + ((s_code) ? $.lang[LANG]['editor.publish.step3.1'] + ' (' + s_code + ')' : '') + $.lang[LANG]['editor.publish.step3.2'],0,true);
3336                var w = getProgressWidth() + (20/slist.length) * (sidx+1);
3337                $('.progress-bar').css('width',w+'%');
3338
3339                pbGalleryCall(slist,sidx,s_orgsid,s_code,r2.count,0);
3340            }).fail(function(r2_error) {
3341                console.log(r2_error);
3342                pbEndCall(false);
3343            });
3344        }
3345
3346        var pbGalleryCall = function(sitelist,siteidx,sidorg,sidcode,gcount,gpidx) {
3347            var sitesid = (sidcode) ? sidorg+'__'+sidcode : sidorg;
3348
3349            var pbGallery_r = pbGallery(sitesid,onoff,gcount,gpidx,sitelist.length,siteidx);
3350            pbGallery_r.done(function(r3) {
3351                $.progressON('',sidorg + ((sidcode) ? $.lang[LANG]['editor.publish.step4.1'] + ' (' + sidcode + ')' : '') + $.lang[LANG]['editor.publish.step4.2'],0,true);
3352                $('.progress-bar').css('width',r3.w+'%');
3353
3354                if(r3.done == true) pbPagesCall(sitelist,siteidx,sidorg,sidcode,r3.count,0);
3355                else pbGalleryCall(sitelist,siteidx,sidorg,sidcode,gcount,gpidx+1);
3356
3357            }).fail(function(r3_error) {
3358                console.log(r3_error);
3359                pbEndCall(false);
3360            });
3361        }
3362
3363        var pbPagesCall = function(sitelist,siteidx,sidorg,sidcode,bcount,bpidx) {
3364            var sitesid = (sidcode) ? sidorg+'__'+sidcode : sidorg;
3365
3366            var pbPages_r = pbPages(sitesid,onoff,bcount,bpidx,sitelist.length,siteidx);
3367            pbPages_r.done(function(r4) {
3368                $('.progress-bar').css('width',r4.w+'%');
3369
3370                if(r4.done == true) {
3371                    if(sitelist.length == (siteidx+1)) pbEndCall(true);
3372                    else pbSiteCall(sitelist,siteidx+1);
3373                } else {
3374                    pbPagesCall(sitelist,siteidx,sidorg,sidcode,bcount,bpidx+1);
3375                }
3376
3377            }).fail(function(r4_error) {
3378                console.log(r4_error);
3379                pbEndCall(false);
3380            });
3381        }
3382
3383        var pbEndCall = function(isCompleted) {
3384            $('.progress-bar').css('width','100%');
3385        
3386            if(!isCompleted) {
3387                $.progressOFF();
3388                return false;
3389            }
3390
3391            if(typeof endCallback == 'function') {
3392                endCallback(sid,onoff);
3393            }
3394        }
3395
3396        var sites_r = sites(sid);
3397        sites_r.done(function(r1) {
3398            $.progressON('',$.lang[LANG]['editor.publish.step1'],0,true);
3399            pbSiteCall(r1.lists,0);
3400        }).fail(function(r1_error) {
3401            console.log(r1_error);
3402            pbEndCall(false);
3403        });
3404    }
3405
3406    $.fn.sitePublishByConfig = function(sid) {
3407        var $publishTarget = $(this);
3408        var isConfigPbs = (typeof CONFIG_PBS != 'undefined' && CONFIG_PBS) ? true : false;
3409        var publishDomain = (typeof PUBDOMAIN != 'undefined' && PUBDOMAIN) ? PUBDOMAIN : ((typeof DOMAIN != 'undefined' && DOMAIN) ? DOMAIN : $('#pubhost a').attr('href'));
3410
3411        if (isConfigPbs) {
3412            $publishTarget.sitePublishVer02(sid);
3413        } else {
3414            $publishTarget.sitePublishVer01(sid, 1, function() {
3415                setTimeout(function() {
3416                    if (typeof SLANG != 'undefined' && typeof SLANG.select_code != 'undefined' && SLANG.select_code) {
3417                        changeLanguage(SLANG.select_code, 'sync_publish');
3418                    }
3419
3420                    $.progressOFF();
3421                    $.processON();
3422                    $('.processModal p').text('');
3423                    $('.processModal p').css({
3424                        'width': '385px',
3425                        'height': '215px',
3426                        'top': '0',
3427                        'margin': 'auto',
3428                        'background': 'none',
3429                    });
3430
3431                    if ($('.processModal').length == 1) {
3432                        if (typeof CONFIG_PBS != 'undefined') CONFIG_PBS = true;
3433
3434                        $.processOFF();
3435                        var modal = $publishTarget.showModalFlat($.lang[LANG]['editor.publish.priview.title'], $.lang[LANG]['editor.publish.priview'], true, false, function() {
3436                            if (publishDomain) window.open(publishDomain, '_blank');
3437                            modal.modal('hide');
3438                        }, 'ok', '', 'cl-p130 cl-cmmodal cl-s-btn w560 cl-p0 cl-okbtn-pbt70 cl-publish-complete', '', '', function() {
3439                            $('.cl-publish-complete .ok-button-dialog, .cl-publish-complete .close').on('click', function() {
3440                                $.processOFF();
3441                            });
3442                        });
3443                    }
3444                }, 1000);
3445            });
3446        }
3447    }
3448
3449    $.fn.sitePublishVer02 = function(sid) {
3450
3451        $.progressON($.lang[LANG]['editor.publish.step.start'],'',0,true);
3452
3453        $.sp = {
3454            step: 0,
3455
3456            site_list: {},
3457            site_total: 0,
3458            site_idx: 0,
3459            site_per: 100,
3460
3461            sid: sid,
3462            sid_code: '',
3463            org_sid: sid,
3464
3465            step_k: {'d':3, 'i':2, 'u':1},
3466            step_total: [0,0,0,0],
3467            step_success: [0,0,0,0],
3468
3469            change_total: 0,
3470            change_success: 0,
3471            change_list: {},
3472
3473            per: 0,
3474            error_msg: $.lang[LANG]['editor.publish.step.error'],
3475            end: function(isError) {
3476                if(typeof isError == 'undefined') isError = false;
3477
3478                if(isError) {
3479                    $.progressOFF();
3480                    $(this).showModalFlat('ERROR',$.sp.error_msg, true, false, '', 'ok', '', 'cl-p130 cl-cmmodal cl-s-btn w560 cl-p0 cl-okbtn-pbt70');
3481                } else {
3482
3483                    var isNext = (typeof $.sp.site_list[$.sp.site_idx+1] != 'undefined' && $.sp.site_idx+1 <= $.sp.site_total) ? true : false;
3484                    if(isNext) {
3485                        setTimeout(function() {
3486                            $.progressON('',$.lang[LANG]['editor.publish.step.restart']);
3487                            $('.progress-bar').css('width','0%');
3488                            $.sp.site_idx++;
3489                            setTimeout(function() {
3490                                $.sp.step1();
3491                            },1500);
3492                        },1500);
3493                    } else {
3494
3495                        $('.progress-bar').css('width','70%');
3496                        setTimeout(function() {
3497                            $('.progress-bar').css('width','100%');
3498
3499                            if(typeof SLANG != 'undefined' && typeof SLANG.select_code != 'undefined' && SLANG.select_code) {
3500                                changeLanguage(SLANG.select_code,'sync_publish');
3501                            }
3502
3503                            $.progressOFF();
3504                            $.processON();
3505
3506                            var time = $.now();
3507                            $('.processModal p').text('');
3508                            $('.processModal p').css({
3509                                'width' : '385px',
3510                                'height' : '215px',
3511                                'top' : '0',
3512                                'margin' : 'auto',
3513                                'background' : 'none',
3514                            });
3515
3516                            if($('.processModal').length ==1) {
3517                                $.processOFF();
3518                                var modal = $(this).showModalFlat($.lang[LANG]['editor.publish.priview.title'],$.lang[LANG]['editor.publish.priview'],  true, false ,function(){
3519                                        window.open(DOMAIN, '_blank');
3520                                        modal.modal('hide');
3521                                    },'ok', '', 'cl-p130 cl-cmmodal cl-s-btn w560 cl-p0 cl-okbtn-pbt70 cl-publish-complete','','',function(){
3522                                        $('.cl-publish-complete .ok-button-dialog, .cl-publish-complete .close').on('click',function(){
3523                                        $.processOFF();
3524                                    });
3525                                }); 
3526                            }
3527                        }, 500);
3528
3529                    }
3530
3531                }
3532
3533            },
3534            step0: function(sid) {
3535                $.sp.step = 0;
3536
3537                var sp0_deferred = $.Deferred();
3538                if(typeof sid == 'undefined') sp0_deferred.reject('sid Undefined :(');
3539                else {
3540                    $.ajax({
3541                        url : '/template/publishSites',
3542                        data : { sid : sid },
3543                        type : 'POST',
3544                        dataType : 'json',
3545                        async : true,
3546                        cashe : false,
3547                        success : function(data) {
3548                            if(typeof data.error != 'undefined' && data.error) {
3549                                sp0_deferred.reject(data.error);
3550                                return false;
3551                            }
3552
3553                            $.sp.site_list = data.lists;
3554                            $.sp.site_total = data.lists.length;
3555                            $.sp.site_idx = 0;
3556                            $.sp.site_per = Math.ceil(100 / $.sp.site_total);
3557
3558                            $.progressON('',$.lang[LANG]['editor.publish.step.0'],0,true);
3559                            $('.progress-bar').css('width','5%');
3560
3561                            sp0_deferred.resolve();
3562                        }
3563                    });
3564                }
3565                return sp0_deferred.promise();
3566            },
3567            step1: function() {
3568                $.sp.step = 1;
3569
3570                $.sp.org_sid = $.sp.site_list[$.sp.site_idx]['sid'];
3571                $.sp.sid_code = $.sp.site_list[$.sp.site_idx]['code'];
3572                $.sp.sid = ($.sp.sid_code) ? $.sp.org_sid+'__'+$.sp.sid_code : $.sp.org_sid;
3573
3574                if($.sp.site_idx > 0) {
3575                    $.progressON('', $.sp.org_sid + (($.sp.sid_code) ? $.lang[LANG]['editor.publish.step.0.p'] + ' (' + $.sp.sid_code + ')' : '') + $.lang[LANG]['editor.publish.step.0.n'],0,true);
3576                    $('.progress-bar').css('width','5%');
3577                }
3578                var sp1_1 = $.sp.step1_1();
3579                sp1_1.done(function(r1_1) {
3580                    if(r1_1 > 0) $.sp.step2('d',0);
3581                    else $.sp.end();
3582                }).fail(function(r1_1_error) {
3583                    console.log('r1_1_error: '+r1_1_error);
3584                    $.sp.end(true);
3585                });
3586            },
3587            step1_1: function() {
3588                // sites[idx] - pf_site → pb_site (UPDATE or INSERT)
3589                // sites[idx] - pf_site.activate, pb_site.activate = 1 or 9 (UPDATE)
3590                // return pf_publish total list
3591                var sp1_1_deferred = $.Deferred();
3592                $.progressON('', $.sp.org_sid + (($.sp.sid_code) ? $.lang[LANG]['editor.publish.step.1.p'] + ' (' + $.sp.sid_code + ')' : '') + $.lang[LANG]['editor.publish.step.1.n'],0,true);
3593
3594                $.ajax({
3595                    url : '/template/sitepublish1',
3596                    data : { sid : $.sp.sid, onoff : 1 },
3597                    type : 'POST',
3598                    dataType : 'json',
3599                    async : true,
3600                    cashe : false,
3601                    success : function(data1) {
3602                        $('.progress-bar').css('width','20%');
3603
3604                        $.sp.step_total = [0,0,0,0];
3605                        $.sp.step_success = [0,0,0,0];
3606
3607                        $.sp.change_total = data1.total;
3608                        $.sp.change_success = 0;
3609                        $.sp.change_list = {};
3610                        $.sp.per = Math.ceil(70 / data1.total);
3611
3612                        sp1_1_deferred.resolve(data1.total);
3613                    }
3614                });
3615
3616                return sp1_1_deferred.promise();
3617            },
3618            step2: function(step,start) {
3619                // d->i->u
3620
3621                var sp2_1 = $.sp.step2_1(step,start);
3622                sp2_1.done(function(r2_1) {
3623                    if(r2_1 > 0) $.sp.step2(step,r2_1);
3624                    else {
3625                        if(step == 'd') $.sp.step2('i',0);
3626                        else if(step == 'i') $.sp.step2('u',0);
3627                        else if(step == 'u') $.sp.step3();
3628                        else $.sp.end();
3629                    }
3630                }).fail(function(r2_1_error) {
3631                    console.log('r2_1_error: '+r2_1_error);
3632                    $.sp.end(true);
3633                });
3634            },
3635            step2_1: function(this_step,this_start) {
3636                // sites[idx] - pf_publish.pbs_val == pb_page.seq (DELETE | INSERT | UPDATE)
3637                // sites[idx] - pf_publish.pbs_val == pb_gallery.seq (DELETE | INSERT | UPDATE)
3638                // return pb_page.seq, pb_gallery.seq list + (200개씩 처리) more?
3639                        // $list = array('b'=>array(), 'g'=>array(), 'next_start'=>$start+$limit);
3640                        // json_result(array('result' => 'done pf_publish delete', 'list' => $list, 'total' => $total));
3641                var sp2_1_deferred = $.Deferred();
3642                $.progressON('', $.sp.org_sid + (($.sp.site_code) ? $.lang[LANG]['editor.publish.step.2.p'] + ' (' + $.sp.site_code + ')' : '') + $.lang[LANG]['editor.publish.step.2.n'],0,true);
3643
3644                $.ajax({
3645                    url : '/template/sitepublish2/'+this_step,
3646                    data : { sid : $.sp.sid, start: this_start },
3647                    type : 'POST',
3648                    dataType : 'json',
3649                    async : true,
3650                    cashe : false,
3651                    success : function(data2) {
3652                        var this_step_k = $.sp.step_k[this_step];
3653                        if(this_start > 0) {
3654                            $.sp.change_list[this_step].b = $.sp.change_list[this_step].b.concat(data2.list.b);
3655                            $.sp.change_list[this_step].g = $.sp.change_list[this_step].g.concat(data2.list.g);
3656                        } else {
3657                            $.sp.step_total[this_step_k] = data2.total;
3658                            $.sp.change_list[this_step] = data2.list;
3659                        }
3660
3661                        var this_success = data2.list.b.length + data2.list.g.length;
3662                        $.sp.step_success[this_step_k] = $.sp.step_success[this_step_k] + this_success;
3663                        $.sp.change_success = $.sp.change_success + this_success;
3664
3665                        var next_start = ($.sp.step_success[this_step_k] < data2.total) ? data2.list.next_start : 0,
3666                            bar_w = 20 + ($.sp.per * $.sp.change_success);
3667                        $('.progress-bar').css('width',bar_w+'%');
3668
3669                        sp2_1_deferred.resolve(next_start);
3670                    }
3671                });
3672                return sp2_1_deferred.promise();
3673            },
3674            step3: function() {
3675                $('.progress-bar').css('width','95%');
3676
3677                var sp3_1 = $.sp.step3_1();
3678                sp3_1.done(function() {
3679                    $.sp.end();
3680                }).fail(function(r3_1_error) {
3681                    console.log('r3_1_error: '+r3_1_error);
3682                    $.sp.end(true);
3683                });
3684            },
3685            step3_1: function() {
3686                // sites[idx] - pf_publish.sid == SID (DELETE)
3687                var sp3_1_deferred = $.Deferred();
3688                $.progressON('', $.sp.org_sid + (($.sp.site_code) ? $.lang[LANG]['editor.publish.step.3.p'] + ' (' + $.sp.site_code + ')' : '') + $.lang[LANG]['editor.publish.step.3.n'],0,true);
3689
3690                $.ajax({
3691                    url : '/template/sitepublish3/',
3692                    data : { sid : $.sp.sid },
3693                    type : 'POST',
3694                    dataType : 'json',
3695                    async : true,
3696                    cashe : false,
3697                    success : function(data3) {
3698                        $('.progress-bar').css('width','100%');
3699                        sp3_1_deferred.resolve();
3700                    }
3701                });
3702                return sp3_1_deferred.promise();
3703
3704            }
3705        }
3706
3707        var sp0 = $.sp.step0(sid);
3708        sp0.done(function() {
3709            $.sp.step1();
3710        }).fail(function(r0_error) {
3711            console.log('r0_error: '+r0_error);
3712            $.sp.end();
3713        });
3714    }
3715
3716    $.fn.publishGallery = function(sid) {
3717        $.progressON($.lang[LANG]['editor.publish.step.start'],'',0,true);
3718        $.sp =  {
3719            domain: (typeof MODE != 'undefined' && MODE == 'config')? DOMAIN : $('#pubhost a').attr('href'),
3720            step1: function() {
3721                var deferred = $.Deferred();
3722
3723                $.ajax({
3724                    url : '/template/publishGallery/step1',
3725                    data : { sid : sid },
3726                    type : 'POST',
3727                    dataType : 'json',
3728                    async : true,
3729                    cashe : false,
3730                    success : function(data1) {
3731                        console.log('data', data1);
3732                        $('.progress-bar').css('width','25%');
3733                        deferred.resolve(data1);
3734                    }
3735                });
3736
3737                return deferred.promise();
3738            },
3739            step2: function() {
3740                var deferred = $.Deferred();
3741
3742                $.ajax({
3743                    url : '/template/publishGallery/step2',
3744                    data : { sid : sid },
3745                    type : 'POST',
3746                    dataType : 'json',
3747                    async : true,
3748                    cashe : false,
3749                    success : function(data2) {
3750                        console.log('data', data2);
3751                        $('.progress-bar').css('width','50%');
3752
3753                        deferred.resolve(data2);
3754                    }
3755                });
3756
3757                return deferred.promise();
3758            },
3759            clear: function() {
3760                var deferred = $.Deferred();
3761
3762                $.ajax({
3763                    url : '/template/publishGallery/clear',
3764                    data : { sid : sid },
3765                    type : 'POST',
3766                    dataType : 'json',
3767                    async : true,
3768                    cashe : false,
3769                    success : function(data3) {
3770                        console.log('data', data3);
3771                        $('.progress-bar').css('width','75%');
3772                        deferred.resolve(data3);
3773                    }
3774                });
3775
3776                return deferred.promise();
3777            },
3778            end: function(isError) {
3779                if(typeof isError == 'undefined') isError = false;
3780                if(isError) {
3781                    $.progressOFF();
3782                    $(this).showModalFlat('ERROR','error', true, false, '', 'ok', '', 'cl-p130 cl-cmmodal cl-s-btn w560 cl-p0 cl-okbtn-pbt70');
3783                } else {
3784                    $('.progress-bar').css('width','100%');
3785                    setTimeout(function() {
3786                        $.progressOFF();
3787                        $.processON();
3788                        if($('.processModal').length ==1) {
3789                            $.processOFF();
3790                            var modal = $(this).showModalFlat($.lang[LANG]['editor.publish.priview.title'],$.lang[LANG]['editor.publish.priview'],  true, false ,function(){
3791                                    window.open($.sp.domain, '_blank');
3792                                    modal.modal('hide');
3793                                },'ok', '', 'cl-p130 cl-cmmodal cl-s-btn w560 cl-p0 cl-okbtn-pbt70 cl-publish-complete','','',function(){
3794                                    $('.cl-publish-complete .ok-button-dialog, .cl-publish-complete .close').on('click',function(){
3795                                    $.processOFF();
3796                                });
3797                            }); 
3798                        }
3799                    }, 500);
3800                }
3801            }
3802        }
3803
3804        $.sp.step1().then(function (res1) {
3805            return $.sp.step2(res1);
3806        })
3807        .then(function (res2) {
3808            return $.sp.clear(res2);
3809        })
3810        .done(function () {
3811            return $.sp.end();
3812        })
3813        .fail(function (err) {
3814            return $.sp.end(err);
3815        });
3816    }
3817
3818    $.musicON = function(play) {
3819        play = (typeof play == 'undefined') ? true : play;
3820        var tpl = '\
3821            <div id="cl-music-player" class="cl-mplayer"></div>\
3822            <div id="cl-music-container" class="jp-audio" role="application" aria-label="media player">\
3823                <div class="jp-type-playlist">\
3824                    <div class="jp-gui jp-interface">\
3825                        <div class="jp-controls-holder">\
3826                            <div class="jp-controls">\
3827                                <div class="music-player-controls">\
3828                                    <span class="jp-backward" role="button" tabindex="0"><i class="fa fa-backward" aria-hidden="true"></i></span>\
3829                                    <span class="jp-play" role="button" tabindex="0"><i class="fa fa-pause" aria-hidden="true"></i></span>\
3830                                    <span class="jp-forward" role="button" tabindex="0"><i class="fa fa-forward" aria-hidden="true"></i></span>\
3831                                </div>\
3832                                <div class="music-player-progress">\
3833                                    <div class="jp-progress">\
3834                                        <div class="jp-seek-bar">\
3835                                            <div class="jp-play-bar"></div>\
3836                                        </div>\
3837                                    </div>\
3838                                </div>\
3839                                <div class="jp-lists">\
3840                                    <span class="music-lists" role="button" tabindex="0">LIST</span>\
3841                                </div>\
3842                                <div class="music-playlist-wrap">\
3843                                    <div class="jp-playlist"><ul class="music-playlist"><li></li></li></div>\
3844                                </div>\
3845                            </div>\
3846                        </div>\
3847                    </div>\
3848                    <div class="jp-no-solution">\
3849                        <span>Update Required</span>\
3850                        To play the media you will need to either update your browser to a recent version or update your <a href="http://get.adobe.com/flashplayer/" target="_blank">Flash plugin</a>.\
3851                    </div>\
3852                </div>\
3853            </div>\
3854            ',
3855            equalizer_img = ($('body').width() < 769) ? 'https://storage.googleapis.com/i.addblock.net/equal_stop.gif' : 'https://storage.googleapis.com/i.addblock.net/equal.gif',
3856            checkFree = (!property.VALIDPLAN || property.VALIDTYPE == 'PK') ? true : false,
3857            move_position = (checkFree) ? 'class="moved"' : '',
3858            vpModeOnoff = (property.SETTINGS.vpMode_onoff === true) ? true : false,
3859            vpOption = (property.SETTINGS.viewportMode) ? property.SETTINGS.viewportMode : '',
3860            WebType = $.mpcWeb.mpcCheckWebType(),
3861            checkFnav = ($('.fnav').length > 0 && vpOption=='mobile_web') ? true : false,
3862            $music_icon = $('<div id="cl-music-player-icon" '+move_position+'><img src="' + equalizer_img + '" class="hand"></div>');
3863
3864        $('#goto-top').after($music_icon);
3865        $('#cl-music-player-icon').after(tpl);
3866        if($('.fnav').length > 0) {
3867            if(window.innerWidth <= 480) {
3868                $('#goto-top').addClass('movedOne');
3869                $music_icon.addClass('movedOne');
3870            }
3871        } else if($(`.quickmenu.non_config`).length > 0) {
3872            quickMenuMusicPosition(property);
3873        }
3874
3875        if(vpModeOnoff && WebType == 'MOBILE') $.mpcWeb.mpcMusicandGoTop(checkFnav,vpOption);
3876
3877        ($('body').width() < 769) ? $('.jp-play i').removeClass('fa-pause').addClass('fa-play').parent().addClass('pause') : '';
3878        var music = (typeof property == 'undefined') ? [] : property.MUSIC;
3879
3880        if(music.length==0) {
3881            $music_icon.addClass('hide');
3882            $music_icon.removeClass('movedOne');
3883            $('#goto-top').removeClass('movedOne');
3884        }
3885        var myPlaylist = new jPlayerPlaylist({
3886            jPlayer: '#cl-music-player',
3887                cssSelectorAncestor: '#cl-music-container'
3888            }, music, {
3889            playlistOptions: {
3890                loop: true,
3891                autoPlay: play,
3892                loopOnPrevious: true,
3893                enableRemoveControls: false
3894            },
3895            ready: function() {
3896                if (!window._musicUserInteracted) {
3897                    $(this).jPlayer('option', 'muted', true);
3898                    $(document).one('click scroll touchstart keydown', function() {
3899                        $('#cl-music-player').jPlayer('option', 'muted', false);
3900                    });
3901                }
3902            },
3903            ended: function() { 
3904                // var $item = $('.music-playlist li'),
3905                //     idx = $item.parent().find('.active').index(),
3906                //     active = (idx+1 > $item.length) ? 0 : idx+1;
3907
3908                // $item.removeClass('active');
3909                // $item.eq(active).addClass('active');
3910            },            
3911            swfPath: '/js',
3912            solution: 'html, flash',
3913            supplied: 'mp3',
3914            preload: 'metadata',
3915            volume: 1,
3916            loop: true,
3917            muted: false,
3918            backgroundColor: '#000000',
3919
3920            smoothPlayBar: true,
3921            keyEnabled: false,
3922            audioFullScreen: false // Allows the audio poster to go full screen via keyboard
3923        });
3924
3925        $music_icon.click(function() {
3926            $(this).toggleClass('show');
3927            if($(this).hasClass('show')) {
3928                $('#cl-music-container').css('display','block');
3929            } else {
3930                $('#cl-music-container').css('display','none');
3931            }
3932        });
3933
3934        var $play = $('.jp-play'),
3935            $next = $('.jp-forward'),
3936            $prev = $('.jp-backward'),
3937            $list = $('.music-lists'),
3938            $playlist_wrap = $('.music-playlist-wrap'),
3939            $playlist = $('.music-playlist'),
3940            $item = $('.music-playlist li');
3941
3942        $playlist.empty();
3943        if(myPlaylist.playlist.length) {
3944            var index = myPlaylist.current;
3945            $.each(myPlaylist.playlist, function(i,v) {
3946                var active = (i == index) ? 'jp-playlist-current' : '',
3947                    item = '<li class="' + active + '" data-music-index="' + i + '"><span class="hand">' + v.title + '</span></li>';
3948                $playlist.append(item);
3949            });
3950        }
3951
3952        $list.click(function() {
3953            $playlist_wrap.toggle();
3954            if($playlist_wrap.css('display') == 'block') {
3955                $list.text('CLOSE');
3956            } else {
3957                $list.text('LIST');
3958            }
3959        });
3960
3961        $('body').on( 'click', '.music-playlist li a', function(e) {
3962            var $pause_icon = '<i class="fa fa-pause"></i>';
3963                $equalizer = $("#cl-music-player-icon"),
3964                src = 'https://storage.googleapis.com/i.addblock.net/equalizer.gif',
3965            $equalizer.find('img').attr('src',src);
3966            $('.jp-play').removeClass('pause');
3967            $('.jp-play').html($pause_icon);
3968        });
3969
3970        $('.music-playlist li span').click(function() {
3971            var idx = $(this).parent().attr('data-music-index');
3972            if(typeof idx == 'undefined') return;
3973            myPlaylist.play(idx);
3974            myPlaylist.current = idx;
3975            $('.music-playlist li').removeClass('jp-playlist-current');
3976            $('.music-playlist li').eq(idx).addClass('jp-playlist-current');
3977            // $.musicPlay();
3978        });
3979
3980        $play.click(function() {
3981            if($(this).hasClass('pause')) {
3982                $.musicPlay();
3983            } else {
3984                $.musicPause();
3985            }
3986        });
3987        $next.click(function() {
3988            $.musicNext(myPlaylist);
3989
3990        });
3991        $prev.click(function() {
3992            $.musicPrev(myPlaylist);
3993        })
3994
3995        document.onkeydown = function(evt) {
3996            evt = evt || window.event;
3997            if (evt.keyCode == 27) {
3998                $.musicPause();
3999            }
4000        };
4001        // myPlaylist.play();
4002        // $('#cl-music-player').jPlayer('play');
4003    }
4004    $.musicPause = function() {
4005        var $play_icon = '<i class="fa fa-play"></i>',
4006            $equalizer = $('#cl-music-player-icon'),
4007            src = 'https://storage.googleapis.com/i.addblock.net/equal_stop.gif';
4008        $equalizer.find('img').attr('src',src);
4009        $('.jp-play').addClass('pause');
4010        $('.jp-play').html($play_icon);
4011        $('#cl-music-player').jPlayer('pause');
4012    }
4013    $.musicPlay = function() {
4014        var $pause_icon = "<i class='fa fa-pause'></i>";
4015            $equalizer = $('#cl-music-player-icon'),
4016            src = 'https://storage.googleapis.com/i.addblock.net/equalizer.gif',
4017        $equalizer.find('img').attr('src',src);
4018        $('.jp-play').removeClass('pause');
4019        $('.jp-play').html($pause_icon);
4020        $('#cl-music-player').jPlayer('play');
4021    }
4022    $.musicStop = function() {
4023        $('#cl-music-player').jPlayer('stop');
4024    }
4025    $.musicRepeat = function() {
4026    }
4027    $.musicOFF = function() {
4028    }
4029    $.musicNext = function(player) {
4030        player.next();
4031        var index = player.current;
4032        $.musicPlay();
4033    }
4034    $.musicPrev = function(player) {
4035        player.previous();
4036        var index = player.current;
4037        $.musicPlay();
4038    }
4039
4040
4041    $.fnav = {
4042        getFnav: function() {
4043            var data = (PAGE_MODE == 'c') ? SETTINGS.fnav : property.SETTINGS.fnav;
4044            if(typeof data == 'undefined' || $.isEmptyObject(data)) data = new Array();
4045            
4046            return data;
4047        },
4048        getFnavColor: function(target) {
4049            var color = '';
4050            if(target == 'font') {
4051                color = (PAGE_MODE == 'c') ? SETTINGS.fnavFcolor : property.SETTINGS.fnavFcolor;
4052            } else if(target == 'bg') {
4053                color = (PAGE_MODE == 'c') ? SETTINGS.fnavBg : property.SETTINGS.fnavBg;
4054                var hexRegex = /^([0-9a-fA-F]{3}|[0-9a-fA-F]{4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/;
4055                if(hexRegex.test(color)) color = '#'+color;
4056            }
4057
4058            if(typeof color == 'undefined' || !color) return (target == 'font') ? '#ffffff' : '#000000';
4059            else return color;
4060        },
4061        checkFnavON: function(data) {
4062            var result = false,
4063                fnav_data = (typeof data != 'undefined') ? data : $.fnav.getFnav();
4064
4065            $.each(fnav_data, function(i,obj) {
4066                if(obj['display'] == 'on') result = true;
4067            });
4068
4069            return result;
4070        },
4071        draw: function(data) {
4072            var fnav_data = (typeof data != 'undefined') ? data : $.fnav.getFnav(),
4073                hasON = $.fnav.checkFnavON(fnav_data);
4074
4075            if (window.location.href.indexOf('_checkout') != -1) hasON = false;
4076
4077            if(!hasON) {
4078                $('.fnav.fnav-mobile-fnav').remove();
4079            } else {
4080                var fnav_html = $.fnav.listHTML(fnav_data,hasON);
4081                if(fnav_html.length > 0) {
4082                    if($('.dsgn-body').find('.fnav.fnav-mobile-fnav').length > 0) $('.dsgn-body .fnav.fnav-mobile-fnav').replaceWith(fnav_html);
4083                    else $('.dsgn-body').find('.el-footer').before(fnav_html);
4084                } else {
4085                    $('.dsgn-body').find('.fnav.fnav-mobile-fnav').remove();
4086                }
4087            }
4088        },
4089        listHTML: function(fnav_data,hasON) {
4090            if(typeof fnav_data == 'undefined') fnav_data = $.fnav.getFnav();
4091            if(typeof hasON == 'undefined') hasON = $.fnav.checkFnavON(fnav_data);
4092
4093            var fnav_fcolor = $.fnav.getFnavColor('font'),
4094                fnav_bg = $.fnav.getFnavColor('bg'),
4095                str = '';
4096                
4097            if(hasON) {
4098                $.each(fnav_data, function(i,v) {
4099                    str += $.fnav.itemHTML(v.idx, v.name, v.type, v.value, v.target, v.icon, v.display); 
4100                });
4101            }
4102
4103            return '\
4104                            <div class="fnav fnav-mobile-fnav" style="--fnav-bgcolor: '+fnav_bg+'; --fnav-color: '+fnav_fcolor+'; ">\
4105                            ' + str + '\
4106                            </div>\
4107            ';
4108        },
4109        itemHTML: function(idx,name,type,value,target,icon,display) {
4110            var href = '#', 
4111                attr_target = (type == "tel") ? ' target=""' : ' target="' + target + '"',
4112                attr_link = '';
4113
4114            if(icon == 'empty') icon = '';
4115
4116            if(value) {
4117                if(type == "tel") {
4118                    href = (value.match(/^tel:/)) ? value : 'tel:' + value;
4119                } else { //link
4120                    if(checkBase64Encode(decodeURIComponent(value))) value = Base64.decode(decodeURIComponent(value));
4121                    else value = (checkBase64Encode(value)) ? Base64.decode(value) : value;
4122                    
4123                    var menulist = (PAGE_MODE == 'c') ? MENULIST : property.MENULIST,
4124                        one = (PAGE_MODE == 'c') ? ONE : property.ONE,
4125                        view = (PAGE_MODE == 'c') ? VIEW : property.VIEW;
4126
4127                    href = makeLinkUrl(value,one,view);
4128                    if($.inArray(normalizeModalMenuLinkPage(value), menulist) > -1) {
4129                        attr_link = 'data-user-link="' + href + '"';
4130                    } else if(value.match(/^\@/g)) {
4131                        attr_link = 'attr-bookmark="' + value.replace(/^\@/g,'') + '"';
4132                    } else {
4133                        var link = encodeURIComponent(Base64.encode(value));
4134                        attr_link = 'attr-link="' + link + '"';
4135                    }
4136                }
4137
4138            }
4139
4140            if(display != 'on') return '';
4141            else return '\
4142                                <div class="fnav-item" data-idx="' + idx + '" data-type="' + type + '">\
4143                                    <a href="' + href + '" ' + attr_target + ' ' + attr_link + '>\
4144                                        <i class="' + icon + '" aria-hidden="true"></i>\
4145                                        <span class="fnav-name">' + name + '</span>\
4146                                    </a>\
4147                                </div>\
4148            ';
4149        },
4150
4151    }
4152
4153    $.mpcWeb = {
4154        init: function(vpOption,contents,WebType,zoom,pagemove) {   
4155            var device_w = (vpOption=='mobile_pc') ? 1440 : 'device-width',
4156                scale = (vpOption=='mobile_pc') ? (window.screen.width / 1440) : 1.0,
4157                zoom = (zoom) ? '' : ', maximum-scale=1, user-scalable=no',
4158                mpc_icon = (vpOption == 'mobile_pc') ? '<i class="fa fa-mobile mpc_icon" aria-hidden="true"></i>' : '<i class="fa fa-desktop mpc_icon" aria-hidden="true"></i>',
4159                checkFnav = ($('.fnav').length > 0 && vpOption=="mobile_web") ? true : false;
4160
4161            //$.mpcWeb.mpcWebShowcase(vpOption,contents,pagemove);
4162
4163            $('.dsgn-body .mobilepc_ch .mpc_icon').remove();
4164            $('.dsgn-body .mobilepc_ch').prepend(mpc_icon);
4165            document.documentElement.setAttribute('data-mpc-vpmode',vpOption);
4166            
4167            var viewport = document.querySelector('meta[name="viewport"]');
4168            if(viewport) viewport.setAttribute('content','width='+device_w+', initial-scale='+scale+''+zoom+'');
4169            setTimeout(function() {
4170                if(typeof Event == 'function') window.dispatchEvent(new Event('resize'));
4171                else {
4172                    var resizeEvent = document.createEvent('Event');
4173                    resizeEvent.initEvent('resize',true,true);
4174                    window.dispatchEvent(resizeEvent);
4175                }
4176
4177                if(typeof $.clnav != 'undefined'
4178                    && typeof $.clnav.check == 'function'
4179                    && $.clnav.check()
4180                ) {
4181                    if(typeof $.clnav.refreshMobileStyle == 'function') $.clnav.refreshMobileStyle();
4182                    else if(typeof $.clnav.setMobileStyle == 'function') {
4183                        var $header = $('.cl-nav').first();
4184                        if($header.length) $.clnav.setMobileStyle($header);
4185                        if(typeof $.clnav.setRootcss == 'function') $.clnav.setRootcss();
4186                    }
4187                }
4188            }, 80);
4189
4190            /*if($('.dsgn-body').hasClass('sidebar')) {
4191                $('.dsgn-body').removeClass('sidebar').addClass('removed-sidebar');
4192            } else if ($('.dsgn-body').hasClass('removed-sidebar')) {
4193                $('.dsgn-body').removeClass('removed-sidebar').addClass('sidebar');                
4194            }*/
4195
4196            $.mpcWeb.mpcMusicandGoTop(checkFnav,vpOption);     
4197
4198            if(checkFnav && WebType == 'MOBILE') {
4199                $('.fnav.fnav-mobile-fnav').css('margin-bottom','53px');
4200                $('.element.el-footer').css('margin-bottom','100px');
4201            } else {
4202                $('.mobilepc_ch').css('margin-bottom','0px');
4203                $('.element.el-footer').css('margin-bottom','0px');
4204            }
4205        },
4206
4207
4208        mpcWebhtml: function(vpOption,contents,zoom,pagemove,sid) {
4209            //if (window.location.href.indexOf('_checkout') != -1) return false;
4210            sid = (sid) ? sid : (typeof property != 'undefined' ? property.SID : SID);
4211            pagemove = ((typeof pagemove == 'undefined') || !pagemove) ? '' : pagemove;
4212            
4213            $.mpcWeb.mpcCookie(vpOption,sid);
4214
4215            if($.cookie('vpmode')) {
4216                vpOption = $.cookie('vpmode');
4217            }
4218            
4219            var vpChangeText = (vpOption=="mobile_pc") ? $.lang[LANG]['editor.mobile.changePc.mobileWeb'] : $.lang[LANG]['editor.mobile.changePc.mobilePc'],    
4220                mpc_html = "\
4221                <div class='mobilepc_ch' data-desktop-option='"+vpOption+"'>\
4222                    <p class='hand'>\
4223                        <span class='mpc-name'>" + vpChangeText + "</span>\
4224                    </p>\
4225                </div>\
4226            ",
4227                WebType = $.mpcWeb.mpcCheckWebType();
4228
4229            if(WebType == 'MOBILE') {
4230                if(window.location.href.indexOf('_checkout') == -1) {
4231                    $('.dsgn-body').find('.mobilepc_ch').remove();
4232                    $('.dsgn-body').append(mpc_html);
4233                }                
4234                $.mpcWeb.init(vpOption,contents,WebType,zoom,pagemove);
4235                $.mpcWeb.mpcChangeVal(vpOption,contents,WebType,zoom,pagemove,sid);
4236            }
4237        },   
4238
4239        mpcWebShowcase : function(vpOption,contents,pagemove) {
4240            $.each(contents,function(i,v) {
4241                var v_el = (pagemove=='pagemove') ? v : v.element;
4242                if((vpOption == "mobile_pc") && (v_el.type == 'showcase')) $("."+v_el.elname).addClass('mobilePc_he
4242ight');
4243                else $("."+v_el.elname).removeClass('mobilePc_height');
4244            });
4245            
4246        },
4247
4248        mpcChangeVal : function(vpOption,contents,WebType,zoom,pagemove,sid) {
4249            //if (window.location.href.indexOf('_checkout') != -1) return false;
4250            sid = (sid) ? sid : (typeof property != 'undefined' ? property.SID : SID);
4251            $('.mobilepc_ch').off('click.mpcWeb').on('click.mpcWeb', function() {
4252                vpOption = (vpOption=="mobile_pc") ? 'mobile_web' : 'mobile_pc';
4253                var vpChangeText = (vpOption=="mobile_pc") ? $.lang[LANG]['editor.mobile.changePc.mobileWeb'] : $.lang[LANG]['editor.mobile.changePc.mobilePc'];
4254                
4255                $(this).find('.mpc-name').text(vpChangeText);
4256                $(this).attr('data-desktop-option',vpOption);
4257                document.documentElement.setAttribute('data-mpc-vpmode',vpOption);
4258
4259                $.mpcWeb.init(vpOption,contents,WebType,zoom,pagemove);
4260
4261                if(typeof property != 'undefined') {
4262                    if(property.ONE && !property.VIEW || property.PAGE == property.MENULINK[0] && !property.VIEW) setSitePopup();
4263
4264                    setTimeout(() => {
4265                        if(typeof property.SETTINGS.qm_onoff != 'undefined' && property.SETTINGS.qm_onoff==true) {
4266                            var device_type = (vpOption=='mobile_pc') ? 'pc' : 'mobile',
4267                                mpc_height = $('.mobilepc_ch').innerHeight();
4268                                            
4269                            $.quickmenu.setHTML($.quickmenu['quickmenu'], device_type);
4270                            mobileWebQuickmenuPosition(property,device_type);    
4271                            if($('#cl-music-player-icon').length > 0) quickMenuMusicPosition(property);
4272                        }    
4273                    }, 500);
4274                }
4275                if($('.element[data-type="forum"]').length > 0) {
4276                    var icon_notice = '<i class="tpl-forum-list-notice-icon cl-icon notice01" aria-hidden="true"></i>';
4277                    
4278                    $('.element[data-type="forum"] .tpl-forum-list-title .tpl-forum-list-notice-icon').remove();
4279
4280                    $('.element[data-type="forum"]').each(function(idx, v) {
4281                        var $forum = $(v);
4282                        var type = $(v).attr('data-type2');
4283
4284                        if($forum.find('.tpl-forum-list-title[data-option="N"]').length > 0) { //forum notice
4285                            if(vpOption == 'mobile_web' && type == 'thumb') {
4286                                $forum.find('.tpl-forum-list-num.n').each(function(idx, n){
4287                                    var num = $(n).attr('data-fm-num');
4288                                    $(n).html(num);
4289                                });
4290                            } else {
4291                                $forum.find('.tpl-forum-list-num.n').html(icon_notice);
4292                            }
4293
4294                            if($forum.find('.tpl-forum-list-num').hasClass('hidden')) { // field_disabled = num
4295                                 $forum.find('.tpl-forum-list-title[data-option="N"]').prepend(icon_notice);
4296                            } else {
4297                                if(vpOption == 'mobile_web') {
4298                                    $forum.find('.tpl-forum-list-title[data-option="N"]').prepend(icon_notice);
4299                                    if(type == 'normal' && $forum.find('.tpl-forum-list-num').css('display') != 'none') {
4300                                        $forum.find('.tpl-forum-list-title .tpl-forum-list-notice-icon').addClass('hide');
4301                                    }
4302                                } else {
4303                                    $forum.find('.tpl-forum-list-num.n').html(icon_notice);
4304                                }
4305                            }
4306                        }
4307                    });
4308                }
4309                $('.element[data-msny="true"]').each(function() {
4310                    reloadBlockMasonry('refresh',$(this));
4311                });
4312
4313                $.mpcWeb.mpcCookie(vpOption,sid);
4314
4315                if (window.location.href.indexOf('_checkout') != -1) {
4316                    $('.dsgn-body').find('.mobilepc_ch').remove();
4317                }
4318
4319                if($('body').hasClass('openBandBanner')) $.siteBanner.call('band',false,false,true,true)
4320                if($('body').hasClass('openPopupBanner')) $.siteBanner.call('popup',false,false,true,true)
4321
4322                setTimeout(function(){
4323                    $.fheader.position();
4324					setFixedMenuCss(false);
4325				},50);
4326
4327            });
4328        },
4329
4330        mpcCheckWebType : function(){
4331            var filter = "win16|win32|win64|mac|macintel",
4332                WebType = "";
4333
4334            if (navigator.platform) {
4335                if (filter.indexOf(navigator.platform.toLowerCase()) < 0) WebType = "MOBILE";
4336                else WebType = "PC";
4337            }
4338
4339            return WebType;
4340        },
4341
4342        mpcMusicandGoTop : function(checkFnav,vpOption) {
4343            var checkmpc = ($('.mobilepc_ch').length > 0) ? true : false;
4344
4345            if(checkmpc && vpOption == 'mobile_pc') {
4346                if($('#cl-music-player-icon').length > 0) $('#goto-top,#cl-music-player-icon').removeClass('moveMpc movepc movedOne').addClass('moved');
4347                else $('#goto-top,#cl-music-player-icon').removeClass('movedOne moveMpc movepc').addClass('moved');
4348            } else {
4349                if(checkFnav) {
4350                    if($('#cl-music-player-icon').length > 0) {
4351                        $('#goto-top').css('bottom','');  
4352                        $('#goto-top,#cl-music-player-icon').removeClass('movedOne movepc moved').addClass('moveMpc');
4353                    } else $('#goto-top').removeClass('movedOne movepc moved moveMpc').css('bottom','120px');  
4354                } else {
4355                    if($('#cl-music-player-icon').length > 0) $('#goto-top,#cl-music-player-icon').removeClass('moveMpc movepc moved').addClass('movedOne');
4356                    else $('#goto-top,#cl-music-player-icon').removeClass('movedOne movepc moveMpc moved');
4357                }          
4358            }
4359        },
4360        mpcCookie : function(vpOption,sid) {
4361            sid = (sid) ? sid : (typeof property != 'undefined' ? property.SID : SID);
4362            var date = new Date();
4363            date.setTime(date.getTime() + 6*60*60*1000); // 6h
4364
4365            $.cookie('vpmode-'+sid, vpOption, { expires: date, path : '/' });
4366        },
4367        mpcGetVpmode : function(vpmode,settings,sid) {
4368            sid = (sid) ? sid : (typeof property != 'undefined' ? property.SID : SID);
4369            if($.cookie('vpmode-'+sid)) vpmode = $.cookie('vpmode-'+sid);
4370            else vpmode = (typeof $('.mobilepc_ch').attr('data-desktop-option') != 'undefined') ? $('.mobilepc_ch').attr('data-desktop-option') : settings.viewportMode;
4371            
4372            return vpmode;
4373        }
4374    }
4375
4376    /* menu 추가 버튼 설정 **************************************************************/
4377    $.menuFixBtn = {
4378        topSet : function(num,checkmodal,validArray,slang){
4379            var str = '',
4380                searchOn = '',
4381                cartOn = '',
4382                umOn = '',
4383                ssid = (PAGE_MODE == 'c') ? SID : property.SID,
4384                is_templates = checkTemplateSite(ssid),
4385                s_service = (PAGE_MODE == 'c') ? SERVICE : property.SERVICE,
4386                checkGabia = (s_service.indexOf('gabia') > -1) ? true : false,
4387                checkBS = (validArray['validplan'] && (validArray['validtype'] == 'BS' || (checkGabia && (validArray['validtype'] == 'FR')))) ? true : false,
4388                checkBN = (validArray['validplan'] && validArray['validtype'] == 'BN') ? true : false,
4389                checkSM = (validArray['validplan'] && validArray['validtype'] == 'SM') ? true : false,
4390                checkFREE = (!validArray['validplan'] || validArray['validplan'] == 'FR' || validArray['validplan'] == 'PK') ? true : false,
4391                checkElView = ($('.elviewhtml').length>0) ? true : false,
4392                fixBtnSITEUM = (checkElView) ? '' : ((PAGE_MODE=='c') ? SITEUM : property.SITEUM),
4393                checkSITEUM = (!checkElView && ((checkBN && typeof fixBtnSITEUM!='undefined' && Number(fixBtnSITEUM) > 0) || checkSM)) ? true : (checkElView ? true : false),
4394                checkmodal = (typeof checkmodal != 'undefined' && checkmodal) ? true : false,
4395                fixon = (typeof $('.el-menu header.navbar').attr('data-fixon') != 'undefined' && $('.el-menu header.navbar').attr('data-fixon')) ? $('.el-menu header.navbar').attr('data-fixon') : '',
4396                dropdownClass = (PAGE_MODE=='c') ? '' : 'dropdown ',
4397                slang = (typeof langObj != 'undefined' && langObj) ? langObj : ((PAGE_MODE == 'c') ? SLANG : property.SLANG);
4398                // lang_str = LANG;
4399                
4400                if(!checkElView) {
4401                    if(checkBN && !checkSITEUM) return '';
4402                    searchOn = (!checkSM) ? 'style="display:none;"' : '';
4403                    umOn = (checkBS || checkFREE || (checkBN && !checkSITEUM)) ? 'style="display:none;"' : '';   
4404                    cartOn = (checkFREE) ? 'style="display:none;"' : ((checkSM) ? '' : 'style="display:none;"');
4405                    if(fixon && (checkBN || checkSM) && checkSITEUM) {
4406                        searchOn = ((checkSM) && fixon.indexOf('search')>-1) ? '' : 'style="display:none;"';
4407                        cartOn = ((checkSM) && fixon.indexOf('cart')>-1) ? '' : 'style="display:none;"';
4408                        umOn = ((checkBN || checkSM) && fixon.indexOf('um')>-1) ? '' : 'style="display:none;"';
4409                    }
4410                    if(fixon == 'all') {
4411                        searchOn = 'style="display:none;"';
4412                        cartOn = 'style="display:none;"';
4413                        umOn = 'style="display:none;"';
4414                    }
4415                }
4416               
4417                if(checkElView || checkmodal || is_templates) {
4418                    umOn = (checkBS || checkFREE) ? 'style="display:none;"' : '';  
4419                    searchOn = cartOn = (checkSM) ? '' : 'style="display:none;"';
4420                }
4421               
4422                /* 다국어 / 사이트 언어별 lang 체크 ***/
4423                // if((typeof slang != 'undefined' && typeof slang.select_code != 'undefined' && slang.select_code)
4424                //             || (!$.isEmptyObject(slang) && slang.select_code)) {
4425                //     //searchOn = (slang['select_code']=='ko' && checkSM) ? '' : 'style="display:none;"';
4426                //     lang_str = (slang['select_code'].toLowerCase()=='ko') ? 'ko' : lang_str;
4427                // } 
4428
4429            switch(num) {
4430                case "01" : 
4431                    str = '\
4432                        <li class="siteSEARCH cl-fixbtn '+((!searchOn) ? 'cl-visible' : '')+'" '+searchOn+'><a href="#">SEARCH</a></li>\
4433                        <li class="siteUM cl-fixbtn '+dropdownClass+''+((!umOn) ? 'cl-visible' : '')+'" '+umOn+'>\
4434                            <a href="javascript:;" class="cl-login">LOGIN</a>\
4435                            <a href="javascript:;" class="cl-logout dropdown-toggle" style="display:none;">MY PAGE</a>\
4436                        </li>\
4437                        <li class="siteCART cl-fixbtn '+((!cartOn) ? 'cl-visible' : '')+'" '+cartOn+'><a href="#"><span class=\"cart-text\">CART</span><div class=\"cart-active\">5</div></a></li>\
4438                        '; 
4439                    break;
4440                
4441                case "02" : 
4442                    str = '\
4443                        <li class="siteSEARCH cl-fixbtn '+((!searchOn) ? 'cl-visible' : '')+'" '+searchOn+'><a href="#">Search</a></li>\
4444                        <li class="siteUM cl-fixbtn '+dropdownClass+''+((!umOn) ? 'cl-visible' : '')+'" '+umOn+'>\
4445                            <a href="javascript:;" class="cl-login">Login</a>\
4446                            <a href="javascript:;" class="cl-logout dropdown-toggle" style="display:none;">My page</a>\
4447                        </li>\
4448                        <li class="siteCART cl-fixbtn '+((!cartOn) ? 'cl-visible' : '')+'" '+cartOn+'>\
4449                            <a href="#"><span class=\"cart-text\">Basket</span><div class=\"cart-active\">5</div></a>\
4450                        </li>\
4451                        ';
4452                    break;
4453
4454                case "03" : 
4455                    str = '\
4456                        <li class="siteSEARCH cl-fixbtn '+((!searchOn) ? 'cl-visible' : '')+'" '+searchOn+'><a href="#">검색</a></li>\
4457                        <li class="siteUM cl-fixbtn '+dropdownClass+''+((!umOn) ? 'cl-visible' : '')+'" '+umOn+'>\
4458                            <a href="javascript:;" class="cl-login">로그인</a>\
4459                            <a href="javascript:;" class="cl-logout dropdown-toggle" style="display:none;">마이페이지</a>\
4460                        </li>\
4461                        <li class="siteCART cl-fixbtn '+((!cartOn) ? 'cl-visible' : '')+'" '+cartOn+'>\
4462                            <a href="#"><span class=\"cart-text\">장바구니</span>\
4463                                <div class=\"cart-active\"><span class=\"cart-active-txt\">5</span></div>\
4464                            </a>\
4465                        </li>\
4466                        ';
4467                    break;
4468                
4469                case "04" : 
4470                    str = '\
4471                        <li class="siteSEARCH cl-fixbtn '+((!searchOn) ? 'cl-visible' : '')+'" '+searchOn+'><a href="#">'+clSVG('fixbtn_search4',28,28,true)+'</a></li>\
4472                        <li class="siteUM cl-fixbtn '+dropdownClass+''+((!umOn) ? 'cl-visible' : '')+'" '+umOn+'>\
4473                            <a href="javascript:;" class="cl-login">'+clSVG('fixbtn_um_login4',28,28,true)+'</a>\
4474                            <a href="javascript:;" class="cl-logout dropdown-toggle" style="display:none;">'+clSVG('fixbtn_um_mypage4',28,28,true)+'</a>\
4475                        </li>\
4476                        <li class="siteCART cl-fixbtn '+((!cartOn) ? 'cl-visible' : '')+'" '+cartOn+'>\
4477                            <a href="#">'+clSVG('fixbtn_cart4',28,28,true)+'\
4478                                <div class=\"cart-active\"><span class=\"cart-active-txt\">5</span></div>\
4479                            </a>\
4480                        </li>\
4481                        ';
4482                    break;
4483                
4484                case "05" : 
4485                    str = '\
4486                        <li class="siteSEARCH cl-fixbtn '+((!searchOn) ? 'cl-visible' : '')+'" '+searchOn+'><a href="#">'+clSVG('fixbtn_search5',28,28,true)+'</a></li>\
4487                        <li class="siteUM cl-fixbtn '+dropdownClass+''+((!umOn) ? 'cl-visible' : '')+'" '+umOn+'>\
4488                            <a href="javascript:;" class="cl-login">'+clSVG('fixbtn_um_login5',28,28,true)+'</a>\
4489                            <a href="javascript:;" class="cl-logout dropdown-toggle" style="display:none;">'+clSVG('fixbtn_um_mypage5',28,28,true)+'</a>\
4490                        </li>\
4491                        <li class="siteCART cl-fixbtn '+((!cartOn) ? 'cl-visible' : '')+'" '+cartOn+'>\
4492                            <a href="#">'+clSVG('fixbtn_cart5',28,28,true)+'\
4493                                <div class=\"cart-active\"><span class=\"cart-active-txt\">5</span></div>\
4494                            </a>\
4495                        </li>\
4496                        ';
4497                    break;
4498                
4499                case "06" : 
4500                    str = '\
4501                        <li class="siteSEARCH cl-fixbtn '+((!searchOn) ? 'cl-visible' : '')+'" '+searchOn+'><a href="#">'+clSVG('fixbtn_search6',28,28,true)+'</a></li>\
4502                        <li class="siteUM cl-fixbtn '+dropdownClass+''+((!umOn) ? 'cl-visible' : '')+'" '+umOn+'>\
4503                            <a href="javascript:;" class="cl-login">'+clSVG('fixbtn_um_login6',28,28,true)+'</a>\
4504                            <a href="javascript:;" class="cl-logout dropdown-toggle" style="display:none;">'+clSVG('fixbtn_um_mypage6',28,28,true)+'</a>\
4505                        </li>\
4506                        <li class="siteCART cl-fixbtn '+((!cartOn) ? 'cl-visible' : '')+'" '+cartOn+'>\
4507                            <a href="#">'+clSVG('fixbtn_cart6',28,28,true)+'\
4508                                <div class=\"cart-active\"><span class=\"cart-active-txt\">5</span></div>\
4509                            </a>\
4510                        </li>\
4511                        ';
4512                    break;
4513                
4514                case "07" : 
4515                    str = '\
4516                        <li class="siteSEARCH cl-fixbtn '+((!searchOn) ? 'cl-visible' : '')+'" '+searchOn+'><a href="#">'+clSVG('fixbtn_search7',28,28,true)+'</a></li>\
4517                        <li class="siteUM cl-fixbtn '+dropdownClass+''+((!umOn) ? 'cl-visible' : '')+'" '+umOn+'>\
4518                            <a href="javascript:;" class="cl-login">'+clSVG('fixbtn_um_login7',28,28,true)+'</a>\
4519                            <a href="javascript:;" class="cl-logout dropdown-toggle" style="display:none;">'+clSVG('fixbtn_um_mypage7',28,28,true)+'</a>\
4520                        </li>\
4521                        <li class="siteCART cl-fixbtn '+((!cartOn) ? 'cl-visible' : '')+'" '+cartOn+'>\
4522                            <a href="#">'+clSVG('fixbtn_cart7',28,28,true)+'\
4523                                <div class=\"cart-active\">5</div>\
4524                            </a>\
4525                        </li>\
4526                        ';
4527                    break;
4528
4529                case "08" : 
4530                    str = '\
4531                        <li class="siteSEARCH cl-fixbtn '+((!searchOn) ? 'cl-visible' : '')+'" '+searchOn+'><a href="#">'+clSVG('fixbtn_search8',28,28,true)+'<span class=\"btn_text\">SEARCH</span></a></li>\
4532                        <li class="siteUM cl-fixbtn '+dropdownClass+''+((!umOn) ? 'cl-visible' : '')+'" '+umOn+'>\
4533                            <a href="javascript:;" class="cl-login">'+clSVG('fixbtn_um_login8',28,28,true)+'<span class=\"btn_text\">LOGIN</span></a>\
4534                            <a href="javascript:;" class="cl-logout dropdown-toggle" style="display:none;">'+clSVG('fixbtn_um_mypage8',28,28,true)+'<span class=\"btn_text\">MY PAGE</span></a>\
4535                        </li>\
4536                        <li class="siteCART cl-fixbtn '+((!cartOn) ? 'cl-visible' : '')+'" '+cartOn+'>\
4537                            <a href="#">'+clSVG('fixbtn_cart8',28,28,true)+'\
4538                                <span class=\"btn_text\">CART</span><div class=\"cart-active\">5</div>\
4539                            </a>\
4540                        </li>\
4541                        ';
4542                    break;
4543                
4544                case "09" : 
4545                    str = '\
4546                        <li class="siteSEARCH cl-fixbtn '+((!searchOn) ? 'cl-visible' : '')+'" '+searchOn+'><a href="#">검색</a></li>\
4547                        <li class="siteUM cl-fixbtn '+dropdownClass+''+((!umOn) ? 'cl-visible' : '')+'" '+umOn+'>\
4548                            <a href="javascript:;" class="cl-login">로그인</a>\
4549                            <a href="javascript:;" class="cl-logout dropdown-toggle" style="display:none;">마이페이지</a>\
4550                        </li>\
4551                        <li class="siteCART cl-fixbtn '+((!cartOn) ? 'cl-visible' : '')+'" '+cartOn+'>\
4552                            <a href="#">'+clSVG('fixbtn_cart9',28,28,true)+'\
4553                                <div class=\"cart-active\">5</div>\
4554                            </a>\
4555                        </li>\
4556                        ';
4557                    break;
4558                
4559                case "10" : 
4560                    str = '\
4561                        <li class="siteUM cl-fixbtn '+dropdownClass+''+((!umOn) ? 'cl-visible' : '')+'" '+umOn+'>\
4562                            <a href="javascript:;" class="cl-login">LOGIN</a>\
4563                            <a href="javascript:;" class="cl-logout dropdown-toggle" style="display:none;">MY PAGE</a>\
4564                        </li>\
4565                        <li class="siteSEARCH cl-fixbtn '+((!searchOn) ? 'cl-visible' : '')+'" '+searchOn+'><a href="#">'+clSVG('fixbtn_search10',28,28,true)+'</a></li>\
4566                        <li class="siteCART cl-fixbtn '+((!cartOn) ? 'cl-visible' : '')+'" '+cartOn+'>\
4567                            <a href="#">'+clSVG('fixbtn_cart9',28,28,true)+'\
4568                                <div class=\"cart-active\"><span class=\"cart-active-txt\">5</span></div>\
4569                            </a>\
4570                        </li>\
4571                        ';
4572                    break;
4573
4574                default : 
4575                    break;
4576            }
4577            
4578            return str;
4579        },
4580        sidebarSet : function(num,checkmodal,validArray,slang) {
4581            var str = '',
4582                searchOn = '',
4583                cartOn = '',
4584                umOn = '',
4585                ssid = (PAGE_MODE == 'c') ? SID : property.SID,
4586                is_templates = checkTemplateSite(ssid),
4587                s_service = (PAGE_MODE == 'c') ? SERVICE : property.SERVICE,
4588                checkGabia = (s_service.indexOf('gabia') > -1) ? true : false,
4589                checkBS = (validArray['validplan'] && (validArray['validtype'] == 'BS' || (checkGabia && (validArray['validtype'] == 'FR')))) ? true : false,
4590                checkBN = (validArray['validplan'] && validArray['validtype'] == 'BN') ? true : false,
4591                checkSM = (validArray['validplan'] && validArray['validtype'] == 'SM') ? true : false,
4592                checkFREE = (!validArray['validplan'] || validArray['validplan'] == 'FR' || validArray['validplan'] == 'PK') ? true : false,
4593                checkElView = ($('.elviewhtml').length>0) ? true : false,
4594                fixBtnSITEUM = (checkElView) ? '' : ((PAGE_MODE=='c') ? SITEUM : property.SITEUM),
4595                checkSITEUM = (!checkElView && ((checkBN && typeof fixBtnSITEUM!='undefined' && Number(fixBtnSITEUM) > 0) || checkSM)) ? true : (checkElView ? true : false),
4596                checkmodal = (typeof checkmodal != 'undefined' && checkmodal) ? true : false,                
4597                fixon = (typeof $('.el-menu header.navbar').attr('data-fixon') != 'undefined' && $('.el-menu header.navbar').attr('data-fixon')) ? $('.el-menu header.navbar').attr('data-fixon') : '',
4598                dropdownClass = (PAGE_MODE=='c') ? '' : 'dropdown ',
4599                slang = (typeof langObj != 'undefined' && langObj) ? langObj : ((PAGE_MODE == 'c') ? SLANG : property.SLANG);
4600                // lang_str = LANG;
4601                
4602                if(!checkElView) {
4603                    searchOn = (!checkSM) ? 'style="display:none;"' : '';                    
4604                    umOn = (checkBS || checkFREE || (checkBN && !checkSITEUM)) ? 'style="display:none;"' : '';   
4605                    cartOn = (checkFREE) ? 'style="display:none;"' : ((checkSM) ? '' : 'style="display:none;"');
4606                    if(fixon && (checkBN || checkSM) && checkSITEUM) {
4607                        searchOn = ((checkSM) && fixon.indexOf('search')>-1) ? '' : 'style="display:none;"';
4608                        cartOn = ((checkSM) && fixon.indexOf('cart')>-1) ? '' : 'style="display:none;"';
4609                        umOn = ((checkBN || checkSM) && fixon.indexOf('um')>-1) ? '' : 'style="display:none;"';
4610                    }
4611                    if(fixon == 'all') {
4612                        searchOn = 'style="display:none;"';
4613                        cartOn = 'style="display:none;"';
4614                        umOn = 'style="display:none;"';
4615                    }
4616                }
4617               
4618                if(checkElView || checkmodal || is_templates) {
4619                    umOn = (checkBS || checkFREE) ? 'style="display:none;"' : '';  
4620                    searchOn = cartOn = (checkSM) ? '' : 'style="display:none;"';
4621                }
4622                   
4623                /* 다국어 / 사이트 언어별 lang 체크 ***/
4624                // if((typeof slang != 'undefined' && typeof slang.select_code != 'undefined' && slang.select_code)
4625                //             || (!$.isEmptyObject(slang) && slang.select_code)) {
4626                //     //searchOn = (slang['select_code']=='ko' && checkSM) ? '' : 'style="display:none;"';
4627                //     lang_str = (slang['select_code'].toLowerCase()!='ko') ? 'en' : 'ko';
4628                // } 
4629
4630            switch(num) {
4631                case "01" : 
4632                    str = '\
4633                        <li class="siteSEARCH cl-fixbtn '+((!searchOn) ? 'cl-visible' : '')+'" '+searchOn+'><a href="#">SEARCH</a></li>\
4634                        <li class="siteUM cl-fixbtn '+dropdownClass+''+((!umOn) ? 'cl-visible' : '')+'" '+umOn+'>\
4635                            <a href="javascript:;" class="cl-login">LOGIN</a>\
4636                            <a href="javascript:;" class="cl-logout dropdown-toggle" style="display:none;">MY PAGE</a>\
4637                        </li>\
4638                        <li class="siteCART cl-fixbtn '+((!cartOn) ? 'cl-visible' : '')+'" '+cartOn+'><a href="#"><span class=\"cart-text\">CART</span><div class=\"cart-active\">5</div></a></li>\
4639                        '; 
4640                    break;
4641                
4642                case "02" : 
4643                    str = '\
4644                        <li class="siteSEARCH cl-fixbtn '+((!searchOn) ? 'cl-visible' : '')+'" '+searchOn+'><a href="#">Search</a></li>\
4645                        <li class="siteUM cl-fixbtn '+dropdownClass+''+((!umOn) ? 'cl-visible' : '')+'" '+umOn+'>\
4646                            <a href="javascript:;" class="cl-login">Login</a>\
4647                            <a href="javascript:;" class="cl-logout dropdown-toggle" style="display:none;">My page</a>\
4648                        </li>\
4649                        <li class="siteCART cl-fixbtn '+((!cartOn) ? 'cl-visible' : '')+'" '+cartOn+'>\
4650                            <a href="#"><span class=\"cart-text\">Basket</span><div class=\"cart-active\">5</div></a>\
4651                        </li>\
4652                        ';
4653                    break;
4654
4655                case "03" : 
4656                    str = '\
4657                        <li class="siteSEARCH cl-fixbtn '+((!searchOn) ? 'cl-visible' : '')+'" '+searchOn+'><a href="#">검색</a></li>\
4658                        <li class="siteUM cl-fixbtn '+dropdownClass+''+((!umOn) ? 'cl-visible' : '')+'" '+umOn+'>\
4659                            <a href="javascript:;" class="cl-login">로그인</a>\
4660                            <a href="javascript:;" class="cl-logout dropdown-toggle" style="display:none;">마이페이지</a>\
4661                        </li>\
4662                        <li class="siteCART cl-fixbtn '+((!cartOn) ? 'cl-visible' : '')+'" '+cartOn+'>\
4663                            <a href="#"><span class=\"cart-text\">장바구니</span>\
4664                                <div class=\"cart-active\"><span class=\"cart-active-txt\">5</span></div>\
4665                            </a>\
4666                        </li>\
4667                        ';
4668                    break;
4669                
4670                case "04" : 
4671                    str = '\
4672                        <li class="siteSEARCH cl-fixbtn '+((!searchOn) ? 'cl-visible' : '')+'" '+searchOn+'><a href="#">'+clSVG('fixbtn_search4',28,28,true)+'</a></li>\
4673                        <li class="siteUM cl-fixbtn '+dropdownClass+''+((!umOn) ? 'cl-visible' : '')+'" '+umOn+'>\
4674                            <a href="javascript:;" class="cl-login">'+clSVG('fixbtn_um_login4',28,28,true)+'</a>\
4675                            <a href="javascript:;" class="cl-logout dropdown-toggle" style="display:none;">'+clSVG('fixbtn_um_mypage4',28,28,true)+'</a>\
4676                        </li>\
4677                        <li class="siteCART cl-fixbtn '+((!cartOn) ? 'cl-visible' : '')+'" '+cartOn+'>\
4678                            <a href="#">'+clSVG('fixbtn_cart4',28,28,true)+'\
4679                                <div class=\"cart-active\"><span class=\"cart-active-txt\">5</span></div>\
4680                            </a>\
4681                        </li>\
4682                        ';
4683                    break;
4684                
4685                case "05" : 
4686                    str = '\
4687                        <li class="siteSEARCH cl-fixbtn '+((!searchOn) ? 'cl-visible' : '')+'" '+searchOn+'><a href="#">'+clSVG('fixbtn_search5',28,28,true)+'</a></li>\
4688                        <li class="siteUM cl-fixbtn '+dropdownClass+''+((!umOn) ? 'cl-visible' : '')+'" '+umOn+'>\
4689                            <a href="javascript:;" class="cl-login">'+clSVG('fixbtn_um_login5',28,28,true)+'</a>\
4690                            <a href="javascript:;" class="cl-logout dropdown-toggle" style="display:none;">'+clSVG('fixbtn_um_mypage5',28,28,true)+'</a>\
4691                        </li>\
4692                        <li class="siteCART cl-fixbtn '+((!cartOn) ? 'cl-visible' : '')+'" '+cartOn+'>\
4693                            <a href="#">'+clSVG('fixbtn_cart5',28,28,true)+'\
4694                                <div class=\"cart-active\"><span class=\"cart-active-txt\">5</span></div>\
4695                            </a>\
4696                        </li>\
4697                        ';
4698                    break;
4699                
4700                case "06" : 
4701                    str = '\
4702                        <li class="siteSEARCH cl-fixbtn '+((!searchOn) ? 'cl-visible' : '')+'" '+searchOn+'><a href="#">'+clSVG('fixbtn_search6',28,28,true)+'</a></li>\
4703                        <li class="siteUM cl-fixbtn '+dropdownClass+''+((!umOn) ? 'cl-visible' : '')+'" '+umOn+'>\
4704                            <a href="javascript:;" class="cl-login">'+clSVG('fixbtn_um_login6',28,28,true)+'</a>\
4705                            <a href="javascript:;" class="cl-logout dropdown-toggle" style="display:none;">'+clSVG('fixbtn_um_mypage6',28,28,true)+'</a>\
4706                        </li>\
4707                        <li class="siteCART cl-fixbtn '+((!cartOn) ? 'cl-visible' : '')+'" '+cartOn+'>\
4708                            <a href="#">'+clSVG('fixbtn_cart6',28,28,true)+'\
4709                                <div class=\"cart-active\"><span class=\"cart-active-txt\">5</span></div>\
4710                            </a>\
4711                        </li>\
4712                        ';
4713                    break;
4714                
4715                case "07" : 
4716                    str = '\
4717                        <li class="siteSEARCH cl-fixbtn '+((!searchOn) ? 'cl-visible' : '')+'" '+searchOn+'><a href="#">'+clSVG('fixbtn_search7',28,28,true)+'</a></li>\
4718                        <li class="siteUM cl-fixbtn '+dropdownClass+''+((!umOn) ? 'cl-visible' : '')+'" '+umOn+'>\
4719                            <a href="javascript:;" class="cl-login">'+clSVG('fixbtn_um_login7',28,28,true)+'</a>\
4720                            <a href="javascript:;" class="cl-logout dropdown-toggle" style="display:none;">'+clSVG('fixbtn_um_mypage7',28,28,true)+'</a>\
4721                        </li>\
4722                        <li class="siteCART cl-fixbtn '+((!cartOn) ? 'cl-visible' : '')+'" '+cartOn+'>\
4723                            <a href="#">'+clSVG('fixbtn_cart7',28,28,true)+'\
4724                                <div class=\"cart-active\">5</div>\
4725                            </a>\
4726                        </li>\
4727                        ';
4728                    break;
4729
4730                case "08" : 
4731                    str = '\
4732                        <li class="siteSEARCH cl-fixbtn '+((!searchOn) ? 'cl-visible' : '')+'" '+searchOn+'><a href="#">'+clSVG('fixbtn_search8',28,28,true)+'<span class=\"btn_text\">SEARCH</span></a></li>\
4733                        <li class="siteUM cl-fixbtn '+dropdownClass+''+((!umOn) ? 'cl-visible' : '')+'" '+umOn+'>\
4734                            <a href="javascript:;javascript:;" class="cl-login">'+clSVG('fixbtn_um_login8',28,28,true)+'<span class=\"btn_text\">LOGIN</span></a>\
4735                            <a href="javascript:;" class="cl-logout dropdown-toggle" style="display:none;">'+clSVG('fixbtn_um_mypage8',28,28,true)+'<span class=\"btn_text\">MY PAGE</span></a>\
4736                        </li>\
4737                        <li class="siteCART cl-fixbtn '+((!cartOn) ? 'cl-visible' : '')+'" '+cartOn+'>\
4738                            <a href="#">'+clSVG('fixbtn_cart8',28,28,true)+'\
4739                                <span class=\"btn_text\">CART</span><div class=\"cart-active\">5</div>\
4740                            </a>\
4741                        </li>\
4742                        ';
4743                    break;
4744                
4745                case "09" : 
4746                    str = '\
4747                        <li class="siteSEARCH cl-fixbtn '+((!searchOn) ? 'cl-visible' : '')+'" '+searchOn+'><a href="#">검색</a></li>\
4748                        <li class="siteUM cl-fixbtn '+dropdownClass+''+((!umOn) ? 'cl-visible' : '')+'" '+umOn+'>\
4749                            <a href="javascript:;" class="cl-login">로그인</a>\
4750                            <a href="javascript:;" class="cl-logout dropdown-toggle" style="display:none;">마이페이지</a>\
4751                        </li>\
4752                        <li class="siteCART cl-fixbtn '+((!cartOn) ? 'cl-visible' : '')+'" '+cartOn+'>\
4753                            <a href="#">'+clSVG('fixbtn_cart9',28,28,true)+'\
4754                                <div class=\"cart-active\">5</div>\
4755                            </a>\
4756                        </li>\
4757                        ';
4758                    break;
4759                
4760                case "10" : 
4761                    str = '\
4762                        <li class="siteUM cl-fixbtn '+dropdownClass+''+((!umOn) ? 'cl-visible' : '')+'" '+umOn+'>\
4763                            <a href="javascript:;" class="cl-login">LOGIN</a>\
4764                            <a href="javascript:;" class="cl-logout dropdown-toggle" style="display:none;">My page</a>\
4765                        </li>\
4766                        <li class="siteSEARCH cl-fixbtn '+((!searchOn) ? 'cl-visible' : '')+'" '+searchOn+'><a href="#">'+clSVG('fixbtn_search10',28,28,true)+'</a></li>\
4767                        <li class="siteCART cl-fixbtn '+((!cartOn) ? 'cl-visible' : '')+'" '+cartOn+'>\
4768                            <a href="#">'+clSVG('fixbtn_cart9',28,28,true)+'\
4769                                <div class=\"cart-active\"><span class=\"cart-active-txt\">5</span></div>\
4770                            </a>\
4771                        </li>\
4772                        ';
4773                    break;
4774
4775                default : 
4776                    break;
4777            }
4778            
4779            return str;
4780        },
4781        fixFhTypeSet : function(pos) {
4782            var str = '';
4783
4784            switch(pos) {
4785                
4786                case "right" : 
4787
4788                    str += '\
4789                        <ul class="menuList">\
4790                            <li class="cl-menulist"><a href="#">Home</a></li>\
4791                            <li class="cl-menulist"><a href="#">Portfolio</a></li>\
4792                            <li class="cl-menulist"><a href="#">Contact</a></li>\
4793                        </ul>\
4794                        <ul class="menufixArea">\
4795                            <li class="siteSEARCH cl-fixbtn"><a href="#">'+clSVG('fixbtn_search4',28,28,true)+'</a></li>\
4796                            <li class="siteUM cl-fixbtn"><a href="#">'+clSVG('fixbtn_um4',28,28,true)+'</a></li>\
4797                            <li class="siteCART cl-fixbtn"><a href="#">'+clSVG('fixbtn_cart4',28,28,true)+'</a></li>\
4798                        </ul>\
4799                        ';
4800
4801                    break;
4802
4803                case "top" : 
4804
4805                    str += '\
4806                        <ul class="menufixArea">\
4807                            <li class="siteSEARCH cl-fixbtn"><a href="#">'+clSVG('fixbtn_search4',28,28,true)+'</a></li>\
4808                            <li class="siteUM cl-fixbtn"><a href="#">'+clSVG('fixbtn_um4',28,28,true)+'</a></li>\
4809                            <li class="siteCART cl-fixbtn"><a href="#">'+clSVG('fixbtn_cart4',28,28,true)+'</a></li>\
4810                        </ul>\
4811                        <ul class="menuList">\
4812                            <li class="cl-menulist"><a href="#">Home</a></li>\
4813                            <li class="cl-menulist"><a href="#">Portfolio</a></li>\
4814                            <li class="cl-menulist"><a href="#">Contact</a></li>\
4815                        </ul>\
4816                        ';
4817
4818                    break;
4819
4820                default : 
4821                    break;
4822            }
4823            
4824            return str;
4825        },
4826        fixLangSet : function(num,def,langObj,checkMobile,validArray){
4827            var checkElView = ($('.elviewhtml').length>0) ? true : false,
4828                s_service = (PAGE_MODE == 'c') ? SERVICE : property.SERVICE,
4829                checkGabia = (s_service.indexOf('gabia') > -1) ? true : false,
4830                checkVALIDPLAN = (PAGE_MODE=='c') ? VALIDPLAN : property.VALIDPLAN,
4831                checkVALIDTYPE = (PAGE_MODE=='c') ? VALIDTYPE : property.VALIDTYPE,
4832                checkBS = (checkVALIDPLAN && (checkVALIDTYPE == 'BS' || (checkGabia && (checkVALIDTYPE == 'FR')))) ? true : false,
4833                slang = (typeof langObj != 'undefined' && langObj) ? langObj : ((PAGE_MODE == 'c') ? SLANG : property.SLANG),
4834                def = (typeof def!='undefined') ? def : true,
4835                checkMobile = (typeof checkMobile!='undefined') ? checkMobile : false;
4836
4837			slang = (slang && typeof slang == 'object') ? slang : {};
4838			var slangLists = $.isArray(slang.lists) ? slang.lists : [];
4839			if(slangLists.length === 0) return false;
4840              
4841            if(typeof validArray != 'undefined') var checkFREE = (!validArray['validplan'] || validArray['validplan'] == 'FR' || validArray['validplan'] == 'PK') ? true : false;
4842            if(!checkElView && ((typeof slang == 'undefined' && typeof slang.select_code == 'undefined' && !slang.select_code)
4843                            || ($.isEmptyObject(slang) && checkBS) || slang.select_code=='') || (checkElView && checkFREE) 
4844                || (typeof slang=='undefined' || !slang.select)) {
4845                    return false;
4846                }
4847          
4848            var str = '',
4849                lang_txt = (typeof slang.select != 'undefined' && slang.select) ? slang.select.trim() : '',
4850                lang_code = (typeof slang.select_code != 'undefined' && slang.select_code) ? slang.select_code.toUpperCase() : '',
4851                checkDropTopClass = ($('.el-menu > header.navbar').hasClass('sidebar') || checkMobile) ? 'dropup' : 'dropdown',
4852                dropdownClass = (PAGE_MODE=='c') ? '' : 'dropdown',
4853                dropdownStr = '';
4854            
4855            if(checkMobile) {
4856                dropdownStr += '\
4857                <div class="dropdown-menu-wrap" id="m-dropdown-wrap-lang">\
4858                    <span class="dropdown-close"><img src="//storage.googleapis.com/i.addblock.net/fa-close-modal-white.png" alt="Close Change Multilingual Site"></span></span>\
4859                ';
4860            }
4861                dropdownStr += '\
4862                    <ul class="dropdown-menu">';
4863                    $.each(slang.lists, function(i,v){
4864                    var active = (v.name == slang.select) ? 'active' : '';
4865                    dropdownStr += '\
4866                        <li class="'+active+'"><a class="cl-langlist " href="javascript:;" data-code="'+v.code+'">'+v.name+'</a></li>';
4867                    });
4868                dropdownStr += '\
4869                    </ul>';
4870            if(checkMobile) {
4871                dropdownStr += '\
4872                </div>\
4873                ';
4874            }                  
4875          
4876            var attrMobile = (checkMobile) ? 'data-toggle="dropdown" data-target="#m-dropdown-wrap-lang"' : '';
4877         
4878            switch(num) {
4879                case "01" : 
4880                    str = (!def) ? '\
4881                        <div class="siteLANG cl-fixbtn '+checkDropTopClass+' cl-visible" data-fixlang="'+lang_txt+'" data-fixlangcode="'+lang_code+'">\
4882                            <a href="#" class="cl-lang dropdown-toggle" '+attrMobile+'>\
4883                                <span class="slang-active">'+lang_code+'</span>\
4884                                ' + clSVG('fixbtn_arrow1',16,16,true) + '\
4885                            </a>' + dropdownStr + '\
4886                        </div>' : '\
4887                        <li class="siteLANG cl-fixbtn dropdown cl-visible" data-fixlang="'+lang_txt+'" data-fixlangcode="'+lang_code+'">\
4888                            <a href="#" class="cl-lang dropdown-toggle">\
4889                                <span class="slang-active">'+lang_code+'</span>\
4890                                ' + clSVG('fixbtn_arrow1',16,16,true) + '\
4891                            </a>' + dropdownStr + '\
4892                        </li>\
4893                        '; 
4894                    break;
4895                
4896                case "02" : 
4897                    str = (!def) ? '\
4898                        <div class="siteLANG cl-fixbtn '+checkDropTopClass+' cl-visible" data-fixlang="'+lang_txt+'" data-fixlangcode="'+lang_code+'">\
4899                            <a href="#" class="cl-lang dropdown-toggle" '+attrMobile+'>\
4900                                <span class="slang-active">'+lang_txt+'</span>\
4901                                ' + clSVG('fixbtn_arrow1',16,16,true) + '\
4902                            </a>' + dropdownStr + '\
4903                        </div>' : '\
4904                        <li class="siteLANG cl-fixbtn dropdown cl-visible" data-fixlang="'+lang_txt+'" data-fixlangcode="'+lang_code+'">\
4905                            <a href="#" class="cl-lang dropdown-toggle">\
4906                                <span class="slang-active">'+lang_txt+'</span>\
4907                                ' + clSVG('fixbtn_arrow1',16,16,true) + '\
4908                            </a>' + dropdownStr + '\
4909                        </li>\
4910                        '; 
4911                    break;
4912                
4913                case "03" : 
4914                    str = (!def) ? '\
4915                        <div class="siteLANG cl-fixbtn '+checkDropTopClass+' cl-visible" data-fixlang="'+lang_txt+'" data-fixlangcode="'+lang_code+'">\
4916                            <a href="#" class="cl-lang dropdown-toggle" '+attrMobile+'>\
4917                                <span class="slang-active">'+lang_code+'</span>\
4918                                ' + clSVG('fixbtn_arrow1',16,16,true) + '\
4919                            </a>' + dropdownStr + '\
4920                        </div>' : '\
4921                        <li class="siteLANG cl-fixbtn dropdown cl-visible" data-fixlang="'+lang_txt+'" data-fixlangcode="'+lang_code+'">\
4922                            <a href="#" class="cl-lang dropdown-toggle">\
4923                                <span class="slang-active">'+lang_code+'</span>\
4924                                ' + clSVG('fixbtn_arrow1',16,16,true) + '\
4925                            </a>' + dropdownStr + '\
4926                        </li>\
4927                        '; 
4928                    break;
4929                
4930                case "04" : 
4931                    str = (!def) ? '\
4932                        <div class="siteLANG cl-fixbtn '+checkDropTopClass+' cl-visible" data-fixlang="'+lang_txt+'" data-fixlangcode="'+lang_code+'">\
4933                            <a href="#" class="cl-lang dropdown-toggle" '+attrMobile+'>\
4934                                <span class="slang-active">'+lang_code+'</span>\
4935                                ' + clSVG('fixbtn_arrow1',16,16,true) + '\
4936                            </a>' + dropdownStr + '\
4937                        </div>\
4938                        ' : '\
4939                        <li class="siteLANG cl-fixbtn dropdown cl-visible" data-fixlang="'+lang_txt+'" data-fixlangcode="'+lang_code+'">\
4940                            <a href="#" class="cl-lang dropdown-toggle" '+attrMobile+'>\
4941                                <span class="slang-active">'+lang_code+'</span>\
4942                                ' + clSVG('fixbtn_arrow1',16,16,true) + '\
4943                            </a>' + dropdownStr + '\
4944                        </li>\
4945                        '; 
4946                    break;
4947                
4948                case "05" : 
4949                    str = (!def) ? '\
4950                        <div class="siteLANG cl-fixbtn '+checkDropTopClass+' cl-visible" data-fixlang="'+lang_txt+'" data-fixlangcode="'+lang_code+'">\
4951                            <a href="#" class="cl-lang dropdown-toggle" '+attrMobile+'>\
4952                                <span class="slang-active" style="display:none;">'+lang_code+'</span>\
4953                                ' + clSVG('fixbtn_lang5',18,18,true) + '\
4954                            </a>' + dropdownStr + '\
4955                        </div>\
4956                        ' : '\
4957                        <li class="siteLANG cl-fixbtn dropdown cl-visible" data-fixlang="'+lang_txt+'" data-fixlangcode="'+lang_code+'">\
4958                            <a href="#" class="cl-lang dropdown-toggle">\
4959                                <span class="slang-active" style="display:none;">'+lang_code+'</span>\
4960                                ' + clSVG('fixbtn_lang5',18,18,true) + '\
4961                            </a>' + dropdownStr + '\
4962                        </li>\
4963                        '; 
4964                    break;
4965
4966                case "06" : 
4967                    str = (!def) ? '\
4968                        <div class="siteLANG cl-fixbtn '+checkDropTopClass+' cl-visible" data-fixlang="'+lang_txt+'" data-fixlangcode="'+lang_code+'">\
4969                            <a href="#" class="cl-lang dropdown-toggle" '+attrMobile+'>\
4970                                ' + clSVG('fixbtn_lang5',18,18,true) + '\
4971                                <span class="slang-active">'+lang_code+'</span>\
4972                            </a>' + dropdownStr + '\
4973                        </div>\
4974                        ' : '\
4975                        <li class="siteLANG cl-fixbtn dropdown cl-visible" data-fixlang="'+lang_txt+'" data-fixlangcode="'+lang_code+'">\
4976                            <a href="#" class="cl-lang dropdown-toggle">\
4977                                ' + clSVG('fixbtn_lang5',18,18,true) + '\
4978                                <span class="slang-active">'+lang_code+'</span>\
4979                            </a>' + dropdownStr + '\
4980                        </li>\
4981                        '; 
4982                    break;
4983                
4984                case "07" : 
4985                    str = (!def) ? '\
4986                        <div class="siteLANG cl-fixbtn '+checkDropTopClass+' cl-visible" data-fixlang="'+lang_txt+'" data-fixlangcode="'+lang_code+'">\
4987                            <a href="#" class="cl-lang dropdown-toggle" '+attrMobile+'>\
4988                                <img src="//storage.googleapis.com/i.addblock.net/flag/flag_'+lang_code.toLowerCase()+'_cir.png" class="cl-lang-img img-responsive"/>\
4989                                <span class="slang-active">'+lang_txt+'</span>\
4990                                ' + clSVG('fixbtn_arrow1',16,16,true) + '\
4991                            </a>' + dropdownStr + '\
4992                        </div>\
4993                        ' : '\
4994                        <li class="siteLANG cl-fixbtn dropdown cl-visible" data-fixlang="'+lang_txt+'" data-fixlangcode="'+lang_code+'">\
4995                            <a href="#" class="cl-lang dropdown-toggle">\
4996                                <img src="//storage.googleapis.com/i.addblock.net/flag/flag_'+lang_code.toLowerCase()+'_cir.png" class="cl-lang-img img-responsive"/>\
4997                                <span class="slang-active">'+lang_txt+'</span>\
4998                                ' + clSVG('fixbtn_arrow1',16,16,true) + '\
4999                            </a>' + dropdownStr + '\
5000                        </li>\
5001                        '; 
5002                    break;
5003                
5004                case "08" : 
5005                    str = (!def) ? '\
5006                        <div class="siteLANG cl-fixbtn '+checkDropTopClass+' cl-visible" data-fixlang="'+lang_txt+'" data-fixlangcode="'+lang_code+'">\
5007                            <a href="#" class="cl-lang dropdown-toggle" '+attrMobile+'>\
5008                                <img src="//storage.googleapis.com/i.addblock.net/flag/flag_'+lang_code.toLowerCase()+'_rec.png" class="cl-lang-img img-responsive"/>\
5009                                <span class="slang-active">'+lang_txt+'</span>\
5010                                ' + clSVG('fixbtn_arrow1',16,16,true) + '\
5011                            </a>' + dropdownStr + '\
5012                        </div>\
5013                        ' : '\
5014                        <li class="siteLANG cl-fixbtn dropdown cl-visible" data-fixlang="'+lang_txt+'" data-fixlangcode="'+lang_code+'">\
5015                            <a href="#" class="cl-lang dropdown-toggle">\
5016                                <img src="//storage.googleapis.com/i.addblock.net/flag/flag_'+lang_code.toLowerCase()+'_rec.png" class="cl-lang-img img-responsive"/>\
5017                                <span class="slang-active">'+lang_txt+'</span>\
5018                                ' + clSVG('fixbtn_arrow1',16,16,true) + '\
5019                            </a>' + dropdownStr + '\
5020                        </li>\
5021                        '; 
5022                    break;
5023
5024                case "09" : 
5025                    str = (!def) ? '\
5026                        <div class="siteLANG cl-fixbtn '+checkDropTopClass+' cl-visible" data-fixlang="'+lang_txt+'" data-fixlangcode="'+lang_code+'">\
5027                            <a href="#" class="cl-lang dropdown-toggle" '+attrMobile+'>\
5028                                <img src="//storage.googleapis.com/i.addblock.net/flag/flag_'+lang_code.toLowerCase()+'_cir.png" class="cl-lang-img img-responsive"/>\
5029                            </a>' + dropdownStr + '\
5030                        </div>\
5031                        ' : '\
5032                        <li class="siteLANG cl-fixbtn dropdown cl-visible" data-fixlang="'+lang_txt+'" data-fixlangcode="'+lang_code+'">\
5033                            <a href="#" class="cl-lang dropdown-toggle">\
5034                                <img src="//storage.googleapis.com/i.addblock.net/flag/flag_'+lang_code.toLowerCase()+'_cir.png" class="cl-lang-img img-responsive"/>\
5035                            </a>' + dropdownStr + '\
5036                        </li>\
5037                        '; 
5038                    break;
5039
5040                case "10" : 
5041                    str = (!def) ? '\
5042                        <div class="siteLANG cl-fixbtn '+checkDropTopClass+' cl-visible" data-fixlang="'+lang_txt+'" data-fixlangcode="'+lang_code+'">\
5043                            <a href="#" class="cl-lang dropdown-toggle" '+attrMobile+'>\
5044                                <span class="slang-active">'+lang_code+'</span>\
5045                            </a>' + dropdownStr + '\
5046                        </div>' : '\
5047                        <li class="siteLANG cl-fixbtn dropdown cl-visible" data-fixlang="'+lang_txt+'" data-fixlangcode="'+lang_code+'">\
5048                            <a href="#" class="cl-lang dropdown-toggle">\
5049                                <span class="slang-active">'+lang_code+'</span>\
5050                            </a>' + dropdownStr + '\
5051                        </li>\
5052                        '; 
5053                    break;
5054
5055                case "11" : 
5056                    str = (!def) ? '\
5057                        <div class="siteLANG cl-fixbtn '+checkDropTopClass+' cl-visible" data-fixlang="'+lang_txt+'" data-fixlangcode="'+lang_code+'">\
5058                            <a href="#" class="cl-lang dropdown-toggle" '+attrMobile+'>\
5059                                <img src="//storage.googleapis.com/i.addblock.net/flag/flag_'+lang_code.toLowerCase()+'_rec.png" class="cl-lang-img img-responsive"/>\
5060                            </a>' + dropdownStr + '\
5061                        </div>\
5062                        ' : '\
5063                        <li class="siteLANG cl-fixbtn dropdown cl-visible" data-fixlang="'+lang_txt+'" data-fixlangcode="'+lang_code+'">\
5064                            <a href="#" class="cl-lang dropdown-toggle">\
5065                                <img src="//storage.googleapis.com/i.addblock.net/flag/flag_'+lang_code.toLowerCase()+'_rec.png" class="cl-lang-img img-responsive"/>\
5066                            </a>' + dropdownStr + '\
5067                        </li>\
5068                        '; 
5069                    break;
5070
5071                default : 
5072                    break;
5073            }
5074           
5075            return str;
5076        },
5077        getData : function($h) {
5078            var data = [],
5079                dataFix = ['fixtype','fixlangtype','fh-type','fixsize','fixlangsize','fixtypeText','fixtypeNum','fixlangtypeNum'];
5080                
5081            $.each(dataFix, function(i,v){
5082                var dataV = 'data-'+v;
5083                data[v] = (typeof $h.attr(dataV)!='undefined' && $h.attr(dataV)) ? $h.attr(dataV) : '';
5084                if(data['fixtype']!='undefined' && data['fixtype']) {
5085                    if(v=='fixtypeText') data[v] = data['fixtype'].replace(/\_\d+/gi,'');
5086                    else if(v=='fixtypeNum') data[v] = data['fixtype'].replace(/(top|sidebar)\_/gi,'');  
5087                    else if(v=='fixlangtypeNum') data[v] = data['fixlangtype'].replace(/lang\_/gi,'');
5088                } 
5089                
5090            })
5091
5092            return data;
5093        }
5094    }
5095
5096    /*** shopping Guide Popup ***/
5097    $.guidePopup = {
5098        set: function() {
5099            var str = '\
5100                    <div class="guide-top">\
5101                        <h3 class="modal-title guidetitle">'+$.lang[LANG]['editor.meta.shoppingmall.guide.title']+'</h3>\
5102                        <div class="guide-menu">\
5103                            <ul>\
5104                                <li class="active hand">\
5105                                    <p>'+$.lang[LANG]['editor.meta.shoppingmall.guide.step.1']+'</p>\
5106                                    <div class="line right"></div>\
5107                                </li>\
5108                                <li class="hand">\
5109                                    <div class="line left"></div>\
5110                                    <div class="line right"></div>\
5111                                    <p>'+$.lang[LANG]['editor.meta.shoppingmall.guide.step.2']+'</p>\
5112                                </li>\
5113                                <li class="hand">\
5114                                    <div class="line left"></div>\
5115                                    <div class="line right"></div>\
5116                                    <p>'+$.lang[LANG]['editor.meta.shoppingmall.guide.step.3']+'</p>\
5117                                </li>\
5118                                <li class="hand">\
5119                                    <div class="line left"></div>\
5120                                    <p>'+$.lang[LANG]['editor.meta.shoppingmall.guide.step.4']+'</p>\
5121                                </li>\
5122                            </ul>\
5123                        </div>\
5124                    </div>\
5125                    <div class="guide-wrap">\
5126                        <div class="step">\
5127                            <div id="step1">\
5128                                <h3>'+$.lang[LANG]['editor.meta.shoppingmall.guide.step.1.title']+'</h3>\
5129                                <p>'+$.lang[LANG]['editor.meta.shoppingmall.guide.step.1.1.contents']+'</p>\
5130                                <img class="img-responsive" src="//storage.googleapis.com/i.addblock.net/guide_img01_1.jpg">\
5131                                <p>'+$.lang[LANG]['editor.meta.shoppingmall.guide.step.1.2.contents']+'</p>\
5132                                <img class="img-responsive" src="//storage.googleapis.com/i.addblock.net/guide_img01_2.jpg">\
5133                                <p>'+$.lang[LANG]['editor.meta.shoppingmall.guide.step.1.3.contents']+'</p>\
5134                                <img class="img-responsive" src="//storage.googleapis.com/i.addblock.net/guide_img01_3.jpg">\
5135                            </div>\
5136                            <div id="step2">\
5137                                <h3>'+$.lang[LANG]['editor.meta.shoppingmall.guide.step.2.title']+'</h3>\
5138                                <p>'+$.lang[LANG]['editor.meta.shoppingmall.guide.step.2.1.contents']+'</p>\
5139                                <img class="img-responsive" src="//storage.googleapis.com/i.addblock.net/guide_img02_1.jpg">\
5140                                <p>'+$.lang[LANG]['editor.meta.shoppingmall.guide.step.2.2.contents']+'</p>\
5141                                <img src="//storage.googleapis.com/i.addblock.net/guide_img02_2.jpg">\
5142                                <p>'+$.lang[LANG]['editor.meta.shoppingmall.guide.step.2.3.contents']+'</p>\
5143                                <img class="img-responsive" src="//storage.googleapis.com/i.addblock.net/guide_img02_3.jpg">\
5144                                <p>'+$.lang[LANG]['editor.meta.shoppingmall.guide.step.2.4.contents']+'</p>\
5145                                <img class="img-responsive" src="//storage.googleapis.com/i.addblock.net/guide_img02_4.jpg">\
5146                            </div>\
5147                            <div id="step3">\
5148                                <h3>'+$.lang[LANG]['editor.meta.shoppingmall.guide.step.3.title']+'</h3>\
5149                                <p>'+$.lang[LANG]['editor.meta.shoppingmall.guide.step.3.1.contents']+'</p>\
5150                                <img class="img-responsive" src="//storage.googleapis.com/i.addblock.net/guide_img03_1.jpg">\
5151                                <p>'+$.lang[LANG]['editor.meta.shoppingmall.guide.step.3.2.contents']+'</p>\
5152                                <img class="img-responsive" src="//storage.googleapis.com/i.addblock.net/guide_img03_2.jpg">\
5153                            </div>\
5154                            <div id="step4">\
5155                                <h3>'+$.lang[LANG]['editor.meta.shoppingmall.guide.step.4.title']+'</h3>\
5156                                <p>'+$.lang[LANG]['editor.meta.shoppingmall.guide.step.4.1.contents']+'</p>\
5157                                <img class="img-responsive" src="//storage.googleapis.com/i.addblock.net/guide_img04_1.jpg">\
5158                                <p>'+$.lang[LANG]['editor.meta.shoppingmall.guide.step.4.2.contents']+'</p>\
5159                                <img class="img-responsive" src="//storage.googleapis.com/i.addblock.net/guide_img04_2.jpg">\
5160                            </div>\
5161                        </div>\
5162                        <div class="modal-footer guideClose">\
5163                            <button type="button" class="btn btn-default btn-sm close-button-dialog clostbtnfalse" data-dismiss="modal">닫기</button>\
5164                        </div>\
5165                    </div>\
5166                    ';
5167                                                    
5168            var shopguideModal = $(this).showModalFlat('',str,true,false,'','close','','guidePopup cl-cmmodal cl-s-btn cover w700', false ,'',function() {
5169                $.guidePopup.scrollevent();
5170            });
5171        },
5172        scrollevent : function() {
5173            $('.guidePopup-wrap').on('shown.bs.modal', function(e) {                    
5174                $('.guidePopup .guide-wrap').scroll(function() {
5175                    if($(this).hasClass('moving')) return false;
5176                    var scrollValue = $('.guidePopup .guide-wrap').scrollTop(),
5177                        issclogin = ($('.guidePopup').attr('class').indexOf('sclogin') > 0 || $('.guidePopup').attr('class').indexOf('naverpay-guide') > 0) ? true : false,
5178                        isCert = ($('.guidePopup').attr('class').indexOf('cert-guide-modal') > 0)? true : false;
5179
5180                    if(issclogin || isCert) {
5181                        if( scrollValue >= $("#step2").position().top && scrollValue < $("#step3").position().top) {
5182                            $('.guidePopup ul li:visible').eq(1).addClass('active').siblings().removeClass('active');
5183                            $('.guidePopup ul li:visible').eq(1).css('zIndex', '2').siblings().css('zIndex', '1');
5184                        } else if( scrollValue >= $("#step3").position().top) {
5185                            $('.guidePopup ul li:visible').eq(2).addClass('active').siblings().removeClass('active');
5186                            $('.guidePopup ul li:visible').eq(2).css('zIndex', '2').siblings().css('zIndex', '1');
5187                        } else {
5188                            $('.guidePopup ul li:visible').eq(0).addClass('active').siblings().removeClass('active');
5189                            $('.guidePopup ul li:visible').eq(0).css('zIndex', '2').siblings().css('zIndex', '1');
5190                        }
5191                    } else {
5192                        var hasStep4 = $("#step4").length > 0,
5193                            step4Top = hasStep4 ? $("#step4").position().top : null;
5194
5195                        if( scrollValue >= $("#step2").position().top && scrollValue < $("#step3").position().top) {
5196                            $('.guidePopup ul li').eq(1).addClass('active').siblings().removeClass('active');
5197                            $('.guidePopup ul li').eq(1).css('zIndex', '2').siblings().css('zIndex', '1');
5198                        } else if( scrollValue >= $("#step3").position().top && (!hasStep4 || scrollValue < step4Top)) {
5199                            $('.guidePopup ul li').eq(2).addClass('active').siblings().removeClass('active');
5200                            $('.guidePopup ul li').eq(2).css('zIndex', '2').siblings().css('zIndex', '1');
5201                        } else if(hasStep4 && scrollValue >= step4Top) {
5202                            $('.guidePopup ul li').eq(3).addClass('active').siblings().removeClass('active');
5203                            $('.guidePopup ul li').eq(3).css('zIndex', '2').siblings().css('zIndex', '1');
5204                        } else {
5205                            $('.guidePopup ul li').eq(0).addClass('active').siblings().removeClass('active');
5206                            $('.guidePopup ul li').eq(0).css('zIndex', '2').siblings().css('zIndex', '1');
5207                        }
5208                    }
5209                    
5210                });
5211
5212                $('.guidePopup .guide-menu li').click(function() {
5213                    if($('.guidePopup .guide-wrap').hasClass('moving')) return false;
5214                    var top = ($(this).index())+1,
5215                        $targetStep = $('#step'+top);
5216
5217                    if($targetStep.length === 0) return false;
5218
5219                    $('.guidePopup .guide-wrap').addClass('moving');
5220
5221                    var top_position = (top==1) ? $targetStep.position().top : ($targetStep.position().top)+60;
5222                   
5223                    $('.guidePopup .guide-wrap').animate({scrollTop : top_position}, 1000, 'easeInOutExpo');
5224
5225                    setTimeout(function() {
5226                        $('.guidePopup .guide-wrap').removeClass('moving');
5227                    },1000);
5228
5229                    $(this).addClass('active').siblings().removeClass('active');
5230                    $(this).css('zIndex', '2').siblings().css('zIndex', '1');                    
5231                });
5232            });
5233        }
5234    }
5235
5236    /* Site config - quickmenu ***/    
5237    $.quickmenu = {
5238        init: function(sid,publish,device) {
5239            var result_data = {};
5240            if(PAGE_MODE == 'c' || (PAGE_MODE != 'c' && typeof property != 'undefined')) {
5241                if (PAGE_MODE != 'c' && typeof property != 'undefined' && property && property.QUICKMENU) {
5242                    result_data = property.QUICKMENU;
5243                } else if (typeof QUICKMENU !== 'undefined' && QUICKMENU) {
5244                    result_data = QUICKMENU;
5245                } else {
5246                    result_data = {};
5247                }
5248            }
5249
5250            $.quickmenu['quickmenu'] = result_data || {};
5251            if (Array.isArray($.quickmenu['quickmenu']['visible']) && $.quickmenu['quickmenu']['visible'].length > 0) {
5252                $.quickmenu['quickmenu']['visible'] = $.quickmenu['quickmenu']['visible'].slice();
5253            } else {
5254                $.quickmenu['quickmenu']['visible'] = [];
5255            }
5256
5257            var quickmenu_total_count = parseInt(result_data['total_count'], 10) || 0;
5258
5259            if(quickmenu_total_count!=0) $.quickmenu.setHTML(result_data,device);
5260            else {
5261                result_data = $.quickmenu.add(sid, false) || $.quickmenu['quickmenu'] || result_data;
5262                $.quickmenu.setHTML(result_data,device);
5263            }         
5264        },
5265        get: function(sid,publish) {
5266            var return_data = {};
5267            $.ajax({
5268                type: 'POST',
5269                data: { sid:sid, publish:publish },
5270                dataType: 'json',
5271                url: (CONFIG_URL) ? '/_config/siteConfig/btype/quickmenu/type/get' : '/config/siteConfig/btype/quickmenu/type/get',   
5272                async:false,
5273                success : function(data) {                    
5274                    checkError(data);                 
5275                    return_data = data;
5276                    $.quickmenu['quickmenu'] = return_data;
5277                    if(!Array.isArray($.quickmenu['quickmenu']['visible'])) $.quickmenu['quickmenu']['visible'] = [];
5278                },
5279                error: function(request, status, error){
5280                    console.log("data error");
5281                    
5282                }
5283            }); 
5284
5285            return return_data;
5286        },
5287        setHTML: function(data,device,checkConfig) {
5288            data = data || {};
5289            if(typeof data['sid'] == 'undefined' || !data['sid']) data['sid'] = (typeof SID != 'undefined') ? SID : '';
5290            if(typeof data['list'] == 'undefined' || !data['list']) data['list'] = {};
5291            if(typeof data['img_type'] == 'undefined' || !data['img_type']) data['img_type'] = {};
5292            if(typeof data['img_type_mode'] == 'undefined' || !data['img_type_mode']) data['img_type_mode'] = {};
5293            if(typeof data['img_type'][device] == 'undefined' || !data['img_type'][device]) data['img_type'][device] = (device=='pc') ? 'default' : 'bottom_default';
5294            if(typeof data['total'] == 'undefined' || !data['total']) data['total'] = {};
5295
5296            var site_settings = (typeof property != 'undefined') ? property.SETTINGS : SETTINGS,
5297                quick_hide = (typeof site_settings.qm_onoff != 'undefined' && site_settings.qm_onoff==true) ? '' : 'hide',
5298                quick_str = '',
5299                quick_style = `<style id="quick-menu-${data['sid']}${device}"></style>`,
5300                quick_css = '',
5301                qm_list = {};
5302
5303            qm_list = data['list'];         
5304            var img_type = data['img_type'][device],
5305                img_type_mode = (data['img_type_mode'][device] == 'mixed') ? 'mixed' : 'single',
5306                is_mixed_img_type = (img_type_mode=='mixed' && ((device=='pc' && (img_type=='default' || img_type=='image')) || (device=='mobile' && typeof img_type == 'string' && img_type.indexOf('right_') === 0))),
5307                render_img_types = [],
5308                img_type_total = ($.isEmptyObject(data['total']) || typeof data['total'][device] == 'undefined' || typeof data['total'][device][img_type] == 'undefined') ? {} : data['total'][device][img_type],
5309                m_icon_settings = [],
5310                link = {},
5311                page_mode = (PAGE_MODE=='c') ? 'c' : '';
5312
5313            var parseQuickmenuSetting = function(setting, fallback) {
5314                var base = $.extend({}, fallback);
5315
5316                if(typeof setting == 'object' && setting) return $.extend(base, setting);
5317                if(typeof setting == 'string' && setting) {
5318                    try {
5319                        return $.extend(base, JSON.parse(setting));
5320                    } catch(e) {
5321                        return base;
5322                    }
5323                }
5324
5325                return base;
5326            };
5327
5328            var getQuickmenuImageValue = function(item, key, current_img_type) {
5329                if(typeof item[key] == 'object' && item[key]) return item[key][current_img_type] || '';
5330                if(typeof item[key] == 'string') return item[key];
5331
5332                return '';
5333            };
5334
5335            var default_icon_settings = {
5336                'onoff': 'true',
5337                '--icon-size': '24px',
5338                '--icon-color': '#000000',
5339                '--icon-bgcolor': '',
5340                '--icon-bgblur': '3px'
5341            };
5342            var default_text_settings = {
5343                'onoff': 'true',
5344                '--text-fname': 'Noto Sans',
5345                '--text-fsize': '12px',
5346                '--text-fweight': '400',
5347                '--text-fcolor': '#000000'
5348            };
5349            var getQuickmenuEffectiveVisible = function(render_img_type, visible) {
5350                if(!is_mixed_img_type && device=='pc' && (img_type=='default' || img_type=='image') && render_img_type!=img_type) return 0;
5351                if(!is_mixed_img_type && device=='mobile' && typeof img_type == 'string' && img_type.indexOf('right_') === 0 && render_img_type!=img_type) return 0;
5352
5353                return visible;
5354            };
5355
5356            var getQuickmenuImageSizeMode = function(render_img_type, icon_settings) {
5357                if(render_img_type.indexOf('image') < 0) return 'common';
5358                if(icon_settings && (icon_settings['quick_img_size_mode']=='common' || icon_settings['quick_img_size_mode']=='origin')) return icon_settings['quick_img_size_mode'];
5359
5360                return 'origin';
5361            };
5362
5363            var getQuickmenuSharedQuickSettings = function(render_img_type) {
5364                var shared_key = '',
5365                    shared_settings = {},
5366                    has_shared_settings = false;
5367
5368                if(device=='pc' && (render_img_type=='default' || render_img_type=='image')) shared_key = 'common';
5369                else if(device=='mobile' && (render_img_type=='right_default' || render_img_type=='right_image')) shared_key = 'right_common';
5370
5371                if(shared_key && qm_list[device] && qm_list[device][shared_key] && qm_list[device][shared_key]['quick_settings']) {
5372                    shared_settings = $.extend({}, qm_list[device][shared_key]['quick_settings']);
5373                    has_shared_settings = true;
5374                } else if(qm_list[device] && qm_list[device][img_type] && qm_list[device][img_type]['quick_settings']) {
5375                    shared_settings = $.extend({}, qm_list[device][img_type]['quick_settings']);
5376                }
5377
5378                if(device=='mobile' && (render_img_type=='right_default' || render_img_type=='right_image') && (!has_shared_settings || typeof shared_settings['--quick-align'] == 'undefined')) {
5379                    shared_settings['--quick-align'] = 'center';
5380                }
5381
5382                return shared_settings;
5383            };
5384
5385            var getQuickmenuRenderTypeOrder = function(render_img_type) {
5386                if(!is_mixed_img_type) return 0;
5387                if(render_img_type==img_type) return 0;
5388
5389                if(device=='pc' && (render_img_type=='default' || render_img_type=='image')) return 1;
5390                if(device=='mobile' && (render_img_type=='right_default' || render_img_type=='right_image')) return 1;
5391
5392                return 2;
5393            };
5394
5395            if(device=='pc') {
5396                $.each(['default', 'image'], function(i, pc_img_type) {
5397                    if(typeof qm_list[device] != 'undefined' && typeof qm_list[device][pc_img_type] != 'undefined') render_img_types.push(pc_img_type);
5398                });
5399            } else if(device=='mobile' && typeof img_type == 'string' && img_type.indexOf('right_') === 0) {
5400                $.each(['right_default', 'right_image'], function(i, right_img_type) {
5401                    if(typeof qm_list[device] != 'undefined' && typeof qm_list[device][right_img_type] != 'undefined') render_img_types.push(right_img_type);
5402                });
5403		            }
5404		            if(render_img_types.length < 1) render_img_types.push(img_type);
5405		            var has_render_image_type = false;
5406		            $.each(render_img_types, function(render_i, render_img_type) {
5407		                if(render_img_type.indexOf('image') > -1) {
5408		                    has_render_image_type = true;
5409		                    return false;
5410		                }
5411		            });
5412		            if(has_render_image_type) {
5413		                quick_css += `
5414		                    .quick-menu-${data['sid']}.quickmenu[data-device='${device}'][data-imgtype='${img_type}'] ul {align-items: center;}
5415		                    .quick-menu-${data['sid']}.quickmenu[data-device='${device}'][data-imgtype='${img_type}'] ul > li {align-self: var(--quick-align, center);}
5416		                `;
5417		            }
5418		            var render_items = [];
5419
5420	            $.each(render_img_types, function(render_i, render_img_type) {
5421	                if(typeof qm_list[device] == 'undefined' || typeof qm_list[device][render_img_type] == 'undefined') return true;
5422
5423	                if(typeof qm_list[device][render_img_type]['quick_settings'] == 'undefined' || !qm_list[device][render_img_type]['quick_settings']) {
5424	                    qm_list[device][render_img_type]['quick_settings'] = {};
5425	                }
5426	                qm_list[device][render_img_type]['quick_settings'] = $.extend({}, qm_list[device][render_img_type]['quick_settings']);
5427
5428	                $.each(qm_list[device][render_img_type], function(i,v){
5429	                    if(i=='quick_settings') {
5430	                        var quick_settings_css = $.extend({}, v, getQuickmenuSharedQuickSettings(render_img_type)),
5431	                            quick_size = parseFloat(String(quick_settings_css['--quick-size'] || '').replace(/[^0-9.]/g, '')),
5432	                            quick_roundedge_per = parseFloat(quick_settings_css['--quick-roundedge-per']);
5433
5434	                        if(!isNaN(quick_size) && !isNaN(quick_roundedge_per)) {
5435	                            quick_settings_css['--quick-roundedge-radius'] = Math.round(quick_size * quick_roundedge_per) + 'px';
5436	                        }
5437
5438	                        v_quick_settings = JSON.stringify(quick_settings_css).replace(/\"/gi,'').replace(/px/gi,'px;').replace(/,|;;/gi,';');
5439	                        quick_css += `.quick-menu-${data['sid']}[data-device='${device}'] li[data-imgtype='${render_img_type}'] ${v_quick_settings}`;
5440
5441	                        return true;
5442	                    }
5443
5444	                    render_items.push({
5445	                        'img_type': render_img_type,
5446	                        'index': i,
5447	                        'val': v
5448	                    });
5449	                });
5450		            });
5451
5452		            var has_duplicate_pos = false,
5453		                seen_pos = {};
5454		            $.each(render_items, function(i, render_item) {
5455		                var item_pos = parseInt(render_item.val.pos, 10);
5456		                if(isNaN(item_pos)) return true;
5457		                if(seen_pos[item_pos]) {
5458		                    has_duplicate_pos = true;
5459		                    return false;
5460		                }
5461		                seen_pos[item_pos] = true;
5462		            });
5463
5464		            render_items.sort(function(a, b) {
5465		                var a_type_order = getQuickmenuRenderTypeOrder(a.img_type),
5466		                    b_type_order = getQuickmenuRenderTypeOrder(b.img_type),
5467		                    a_seq = parseInt(a.val.seq, 10),
5468		                    b_seq = parseInt(b.val.seq, 10);
5469		                var a_pos = parseInt(a.val.pos, 10),
5470		                    b_pos = parseInt(b.val.pos, 10);
5471
5472		                if(has_duplicate_pos && a_type_order != b_type_order) return a_type_order - b_type_order;
5473		                if(!isNaN(a_pos) && !isNaN(b_pos) && a_pos != b_pos) return a_pos - b_pos;
5474		                if(!has_duplicate_pos && a_type_order != b_type_order) return a_type_order - b_type_order;
5475		                if(!isNaN(a_seq) && !isNaN(b_seq) && a_seq != b_seq) return a_seq - b_seq;
5476
5477		                return 0;
5478		            });
5479
5480	            quick_str = `
5481	                <div class="quick-menu-${data['sid']} quickmenu ${quick_hide}" data-pagemode="${page_mode}" data-imgtype="${img_type}" data-device="${device}" data-sitepermit="${site_settings.sitePermit}">
5482	                    <ul>`
5483	                    $.each(render_items, function(render_i, render_item) {
5484	                        var render_img_type = render_item.img_type,
5485	                            i = render_item.index,
5486	                            v = render_item.val,
5487	                            link_option_str = '';
5488	                        link = $.quickmenu.setLink(v['link'],v['link_target']);
5489                      
5490                        if(!$.isEmptyObject(link['option'])) link_option_str = `${link['option']['type']}="${link['option']['val']}"`;
5491                      
5492                        v['icon_settings'] = parseQuickmenuSetting(v['icon_settings'], default_icon_settings);
5493                        v['text_settings'] = parseQuickmenuSetting(v['text_settings'], default_text_settings);
5494
5495                        if(render_img_type.indexOf('default') > -1 && device=='mobile') m_icon_settings.push(String(v['icon_settings']['--icon-size'] || '24px').replace(/px/gi,''));
5496                       
5497                        var v_img_key = (device=='pc') ? 'img' : 'img2',
5498                            v_img_width_key = (device=='pc') ? 'img_width' : 'img2_width',
5499                            v_img_height_key = (device=='pc') ? 'img_height' : 'img2_height';
5500
5501                        var quick_settings = JSON.stringify(qm_list[device][render_img_type]['quick_settings']),
5502                            v_img = htmlspecialchars_decode(getQuickmenuImageValue(v, v_img_key, render_img_type), 'ENT_QUOTES'),
5503                            v_noimage = (v_img.indexOf('quickmenu-noimage') > -1) ? 'quickmenu-noimage' : '',
5504                            val_br_text = v['text'],
5505                            v_img_width = (v_noimage) ? ((device=='mobile' && render_img_type=='right_image') ? 64 : 72) : parseFloat(v[v_img_width_key]),
5506                            v_img_height = (v_noimage) ? ((device=='mobile' && render_img_type=='right_image') ? 64 : 72) : parseFloat(v[v_img_height_key]),
5507                            v_img_ratio = (render_img_type.indexOf('image') > -1 && v_img_width > 0 && v_img_height > 0) ? `${v_img_width} / ${v_img_height}` : '1 / 1',
5508                            v_img_size_mode = getQuickmenuImageSizeMode(render_img_type, v['icon_settings']),
5509                            v_origin_size_css = (render_img_type.indexOf('image') > -1 && v_img_size_mode=='origin' && v_img_width > 0) ? `--quick-size: ${v_img_width}px; --quick-roundedge-per: 0; --quick-roundedge-radius: 0px;` : '',
5510                            v_bgblur = v['icon_settings']['--icon-bgblur'] || '3px',
5511                            render_visible = getQuickmenuEffectiveVisible(render_img_type, v['visible']);
5512
5513                        if(render_img_type.indexOf('default') > -1 && typeof isQuickmenuMaterialIconHtml == 'function' && isQuickmenuMaterialIconHtml(v_img)) {
5514                            var v_material_settings = (typeof getQuickmenuMaterialSettings == 'function') ? getQuickmenuMaterialSettings(v['icon_settings'], v_img) : {};
5515                            v['icon_settings'] = $.extend(v['icon_settings'], {
5516                                'material_style': v_material_settings.style || 'outlined',
5517                                '--material-icon-fill': v_material_settings.fill || '0',
5518                                '--material-icon-weight': v_material_settings.weight || '400',
5519                                '--material-icon-grade': v_material_settings.grade || '0',
5520                                '--material-icon-optical-size': v_material_settings.opticalSize || '24'
5521                            });
5522                            if(typeof updateQuickmenuMaterialIconHtml == 'function') v_img = updateQuickmenuMaterialIconHtml(v_img, v['icon_settings']);
5523                        }
5524
5525                        // if(v['text'].indexOf('br') > -1) {
5526                        //     var brRegex = /<br\s*\/?>/gi;
5527                        //     val_text_array = v['text'].split(brRegex);
5528                        //     val_br_text = `${val_text_array[0]}<br />${val_text_array[1]}<br />${val_text_array[2]}`;
5529                        // }
5530
5531                        
5532
5533                            quick_str += `
5534                        <li class="quickmenu-box${(String(render_visible)=="0") ? ' hide' : ''} ${v_noimage}" data-id="${v['seq']}" data-pos="${v['pos']}" data-imgtype="${render_img_type}">
5535                            <a class="quickmenu-alink" href="${link['link']}" target="${link['target']}" ${link_option_str}>
5536                                `;
5537	                    quick_str += (render_img_type.indexOf('default') > -1) ? ((device=='mobile' && render_img_type=='right_default') ? `
5538	                                <span class="quickmenu-default-content">
5539	                                    <span class="quickmenu-icon ${(v['icon_settings']['onoff']=="false") ? 'hide ' : ''}">${v_img}</span>
5540	                                    <span class="quickmenu-text ${(v['text_settings']['onoff']=="false") ? 'hide ' : ''}">${val_br_text}</span>
5541	                                </span>` : `
5542	                                <span class="quickmenu-icon ${(v['icon_settings']['onoff']=="false") ? 'hide ' : ''}">${v_img}</span>
5543	                                <span class="quickmenu-text ${(v['text_settings']['onoff']=="false") ? 'hide ' : ''}">${val_br_text}</span>`)
5544	                                : ((v_img.indexOf('quickmenu-noimage') >
5544 -1) ? `<span class="quickmenu-noimage">${v_img}</span>` : `<img class="quickmenu-img" src="${v_img}"/>`)
5545                    quick_str += `</a>
5546                        </li>
5547	                        `;
5548
5549	                    quick_css += (render_img_type.indexOf('default') > -1) ? `
5550                            .quick-menu-${data['sid']}[data-device='${device}'] li[data-id='${v['seq']}'] .quickmenu-icon {--icon-size: ${v['icon_settings']['--icon-size']}; --icon-color: ${v['icon_settings']['--icon-color']}; --material-icon-fill: ${v['icon_settings']['--material-icon-fill'] || '0'}; --material-icon-weight: ${v['icon_settings']['--material-icon-weight'] || '400'}; --material-icon-grade: ${v['icon_settings']['--material-icon-grade'] || '0'}; --material-icon-optical-size: ${v['icon_settings']['--material-icon-optical-size'] || '24'};}
5551                            .quick-menu-${data['sid']}[data-device='${device}'] li[data-id='${v['seq']}'] a {--icon-size: ${v['icon_settings']['--icon-size']};}
5552                            .quick-menu-${data['sid']}[data-device='${device}'] li[data-id='${v['seq']}'] .quickmenu-text {--text-fname:${v['text_settings']['--text-fname']}; --text-fsize:${v['text_settings']['--text-fsize']}; --text-fweight:${v['text_settings']['--text-fweight']}; --text-fcolor: ${v['text_settings']['--text-fcolor']};}
5553                            .quick-menu-${data['sid']}[data-device='${device}'] li.quickmenu-box[data-id='${v['seq']}'] {--icon-bgcolor: ${v['icon_settings']['--icon-bgcolor']}; --icon-bgblur: ${v_bgblur};}
5554                            .quick-menu-${data['sid']}[data-device='${device}'] li[data-id='${v['seq']}'] svg {--icon-color: ${v['icon_settings']['--icon-color']}; --icon-size: ${v['icon_settings']['--icon-size']};}
5555                            .quick-menu-${data['sid']}.quickmenu[data-device='mobile'] li[data-id='${v['seq']}'][data-imgtype='right_default'] > a.quickmenu-alink {display: flex; flex-direction: column; align-items: center; justify-content: center; width: 100%; height: 100%; gap: 3px; text-align: center;}
5556                            .quick-menu-${data['sid']}.quickmenu[data-device='mobile'] li[data-id='${v['seq']}'][data-imgtype='right_default'] > a.quickmenu-alink > .quickmenu-default-content {display: flex; flex-direction: column; align-items: center; justify-content: center; width: 100%; height: auto; min-height: 0; gap: 3px; flex: 0 0 auto; margin: 0; text-align: center;}
5557                            .quick-menu-${data['sid']}.quickmenu[data-device='mobile'] li[data-id='${v['seq']}'][data-imgtype='right_default'] > a.quickmenu-alink > .quickmenu-icon {display: flex; align-items: center; justify-content: center; width: var(--icon-size); height: var(--icon-size); flex: 0 0 auto; margin: 0;}
5558                            .quick-menu-${data['sid']}.quickmenu[data-device='mobile'] li[data-id='${v['seq']}'][data-imgtype='right_default'] > a.quickmenu-alink > .quickmenu-text {display: block; width: calc(var(--quick-size) - 20px); height: auto; line-height: 1.4; flex: 0 0 auto; margin: 0;}
5559                            .quick-menu-${data['sid']}.quickmenu[data-device='mobile'] li[data-id='${v['seq']}'][data-imgtype='right_default'] .quickmenu-default-content > .quickmenu-icon {display: flex; align-items: center; justify-content: center; width: var(--icon-size); height: var(--icon-size); flex: 0 0 auto; margin: 0;}
5560                            .quick-menu-${data['sid']}.quickmenu[data-device='mobile'] li[data-id='${v['seq']}'][data-imgtype='right_default'] .quickmenu-default-content > .quickmenu-text {display: block; width: calc(var(--quick-size) - 20px); height: auto; line-height: 1.4; flex: 0 0 auto; margin: 0;}
5561	                        ` : `
5562                            .quick-menu-${data['sid']}[data-device='${device}'] li[data-id='${v['seq']}'][data-imgtype='${render_img_type}'] {--quick-img-ratio: ${v_img_ratio}; ${v_origin_size_css}}
5563                            .quick-menu-${data['sid']}[data-device='${device}'] li[data-id='${v['seq']}'][data-imgtype='${render_img_type}'] img.quickmenu-img {width: 100%; height: 100%; object-fit: cover;}
5564                        `;
5565	                    });
5566
5567	                    // quick_css += (img_type.indexOf('default') > -1 && device=='mobile') ? `
5568                    //     .quick-menu-${data['sid']}.quickmenu[data-imgtype="bottom_default"][data-device='mobile'] {--order-nav: ${Object.keys(img_type_total).length};}` : '';
5569                    quick_str += `</ul>`;
5570
5571                //quick_str += (device == 'pc') ? '' : `<div class="bg-nowrap-btn next"></div>`;
5572                quick_str +=  `</div>`;
5573                
5574
5575            var selector = (device=='pc') ? '' : ' .quickmenu_viewer',
5576                screen_device = ($('body').width() > 768) ? 'pc' : 'mobile';
5577
5578            $(`style#quick-menu-${data['sid']}${device}`).remove();
5579
5580
5581            $('body').prepend($(quick_style).prop('outerHTML'));    
5582            $(`#quick-menu-${data['sid']}${device}`).append(quick_css);              
5583            $(`.sc-quickmenu${selector} .quick-menu-${data['sid']}`).remove();            
5584
5585            $(`.sc-quickmenu${selector}`).append(quick_str);
5586
5587            if(checkConfig !='c' || device == screen_device) {
5588                $(`.el-footer`).siblings(`.quick-menu-${data['sid']}`).remove();         
5589                $('.el-footer').after(quick_str);
5590                $(`.el-footer`).siblings(`.quick-menu-${data['sid']}`).removeClass('non_config').addClass('non_config');
5591                
5592                
5593                if(PAGE_MODE=='c') {
5594                    $('.quickmenu-hover-buffer').remove();
5595                    $('.el_quickmenu_ctrl').remove();
5596                    $(`.quick-menu-${data['sid']}`).before('<div class="quickmenu-hover-buffer"></div>');
5597                    $('.quickmenu-hover-buffer').before(`<div class="el_quickmenu_ctrl config-element-section" style="display:none;"><div class="config-element" data-toggle="tooltip" data-original-title="${$.lang[LANG]['config.label.qm_settings']}"><svg viewBox="0 0 19 19" width="23" height="23"><path d="M17.16 8.16l1.41-1.51c-0.2-0.65-0.48-1.28-0.84-1.9 -0.35-0.61-0.77-1.17-1.23-1.67l-2.02 0.46c-0.7-0.58-1.48-1.03-2.32-1.34l-0.61-1.97C10.9 0.08 10.21 0 9.5 0 8.79 0 8.1 0.08 7.44 0.22L6.83 2.2h0C5.98 2.51 5.19 2.97 4.51 3.54L2.5 3.08c-0.46 0.5-0.87 1.06-1.23 1.67S0.64 6 0.44 6.65l1.4 1.52c-0.16 0.89-0.15 1.8 0 2.68l-1.41 1.51c0.2 0.65 0.48 1.28 0.84 1.9s0.77 1.17 1.23 1.67l2.02-0.46c0.7 0.58 1.48 1.03 2.32 1.34l0.61 1.97v0C8.1 18.92 8.79 19 9.5 19c0.71 0 1.4-0.08 2.06-0.22l0.61-1.97c0.85-0.31 1.63-0.77 2.32-1.34l2.01 0.46c0.46-0.5 0.87-1.06 1.23-1.67 0.35-0.61 0.63-1.25 0.84-1.9l-1.4-1.52C17.31 9.94 17.31 9.04 17.16 8.16zM9.5 15.5c-3.31 0-6-2.69-6-6s2.69-6 6-6 6 2.69 6 6S12.81 15.5 9.5 15.5z"/></svg></div></div>`);
5598                
5599                    updateQuickmenuHoverBuffer();
5600                }
5601            } 
5602            
5603            setTimeout(() => {
5604                if(device=='mobile' && img_type=='bottom_default') {
5605                    var mobile_bottom_height = $(`.quick-menu-${data['sid']}.quickmenu[data-device="mobile"] ul`).height(),
5606                        body_width = (checkConfig !='c' || device == screen_device) ? $('body').width() : 279,
5607                        quick_li_width = 0;
5608  
5609                    $.each($(`.quick-menu-${data['sid']}.quickmenu[data-device="mobile"] ul li`), function(s,q) {
5610                        quick_li_width += $(this).innerWidth();
5611                    })
5612                    
5613                    if(quick_li_width <= body_width) {
5614                        $('.bg-nowrap-btn').remove();
5615                        $(`.quick-menu-${data['sid']}.quickmenu[data-device="mobile"]`).removeClass('width100').addClass('width100');
5616                    } else {
5617                        $(`.quick-menu-${data['sid']}.quickmenu[data-device="mobile"]`).append('<div class="bg-nowrap-btn"></div>');
5618                        $(`.quick-menu-${data['sid']}.quickmenu[data-device="mobile"]`).find('.bg-nowrap-btn').css('height',mobile_bottom_height);
5619                    }
5620                }
5621            }, 500);
5622            
5623                       
5624        },
5625        setLink: function(org_link,org_ltarget) {
5626            var link = (typeof org_link == 'string' && org_link != 'javascript:;' && org_link.length > 0) ? org_link : 'javascript:;',
5627                link_target = (typeof org_ltarget != 'undefined' && (org_ltarget == '1' || org_ltarget == 'ON')) ? '_blank' : '',
5628                link_option = {};
5629
5630            // Keep previously saved phone links usable even when an empty last
5631            // input caused the old editor to append a trailing hyphen.
5632            if(/^tel:/i.test(link)) link = link.replace(/-+$/g, '');
5633
5634            if(link != '' && link != 'javascript:;') {
5635                var _menuList = (PAGE_MODE == 'c') ? MENULIST : property.MENULIST;
5636            
5637                if(link.match(/^\@/g) !== null) {                                                  // link-type: link-bookmark ==> a[attr-bookmark]
5638                    var _settings = (PAGE_MODE == 'c') ? SETTINGS : property.SETTINGS,
5639                        bookmark_seq = link.replace(/^\@/g,'');
5640                        
5641                    if(typeof _settings == 'undefined' || typeof _settings.blockBookmarkList == 'undefined' || _settings.blockBookmarkList['bookmark' + bookmark_seq] == 'undefined') {
5642                        link = '';
5643                        link_option = {};
5644                    } else {
5645                        link_option = {
5646                            'type' : 'attr-bookmark',
5647                            'val' : bookmark_seq
5648                        }
5649                    }
5650                } else if(link.match(/^flink\@[0-9]/gi) !== null) {           
5651                    link_option = {
5652                        'type' : 'attr-flink',
5653                        'val' : link.replace(/^flink\@/gi,'')
5654                    }                     // link-type: link-file     ==> a[attr-flink]                   
5655                    link_target = '';
5656                } else if(_menuList.indexOf(link.replace(/^\//g,"").replace(/ /g,"-")) > -1) {     // link-type: link-menu     ==> a[data-user-link]
5657                    link_option = {
5658                        'type' : 'data-user-link',
5659                        'val' : link
5660                    }
5661                } else {   
5662                    link_option = {
5663                        'type' : 'attr-link',
5664                        'val' : link
5665                    }                                                                         // link-type: link-out      ==> a[attr-link]
5666                }
5667
5668                link = (PAGE_MODE == 'c') ? makeLinkUrl(link, ONE, VIEW) : makeLinkUrl(link, property.ONE, property.VIEW);
5669            }
5670         
5671            return {'link':link, 'target':link_target, 'option':link_option};
5672        },
5673        getCss: function(sid, device) {
5674            let quickmenuCss;
5675
5676            var quick_css = ($(`#quick-menu-${sid}${device}`).text()) ? $(`#quick-menu-${sid}${device}`).text().trim() : '';
5677            quickmenuCss = CSSJSON.toJSON(quick_css);
5678
5679            return quickmenuCss;
5680        },
5681        add: function(sid, publish) {
5682            var return_data = {};
5683
5684            $.ajax({
5685                type: 'POST',
5686                data: { sid:sid, publish:publish, data: $.quickmenu['quickmenu'], sample: true},
5687                dataType: 'json',
5688                url: (CONFIG_URL) ? '/_config/siteConfig/btype/quickmenu/type/add' : '/config/siteConfig/btype/quickmenu/type/add',
5689                async:false,
5690                success : function(data) {
5691                    checkError(data);
5692                    return_data = data;
5693                    $.quickmenu['quickmenu'] = return_data;
5694                },
5695                error: function(request, status, error){
5696                    console.log(error);
5697                    console.log("data error");
5698                }
5699            });
5700
5701            return return_data;
5702        },
5703        getSetting: function(tag) {
5704            var data_obj = $(tag).data(),
5705                obj_etc = ['link','target','visible','name','imgtype'],
5706                settings_obj = {};
5707
5708            $.each(data_obj, function(i,v){
5709                var key_icon = (obj_etc.includes(i)) ? i : `--icon-${i}`;
5710                settings_obj[key_icon] = v;
5711            });
5712
5713            return settings_obj;
5714        },
5715        setCss: function(sid, device, seq, target, css_val, img_type) {
5716            var quick_imgtype = (typeof img_type != 'undefined' && img_type) ? img_type : $.quickmenu['quickmenu']['img_type'][device];
5717
5718            if(target=='quick_settings') $.quickmenu['quickmenu']['list'][device][quick_imgtype]['quick_settings'] = css_val;
5719            else $.quickmenu['quickmenu']['list'][device][quick_imgtype][seq][target] = css_val;
5720        }
5721    }
5722
5723    $.siteBanner = {
5724        checkOffer: function(type) {
5725            // console.log(`$.siteBanner.checkOffer(type ${type})`);
5726            var checkPlan = (typeof VALIDPLAN == 'undefined') ? property.VALIDPLAN : VALIDPLAN,
5727                checkPlanType = (typeof VALIDTYPE == 'undefined') ? property.VALIDTYPE : VALIDTYPE;
5728            if(!checkPlan || checkPlanType == 'PK') {
5729                return false;
5730            }
5731
5732            var site_settings = (typeof property != 'undefined') ? property.SETTINGS : SETTINGS
5733            $.siteBanner.sid = (typeof property != 'undefined') ? property.SID : SID;
5734            if(typeof $.siteBanner.sid == 'undefined' || !$.siteBanner.sid || typeof site_settings == 'undefined' || !site_settings) {
5735                return false;
5736            }
5737
5738            if(type == 'popup') {
5739                if(site_settings.SITELOCK) return false;
5740
5741                var tmp_view = (PAGE_MODE == 'c') ? VIEW : ((typeof property != 'undefined') ? property.VIEW : ''),
5742                    tmp_one = (PAGE_MODE == 'c') ? ONE : ((typeof property != 'undefined') ? property.ONE : ''),
5743                    tmp_page  = (PAGE_MODE == 'c') ? PAGE : ((typeof property != 'undefined') ? property.PAGE : ''),
5744                    tmp_menu  = (PAGE_MODE == 'c') ? MENULINK[0] : ((typeof property != 'undefined') ? property.MENULINK[0] : ''),
5745                    tmp_clpage = ($('div:is(.element.cl-s-page, .psearch-view)').length > 0) ? true : false,
5746                    checkFirstPage = (!tmp_view && !tmp_clpage && (tmp_one || !tmp_one && tmp_page == tmp_menu)) ? true : false;
5747
5748                if(!checkFirstPage) return false;
5749            }
5750
5751            return true;
5752        },
5753        getBannerCookieName: function(type, id, viewType) {
5754            var bannerName = $.siteBanner.sid + (type.charAt(0).toUpperCase() + type.slice(1)) + 'Banner';
5755            if(type == 'band' || (type == 'popup' && viewType == 'slide')) return bannerName;
5756            return bannerName + id;
5757        },
5758	        clearCloseCookie: function(type) {
5759	            // console.log(`$.siteBanner.clearCloseCookie(type ${type})`);
5760	            var isBoth = (typeof type == 'undefined') ? true : false,
5761	                isBand = (isBoth || !isBoth && type == 'band') ? true : false,
5762	                isPopup = (isBoth || !isBoth && type == 'popup') ? true : false;
5763
5764            if(isBand) {
5765                var band_id = $.siteBanner.sid + 'BandBanner';
5766                $.removeCookie(band_id, { path : '/' });
5767            }
5768            if(isPopup) {
5769                var popup_name = $.siteBanner.sid + 'PopupBanner';
5770                $.removeCookie(popup_name, { path : '/' });
5771                if(typeof $.siteBanner.popup != 'undefined' && typeof $.siteBanner.popup.list != 'undefined') {
5772                    $.each($.siteBanner.popup.list, function(id,o) {
5773                        var popup_id = $.siteBanner.sid + 'PopupBanner' + id;
5774                        $.removeCookie(popup_id, { path : '/' });
5775                    });
5776	                }
5777	            }
5778	        },
5779	        getCssColorValue: function(color, fallback) {
5780	            color = color || fallback || '#000000';
5781	            if(typeof Coloris != 'undefined' && typeof Coloris.getColorRegex == 'function' && Coloris.getColorRegex().test(color)) {
5782	                return Coloris.getColorInfo(color, 'rgba');
5783	            }
5784
5785	            return color;
5786	        },
5787	        doNotOffer: function(type,isSC) {
5788	            // console.log(`[siteBanner_step_END (off) /5] $.siteBanner.doNotOffer(type ${type},isSC ${isSC})`);
5789	            if(isSC) $.siteBanner.clearCloseCookie(type);
5790
5791            var isBoth = (typeof type == 'undefined') ? true : false,
5792                isBand = (isBoth || !isBoth && type == 'band') ? true : false,
5793                isPopup = (isBoth || !isBoth && type == 'popup') ? true : false;
5794
5795            if(isBand) {
5796                $.siteBanner.stopBandRolling();
5797
5798                $('body, .cl-bandBanner').removeClass('openBandBanner');
5799                $('.cl-bandBanner, .el-menu_ctrl, .header.el-menu > header').removeInlineCss('margin-top');
5800                document.querySelector('body').style.setProperty('--bandBanner-height-pc', null, null);
5801                document.querySelector('body').style.setProperty('--bandBanner-height-mobile', null, null);
5802                if($('.dsgn-body').hasClass('sidebar')) $('.dsgn-body').removeInlineCss('padding-top');
5803                $('.cl-bandBanner').remove();
5804                $('.element[data-type="gallery"][data-type2="premium"]').refreshRootCss();
5805
5806                $.fheader.position();
5807                $.clnav.setRootcss();
5808            }
5809            if(isPopup) {
5810                $.siteBanner.stopPopupSlideRolling();
5811                $('body, .cl-popupBanner').removeClass('openPopupBanner');
5812                $('.cl-popupBanner').remove();
5813            }
5814        },
5815        init: function(checkBand,checkPopup) {
5816            // console.log(`[siteBanner_step_1 /5] $.siteBanner.init(checkBand ${checkBand},checkPopup ${checkPopup})`);
5817
5818            if(checkBand) $.siteBanner.call('band',false,true,true,true);
5819            if(checkPopup) $.siteBanner.call('popup',false,true,true,true);
5820
5821            if(typeof property == 'undefined') {
5822                $(document).on('mouseenter', '.cl-bandBanner, .cl-popupBanner', function() {
5823                    if(isEDIT) return;
5824                    else outElementButtonDisplay();
5825                });
5826            }
5827
5828            $(document).on('mouseenter', '.cl-bandBanner', function() {
5829                $.siteBanner.band.paused = true;
5830            }).on('mouseleave', '.cl-bandBanner', function() {
5831                $.siteBanner.band.paused = false;
5832            });
5833
5834            $(document).off('click', '.cl-bandBanner .banner-body > a, .cl-popupBanner .banner-body > a')
5835                       .on('click', '.cl-bandBanner .banner-body > a, .cl-popupBanner .banner-body > a', function() {
5836                if($(this).is('[href="javascript:;"]') || $(this).hasClass('clicked')) return false;
5837                var $clicked = $(this);
5838                $clicked.addClass('clicked');
5839
5840                setTimeout(function() {
5841                    $clicked.removeClass('clicked');
5842                }, 3000);
5843            });
5844
5845            $(document).on('click','.cl-bandBanner .banner-closetoday,\
5846                                    .cl-bandBanner .banner-close,\
5847                                    .cl-popupBanner .banner-closetoday,\
5848                                    .cl-popupBanner .banner-close', function() {
5849	                var bannerEL = $(this).closest('.banner-box'),
5850	                    banner_id = bannerEL.attr('id'),
5851	                    banner_type = bannerEL.attr('data-type'),
5852	                    banner_closetime = bannerEL.attr('data-closetime'),
5853	                    clickBtn = $(this),
5854	                    isCloseToday = $(this).is('.banner-closetoday'),
5855	                    banner_render_view_type = (banner_type == 'popup' && typeof $.siteBanner.popup != 'undefined') ? ($.siteBanner.popup.render_view_type || $.siteBanner.popup.view_type || 'individual') : '',
5856	                    date = new Date();
5857                if(banner_type == 'band' && !clickBtn.closest('.banner-header').find('.banner-closetoday').hasClass('hide')) isCloseToday = true;
5858
5859                var time_val = {
5860                    'always'    : 0,
5861                    'onlyone'   : 365 * 24 * 60 * 60 * 1000,
5862                    'week'      : 7 * 24 * 60 * 60 * 1000, 
5863                    'day'       : 24 * 60 * 60 * 1000, 
5864                    '12hours'    : 12 * 60 * 60 * 1000, 
5865                    '6hours'     : 6 * 60 * 60 * 1000, 
5866                    '2hours'     : 2 * 60 * 60 * 1000, 
5867                    '1hours'     : 60 * 60 * 1000, 
5868                    '30min'     : 30 * 60 * 1000, 
5869                    '10min'     : 10 * 60 * 1000, 
5870                    '3min'      : 3 * 60 * 1000,
5871                };
5872
5873                if(isCloseToday) date.setTime(date.getTime() + time_val['day']);
5874                else date.setTime(date.getTime() + time_val[banner_closetime]);
5875
5876                if(banner_type == 'band') {
5877                    $.siteBanner.stopBandRolling();
5878                    banner_id = banner_id.replace(/BandBanner[0-9]+$/,'BandBanner');
5879                }
5880
5881		                if(banner_type == 'popup' && banner_render_view_type == 'slide') {
5882	                    var $popupModal = clickBtn.closest('.banner-modal'),
5883	                        $popupBanner = clickBtn.closest('.cl-popupBanner'),
5884	                        $popupItems = $popupModal.find('> ul > li.banner-box:not(.hide)'),
5885	                        popupTotal = $popupItems.length;
5886
5887	                    $.siteBanner.stopPopupSlideRolling('.cl-popupBanner');
5888	                    $popupItems.addClass('hide');
5889	                    $popupModal.find('.banner-slide-arrow').addClass('hide');
5890	                    $popupModal.find('.banner-slide-pagination').addClass('hide').empty();
5891	                    $popupBanner.removeClass('openPopupBanner').addClass('hide');
5892	                    $('body').removeClass('openPopupBanner');
5893
5894	                    if(isCloseToday || (typeof banner_closetime != 'undefined' && banner_closetime != 'always' && banner_closetime != '')) {
5895	                        $.cookie($.siteBanner.getBannerCookieName('popup', '', 'slide'), true, { path: '/', expires: date});
5896	                    }
5897
5898	                    $.siteBanner.popup.total = Math.max(Number($.siteBanner.popup.total || popupTotal) - popupTotal, 0);
5899	                    return;
5900	                }
5901
5902	                $('#'+banner_id).addClass('hide');
5903	                if(isCloseToday || (typeof banner_closetime != 'undefined' && banner_closetime != 'always' && banner_closetime != '')) {
5904	                    $.cookie(banner_id, true, { path: '/', expires: date});
5905	                }
5906	                $.siteBanner[banner_type].total--;
5907	                if(banner_type == 'popup') {
5908	                    var $popupBanner = clickBtn.closest('.cl-popupBanner'),
5909	                        popupRemain = $popupBanner.find('> .banner-modal > ul > li.banner-box:not(.hide)').length;
5910
5911	                    if(popupRemain < 1 || $.siteBanner.popup.total < 1) {
5912	                        $popupBanner.removeClass('openPopupBanner').addClass('hide');
5913	                        $('body').removeClass('openPopupBanner');
5914	                    }
5915	                }
5916	                if(banner_type == 'band') {
5917	                    $.siteBanner.band.used = false;
5918	                    $.siteBanner.call('band',false,false,true,true);
5919	                }
5920            });
5921	        },
5922
5923	        isPopupSlidePublishableItem: function(item) {
5924	            var period = null,
5925	                periodChk = false,
5926	                periodLabel = '';
5927
5928	            if(!item || item.visible != 'ON') return false;
5929
5930	            period = item.period || {};
5931	            periodChk = (period.chk === true || period.chk == 1 || period.chk == '1');
5932	            periodLabel = String(period.label || '');
5933	            if(!periodChk && (period.visible === false || period.visible == 'false' || periodLabel !== '')) return false;
5934
5935	            return true;
5936	        },
5937
5938	        getPopupRenderableViewType: function(type) {
5939	            var viewType = (type == 'popup' && typeof $.siteBanner[type] != 'undefined') ? ($.siteBanner[type].view_type || 'individual') : 'individual',
5940	                count = 0,
5941	                list = (type == 'popup' && $.siteBanner[type]) ? $.siteBanner[type].list : null,
5942	                sort = (type == 'popup' && $.siteBanner[type]) ? $.siteBanner[type].sort : null;
5943
5944	            if(type != 'popup' || viewType != 'slide' || !list || !sort || typeof sort.length == 'undefined') return viewType;
5945
5946	            $.each(sort, function(idx, id) {
5947	                var item = list[id];
5948
5949	                if(!$.siteBanner.isPopupSlidePublishableItem(item)) return true;
5950	                count++;
5951	            });
5952
5953	            return (count > 1) ? viewType : 'individual';
5954	        },
5955
5956		        call: function(type,isSC,isGet,isSet,isPosition) {
5957	            // console.log(`[siteBanner_step_2 /5] $.siteBanner.call(type ${type}, isSC ${isSC}, isGet ${isGet}, isSet ${isSet}, isPosition ${isPosition})`);
5958	            var parentDocument = $(window.parent.document),
5959	                $detail_modal = parentDocument.find('.product-detail-modal');
5960	            if($detail_modal.length) return false;
5961	            var isOffer = $.siteBanner.checkOffer(type);
5962	            if(!isSC && !isOffer) {
5963	                $.siteBanner.doNotOffer(type,isSC);
5964	                return false;
5965	            }
5966
5967	            var isBand = (type == 'band') ? true : false,
5968	                isPopup = (type == 'popup') ? true : false,
5969	                banner_fn_obj = {'call':false, 'get':false, 'set':false, 'position':false},
5970	                deferredCall = $.Deferred();
5971
5972            if(isBand) {
5973                if(typeof $.siteBanner.band == 'undefined') $.siteBanner.band = {'seqs':[], 'paused':false};
5974                else $.siteBanner.stopBandRolling();
5975
5976                $.siteBanner.band.body = ($.inArray(PAGE_MODE, ['s','r']) > -1) ? window : '.dsgn-body';
5977                if($('html').is('._scroll')) $.siteBanner.band.body = window;
5978                if(isSC) {
5979                    var band_fn = banner_fn_obj;
5980                    if( typeof $.siteBanner.band != 'undefined' && 
5981                        typeof $.siteBanner.band.fn != 'undefined' &&
5982                        typeof $.siteBanner.band.fn_keep != 'undefined'
5983                    ) {
5984                        band_fn = $.siteBanner.band.fn;
5985                        delete $.siteBanner.band.fn_keep;
5986                    }
5987                    $.siteBanner.band.fn = band_fn;
5988                }
5989            }
5990            if(isPopup) {
5991                if(typeof $.siteBanner.popup == 'undefined') $.siteBanner.popup = {};
5992                if(isSC) {
5993                    var popup_fn = banner_fn_obj;
5994                    if( typeof $.siteBanner.popup != 'undefined' && 
5995                        typeof $.siteBanner.popup.fn != 'undefined' &&
5996                        typeof $.siteBanner.popup.fn_keep != 'undefined'
5997                    ) {
5998                        popup_fn = $.siteBanner.popup.fn;
5999                        delete $.siteBanner.popup.fn_keep;
6000                    }
6001                    $.siteBanner.popup.fn = popup_fn;
6002                }
6003            }
6004
6005	            var step1 = $.siteBanner.get(type,isSC,isGet);
6006	            step1.done(function() {
6007	                var step2 = $.siteBanner.set(type,isSC,isSet);
6008	                step2.done(function() {
6009	                    if($.siteBanner[type].used) {
6010	                        var step3 = $.siteBanner.position(type,isSC,isPosition);
6011	                        step3.done(function(step3_r) {
6012	                            fixedConfigBtn();
6013
6014	                            setTimeout(function() {
6015	                                $.clnav.setRootcss();
6016	                            }, 500);
6017	                            deferredCall.resolve();
6018	                        }).fail(function(step3_error) {
6019	                            deferredCall.reject(step3_error);
6020	                        });
6021	                    } else {
6022	                        deferredCall.resolve();
6023	                    }
6024	                }).fail(function(step2_error) {
6025	                    deferredCall.reject(step2_error);
6026	                });
6027	            }).fail(function(step1_error) {
6028	                deferredCall.reject(step1_error);
6029	            });
6030
6031	            return deferredCall.promise();
6032	        },
6033
6034        get: function(type,isSC,isGet) {
6035            // console.log(`[siteBanner_step_3 /5] $.siteBanner.get(type ${type}, isSC ${isSC}, isGet ${isGet})`);
6036            var deferred01 = $.Deferred(),
6037                isBand = (type == 'band') ? true : false,
6038                isPopup = (type == 'popup') ? true : false,
6039                publish = (typeof property != 'undefined') ? property.PUBLISH : false;
6040
6041            if(!isGet) deferred01.resolve();
6042            else {
6043                if(PAGE_MODE == 'c'){ // config(사이트편집)
6044                    $.post('/template/siteBanner/type/get',{ publish:publish, sid:$.siteBanner.sid, v:type }, function(data) {
6045                        checkError(data);
6046                        if(typeof data == 'object') {
6047                            $.siteBanner[type]['sort'] = data.sort;
6048                            $.siteBanner[type]['list'] = data.list;
6049                            $.siteBanner[type]['used'] = data.used;
6050                            $.siteBanner[type]['total'] = data.sort.length;
6051                            $.siteBanner[type]['close_time'] = data.close_time;
6052                            $.siteBanner[type]['close_today'] = data.close_today;
6053    
6054                            if(isBand) {
6055                                $.siteBanner[type]['close_onoff'] = data.close_onoff;
6056                                $.siteBanner[type]['interval'] = data.interval;
6057                            }
6058                            if(isPopup) {
6059                                $.siteBanner[type]['position'] = data.position;
6060                                $.siteBanner[type]['radius'] = data.radius;
6061                                $.siteBanner[type]['close_btn'] = data.close_btn;
6062                                $.siteBanner[type]['btn_style'] = data.btn_style;
6063                                $.siteBanner[type]['btn_color'] = data.btn_color;
6064                                $.siteBanner[type]['bg_layer'] = data.bg_layer;
6065                                $.siteBanner[type]['bg_color'] = data.bg_color;
6066	                                $.siteBanner[type]['view_type'] = data.view_type;
6067	                                $.siteBanner[type]['slide_auto'] = data.slide_auto;
6068	                                $.siteBanner[type]['slide_speed'] = data.slide_speed;
6069	                                $.siteBanner[type]['slide_move_time'] = data.slide_move_time;
6070	                                $.siteBanner[type]['slide_stop_time'] = data.slide_stop_time;
6071	                                $.siteBanner[type]['slide_size_origin'] = data.slide_size_origin;
6072                                $.siteBanner[type]['slide_size_width'] = data.slide_size_width;
6073                                $.siteBanner[type]['slide_arrow'] = data.slide_arrow;
6074	                                $.siteBanner[type]['slide_arrow_style'] = data.slide_arrow_style || '1';
6075	                                $.siteBanner[type]['slide_arrow_size'] = data.slide_arrow_size || '64';
6076                                $.siteBanner[type]['slide_arrow_color'] = data.slide_arrow_color;
6077	                                $.siteBanner[type]['slide_arrow_bg_color'] = data.slide_arrow_bg_color;
6078	                                $.siteBanner[type]['slide_pagination_display'] = data.slide_pagination_display;
6079	                                $.siteBanner[type]['slide_pagination'] = data.slide_pagination;
6080	                                $.siteBanner[type]['slide_pagination_style'] = data.slide_pagination_style || ((data.slide_pagination == 'dot') ? '1' : '11');
6081	                                $.siteBanner[type]['slide_pagination_align'] = data.slide_pagination_align;
6082	                                $.siteBanner[type]['slide_pagination_size'] = data.slide_pagination_size || '52';
6083	                                $.siteBanner[type]['slide_pagination_color'] = data.slide_pagination_color;
6084	                                $.siteBanner[type]['slide_pagination_active_color'] = data.slide_pagination_active_color;
6085                            }
6086                            deferred01.resolve();
6087                        } else {
6088                            deferred01.reject('get error');
6089                        }
6090                    }, 'json');
6091
6092                }else{ // render / site
6093                    // console.log(RENDER.b);
6094                    if(isBand && RENDER.b.BAND != '') {
6095                        $.siteBanner['band']['close_onoff'] = RENDER.b.BAND.close_onoff;
6096                        $.siteBanner['band']['interval'] = RENDER.b.BAND.interval;
6097                        $.siteBanner['band']['sort'] = RENDER.b.BAND.sort;
6098                        $.siteBanner['band']['list'] = RENDER.b.BAND.list;
6099                        $.siteBanner['band']['used'] = RENDER.b.BAND.used;
6100                        $.siteBanner['band']['total'] = RENDER.b.BAND.sort.length;
6101                        $.siteBanner['band']['close_time'] = RENDER.b.BAND.close_time;
6102                        $.siteBanner['band']['close_today'] = RENDER.b.BAND.close_today;
6103                    }
6104                    if(isPopup && RENDER.b.POPUP != '') {
6105                        $.siteBanner['popup']['position'] = RENDER.b.POPUP.position;
6106                        $.siteBanner['popup']['sort'] = RENDER.b.POPUP.sort;
6107                        $.siteBanner['popup']['list'] = RENDER.b.POPUP.list;
6108                        $.siteBanner['popup']['used'] = RENDER.b.POPUP.used;
6109                        $.siteBanner['popup']['total'] = RENDER.b.POPUP.sort.length;
6110                        $.siteBanner['popup']['close_time'] = RENDER.b.POPUP.close_time;
6111                        $.siteBanner['popup']['close_today'] = RENDER.b.POPUP.close_today;
6112                        $.siteBanner['popup']['radius'] = RENDER.b.POPUP.radius;
6113                        $.siteBanner['popup']['close_btn'] = RENDER.b.POPUP.close_btn;
6114                        $.siteBanner['popup']['btn_style'] = RENDER.b.POPUP.btn_style;
6115                        $.siteBanner['popup']['btn_color'] = RENDER.b.POPUP.btn_color;
6116                        $.siteBanner['popup']['bg_layer'] = RENDER.b.POPUP.bg_layer;
6117                        $.siteBanner['popup']['bg_color'] = RENDER.b.POPUP.bg_color;
6118	                        $.siteBanner['popup']['view_type'] = RENDER.b.POPUP.view_type;
6119	                        $.siteBanner['popup']['slide_auto'] = RENDER.b.POPUP.slide_auto;
6120	                        $.siteBanner['popup']['slide_speed'] = RENDER.b.POPUP.slide_speed;
6121	                        $.siteBanner['popup']['slide_move_time'] = RENDER.b.POPUP.slide_move_time;
6122	                        $.siteBanner['popup']['slide_stop_time'] = RENDER.b.POPUP.slide_stop_time;
6123	                        $.siteBanner['popup']['slide_size_origin'] = RENDER.b.POPUP.slide_size_origin;
6124                        $.siteBanner['popup']['slide_size_width'] = RENDER.b.POPUP.slide_size_width;
6125                        $.siteBanner['popup']['slide_arrow'] = RENDER.b.POPUP.slide_arrow;
6126	                        $.siteBanner['popup']['slide_arrow_style'] = RENDER.b.POPUP.slide_arrow_style || '1';
6127	                        $.siteBanner['popup']['slide_arrow_size'] = RENDER.b.POPUP.slide_arrow_size || '64';
6128                        $.siteBanner['popup']['slide_arrow_color'] = RENDER.b.POPUP.slide_arrow_color;
6129	                        $.siteBanner['popup']['slide_arrow_bg_color'] = RENDER.b.POPUP.slide_arrow_bg_color;
6130	                        $.siteBanner['popup']['slide_pagination_display'] = RENDER.b.POPUP.slide_pagination_display;
6131	                        $.siteBanner['popup']['slide_pagination'] = RENDER.b.POPUP.slide_pagination;
6132	                        $.siteBanner['popup']['slide_pagination_style'] = RENDER.b.POPUP.slide_pagination_style || ((RENDER.b.POPUP.slide_pagination == 'dot') ? '1' : '11');
6133	                        $.siteBanner['popup']['slide_pagination_align'] = RENDER.b.POPUP.slide_pagination_align;
6134		                        $.siteBanner['popup']['slide_pagination_size'] = RENDER.b.POPUP.slide_pagination_size || '52';
6135	                        $.siteBanner['popup']['slide_pagination_color'] = RENDER.b.POPUP.slide_pagination_color;
6136	                        $.siteBanner['popup']['slide_pagination_active_color'] = RENDER.b.POPUP.slide_pagination_active_color;
6137                    }
6138                    deferred01.resolve();
6139                }
6140                
6141            }
6142
6143            return deferred01.promise();
6144        },
6145        set: function(type,isSC,isSet) {
6146            // console.log(`[siteBanner_step_4 /5] $.siteBanner.set(type ${type}, isSC ${isSC}, isSet ${isSet})`);
6147            var deferred02 = $.Deferred(),
6148                isBand = (type == 'band') ? true : false,
6149                isPopup = (type == 'popup') ? true : false,
6150                onoff = $.siteBanner[type].used;
6151
6152            if(isSet && onoff) {
6153
6154                var CHK_LANG = LANG;
6155                if (typeof PAGE_MODE != 'undefined' && PAGE_MODE=='c' ) {
6156                    if(typeof SLANG != 'undefined' && typeof SLANG.select_code != 'undefined' && SLANG.select_code && SLANG.use_language == 'on') {
6157                        CHK_LANG = (SLANG.select_code == 'ko') ? 'ko' : 'en';
6158                    }
6159                }
6160
6161                var banner_name = $.siteBanner.sid + (type.charAt(0).toUpperCase() + type.slice(1)) + 'Banner',
6162                    b_list = '',
6163                    b_idx = 0, b_show = 0,
6164                    min = [120, 150],
6165                    max = [0, 0],
6166                    sum = [0, 0],
6167		                    popupViewType = (isPopup && typeof $.siteBanner.getPopupRenderableViewType == 'function') ? $.siteBanner.getPopupRenderableViewType(type) : ((isPopup) ? ($.siteBanner[type].view_type || 'individual') : 'individual'),
6168	                    popupSlideSizeOrigin = (isPopup && $.siteBanner[type].slide_size_origin == 'OFF') ? 'OFF' : 'ON',
6169	                    popupSlideSizeWidth = (isPopup) ? Number($.siteBanner[type].slide_size_width || 500) : 0,
6170	                    popupSlideSizeInfo = null,
6171	                    scPreviewDevice = (isSC) ? ($('#el-siteConfig .sc-device-wrap > li.active').attr('data-device') || 'p') : '',
6172	                    isPopupMobileRender = (isPopup && ((isSC && scPreviewDevice == 'm') || (!isSC && $(window).width() <= 767))),
6173	                    popupMobileMaxWidth = 0;
6174	                if(isPopup) $.siteBanner[type].render_view_type = popupViewType;
6175	                if(isPopup && (!popupSlideSizeWidth || popupSlideSizeWidth < 1)) popupSlideSizeWidth = 500;
6176                if(isPopup && popupViewType == 'slide') popupSlideSizeInfo = $.siteBanner.getPopupSli
6176deSizeInfo(type, popupSlideSizeOrigin, popupSlideSizeWidth, isSC);
6177	                if(isPopup && popupViewType != 'slide' && isPopupMobileRender && typeof $.siteBanner.getPopupMobileIndividualMaxWidth == 'function') popupMobileMaxWidth = $.siteBanner.getPopupMobileIndividualMaxWidth(isSC);
6178
6179	                $.each($.siteBanner[type].sort, function(idx,id) {
6180	                    var o = $.siteBanner[type].list[id],
6181	                        isVisible = (o.visible == 'ON') ? true : false;
6182	                        // console.log(o);
6183	                    if(!isSC && o.period.set && o.period.visible === false) isVisible = false;
6184	                    if(!isSC && isVisible || isSC) {
6185	                        var banner_id =  banner_name + id,
6186	                            banner_cookie = $.siteBanner.getBannerCookieName(type, id, popupViewType),
6187	                            isCookie = (typeof $.cookie(banner_cookie) != 'undefined' && $.cookie(banner_cookie)) ? true : false,
6188	                            popupSize = (type == 'popup' && typeof o.size != 'undefined') ? o.size : {},
6189	                            popupSizeOrigin = (popupSize.origin == 'OFF') ? 'OFF' : 'ON',
6190	                            popupSizeWidth = Number(popupSize.width || o.img.pc.width || 0),
6191	                            popupMobileAutoImage = (type == 'popup' && o.img.mobile && o.img.mobile.chk == '1') ? true : false,
6192	                            popupMobileSourceWidth = Number(((popupMobileAutoImage) ? o.img.pc.width : o.img.mobile.width) || o.img.pc.width || 0),
6193	                            popupMobileSourceHeight = Number(((popupMobileAutoImage) ? o.img.pc.height : o.img.mobile.height) || o.img.pc.height || 0),
6194	                            popupPcDisplayWidth = (popupViewType == 'slide' && popupSlideSizeInfo) ? popupSlideSizeInfo.pc.width : ((popupSizeOrigin == 'OFF' && popupSizeWidth > 0) ? popupSizeWidth : Number(o.img.pc.width)),
6195	                            popupMobileDisplayWidth = (popupViewType == 'slide' && popupSlideSizeInfo) ? popupSlideSizeInfo.mobile.width : ((popupSizeOrigin == 'OFF' && popupSizeWidth > 0) ? popupSizeWidth : popupMobileSourceWidth),
6196	                            popupPcDisplayHeight = (popupViewType == 'slide' && popupSlideSizeInfo) ? popupSlideSizeInfo.pc.height : Number(o.img.pc.height),
6197	                            popupMobileDisplayHeight = (popupViewType == 'slide' && popupSlideSizeInfo) ? popupSlideSizeInfo.mobile.height : popupMobileSourceHeight;
6198
6199		                        if(type == 'popup' && popupViewType != 'slide') {
6200		                            if(isPopupMobileRender && popupMobileMaxWidth > 0) {
6201		                                popupMobileDisplayWidth = popupMobileMaxWidth;
6202		                                if(popupMobileSourceWidth > 0 && popupMobileSourceHeight > 0) {
6203		                                    popupMobileDisplayHeight = Math.round(popupMobileDisplayWidth * popupMobileSourceHeight / popupMobileSourceWidth);
6204		                                }
6205		                            } else if(popupSizeOrigin == 'OFF' && popupSizeWidth > 0 && popupMobileSourceWidth > 0 && popupMobileSourceHeight > 0) {
6206		                                popupMobileDisplayHeight = Math.round(popupMobileDisplayWidth * popupMobileSourceHeight / popupMobileSourceWidth);
6207		                            }
6208		                        }
6209
6210	                        b_idx++;
6211	                        if(!isCookie || isSC) {
6212	                            b_show++;
6213
6214	                            if(isVisible) {
6215	                                if(min[0] > popupPcDisplayHeight) min[0] = popupPcDisplayHeight;
6216	                                if(max[0] < popupPcDisplayHeight) max[0] = popupPcDisplayHeight;
6217	                                if(max[1] < popupMobileDisplayHeight) max[1] = popupMobileDisplayHeight;
6218	                                if(type == 'popup') {
6219	                                    sum[0] += popupPcDisplayWidth;
6220	                                    sum[1] += popupMobileDisplayWidth;
6221	                                } else {
6222	                                    sum[0] += Number(o.img.pc.width);
6223	                                    sum[1] += Number(o.img.mobile.width);
6224	                                }
6225	                            }
6226	                        }
6227                        
6228                        var period_label = (o.period.chk == 1) ? '' : o.period.label;
6229                        var banner_label = (isSC) ? '\
6230                                            <ul class="banner-label" data-period-label="'+period_label+'">\
6231                                                <li class="period-start">' + $.lang[LANG]['sc.banner.period.label.start'] + '</li>\
6232                                                <li class="period-end">' + $.lang[LANG]['sc.banner.period.label.end'] + '</li>\
6233                                            </ul>\
6234                            ' : '',
6235                            banner_str = '';
6236                        if(type == 'band') {
6237                            var band_img_arr = [o.img.pc.path, o.img.mobile.path],
6238                                band_img_mobile = (o.img.mobile.chk == '0') ? true : false,
6239                                band_img_root = (isSC) ? ['--scbandBanner-img-pc','--scbandBanner-img-mobile'] : ['--bandBanner-img-pc','--bandBanner-img-mobile'];
6240                            $.each(band_img_arr, function(img_i,img_v) {
6241                                var check_img = $('<img data-id="' + id + '" data-root="' + band_img_root[img_i] + '" data-sc="' + isSC + '"/>').attr('src',img_v);
6242                                check_img.error(function() {
6243                                    var img_id = $(this).attr('data-id'),
6244                                        img_root = $(this).attr('data-root'),
6245                                        checkSC = $(this).attr('data-sc'),
6246                                        img_s = (checkSC == 'true') ? 'sc-bandBanner' : 'cl-bandBanner';
6247                                    document.querySelector('.'+img_s+' .banner-box[data-id="'+img_id+'"] .banner-img').style.setProperty(img_root, 'url(//storage.googleapis.com/i.addblock.net/img_broken_fill_500.png)', null);
6248                                });
6249                            });
6250
6251                            var banner_img_style = `${band_img_root[0]}: url(${band_img_arr[0]}); ${band_img_root[1]}: url(${(band_img_mobile) ? band_img_arr[1] : band_img_arr[0]});`;
6252
6253                            banner_str = '\
6254                                <li class="banner-box" id="' + banner_id + '">\
6255                                    <div class="banner-content">\
6256                                        <div class="banner-body">\
6257                                            <a href="javascript:;">\
6258                                                <div class="banner-img" style="' + banner_img_style + '">\
6259                                                    <div class="img-banner"></div>\
6260                                                </div>\
6261                                            </a>\
6262                                            ' + banner_label + '\
6263                                        </div>\
6264                                        <div class="banner-header">\
6265                                            <span class="banner-closetoday">' + $.lang[CHK_LANG]['editor.banner.close.today'] + '</span>\
6266                                            ' + clSVG('close',12,12,true,'banner-close') + '\
6267                                        </div>\
6268                                    </div>\
6269                                </li>\
6270                            ';
6271                        } else if(type == 'popup') {
6272
6273                            var popup_img_style = `<img src="${o.img.pc.path}" alt="" class="img-responsive img-banner pc" onerror="this.src=\'//storage.googleapis.com/i.addblock.net/img_broken_fill_500.png\'"/><img src="${(o.img.mobile.chk == '1') ? o.img.pc.path : o.img.mobile.path}" alt="" class="img-responsive img-banner mobile" onerror="this.src=\'//storage.googleapis.com/i.addblock.net/img_broken_fill_500.png\'"/>`;
6274                            banner_str = '\
6275                                <li class="banner-box" id="' + banner_id + '">\
6276                                    <div class="banner-content">\
6277                                        <div class="banner-header">' + clSVG('close',17,17,true,'banner-close') + '</div>\
6278                                        <div class="banner-body">\
6279                                            <a href="javascript:;">\
6280                                                <div class="banner-img">\
6281                                                    '+ popup_img_style +'\
6282                                                </div>\
6283                                            </a>\
6284                                            ' + banner_label + '\
6285                                        </div>\
6286                                        <div class="banner-footer clearfix">\
6287                                            <div class="banner-btn-wrap">\
6288                                                <span class="banner-btn banner-closetoday">' + $.lang[CHK_LANG]['editor.banner.close.today'] + '</span>\
6289                                                <span class="banner-btn banner-close">' + $.lang[CHK_LANG]['config.close'] + '</span>\
6290                                            </div>\
6291                                        </div>\
6292                                    </div>\
6293                                </li>\
6294                            ';
6295                        }
6296
6297	                        var bannerItem = $(banner_str),
6298	                            closeColor = $.siteBanner.getCssColorValue(o.close.color, '#000000');
6299                        bannerItem.attr('data-id', id);
6300                        bannerItem.attr('data-type', type);
6301                        if(isSC) {
6302                            if(!isVisible) bannerItem.addClass('hide');
6303                            if(o.link.val) {
6304                                var blink_o = $.siteBanner.getLINK(o.link.val, o.link.target);
6305                                if(blink_o.link) {
6306                                    bannerItem.find('a').addClass('active');
6307                                }                            
6308                            }
6309                        } else {
6310                            if(isCookie) bannerItem.addClass('hide');
6311                            bannerItem.attr('data-closetime', $.siteBanner[type].close_time);
6312                            if(o.link.val) {
6313                                var blink_o = $.siteBanner.getLINK(o.link.val, o.link.target);
6314                                if(blink_o.link) {
6315                                    bannerItem.find('a').attr('href', blink_o.link);
6316                                    if(blink_o.target) bannerItem.find('a').attr('target', blink_o.target);
6317                                    $.each(blink_o.option, function(o_k, o_v) {
6318                                        bannerItem.find('a').attr(o_k, o_v);
6319                                    });
6320                                }
6321                            }
6322                        }
6323		                        bannerItem.find('.banner-content').css('background-color',o.img.bgcolor);
6324		                        bannerItem.find('.banner-header .banner-closetoday').css('color',closeColor);
6325		                        bannerItem.find('.banner-header .banner-close.cl-icon > svg').css('fill',closeColor);
6326	                        if(type == 'popup' && popupViewType == 'slide' && popupSlideSizeInfo) {
6327	                            $.siteBanner.applyPopupSlideBoxSize(bannerItem, popupSlideSizeInfo);
6328	                        } else if(type == 'popup' && popupViewType != 'slide' && isPopupMobileRender && popupMobileDisplayWidth > 0) {
6329	                            bannerItem.css('width', popupMobileDisplayWidth + 'px');
6330	                            bannerItem.find('.banner-content, .banner-body, .banner-img, .banner-img > img').css('width', '100%');
6331	                        } else if(type == 'popup' && popupSizeOrigin == 'OFF' && popupSizeWidth > 0) {
6332	                            bannerItem.css('width', popupSizeWidth + 'px');
6333	                            bannerItem.find('.banner-content, .banner-body, .banner-img, .banner-img > img').css('width', '100%');
6334	                        }
6335
6336	                        if($.siteBanner[type].close_today == 'OFF') bannerItem.find('.banner-closetoday').addClass('hide');
6337                        if(type == 'band' && $.siteBanner[type].close_onoff == 'OFF') bannerItem.find('.banner-header').addClass('hide');
6338
6339                        if(type == 'popup' && $.siteBanner[type].close_btn == '1') {
6340                            bannerItem.find('.banner-content').css('background-color','');
6341                            bannerItem.find('.banner-body').css('background-color',o.img.bgcolor);
6342                        }
6343
6344                        b_list += bannerItem.outerHTML();
6345                    }
6346                });
6347
6348                if(b_show > 0) {
6349                    $.siteBanner[type].total = b_show;
6350                    if(isBand) {
6351                        $.siteBanner[type].min_h = min;
6352                    } else if(isPopup) {
6353                        $.siteBanner[type].total_w = sum;
6354                        $.siteBanner[type].max_h = max;
6355                    }
6356
6357					                    var popup_slide_arrow_style_for_html = $.siteBanner[type].slide_arrow_style || '1',
6358					                        popup_slide_arrow_color_for_html = $.siteBanner[type].slide_arrow_color || '#ffffff',
6359					                        popup_slide_arrow_size_for_html = $.siteBanner.getPopupSli
6359deControlSizeValue($.siteBanner[type].slide_arrow_size, '64'),
6360					                        popup_slide_arrow_mobile_size_for_html = (!isSC && typeof $.siteBanner.getPopupSlideMobileArrowSize == 'function') ? $.siteBanner.getPopupSlideMobileArrowSize() : 0,
6361					                        popup_slide_arrow_icon_size_for_html = (isSC && scPreviewDevice == 'm') ? '36' : ((popup_slide_arrow_mobile_size_for_html > 0) ? String(popup_slide_arrow_mobile_size_for_html) : popup_slide_arrow_size_for_html),
6362					                        popup_slide_arrow_prev_svg = $.siteBanner.getPopupSlideArrowStyleSvg(popup_slide_arrow_style_for_html, popup_slide_arrow_color_for_html, popup_slide_arrow_icon_size_for_html),
6363					                        popup_slide_arrow_next_svg = $.siteBanner.getPopupSlideArrowStyleSvg(popup_slide_arrow_style_for_html, popup_slide_arrow_color_for_html, popup_slide_arrow_icon_size_for_html);
6364
6365				                    if(isSC) {
6366					                        var popup_slide_control = (isPopup) ? '<div class="banner-slide-arrow"><button type="button" class="banner-slide-prev">' + popup_slide_arrow_prev_svg + '</button><button type="button" class="banner-slide-next">' + popup_slide_arrow_next_svg + '</button></div><div class="banner-slide-pagination el_popup_slide_pagination"><div class="slider-pagination-popup"></div></div>' : '';
6367				                        var popup_mobile_mockup = (isPopup) ? '<img class="sc-popup-mobile-mockup" src="https://storage.googleapis.com/i.addblock.net/sample/popup_mockup.png" alt="">' : '';
6368				                        $('#el-siteConfig .sc-siteBanner').replaceWith(`
6369				                            <div class="sc-siteBanner sc-${type}Banner ${scPreviewDevice}">
6370			                                ${popup_mobile_mockup}
6371			                                <div class="banner-modal">
6372		                                    <ul>${b_list}</ul>
6373		                                    ${popup_slide_control}
6374                                    <div class="banner-description" data-closetoday="m"><span>${clSVG('info',18,18,true,'')}${$.lang[LANG]['sc.banner.band.close.today.m']}</span></div>
6375                                    <div class="banner-description" data-overflow="x"><span>${clSVG('info',18,18,true,'')}${$.lang[LANG]['sc.banner.popup.position.overflow']}</span></div>
6376                                </div>
6377                            </div>
6378	                        `);
6379		                    } else {
6380		                        var popup_slide_control = (isPopup) ? '<div class="banner-slide-arrow"><button type="button" class="banner-slide-prev">' + popup_slide_arrow_prev_svg + '</button><button type="button" class="banner-slide-next">' + popup_slide_arrow_next_svg + '</button></div><div class="banner-slide-pagination el_popup_slide_pagination"><div class="slider-pagination-popup"></div></div>' : '';
6381	                        var bannerEL = $(`
6382	                            <div class="cl-${type}Banner">
6383	                                <div class="banner-modal">
6384                                    <ul>${b_list}</ul>
6385                                    ${popup_slide_control}
6386                                </div>
6387                            </div>
6388                        `);
6389
6390                        if($(`.cl-${type}Banner`).length > 0) $(`.cl-${type}Banner`).remove();
6391                        if($('html').is('._scroll')) {
6392                            if($('.editor-navbar').length > 0) $('.editor-navbar').after(bannerEL);
6393                            else $('body').prepend(bannerEL);
6394                        } else {
6395                            $('.dsgn-body').prepend(bannerEL);
6396                        }
6397                    }
6398
6399                    if(Number($.siteBanner[type].radius) > 0) {
6400                        $.siteBanner.setPopupRadiusCss('.banner-modal', $.siteBanner[type].radius);
6401                    }
6402                    if(isPopup) {
6403                        var popupBtnStyle = $.siteBanner[type].btn_style || '1',
6404                            popupBtnColor = $.siteBanner[type].btn_color || '#696c71',
6405                            popupBgLayer = $.siteBanner[type].bg_layer || 'OFF',
6406                            popupBgColor = $.siteBanner[type].bg_color || 'rgba(0, 0, 0, 0.6)',
6407		                            popupViewType = $.siteBanner[type].render_view_type || $.siteBanner[type].view_type || 'individual',
6408	                            popupSlideAuto = $.siteBanner[type].slide_auto || 'OFF',
6409	                            popupSlideSpeed = $.siteBanner[type].slide_speed || '3',
6410	                            popupSlideMoveTime = $.siteBanner[type].slide_move_time || '1',
6411		                            popupSlideStopTime = $.siteBanner[type].slide_stop_time || '3',
6412			                            popupSlideArrow = $.siteBanner[type].slide_arrow || 'OFF',
6413			                            popupSlideArrowStyle = $.siteBanner[type].slide_arrow_style || '1',
6414			                            popupSlideArrowSize = $.siteBanner.getPopupSli
6414deControlSizeValue($.siteBanner[type].slide_arrow_size, '64'),
6415			                            popupSlideArrowColor = $.siteBanner[type].slide_arrow_color || '#ffffff',
6416			                            popupSlideArrowBgColor = $.siteBanner[type].slide_arrow_bg_color || '#000000',
6417			                            popupSlidePaginationDisplay = $.siteBanner[type].slide_pagination_display || 'ON',
6418			                            popupSlidePagination = $.siteBanner[type].slide_pagination || 'number',
6419			                            popupSlidePaginationStyle = $.siteBanner[type].slide_pagination_style || ((popupSlidePagination == 'dot') ? '1' : '11'),
6420			                            popupSlidePaginationAlign = $.siteBanner[type].slide_pagination_align || 'right',
6421		                            popupSlidePaginationSize = $.siteBanner.getPopupSlideControlSizeValue($.siteBanner[type].slide_pagination_size, '52'),
6422		                            popupSlidePaginationColor = $.siteBanner[type].slide_pagination_color || '#ffffff',
6423		                            popupSlidePaginationActiveColor = $.siteBanner[type].slide_pagination_active_color || '#000000';
6424
6425	                        if($.inArray(popupSlidePaginationAlign, ['left','center','right']) < 0) popupSlidePaginationAlign = 'right';
6426	                        if(!$.siteBanner.isPopupSlideArrowStyleValue(popupSlideArrowStyle)) popupSlideArrowStyle = '1';
6427	                        if(!$.siteBanner.isPopupSlidePaginationStyleValue(popupSlidePaginationStyle)) popupSlidePaginationStyle = (popupSlidePagination == 'dot') ? '1' : '11';
6428	                        popupSlidePagination = $.siteBanner.getPopupSlidePaginationTypeByStyle(popupSlidePaginationStyle);
6429	                        $('.sc-popupBanner .banner-modal, .cl-popupBanner .banner-modal').each(function() {
6430                            $(this).attr('data-btnstyle', popupBtnStyle)
6431                                   .attr('data-bglayer', popupBgLayer)
6432		                                   .attr('data-viewtype', popupViewType)
6433		                                   .attr('data-slidesizeorigin', popupSlideSizeOrigin)
6434	                                   .attr('data-slideauto', popupSlideAuto)
6435	                                   .attr('data-slidespeed', popupSlideSpeed)
6436	                                   .attr('data-slidemovetime', popupSlideMoveTime)
6437				                                   .attr('data-slidestoptime', popupSlideStopTime)
6438				                                   .attr('data-slidearrow', popupSlideArrow)
6439				                                   .attr('data-slidearrowstyle', popupSlideArrowStyle)
6440				                                   .attr('data-slidearrowsize', popupSlideArrowSize)
6441				                                   .attr('data-slidepaginationdisplay', popupSlidePaginationDisplay)
6442			                                   .attr('data-slidepagination', popupSlidePagination)
6443			                                   .attr('data-slidepaginationstyle', popupSlidePaginationStyle)
6444			                                   .attr('data-slidepaginationalign', popupSlidePaginationAlign)
6445		                                   .attr('data-slidepaginationsize', popupSlidePaginationSize);
6446	                            this.style.setProperty('--popup-btn-color', popupBtnColor);
6447	                            this.style.setProperty('--popup-bg-color', popupBgColor);
6448		                            this.style.setProperty('--popup-slide-arrow-color', popupSlideArrowColor);
6449		                            this.style.setProperty('--slider-nav-color', popupSlideArrowColor);
6450		                            this.style.setProperty('--popup-slide-arrow-bg-color', popupSlideArrowBgColor);
6451		                            this.style.setProperty('--popup-slide-pagination-color', popupSlidePaginationColor);
6452		                            this.style.setProperty('--slider-page-color', popupSlidePaginationColor);
6453		                            this.style.setProperty('--popup-slide-pagination-active-color', popupSlidePaginationActiveColor);
6454		                            this.style.setProperty('--slider-page-align', popupSlidePaginationAlign);
6455		                            $.siteBanner.applyPopupSlideControlSize(this, popupSlideArrowSize, popupSlidePaginationSize);
6456		                            $.siteBanner.updatePopupSlideArrowIcons(this, popupSlideArrowStyle, popupSlideArrowColor);
6457		                        });
6458	                        $.siteBanner.setPopupSlide(isSC);
6459	                    }
6460	                    if(Number($.siteBanner[type].close_btn) > 0) {
6461	                        $('.banner-modal').each(function() {
6462                            $(this).attr('data-closebtn',$.siteBanner[type].close_btn)
6463                        });
6464                    }
6465                } else {
6466                    delete $.siteBanner[type].min_h;
6467                    delete $.siteBanner[type].total_w;
6468
6469                    $.siteBanner[type].total = 0;
6470                    $.siteBanner[type].used = false;
6471                    $.siteBanner.doNotOffer(type,isSC);
6472                }
6473
6474                deferred02.resolve();
6475            } else {
6476                if(isSet && !onoff) $.siteBanner.doNotOffer(type,isSC);
6477                deferred02.resolve();
6478            }
6479
6480            return deferred02.promise();
6481        },
6482        position: function(type,isSC,isPosition) {
6483            // console.log(`[siteBanner_step_END (on) /5] $.siteBanner.position(type ${type}, isSC ${isSC}, isPosition ${isPosition})`);
6484            var deferred03 = $.Deferred(),
6485                isClnav = $('header').is('.cl-nav'),
6486                isBand = (type == 'band') ? true : false,
6487                isPopup = (type == 'popup') ? true : false;
6488
6489            if(!isPosition) {
6490                deferred03.resolve();
6491            } else {
6492
6493                if(isBand) {
6494                    $.siteBanner.stopBandRolling();
6495
6496                    var m_h = $.siteBanner[type].min_h[0],
6497                        m_h2 = $.siteBanner[type].min_h[1];
6498                    if(m_h > 120) m_h = 120;
6499                    if(m_h2 != 50) m_h2 = 50;
6500
6501                    if(isSC) {
6502                        $('#el-siteConfig .sc-siteBanner').attr('data-min-p',m_h).attr('data-min-m',m_h2);
6503                        document.querySelector('#el-siteConfig .sc-siteBanner').style.setProperty('--scbandBanner-height-pc', m_h+'px', null);
6504                        document.querySelector('#el-siteConfig .sc-siteBanner').style.setProperty('--scbandBanner-height-mobile', m_h2+'px', null);
6505
6506                        var sc_device = $('#el-siteConfig .sc-device-wrap > li.active').attr('data-device');
6507                        if(sc_device == 'm') $('#el-siteConfig .sc-siteBanner .banner-description[data-closetoday="m"]').addClass('active');
6508                        else $('#el-siteConfig .sc-siteBanner .banner-description[data-closetoday="m"]').removeClass('active');
6509                    } else {
6510                        document.querySelector('body').style.setProperty('--bandBanner-height-pc', m_h+'px', null);
6511                        document.querySelector('body').style.setProperty('--bandBanner-height-mobile', m_h2+'px', null);
6512
6513                        $('body, .cl-bandBanner').addClass('openBandBanner');
6514                        $('.element[data-type="gallery"][data-type2="premium"]').refreshRootCss();
6515
6516                        var parentDocument = $(window.parent.document),
6517                            $detail_modal = parentDocument.find('.product-detail-modal');
6518                        if($detail_modal.length) $('.cl-bandBanner').addClass('detail');                  
6519
6520                        if(!isClnav) {
6521                            var isHeader = ($('.el-menu header.navbar').hasClass('transparent')) ? true : false,
6522                                isSidebar = ($('.el-menu header.navbar').hasClass('sidebar')) ? true : false,
6523                                header_h = (isHeader || (isSidebar && $('body').width() > 767)) ? 0 : $('.el-menu header.navbar').outerHeight(),
6524                                band_h = ($('body').width() > 767) ? m_h : m_h2;
6525                            $('.dsgn-body').css('padding-top', (band_h+header_h)+'px'); 
6526                        }
6527
6528                        if($.siteBanner.band.total > 1) {
6529                            var rolling_id = setInterval($.siteBanner.setBandRolling, $.siteBanner.band.interval);
6530                            $.siteBanner.band.seqs.push(rolling_id);
6531                            $('.cl-bandBanner').attr('data-seq',rolling_id);
6532                        }
6533
6534                        if(!isClnav) {
6535                            $($.siteBanner.band.body).scroll(function(event) {
6536                                if($('.cl-bandBanner').hasClass('openBandBanner') && $('.element[data-type="gallery"][data-type2="premium"][data-feature*="fixedscroll"]').length == 0) {
6537                                    if($(this).scrollTop() < $('.cl-bandBanner').outerHeight()) {
6538                                        if($('.header.el-menu > header').hasClass('transparent')) $('.dsgn-body').css('padding-top',$.siteBanner.getBandHeight()+'px');
6539                                        $('.cl-bandBanner, .el-menu_ctrl, .header.el-menu > header').css('margin-top',-$(this).scrollTop()+'px');
6540                                    } else {
6541                                        if($('.header.el-menu > header').hasClass('transparent')) $('.dsgn-body').css('padding-top',$.siteBanner.getBandHeight()+'px');
6542                                        $('.cl-bandBanner, .el-menu_ctrl, .header.el-menu > header').css('margin-top',-$('.cl-bandBanner').outerHeight()+'px');
6543                                    }
6544                                }
6545                            });
6546                        }
6547                    }
6548
6549                    deferred03.resolve();
6550                } else if(isPopup) {
6551	                    var sc_device = (isSC) ? ($('#el-siteConfig .sc-device-wrap > li.active').attr('data-device') || 'p') : '',
6552	                        p_selector = (isSC) ? '.sc-popupBanner' : '.cl-popupBanner',
6553	                        $popupPositionContainer = (isSC && sc_device == 'm') ? $(p_selector+' > .banner-modal') : $(p_selector),
6554	                        body_w = (isSC) ? $popupPositionContainer.width() : $('.dsgn-body').width(),
6555	                        device_idx = (isSC) ? ((sc_device == 'm') ? 1 : 0) : ((body_w <= 767) ? 1 : 0),
6556	                        isScMobileStack = (isSC && sc_device == 'm'),
6557	                        isMobileStack = isScMobileStack || (!isSC && device_idx == 1),
6558		                        device_offset = (isMobileStack) ? 0 : 30 + (($.siteBanner.popup.total - 1) * 30),
6559		                        popupViewType = $.siteBanner.popup.render_view_type || $.siteBanner.popup.view_type || 'individual',
6560		                        p_overflow = (popupViewType == 'slide') ? false : (((body_w - device_offset) < $.siteBanner.popup.total_w[device_idx]) ? true : false),
6561		                        p_position = $.siteBanner.popup.position || 'center center',
6562		                        p_arr = p_position.split(' '),
6563		                        p_justify = (p_arr[0]) ? p_arr[0] : 'center',
6564		                        p_align = (p_arr[1]) ? p_arr[1] : 'center',
6565		                        preview_justify = (isMobileStack) ? 'center' : p_justify,
6566		                        preview_align = (isMobileStack) ? 'center' : p_align,
6567		                        setPopupOverflowPosition = function() {
6568		                            var step = (isMobileStack) ? 35 : 30,
6569		                                mobileStackGutter = (isMobileStack) ? ((isScMobileStack) ? 0 : 30) : 0,
6570		                                alignGap = (isSC) ? 0 : (step * 2),
6571		                                topStart = (isSC && sc_device == 'p') || isMobileStack ? 0 : step,
6572		                                $banner = $popupPositionContainer,
6573		                                $items = $(p_selector+' .banner-box:not(.hide)'),
6574                                bannerOffset = $banner.offset() || {top:0},
6575                                containerWidth = $banner.innerWidth() || body_w,
6576                                containerHeight = $banner.innerHe
6576ight(),
6577                                visualWidth = 0,
6578                                visualHeight = 0,
6579		                                baseLeft = (isMobileStack) ? mobileStackGutter : ((isSC) ? 0 : step),
6580                                baseTop = topStart,
6581                                pi_i = $items.length;
6582
6583                            if(!containerHeight || containerHeight < 1) {
6584                                containerHeight = (!isSC) ? ($(window).height() - bannerOffset.top) : $banner.height();
6585                            }
6586                            if(!containerHeight || containerHeight < 1) containerHeight = 0;
6587
6588                            $items.each(function(i) {
6589                                var $item = $(this),
6590                                    itemWidth = $item.outerWidth() || parseInt($item.css('width'), 10) || 0,
6591                                    itemHeight = $item.outerHeight() || parseInt($item.css('height'), 10) || 0;
6592
6593                                visualWidth = Math.max(visualWidth, ((isMobileStack) ? 0 : (i * step)) + itemWidth);
6594                                visualHeight = Math.max(visualHeight, (i * step) + itemHeight);
6595                            });
6596
6597	                            if((!isMobileStack || isScMobileStack) && containerWidth > visualWidth + alignGap) {
6598	                                if(preview_justify == 'center') baseLeft = Math.round((containerWidth - visualWidth) / 2);
6599		                                else if(preview_justify == 'right') baseLeft = containerWidth - visualWidth - ((isSC) ? 0 : step);
6600		                            }
6601		                            if(containerHeight > visualHeight + alignGap) {
6602		                                if(preview_align == 'center') baseTop = Math.round((containerHeight - visualHeight) / 2);
6603		                                else if(preview_align == 'bottom') baseTop = containerHeight - visualHeight - ((isSC) ? 0 : step);
6604		                            }
6605
6606	                            baseLeft = (isMobileStack) ? mobileStackGutter : ((isSC) ? Math.max(0, baseLeft) : Math.max(step, baseLeft));
6607                            baseTop = Math.max(topStart, baseTop);
6608
6609	                            $items.each(function(i) {
6610	                                var $item = $(this),
6611	                                    itemWidth = $item.outerWidth() || parseInt($item.css('width'), 10) || 0,
6612	                                    itemLeft = baseLeft + (i * step);
6613
6614		                                if(isScMobileStack) {
6615		                                    if(preview_justify == 'center') itemLeft = Math.round((containerWidth - itemWidth) / 2);
6616		                                    else if(preview_justify == 'right') itemLeft = containerWidth - itemWidth - mobileStackGutter;
6617		                                    else itemLeft = mobileStackGutter;
6618	                                    itemLeft = Math.max(mobileStackGutter, itemLeft);
6619	                                } else if(isMobileStack) {
6620	                                    itemLeft = Math.max(mobileStackGutter, Math.round((containerWidth - itemWidth) / 2));
6621	                                }
6622
6623	                                $item.css({'top':(baseTop + (i * step))+'px', 'left':itemLeft+'px', 'margin-right':((isMobileStack) ? 0 : pi_i * step)+'px'});
6624                                pi_i--;
6625                            });
6626                        };
6627
6628	                    $(p_selector+' > .banner-modal').attr('data-justify', preview_justify)
6629                                                        .attr('data-align', preview_align)
6630                                                        .attr('data-overflow', p_overflow);
6631
6632                    if(p_overflow) {
6633                        // 계단식
6634                        if(isSC) setPopupOverflowPosition();
6635                    } else {
6636                        // 나열
6637                        $(p_selector+' .banner-box:not(.hide)').each(function(i) {
6638	                            $(this).removeInlineCss('top left margin-right');
6639	                        });
6640	                    }
6641		                    if(popupViewType == 'slide') $.siteBanner.setPopupSlide(isSC);
6642
6643	                    if(!isSC) {
6644	                        $(window).resize(function() {
6645                            if(this.resizeTO) {
6646                                clearTimeout(this.resizeTO);
6647                            }
6648                            this.resizeTO = setTimeout(function() {
6649                                $(this).trigger('resizeEnd');
6650                            }, 500);
6651                        });
6652                        $(window).on('resizeEnd', function() {
6653                            if($('.cl-popupBanner').hasClass('openPopupBanner')) {
6654                                var reposition = $.siteBanner.position('popup',isSC,true);
6655                                reposition.done(function(rp_r) {
6656                                }).fail(function(rp_error) {
6657                                });
6658                            }
6659	                        });
6660
6661	                        setTimeout(function() {
6662	                            if(typeof $.siteBanner.popup != 'undefined' && $.siteBanner.popup.site_config_hidden === true) {
6663	                                $.siteBanner.stopPopupSlideRolling('.cl-popupBanner');
6664	                                $('body, .cl-popupBanner').removeClass('openPopupBanner');
6665	                                return;
6666	                            }
6667
6668	                            var isPB = (typeof property != 'undefined') ? true : false,
6669	                                band_h = $.siteBanner.getBandHeight(),
6670	                                header_h = ($('.el-menu header.navbar').hasClass('transparent')) ? 0 : $('.el-menu header.navbar').outerHeight(),
6671	                                editor_navbar_t = (typeof PAGE_MODE != 'undefined' && PAGE_MODE == 'c' && (preview_align == 'top' || preview_align == 'center' || preview_align == 'bottom') && $('.editor-navbar').css('display') != 'none') ? Math.max(0, ($('.editor-navbar').outerHeight() || 35) - 30 + ((preview_align == 'top') ? 30 : 0)) : 0,
6672	                                popup_t = band_h + header_h,
6673                                popup_l = 0;
6674                            if($('.el-menu header.navbar').hasClass('sidebar')) {
6675                                if($('body').width() > 767) {
6676                                    popup_t = band_h;
6677                                    if(isPB) popup_l = 260;
6678                                    if($('.dsgn-body').hasClass('mode-render')) document.querySelector('.cl-popupBanner').style.setProperty('width', 'calc(100% - 260px)', null);
6679                                }
6680                            }
6681                            if(editor_navbar_t > 0) popup_t = Math.max(popup_t, editor_navbar_t);
6682
6683                            $('.cl-popupBanner').css({'top':parseInt(popup_t)+'px','left':popup_l+'px'});
6684                            if(!p_overflow) $(p_selector).css('bottom',0);
6685                            $('body, .cl-popupBanner').addClass('openPopupBanner');
6686	                            if(p_overflow) setPopupOverflowPosition();
6687	                            if(popupViewType == 'slide') $.siteBanner.setPopupSli
6687de(isSC);
6688                        }, 300);
6689	                    }
6690                    deferred03.resolve();
6691                }
6692            }
6693            return deferred03.promise();
6694        },
6695
6696        getLINK: function(org_link,org_ltarget) {
6697            var link = (typeof org_link == 'string' && org_link != 'javascript:;' && org_link.length > 0) ? org_link : 'javascript:;',
6698                link_target = (typeof org_ltarget != 'undefined' && (org_ltarget == '1' || org_ltarget == 'ON')) ? '_blank' : '',
6699                link_option = {};
6700
6701            if(link != '' && link != 'javascript:;') {
6702                var _menuList = (PAGE_MODE == 'c') ? MENULIST : property.MENULIST;
6703            
6704                if(link.match(/^\@/g) !== null) {                                                  // link-type: link-bookmark ==> a[attr-bookmark]
6705                    var _settings = (PAGE_MODE == 'c') ? SETTINGS : property.SETTINGS,
6706                        bookmark_seq = link.replace(/^\@/g,'');
6707                        
6708                    if(typeof _settings == 'undefined' || typeof _settings.blockBookmarkList == 'undefined' || _settings.blockBookmarkList['bookmark' + bookmark_seq] == 'undefined') {
6709                        link = '';
6710                        link_option = {};
6711                    } else {
6712                        link_option['attr-bookmark'] = bookmark_seq;
6713                    }
6714                } else if(link.match(/^flink\@[0-9]/gi) !== null) {                                // link-type: link-file     ==> a[attr-flink]
6715                    link_option['attr-flink'] = link.replace(/^flink\@/gi,'');
6716                    link_target = '';
6717                } else if(_menuList.indexOf(link.replace(/^\//g,"").replace(/ /g,"-")) > -1) {     // link-type: link-menu     ==> a[data-user-link]
6718                    link_option['data-user-link'] = link;
6719                } else {                                                                            // link-type: link-out      ==> a[attr-link]
6720                    link_option['attr-link'] = link;
6721                }
6722
6723                link = (PAGE_MODE == 'c') ? makeLinkUrl(link, ONE, VIEW) : makeLinkUrl(link, property.ONE, property.VIEW);
6724            }
6725
6726            return {'link':link, 'target':link_target, 'option':link_option};
6727        },
6728	        getBandHeight: function() {
6729	            if($('body').hasClass('openBandBanner')) {
6730	                var bandbanner_p = getComputedStyle(document.querySelector('body')).getPropertyValue('--bandBanner-height-pc'),
6731	                    bandbanner_m = getComputedStyle(document.querySelector('body')).getPropertyValue('--bandBanner-height-mobile');
6732
6733	                if($('body').width()>767) return parseInt(bandbanner_p);
6734	                else return parseInt(bandbanner_m);
6735	            } else {
6736	                return 0;
6737	            }
6738	        },
6739	        getPopupMobileIndividualMaxWidth: function(isSC) {
6740	            var maxWidth = 0,
6741	                $modal = null,
6742	                windowWidth = 0,
6743	                bodyWidth = 0;
6744
6745		            if(isSC) {
6746		                $modal = $('#el-siteConfig .sc-popupBanner.m > .banner-modal');
6747		                maxWidth = (($modal.innerWidth() || 294) - 34);
6748		            } else {
6749	                windowWidth = $(window).width() || 0;
6750	                bodyWidth = $('.dsgn-body').width() || 0;
6751	                maxWidth = ((windowWidth > 0) ? windowWidth : bodyWidth) - 60;
6752	            }
6753
6754	            return (maxWidth > 0) ? maxWidth : 0;
6755	        },
6756	        bindPopupSlideEvents: function() {
6757	            var arrowSelector = '.cl-popupBanner .banner-modal[data-viewtype="slide"] .banner-slide-prev, .cl-popupBanner .banner-modal[data-viewtype="slide"] .banner-slide-next, #el-siteConfig .sc-popupBanner .banner-modal[data-viewtype="slide"] .banner-slide-prev, #el-siteConfig .sc-popupBanner .banner-modal[data-viewtype="slide"] .banner-slide-next',
6758	                dotSelector = '.cl-popupBanner .banner-modal[data-viewtype="slide"] .banner-slide-dot, #el-siteConfig .sc-popupBanner .banner-modal[data-viewtype="slide"] .banner-slide-dot',
6759	                swipeSelector = '.cl-popupBanner .banner-modal[data-viewtype="slide"] .banner-body';
6760
6761	            $(document).off('click.sitePopupSlide', arrowSelector)
6762	                       .on('click.sitePopupSlide', arrowSelector, function(e) {
6763	                e.preventDefault();
6764	                e.stopPropagation();
6765
6766		                var direction = ($(this).hasClass('banner-slide-prev')) ? -1 : 1,
6767		                    $modal = $(this).closest('.banner-modal');
6768
6769		                if($.siteBanner.isPopupSlideManualMoving($modal)) return;
6770		                $.siteBanner.stopPopupSlideRollingModal($modal);
6771		                $.siteBanner.finishPopupSlide($modal);
6772		                $.siteBanner.nextPopupSlide($modal, direction, true);
6773		                $.siteBanner.startPopupSlideRollingModal($modal);
6774		            });
6775
6776	            $(document).off('click.sitePopupSlideDot', dotSelector)
6777	                       .on('click.sitePopupSlideDot', dotSelector, function(e) {
6778	                e.preventDefault();
6779	                e.stopPropagation();
6780
6781	                var $modal = $(this).closest('.banner-modal'),
6782	                    index = Number($(this).attr('data-index') || 0),
6783	                    currentIndex = Number($modal.attr('data-slide-index') || 0),
6784	                    direction = (index > currentIndex) ? 1 : -1;
6785
6786		                if(index == currentIndex) return;
6787		                if($.siteBanner.isPopupSlideManualMoving($modal)) return;
6788		                $.siteBanner.stopPopupSlideRollingModal($modal);
6789		                $.siteBanner.finishPopupSlide($modal);
6790		                $.siteBanner.showPopupSlide($modal, index, direction, true);
6791		                $.siteBanner.startPopupSlideRollingModal($modal);
6792		            });
6793
6794		            $(document).off('touchstart.sitePopupSlideSwipe touchmove.sitePopupSlideSwipe touchend.sitePopupSlideSwipe touchcancel.sitePopupSlideSwipe', swipeSelector)
6795		                       .on('touchstart.sitePopupSlideSwipe', swipeSelector, function(e) {
6796		                var event = e.originalEvent,
6797		                    touch = (event && event.touches && event.touches.length) ? event.touches[0] : null,
6798		                    $modal = $(this).closest('.banner-modal');
6799
6800		                if(!touch || ($(window).width() || window.innerWidth) > 767) return;
6801		                $modal.data('popupSlideTouch', {
6802		                    x: touch.clientX,
6803		                    y: touch.clientY
6804		                });
6805		            }).on('touchmove.sitePopupSlideSwipe', swipeSelector, function(e) {
6806		                var event = e.originalEvent,
6807		                    touch = (event && event.touches && event.touches.length) ? event.touches[0] : null,
6808		                    $modal = $(this).closest('.banner-modal'),
6809		                    touchData = $modal.data('popupSlideTouch');
6810
6811		                if(!touch || !touchData) return;
6812
6813		                var moveX = touch.clientX - touchData.x,
6814		                    moveY = touch.clientY - touchData.y,
6815		                    absX = Math.abs(moveX),
6816		                    absY = Math.abs(moveY);
6817
6818		                if(absX > 10 && absX > absY) {
6819		                    e.preventDefault();
6820		                }
6821		            }).on('touchend.sitePopupSlideSwipe', swipeSelector, function(e) {
6822		                var event = e.originalEvent,
6823		                    touch = (event && event.changedTouches && event.changedTouches.length) ? event.changedTouches[0] : null,
6824		                    $modal = $(this).closest('.banner-modal'),
6825		                    touchData = $modal.data('popupSlideTouch');
6826
6827		                $modal.removeData('popupSlideTouch');
6828		                if(!touch || !touchData) return;
6829
6830		                var moveX = touch.clientX - touchData.x,
6831		                    moveY = touch.clientY - touchData.y,
6832		                    absX = Math.abs(moveX),
6833		                    absY = Math.abs(moveY);
6834
6835		                if(absX < 40 || absX <= absY || $modal.find('> ul > li.banner-box:not(.hide)').length < 2) return;
6836
6837			                e.preventDefault();
6838			                e.stopPropagation();
6839			                if($.siteBanner.isPopupSlideManualMoving($modal)) return;
6840			                $.siteBanner.stopPopupSlideRollingModal($modal);
6841			                $.siteBanner.finishPopupSlide($modal);
6842			                $.siteBanner.nextPopupSlide($modal, (moveX < 0) ? 1 : -1, true);
6843			                $.siteBanner.startPopupSlideRollingModal($modal);
6844			            }).on('touchcancel.sitePopupSlideSwipe', swipeSelector, function(e) {
6845			                $(this).closest('.banner-modal').removeData('popupSlideTouch');
6846			            });
6847		        },
6848		        getPopupCloseButtonHeight: function(type, isSC, device, width) {
6849		            type = type || 'popup';
6850		            if(typeof $.siteBanner[type] != 'undefined' && $.siteBanner[type].close_btn == '1') return 0;
6851		            if(device != 'mobile') return 44;
6852		            if(isSC) return 36;
6853
6854		            var minWidth = 360,
6855		                maxWidth = 768,
6856		                minHeight = 44,
6857		                maxHeight = 56,
6858		                viewportWidth = Number(width || 0);
6859
6860		            if(!viewportWidth || viewportWidth < 1) viewportWidth = minWidth;
6861		            if(viewportWidth < minWidth) viewportWidth = minWidth;
6862		            if(viewportWidth > maxWidth) viewportWidth = maxWidth;
6863
6864		            return Math.round(minHeight + ((viewportWidth - minWidth) * (maxHeight - minHeight) / (maxWidth - minWidth)));
6865		        },
6866	        getPopupSlideSizeInfo: function(type, origin, width, isSC) {
6867	            type = type || 'popup';
6868
6869
6870	            var list = (typeof $.siteBanner[type] != 'undefined' && typeof $.siteBanner[type].list != 'undefined') ? $.siteBanner[type].list : {},
6871	                sort = (typeof $.siteBanner[type] != 'undefined' && typeof $.siteBanner[type].sort != 'undefined') ? $.siteBanner[type].sort : [],
6872	                targetWidth = Number(width || 0),
6873	                sizeInfo = {
6874	                    pc: {width: 0, height: 0},
6875	                    mobile: {width: 0, height: 0}
6876	                },
6877	                baseSize = {
6878	                    pc: {width: 0, height: 0},
6879	                    mobile: {width: 0, height: 0}
6880	                };
6881
6882	            if(!targetWidth || targetWidth < 1) targetWidth = 500;
6883
6884	            $.each(sort, function(idx, id) {
6885	                var o = list[id],
6886	                    isVisible = (type == 'popup') ? $.siteBanner.isPopupSlidePublishableItem(o) : ((o && o.visible == 'ON') ? true : false),
6887	                    isCookie = false,
6888	                    pcImg = null,
6889	                    mobileImg = null,
6890	                    pcWidth = 0,
6891	                    pcHeight = 0,
6892	                    mobileWidth = 0,
6893	                    mobileHeight = 0;
6894
6895	                if(!o || !o.img) return true;
6896	                if(!isVisible) return true;
6897
6898	                if(!isSC) {
6899	                    var cookieName = $.siteBanner.getBannerCookieName(type, id, 'slide');
6900	                    isCookie = (typeof $.cookie(cookieName) != 'undefined' && $.cookie(cookieName)) ? true : false;
6901	                    if(isCookie) return true;
6902	                }
6903
6904	                pcImg = o.img.pc || {};
6905	                mobileImg = (o.img.mobile && o.img.mobile.chk == '1') ? pcImg : (o.img.mobile || {});
6906
6907	                pcWidth = Number(pcImg.width || 0);
6908	                pcHeight = Number(pcImg.height || 0);
6909	                mobileWidth = Number(mobileImg.width || pcWidth || 0);
6910	                mobileHeight = Number(mobileImg.height || pcHeight || 0);
6911
6912		                if(pcWidth > 0 && pcHeight > 0) {
6913		                    if(baseSize.pc.width < pcWidth || (baseSize.pc.width == pcWidth && baseSize.pc.height < pcHeight)) {
6914		                        baseSize.pc.width = pcWidth;
6915		                        baseSize.pc.height = pcHeight;
6916		                    }
6917		                }
6918		                if(mobileWidth > 0 && mobileHeight > 0) {
6919		                    if(baseSize.mobile.width < mobileWidth || (baseSize.mobile.width == mobileWidth && baseSize.mobile.height < mobileHeight)) {
6920		                        baseSize.mobile.width = mobileWidth;
6921		                        baseSize.mobile.height = mobileHeight;
6922		                    }
6923		                }
6924		            });
6925
6926		            sizeInfo.pc.width = baseSize.pc.width;
6927		            sizeInfo.pc.height = baseSize.pc.height;
6928		            sizeInfo.mobile.width = baseSize.mobile.width;
6929		            sizeInfo.mobile.height = baseSize.mobile.height;
6930
6931		            if(sizeInfo.pc.width < 1) sizeInfo.pc.width = targetWidth;
6932		            if(sizeInfo.pc.height < 1) sizeInfo.pc.height = targetWidth;
6933		            if(sizeInfo.mobile.width < 1) sizeInfo.mobile.width = sizeInfo.pc.width;
6934		            if(sizeInfo.mobile.height < 1) sizeInfo.mobile.height = sizeInfo.pc.height;
6935
6936		            if(origin == 'OFF') {
6937		                var pcHeight = (baseSize.pc.width > 0) ? Math.round(targetWidth * baseSize.pc.height / baseSize.pc.width) : 0,
6938		                    mobileHeight = (baseSize.mobile.width > 0) ? Math.round(targetWidth * baseSize.mobile.height / baseSize.mobile.width) : 0;
6939
6940		                sizeInfo.pc.width = targetWidth;
6941		                sizeInfo.mobile.width = targetWidth;
6942	                if(pcHeight > 0) sizeInfo.pc.height = pcHeight;
6943	                if(mobileHeight > 0) sizeInfo.mobile.height = mobileHeight;
6944	            }
6945
6946	            if(sizeInfo.pc.height < 1) sizeInfo.pc.height = sizeInfo.mobile.height;
6947	            if(sizeInfo.mobile.height < 1) sizeInfo.mobile.height = sizeInfo.pc.height;
6948
6949		            var maxPcWidth = 0,
6950		                maxPcHeight = 0,
6951		                maxMobileWidth = 0,
6952		                maxMobileHeight = 0,
6953		                previewPcWidth = 0,
6954		                previewPcHeight = 0,
6955		                previewMobileWidth = 0,
6956		                previewMobileHeight = 0,
6957			                bodyWidth = 0,
6958			                windowWidth = 0,
6959			                windowHeight = 0,
6960			                pcCloseBtnHeight = 0,
6961			                mobileCloseBtnHeight = 0,
6962			                renderCloseBtnHeight = 0,
6963				                fitPopupSlideSize = function(size, maxWidth, maxHeight) {
6964			                    var nextWidth = Number(size.width || 0),
6965			                        nextHeight = Number(size.height || 0),
6966			                        ratio = 1;
6967
6968		                    if(nextWidth < 1 || nextHeight < 1) return;
6969		                    if(maxWidth > 0 && nextWidth > maxWidth) {
6970		                        ratio = maxWidth / nextWidth;
6971		                        nextWidth = maxWidth;
6972		                        nextHeight = Math.round(nextHeight * ratio);
6973		                    }
6974		                    if(maxHeight > 0 && nextHeight > maxHeight) {
6975		                        ratio = maxHeight / nextHeight;
6976		                        nextHeight = maxHeight;
6977		                        nextWidth = Math.round(nextWidth * ratio);
6978		                    }
6979			                    size.width = nextWidth;
6980			                    size.height = nextHeight;
6981			                },
6982			                fillPopupSlideWidth = function(size, maxWidth) {
6983			                    var nextWidth = Number(size.width || 0),
6984			                        nextHeight = Number(size.height || 0),
6985			                        ratio = 1;
6986
6987			                    if(maxWidth < 1 || nextWidth < 1 || nextHeight < 1) return;
6988			                    ratio = maxWidth / nextWidth;
6989			                    size.width = maxWidth;
6990			                    size.height = Math.round(nextHeight * ratio);
6991			                };
6992
6993		            if(isSC) {
6994		                previewPcWidth = $('#el-siteConfig .sc-body').innerWidth();
6995		                if(!previewPcWidth || previewPcWidth < 1) previewPcWidth = $('#el-siteConfig .sc-popupBanner.p').innerWidth();
6996		                if(!previewPcWidth || previewPcWidth < 1) previewPcWidth = $('#el-siteConfig .sc-popupBanner').innerWidth();
6997		                if(previewPcWidth > 0) maxPcWidth = previewPcWidth - 60;
6998		                previewPcHeight = $('#el-siteConfig .sc-popupBanner.p').innerHeight();
6999		                if(!previewPcHeight || previewPcHeight < 1) previewPcHeight = $('#el-siteConfig .sc-popupBanner').innerHeight();
7000		                if(!previewPcHeight || previewPcHeight < 1) {
7001		                    previewPcHeight = $('#el-siteConfig .sc-body').height();
7002		                    if(previewPcHeight > 216) previewPcHeight = previewPcHeight - 216;
7003		                }
7004		                pcCloseBtnHeight = $.siteBanner.getPopupCloseButtonHeight(type, isSC, 'pc', previewPcWidth);
7005		                if(previewPcHeight > 0) maxPcHeight = previewPcHeight - 30 - pcCloseBtnHeight;
7006		                previewMobileWidth = $('#el-siteConfig .sc-popupBanner.m').innerWidth();
7007		                if(!previewMobileWidth || previewMobileWidth < 1) previewMobileWidth = 480;
7008		                maxMobileWidth = previewMobileWidth - 60;
7009		                previewMobileHeight = $('#el-siteConfig .sc-popupBanner.m > .banner-modal').innerHeight();
7010		                if(!previewMobileHeight || previewMobileHeight < 1) previewMobileHeight = 526;
7011		                mobileCloseBtnHeight = $.siteBanner.getPopupCloseButtonHeight(type, isSC, 'mobile', previewMobileWidth);
7012		                if(previewMobileHeight > 0) maxMobileHeight = previewMobileHeight - 30 - mobileCloseBtnHeight;
7013		            } else {
7014		                bodyWidth = $('.dsgn-body').width();
7015		                windowWidth = $(window).width();
7016		                windowHeight = $(window).height();
7017		                renderCloseBtnHeight = $.siteBanner.getPopupCloseButtonHeight(type, isSC, (windowWidth > 0 && windowWidth <= 768) ? 'mobile' : 'pc', windowWidth || bodyWidth);
7018		                if(windowWidth > 0 && windowWidth <= 767) maxMobileWidth = windowWidth - 60;
7019		                else if(bodyWidth > 0) maxPcWidth = bodyWidth - 60;
7020		                else if(windowWidth > 0) maxPcWidth = windowWidth - 60;
7021		                if(windowHeight > 0) {
7022		                    maxPcHeight = windowHeight - 60 - renderCloseBtnHeight;
7023		                    maxMobileHeight = windowHeight - 60 - renderCloseBtnHeight;
7024		                }
7025		            }
7026
7027			            fitPopupSlideSize(sizeInfo.pc, maxPcWidth, 0);
7028			            fitPopupSlideSize(sizeInfo.mobile, maxMobileWidth, maxMobileHeight);
7029			            fillPopupSlideWidth(sizeInfo.mobile, maxMobileWidth);
7030
7031	            return sizeInfo;
7032	        },
7033	        applyPopupSlideBoxSize: function(target, sizeInfo) {
7034	            var $items = $(target),
7035	                pcWidth = Number(sizeInfo && sizeInfo.pc ? sizeInfo.pc.width : 0),
7036	                pcHeight = Number(sizeInfo && sizeInfo.pc ? sizeInfo.pc.height : 0),
7037	                mobileWidth = Number(sizeInfo && sizeInfo.mobile ? sizeInfo.mobile.width : 0),
7038	                mobileHeight = Number(sizeInfo && sizeInfo.mobile ? sizeInfo.mobile.height : 0);
7039
7040	            if(!$items.length) return;
7041	            if(pcWidth < 1) pcWidth = mobileWidth || 500;
7042	            if(pcHeight < 1) pcHeight = mobileHeight || pcWidth;
7043	            if(mobileWidth < 1) mobileWidth = pcWidth;
7044	            if(mobileHeight < 1) mobileHeight = pcHeight;
7045
7046	            $items.each(function() {
7047	                this.style.setProperty('--popup-slide-box-width-pc', pcWidth + 'px');
7048	                this.style.setProperty('--popup-slide-box-height-pc', pcHeight + 'px');
7049	                this.style.setProperty('--popup-slide-box-width-mobile', mobileWidth + 'px');
7050	                this.style.setProperty('--popup-slide-box-height-mobile', mobileHeight + 'px');
7051	            });
7052		            $items.css({'width': '', 'height': ''});
7053		            $items.find('.banner-content, .banner-body, .banner-body > a, .banner-img').css({'width': '', 'height': ''});
7054		            $items.find('.banner-img > img').css({'width': '', 'height': '', 'max-width': '', 'max-height': ''});
7055		        },
7056		        setPopupRadiusCss: function(target, radius) {
7057		            var popupRadius = Number(radius || 0),
7058		                popupMobileRadius = popupRadius * 0.75;
7059
7060		            $(target).each(function() {
7061		                this.style.setProperty('--popup-radius', popupRadius + 'px');
7062		                this.style.setProperty('--popup-radius-mobile', popupMobileRadius + 'px');
7063		            });
7064		        },
7065		        getPopupSlideControlSizeValue: function(val, fallback) {
7066		            var sizes = [28, 40, 52, 64, 76],
7067		                n = parseInt(String(val || fallback || 52).replace(/[^0-9]/g, ''), 10),
7068		                closest = parseInt(fallback || 52, 10),
7069		                minDiff = 9999;
7070
7071		            if(isNaN(n)) n = parseInt(fallback || 52, 10);
7072		            $.each(sizes, function(i, size) {
7073		                var diff = Math.abs(size - n);
7074		                if(diff < minDiff) {
7075		                    minDiff = diff;
7076		                    closest = size;
7077		                }
7078		            });
7079
7080		            return String(closest);
7081		        },
7082		        getPopupSlideStyleValues: function(max) {
7083		            var values = [];
7084
7085		            for(var i = 1; i <= max; i++) values.push(String(i));
7086
7087		            return values;
7088		        },
7089		        isPopupSlideArrowStyleValue: function(val) {
7090		            return ($.inArray(String(val), $.siteBanner.getPopupSlideStyleValues(27)) > -1);
7091		        },
7092		        isPopupSlidePaginationStyleValue: function(val) {
7093		            return ($.inArray(String(val), $.siteBanner.getPopupSlideStyleValues(18)) > -1);
7094		        },
7095		        getPopupSlidePaginationTypeByStyle: function(style) {
7096		            style = String(style || '11');
7097
7098		            return ($.inArray(style, ['11','12','13']) > -1) ? 'number' : 'dot';
7099		        },
7100		        setPopupSvgColor: function(svg, color) {
7101		            var $svg = $(svg),
7102		                fillTargets = 'path, circle, rect, polygon, line, polyline, ellipse, text';
7103
7104			            color = $.siteBanner.getCssColorValue(color, '#222428');
7105			            $svg.attr('data-color', color);
7106		            $svg.find(fillTargets).each(function() {
7107		                var $el = $(this),
7108		                    fill = $el.attr('fill'),
7109		                    stroke = $el.attr('stroke'),
7110		                    styleAttr = $el.attr('style') || '';
7111
7112		                if(fill != 'none' && styleAttr.indexOf('fill:none') < 0) {
7113		                    $el.attr('fill', color).css('fill', color);
7114		                }
7115		                if(stroke && stroke != 'none') {
7116		                    $el.attr('stroke', color).css('stroke', color);
7117		                }
7118		            });
7119
7120		            return $svg;
7121		        },
7122		        getPopupSlideArrowStylePreviewMap: function() {
7123		            return {
7124		                1: '<svg data-color="#222428" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="48" height="48"><path d="m19.06 12-1.41 1.41L28.23 24 17.65 34.59 19.06 36l12-12-12-12z"/></svg>',
7125		                2: '<svg data-color="#d0d0d0" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="48" height="48"><path d="M24 4C12.95 4 4 12.95 4 24s8.95 20 20 20 20-8.95 20-20S35.05 4 24 4Zm-2.86 27-.85-.85L26.44 24l-6.15-6.15.85-.85 7 7-7 7Z"/></svg>',
7126		                3: '<svg data-color="#d0d0d0" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="48" height="48"><path d="M4 4v40h40V4H4Zm17.14 27-.85-.85L26.44 24l-6.15-6.15.85-.85 7 7-7 7Z"/></svg>',
7127		                4: '<svg data-color="#222428" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="48" height="48"><path d="M41 24 31 14l-1.41 1.41L37.17 23H7v2h30.17l-7.58 7.59L31 34l8.58-8.59h.01L41 24z"/></svg>',
7128		                5: '<svg data-color="#222428" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="48" height="48"><path d="M24 4C12.95 4 4 12.95 4 24s8.95 20 20 20 20-8.95 20-20S35.05 4 24 4Zm0 39C13.52 43 5 34.48 5 24S13.52 5 24 5s19 8.52 19 19-8.52 19-19 19Z"/><path d="M20.29 17.85 26.44 24l-6.15 6.15.85.85 7-7-7-7-.85.85z"/></svg>',
7129		                6: '<svg data-color="#222428" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="48" height="48"><path d="m21.14 31 7-7-7-7-.85.85L26.44 24l-6.15 6.15.85.85z"/><path d="M4 4v40h40V4H4Zm38.8 38.8H5.2V5.2h37.6v37.6Z"/></svg>',
7130		                7: '<svg data-color="#222428" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="48" height="48"><path d="M41 24c0-.05 0-.1-.02-.15 0-.03 0-.06-.01-.09 0-.02-.02-.03-.03-.05a.746.746 0 0 0-.07-.12c-.03-.04-.05-.08-.09-.11a.55.55 0 0 0-.09-.07c-.04-.03-.08-.06-.13-.08 0 0-.02 0-.03-.01-.01 0-.02-.01-.03-.02-7.13-2.38-7.81-8.12-7.83-8.36a.745.745 0 0 0-.82-.67.75.75 0 0 0-.67.82c.02.24.58 5.07 5.69 8.18H7.75c-.41 0-.75.34-.75.75s.34.75.75.75h29.11c-5.11 3.1-5.66 7.94-5.69 8.18-.04.41.26.78.67.82h.07c.38 0 .71-.29.75-.68 0-.06.66-5.97 7.83-8.36 0 0 .01 0 .02-.01h.01c.01 0 .03-.01.04-.02.06-.03.11-.06.16-.09.02-.02.04-.03.05-.05 0 0 0-.01.01-.02.04-.04.08-.09.11-.14.02-.03.03-.06.04-.09 0-.02.02-.04.03-.06 0-.03 0-.06.01-.09.01-.05.02-.1.02-.15Z"/></svg>',
7131		                8: '<svg data-color="#222428" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="48" height="48"><path d="M5.04 30.38c.22.64.47 1.29.75 1.91l.91-.42c-.27-.59-.51-1.2-.71-1.81l-.95.32ZM5.09 25.88l-1 .1c.07.68.17 1.36.3 2.03l.98-.2c-.13-.64-.23-1.28-.29-1.92ZM5.15 21.6l-.99-.13c-.08.67-.14 1.36-.15 2.04l1 .02c.01-.65.06-1.3.14-1.94ZM13.69 6.86c-.58.35-1.16.74-1.7 1.15l.6.8c.52-.39 1.06-.76 1.61-1.09l-.52-.86ZM9.72 38c.48.49.99.96 1.51 1.39l.64-.77c-.49-.41-.98-.86-1.43-1.32l-.71.7ZM10.12 9.6c-.49.47-.96.98-1.4 1.5l.76.65c.42-.5.87-.97 1.33-1.42l-.7-.72ZM6.16 17.44l-.94-.34c-.24.64-.44 1.3-.61 1.96l.97.25c.16-.62.35-1.25.58-1.86ZM6.95 34.45c.36.58.75 1.15 1.16 1.69l.79-.61c-.39-.51-.76-1.05-1.1-1.6l-.85.52ZM30.45 5.06c-.65-.22-1.31-.41-1.97-.56l-.22.97c.63.14 1.26.32 
71311.87.53l.32-.95ZM42.86 17.32c-.23-.64-.49-1.28-.78-1.89l-.9.43c.28.58.53 1.19.74 1.8l.94-.33ZM42.88 21.82l.99-.11c-.08-.67-.19-1.35-.34-2.02l-.98.21c.14.63.25 1.28.32 1.92ZM22.28 5.08l-.09-1c-.68.06-1.36.16-2.03.29l.19.98c.64-.12 1.28-.22 1.93-.27ZM26.05 4.1C25.38 4.03 24.69 4 24 4v1c.65 0 1.3.03 1.94.1l.1-1ZM8.08 13.62l-.84-.55c-.37.57-.72 1.17-1.03 1.77l.89.46c.3-.57.63-1.14.98-1.68ZM37.41 37.46l.71.71c.48-.48.95-.99 1.38-1.52l-.78-.63c-.41.5-.85.99-1.31 1.44ZM36.53 8.41l-.63.78c.5.4.99.84 1.45 1.3l.7-.71c-.49-.48-1-.94-1.53-1.36ZM39.7 11.6l-.78.62c.4.51.78 1.04 1.13 1.59l.84-.54c-.37-.57-.76-1.14-1.19-1.67ZM13.21 40.84c.57.37 1.17.71 1.78 1.02l.45-.89c-.58-.29-1.15-.62-1.69-.97l-.54.84ZM34.06 40.12l.53.85c.58-.36 1.14-.76 1.68-1.17l-.61-.79c-.51.4-1.05.77-1.6 1.12ZM43 24.15c0 .65-.04 1.3-.11 1.94l.99.11c.07-.67.11-1.36.12-2.05h-1ZM41.94 30.27l.94.33c.23-.64.42-1.31.58-1.97l-.97-.23c-.15.63-.33 1.26-.55 1.87ZM40.08 34.12l.85.53c.36-.58.7-1.18 1-1.79l-.9-.44c-.29.58-.61 1.15-.95 1.7ZM32.72 6l-.44.9c.58.28 1.16.6 1.71.94l.53-.85c-.58-.36-1.18-.69-1.8-.99ZM17.25 42.83c.63.23 1.29.43 1.96.59l.24-.97c-.63-.16-1.26-.35-1.86-.56l-.34.94ZM21.63 43.86c.68.08 1.36.13 2.04.14l.02-1c-.65-.01-1.3-.05-1.94-.13l-.12.99ZM17.78 4.99c-.65.21-1.29.46-1.91.74l.41.91c.59-.26 1.2-.5 1.82-.7l-.31-.95ZM30.2 41.96l.33.95c.64-.22 1.28-.48 1.9-.77l-.42-.91c-.59.27-1.19.52-1.8.73ZM26.03 42.89l.11.99c.68-.07 1.36-.18 2.02-.32l-.21-.98c-.63.13-1.28.24-1.92.3ZM26.26 28.6l4.59-4.6-4.59-4.6-.71.71 3.39 3.39H17.85v1h11.09l-3.39 3.39.71.71z"/></svg>',
7132		                9: '<svg data-color="#222428" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="48" height="48"><path d="m19.74 4-.9.43L28.16 24l-9.32 19.57.9.43 9.52-20-9.52-20z"/></svg>',
7133		                10: '<svg data-color="#222428" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="48" height="48"><path d="M41.89 24.57v-.02c.07-.17.11-.35.11-.55 0-.19-.04-.38-.11-.55v-.02c-.08-.18-.19-.35-.33-.49l-9.19-9.19c-.59-.59-1.54-.59-2.12 0s-.59 1.54 0 2.12l6.63 6.63H7.5c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5h29.38l-6.63 6.63a1.49 1.49 0 0 0 0 2.12c.59.59 1.54.59 2.12 0l9.19-9.19c.14-.14.25-.31.33-.49Z"/></svg>',
7134		                11: '<svg data-color="#222428" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="48" height="48"><path d="m19.06 12-1.41 1.41L28.23 24 17.65 34.59 19.06 36l12-12-12-12z"/></svg>',
7135		                12: '<svg data-color="#222428" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="48" height="48"><path d="M31.55 23.12a2.74 2.74 0 0 0-.65-1.06l-9.9-9.9c-1.04-1.04-2.85-1.04-3.89 0a2.758 2.758 0 0 0 0 3.89l7.96 7.96-7.96 7.96a2.758 2.758 0 0 0 0 3.89 2.732 2.732 0 0 0 3.88 0l9.9-9.9c.74-.74.99-1.83.65-2.83Zm-1.71 1.76-9.9 9.9c-.47.47-1.29.47-1.77 0s-.49-1.28 0-1.77l8.49-8.49c.29-.29.29-.77 0-1.06l-8.49-8.49a1.25 1.25 0 0 1 0-1.77 1.234 1.234 0 0 1 1.76 0l9.9 9.9c.13.13.23.29.29.48.16.46.04.95-.29 1.29Z"/></svg>',
7136		                13: '<svg data-color="#222428" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="48" height="48"><path d="m40 24-.01-.01-2.49-2.49L28 12h-7.07l9.5 9.5H8v5h22.43l-9.5 9.5H28l8.46-8.47h.01l1.03-1.03L40 24z"/></svg>',
7137		                14: '<svg data-color="#222428" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="48" height="48"><path d="M34.25 24v-.01L22.25 12h-7.07l12 12-12 12h7.07l8.47-8.47L34.25 24z"/></svg>',
7138		                15: '<svg data-color="#222428" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="48" height="48"><path d="M39.56 23.99 27.57 12H20.5l12 12-12 12h7.07l8.47-8.47L39.57 24l-.01-.01z"/><path d="m27.5 24-.01-.01L15.5 12H8.43l12 12-12 12h7.07l8.47-8.47L27.5 24z"/></svg>',
7139		                16: '<svg data-color="#222428" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="48" height="48"><path d="M35.96 24.19c.08-.19.05-.41-.11-.56-.01-.01-.03-.01-.04-.02L25.24 13.04c-.2-.2-.51-.2-.71 0-.2.2-.2.51 0 .71l9.75 9.75H12.5c-.28 0-.5.22-.5.5s.22.5.5.5h21.79l-9.75 9.75c-.19.19-.19.5 0 .69.19.2.51.2.71.01l10.61-10.61.01-.01c.03-.04.06-.08.08-.12 0 0 .01-.02.02-.03Z"/></svg>',
7140		                17: '<svg data-color="#222428" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="48" height="48"><path d="m31.87 19.4-.71.71 7.63 7.63H8v1h33.21l-9.34-9.34z"/></svg>',
7141		                18: '<svg data-color="#222428" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="48" height="48"><path d="M30.74 22.69 19.68 12.48c-1.14-1.06-3-.24-3 1.31v20.42c0 1.56 1.85 2.37 3 1.31l11.06-10.21c.77-.71.77-1.92 0-2.63Z"/></svg>',
7142		                19: '<svg data-color="#222428" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="48" height="48"><path d="M17.5 12v24l13-12-13-12z"/></svg>',
7143		                20: '<svg data-color="#d0d0d0" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="48" height="48"><path d="M24 4C12.95 4 4 12.95 4 24s8.95 20 20 20 20-8.95 20-20S35.05 4 24 4Zm-3.33 28V16l8.67 8-8.67 8Z"/></svg>',
7144		                21: '<svg data-color="#d0d0d0" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="48" height="48"><path d="M4 4v40h40V4H4Zm16.67 28V16l8.67 8-8.67 8Z"/></svg>',
7145		                22: '<svg data-color="#222428" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="48" height="48"><path d="M41 24 28 12v11H7v2h21v11l13-12z"/></svg>',
7146		                23: '<svg data-color="#222428" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="48" height="48"><path d="M24 4C12.95 4 4 12.95 4 24s8.95 20 20 20 20-8.95 20-20S35.05 4 24 4Zm0 39C13.52 43 5 34.48 5 24S13.52 5 24 5s19 8.52 19 19-8.52 19-19 19Z"/><path d="m20.67 32 8.66-8-8.66-8v16z"/></svg>',
7147		                24: '<svg data-color="#222428" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="48" height="48"><path d="M3.5 3.5v41h41v-41h-41Zm40 40h-39v-39h39v39Z"/><path d="M20.67 16v16l8.66-8-8.66-8z"/></svg>',
7148		                25: '<svg data-color="#222428" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="48" height="48"><path d="M39 22.15 35.58 19 28 12v7H7v10h21v7l7.58-7L39 25.85 41 24l-2-1.85z"/></svg>',
7149		                26: '<svg data-color="#222428" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="48" height="48"><path d="M6.95 34.45c.36.58.75 1.15 1.16 1.69l.79-.61c-.39-.51-.76-1.05-1.1-1.6l-.85.52ZM5.04 30.38c.22.64.47 1.29.75 1.91l.91-.42c-.27-.59-.51-1.2-.71-1.81l-.95.32ZM10.12 9.6c-.49.47-.96.98-1.4 1.5l.76.65c.42-.5.87-.97 1.33-1.42l-.7-.72ZM9.72 38c.48.49.99.96 1.51 1.39l.64-.77c-.49-.41-.98-.86-1.43-1.32l-.71.7ZM13.21 40.84c.57.37 1.17.71 1.78 1.02l.45-.89c-.58-.29-1.15-.62-1.69-.97l-.54.84ZM5.09 25.88l-1 .1c.07.68.17 1.36.3 2.03l.98-.2c-.13-.64-.23-1.28-.29-1.92ZM13.69 6.86c-.58.35-1.16.74-1.7 1.15l.6.8c.52-.39 1.06-.76 1.61-1.09l-.52-.86ZM26.05 4.1C25.38 4.03 24.69 4 24 4v1c.65 0 1.3.03 1.94.1l.1-1ZM5.15 21.6l-.99-.13c-.08.67-.14 1.36-.15 2.04l1 .02c.01-.65.06-1.3.14-1.94ZM42.86 17.32c-.23-.64-.49-1.28-.78-1.89l-.9.43c.28.58.53 1.19.74 1.8l.94-.33ZM42.88 21.82l.99-.11c-.08-.67-.19-1.35-.34-2.02l-.98.21c.14.63.25 1.28.32 1.92ZM17.78 4.99c-.65.21-1.29.46-1.91.74l.41.91c.59-.26 1.2-.5 1.82-.7l-.31-.95
7149ZM6.16 17.44l-.94-.34c-.24.64-.44 1.3-.61 1.96l.97.25c.16-.62.35-1.25.58-1.86ZM8.08 13.62l-.84-.55c-.37.57-.72 1.17-1.03 1.77l.89.46c.3-.57.63-1.14.98-1.68ZM40.08 34.12l.85.53c.36-.58.7-1.18 1-1.79l-.9-.44c-.29.58-.61 1.15-.95 1.7ZM17.25 42.83c.63.23 1.29.43 1.96.59l.24-.97c-.63-.16-1.26-.35-1.86-.56l-.34.94ZM34.06 40.12l.53.85c.58-.36 1.14-.76 1.68-1.17l-.61-.79c-.51.4-1.05.77-1.6 1.12ZM37.41 37.46l.71.71c.48-.48.95-.99 1.38-1.52l-.78-.63c-.41.5-.85.99-1.31 1.44ZM32.72 6l-.44.9c.58.28 1.16.6 1.71.94l.53-.85c-.58-.36-1.18-.69-1.8-.99ZM39.7 11.6l-.78.62c.4.51.78 1.04 1.13 1.59l.84-.54c-.37-.57-.76-1.14-1.19-1.67ZM43 24.15c0 .65-.04 1.3-.11 1.94l.99.11c.07-.67.11-1.36.12-2.05h-1ZM41.94 30.27l.94.33c.23-.64.42-1.31.58-1.97l-.97-.23c-.15.63-.33 1.26-.55 1.87ZM36.53 8.41l-.63.78c.5.4.99.84 1.45 1.3l.7-.71c-.49-.48-1-.94-1.53-1.36ZM21.63 43.86c.68.08 1.36.13 2.04.14l.02-1c-.65-.01-1.3-.05-1.94-.13l-.12.99ZM26.03 42.89l.11.99c.68-.07 1.36-.18 2.02-.32l-.21-.98c-.63.13-1.28.24-1.92.3ZM22.19 4.08c-.68.06-1.36.16-2.03.29l.19.98c.64-.12 1.28-.22 1.93-.27l-.09-1ZM30.2 41.96l.33.95c.64-.22 1.28-.48 1.9-.77l-.42-.91c-.59.27-1.19.52-1.8.73ZM28.47 4.5l-.22.97c.63.14 1.26.32 
71491.87.53l.32-.95c-.65-.22-1.31-.41-1.97-.56ZM20.67 32l8.66-8-8.66-8v16z"/></svg>',
7150		                27: '<svg data-color="#222428" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="48" height="48"><path d="m14.71 12-1.42 1.41L23.88 24 13.29 34.59 14.71 36l12-12-12-12z"/><path d="m22.71 12-1.42 1.41L31.88 24 21.29 34.59 22.71 36l12-12-12-12z"/></svg>'
7151		            };
7152		        },
7153		        getPopupSlideArrowStylePreviewSvg: function(style) {
7154		            var navObj = $.siteBanner.getPopupSlideArrowStylePreviewMap();
7155
7156		            style = String(style || '1');
7157		            if(typeof navObj[style] == 'undefined') style = '1';
7158
7159		            return navObj[style] || '';
7160		        },
7161		        getPopupSlideArrowStyleSvg: function(style, color, size) {
7162		            var svgHtml = '',
7163		                svgSize = parseInt(String(size || '52').replace(/[^0-9]/g, ''), 10),
7164		                $wrap = null,
7165		                $svg = null;
7166
7167		            if(isNaN(svgSize) || svgSize < 1) svgSize = 52;
7168		            style = String(style || '1');
7169		            if(!$.siteBanner.isPopupSlideArrowStyleValue(style)) style = '1';
7170		            color = color || '#222428';
7171
7172		            if(typeof contentsSliderNav == 'function') {
7173		                $wrap = $('<div></div>').append(contentsSliderNav(Number(svgSize), Number(style)));
7174		                $svg = $wrap.find('.slider-nav-btn.next svg').eq(0).clone();
7175		                if(!$svg.length) $svg = $wrap.find('svg').eq(0).clone();
7176		                if($svg.length) {
7177		                    $svg.addClass('banner-slide-arrow-icon').attr({'width':svgSize,'height':svgSize});
7178		                    if(!$svg.attr('viewBox')) $svg.attr('viewBox', '0 0 ' + svgSize + ' ' + svgSize);
7179		                    $.siteBanner.setPopupSvgColor($svg, color);
7180		                    svgHtml = $('<div></div>').append($svg).html();
7181		                }
7182		            }
7183		            if(!svgHtml) {
7184		                $svg = $('<svg class="banner-slide-arrow-icon" data-color="' + color + '" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 52 52" width="' + svgSize + '" height="' + svgSize + '"><path fill="' + color + '" d="m15.06 2-1.41 1.41L36.23 26 13.65 48.59 15.06 50l24-24-24-24z"/></svg>');
7185		                svgHtml = $('<div></div>').append($svg).html();
7186		            }
7187
7188		            return svgHtml;
7189		        },
7190		        getPopupSlideArrowStyleListHtml: function() {
7191		            var html = '',
7192		                navObj = $.siteBanner.getPopupSlideArrowStylePreviewMap();
7193
7194		            $.each(navObj, function(n, v) {
7195		                html += '<li role="presentation"><a data-value="' + n + '">' + v + '</a></li>';
7196		            });
7197
7198		            return html;
7199		        },
7200		        getPopupSlidePaginationStyleMap: function() {
7201		            return {
7202		                1: '<svg data-color="#000000" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 98 42" width="98" height="42"><circle cx="36" cy="21" r="6"/><circle cx="52" cy="21" r="2.5" style="stroke:#000; fill:none;"/><circle cx="65" cy="21" r="2.5" style="stroke:#000; fill:none;"/></svg>',
7203		                5: '<svg data-color="#000000" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 98 42" width="98" height="42"><path d="M11 19h16c1.1 0 2 .9 2 2s-.9 2-2 2H11c-1.1 0-2-.9-2-2s.9-2 2-2Z"/><rect width="20" height="4" x="39" y="19" rx="2" ry="2" style="opacity:.5;"/><rect width="20" height="4" x="69" y="19" class="st0" rx="2" ry="2" style="opacity:.5;"/></svg>',
7204		                3: '<svg data-color="#000000" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 98 42" width="98" height="42"><path d="M27.5 15.5h11v11h-11z"/><path d="M48.5 18h6v6h-6z" style="fill:none;"/><path d="M49 18.5h5v5h-5z" style="fill:none; stroke:#000;"/><path d="M64.5 18h6v6h-6z" style="fill:none;"/><path d="M65 18.5h5v5h-5z" style="fill:none; stroke:#000;"/></svg>',
7205		                2: '<svg data-color="#000000" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 98 42" width="98" height="42"><circle cx="34" cy="21" r="5.5"/><circle cx="52.5" cy="21" r="3" style="opacity:.2;"/><circle id="Ellipse_185" cx="67.5" cy="21" r="2" style="opacity:.2;"/></svg>',
7206		                7: '<svg data-color="#000000" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 98 42" width="98" height="42"><g><path d="M7 20.5h20v1H7z"/><path  d="M39 20.5h20v1H39z" style="opacity:0.5;"/><path d="M71 20.5h20v1H71z" style="opacity:0.5;"/><path d="M7 16h20v10H7z" style="fill:none;"/><path d="M39 16h20v10H39z" style="fill:none;"/><path d="M71 16h20v10H71z" style="fill:none;"/></g></svg>',
7207		                9: '<svg data-color="#000000" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 98 42" width="98" height="42"><path d="M35.5 9h27v24h-27z" style="fill:none;"/><path d="M62.5 9h27v24h-27z" style="fill:none;"/><g><path d="M17.07 20.15c0-2.45 1.29-3.92 3.07-3.92s3.08 1.46 3.08 3.92-1.3 3.92-3.08 3.92-3.07-1.46-3.07-3.92Zm5.34 0c0-2.06-.92-3.19-2.27-3.19s-2.27 1.13-2.27 3.19.92 3.19 2.27 3.19 2.27-1.13 2.27-3.19ZM26.47 16.3V24h-.79v-7h-1.81v-.7h2.61Z" style="fill:#222428;"/></g><g><path d="M43.07 20.15c0-2.45 1.29-3.92 3.07-3.92s3.08 1.46 3.08 3.92-1.3 3.92-3.08 3.92-3.07-1.46-3.07-3.92Zm5.34 0c0-2.06-.92-3.19-2.27-3.19s-2.27 1.13-2.27 3.19.92 3.19 2.27 3.19 2.27-1.13 2.27-3.19ZM55.59 23.3v.7h-5.4v-.56l3.2-3.13c.87-.86 1.03-1.38 1.03-1.9 0-.89-.63-1.44-1.8-1.44-.9 0-1.59.28-2.1.86l-.56-.48c.59-.7 1.55-1.1 2.73-1.1 1.56 0 2.55.79 2.55 2.08 0 .74-.23 1.4-1.27 2.41l-2.62 2.57h4.24Z" style="fill:#222428; opacity:0.5;"/></g><g><path d="M70.07 20.15c0-2.45 1.29-3.92 3.07-3.92s3.08 1.46 3.08 3.92-1.3 3.92-3.08 3.92-3.07-1.46-3.07-3.92Zm5.34 0c0-2.06-.92-3.19-2.27-3.19s-2.27 1.13-2.27 3.19.92 3.19 2.27 3.19 2.27-1.13 2.27-3.19ZM82.34 21.79c0 1.29-.94 2.28-2.79 2.28-1.11 0-2.18-.39-2.77-.99l.38-.63c.49.52 1.39.89 2.39.89 1.28 0 1.98-.59 1.98-1.55s-.65-1.53-2.08-1.53h-.55v-.58l2.13-2.67h-3.94v-.7h4.95v.56l-2.18 2.74c1.65.09 2.48.96 2.48 2.19Z" style="fill:#222428; opacity:0.5;"/></g><path d="M8.5 9h27v24h-27z" style="fill:none;"/></svg>',
7208		                6: '<svg data-color="#000000" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 98 42" width="98" height="42"><path d="M60 25c-2.21 0-4-1.79-4-4s1.79-4 4-4 4 1.79 4 4-1.79 4-4 4Zm0-7c-1.65 0-3 1.35-3 3s1.35 3 3 3 3-1.35 3-3-1.35-3-3-3ZM72 25c-2.21 0-4-1.79-4-4s1.79-4 4-4 4 1.79 4 4-1.79 4-4 4Zm0-7c-1.65 0-3 1.35-3 3s1.35 3 3 3 3-1.35 3-3-1.35-3-3-3ZM26 17h22c2.21 0 4 1.79 4 4s-1.79 4-4 4H26c-2.21 0-4-1.79-4-4s1.79-4 4-4Z"/></svg>',
7209		                10: '<svg data-color="#000000" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 98 42" width="98" height="42"><path d="M62.5 9h-53v24h79V9h-26Zm-27 23h-25V10h25v22Zm26 0h-25V10h25v22Zm26 0h-25V10h25v22Z" style="fill:#797979"/><g><path d="M17.99 20.98c0-2.55.89-3.78 2.29-3.78s2.28 1.24 2.28 3.78-.89 3.82-2.28 3.82-2.29-1.27-2.29-3.82Zm3.68 0c0-2.14-.56-3.04-1.39-3.04s-1.4.9-1.4 3.04.56 3.09 1.4 3.09 1.39-.93 1.39-3.09ZM23.93 23.91h1.63v-5.47h-1.3v-.58c.65-.12 1.12-.29 1.52-.52h.7v6.57h1.47v.76h-4.02v-.76Z" style="fill:#222428;"/></g><g><path d="M43.99 20.98c0-2.55.89-3.78 2.29-3.78s2.28 1.24 2.28 3.78-.89 3.82-2.28 3.82-2.29-1.27-2.29-3.82Zm3.68 0c0-2.14-.56-3.04-1.39-3.04s-1.4.9-1.4 3.04.56 3.09 1.4 3.09 1.39-.93 1.39-3.09ZM49.49 24.13c2.3-2.01 3.36-3.47 3.36-4.73 0-.84-.44-1.45-1.35-1.45-.6 0-1.12.37-1.52.85l-.53-.52c.6-.65 1.23-1.08 2.16-1.08 1.31 0 2.13.86 2.13 2.17 0 1.46-1.15 2.95-2.87 4.58.38-.03.83-.07 1.2-.07h2.03v.79h-4.61v-.54Z" style="fill:#222428;"/></g><g><path d="M69.99 20.98c0-2.55.89-3.78 2.29-3.78s2.28 1.24 2.28 3.78-.89 3.82-2.28 3.82-2.29-1.27-2.29-3.82Zm3.68 0c0-2.14-.56-3.04-1.39-3.04s-1.4.9-1.4 3.04.56 3.09 1.4 3.09 1.39-.93 1.39-3.09ZM75.34 23.8l.46-.6c.43.45.99.84 1.82.84.87 0 1.49-.52 1.49-1.36s-.59-1.47-2.28-1.47v-.7c1.51 0 2.03-.61 2.03-1.4 0-.71-.48-1.16-1.24-1.18-.59.02-1.11.32-1.52.73l-.49-.58c.55-.51 1.2-.88 2.05-.88 1.23 0 2.13.66 2.13 1.84 0 .89-.53 1.48-1.31 1.77v.04c.87.2 1.56.86 1.56 1.86 0 1.31-1.05 2.09-2.35 2.09-1.15 0-1.87-.48-2.35-1Z" style="fill:#222428;"/></g><g><path d="M9.5 31h27v2h-27z" style="fill:#fff"/><path d="M9.5 31h27v2h-27z"/></g></svg>',
7210		                11: '<svg data-color="#000000" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 98 42" width="98" height="42"><path d="M41 11h16c5.52 0 10 4.48 10 10s-4.48 10-10 10H41c-5.52 0-10-4.48-10-10s4.48-10 10-10Z" style="opacity:.3; isolation:isolate"/><path d="M43.92 17.14V25h-.99v-6.62l-2 .73v-.9l2.84-1.07h.16Z" style="isolation:isolate; fill:#fff;"/><g style="opacity:.5; isolation:isolate"><path d="m51.22 17.18-3.26 8.49h-.85l3.27-8.49h.85ZM53.45 21.28l-.79-.2.39-3.89h4.01v.92h-3.17l-.24 2.13c.14-.08.32-.16.55-.23.22-.07.47-.11.76-.11.36 0 .69.06.97.19.29.12.53.3.73.53.2.23.36.5.46.83s.16.68.16 1.08c0 .38-.05.72-.15 1.04-.1.31-.25.59-.46.82s-.46.42-.77.54c-.31.13-.67.19-1.09.19-.31 0-.61-.04-.89-.13s-.53-.22-.75-.4c-.22-.18-.4-.41-.54-.68a2.51 2.51 0 0 1-.26-.95h.95c.04.29.13.54.26.74.13.2.3.35.51.45.21.1.45.15.73.15.24 0 .45-.04.63-.12.18-.08.34-.2.46-.36.13-.15.22-.34.29-.56.07-.22.1-.46.1-.74 0-.25-.03-.48-.1-.69s-.17-.4-.3-.55c-.13-.16-.3-.28-.49-.37s-.42-.13
7210-.67-.13c-.33 0-.58.04-.75.13-.17.09-.34.21-.52.37Z" style="fill:#fff;"/></g></svg>',
7211		                12: '<svg data-color="#000000" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 98 42" width="98" height="42"><rect width="84" height="30" x="7" y="6" rx="15" ry="15" style="opacity:.3"/><path d="M23.92 17.07v7.86h-.99v-6.62l-2 .73v-.9l2.84-1.07h.16Z" style="isolation:isolate; fill:#fff;"/><g style="isolation:isolate;opacity:.5"><path d="m31.22 16.81-3.26 8.49h-.85l3.27-8.49h.85ZM37.31 23.81v.82h-5.12v-.71l2.56-2.85c.31-.35.56-.65.73-.89.17-.25.3-.46.37-.66s.11-.39.11-.6c0-.26-.05-.49-.16-.7s-.26-.38-.46-.5-.45-.19-.74-.19c-.35 0-.64.07-.87.2s-.4.32-.52.56-.17.52-.17.83h-.99c0-.44.1-.84.29-1.21s.48-.66.86-.87c.38-.22.85-.33 1.4-.33.49 0 .92.09 1.27.26s.62.42.81.73.28.68.28 1.1c0 .23-.04.46-.12.7-.08.23-.18.47-.32.7-.13.23-.29.46-.47.69-.18.22-.37.45-.57.67l-2.09 2.27h3.92Z" style="fill:#fff;"/></g><path id="Path_4" d="m53.1 15.59-.49-.49-5.41 5.41-.49.49.49.49 5.42 5.41.49-.49L47.69 21l5.41-5.42Z" style="fill:#fff;"/><path id="Path_5" d="m71.06 26.42.49.49 5.42-5.41.49-.49-.49-.49-5.42-5.42-.49.49 5.42 5.42-5.42 5.42Z" style="fill:#fff;"/><g style="opacity:.3"><path d="M61 16h1v10h-1z" style="fill:#fff;"/><path d="M61 16.5h1v9h-1z" style="fill:#fff;"/></g></svg>',
7212		                8: '<svg data-color="#000000" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 98 42" width="98" height="42"><path d="M30 14.5h38a6.5 6.5 0 1 1 0 13H30a6.5 6.5 0 1 1 0-13" style="isolation:isolate;opacity:.17"/><circle cx="36.5" cy="21" r="4" style="fill:#fff"/><circle id="Ellipse_208" cx="49.5" cy="21" r="2" style="opacity:.35;fill:#fff;isolation:isolate;"/><circle cx="61.5" cy="21" r="2" style="opacity:.35;fill:#fff;isolation:isolate;"/></svg>',
7213		                17: '<svg data-color="#000000" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 98 42" width="98" height="42"><path d="M50.12 16h-2v4h-4v2h4v4h2v-4h4v-2h-4v-4zM74.12 20h-4v-4h-2v4h-4v2h4v4h2v-4h4v-2zM32.21 16l-3.33 3.33L25.55 16l-1.67 1.67L27.21 21l-3.33 3.33L25.55 26l3.33-3.33L32.21 26l1.67-1.67L30.55 21l3.33-3.33L32.21 16z"/></svg>',
7214		                13: '<svg data-color="#000000" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 98 42" width="98" height="42"><path d="M31 11h36v20H31z" style="isolation:isolate;fill:#fff;opacity:.3"/><path d="M43.92 17.14V25h-.99v-6.62l-2 .73v-.9l2.84-1.07h.16Z" style="isolation:isolate"/><g style="opacity:.3;isolation:isolate"><path d="m51.22 17.18-3.26 8.49h-.85l3.27-8.49h.85ZM53.45 21.28l-.79-.2.39-3.89h4.01v.92h-3.17l-.24 2.13c.14-.08.32-.16.55-.23.22-.07.47-.11.76-.11.36 0 .69.06.97.19.29.12.53.3.73.53.2.23.36.5.46.83s.16.68.16 1.08c0 .38-.05.72-.15 1.04-.1.31-.25.59-.46.82s-.46.42-.77.54c-.31.13-.67.19-1.09.19-.31 0-.61-.04-.89-.13s-.53-.22-.75-.4c-.22-.18-.4-.41-.54-.68a2.51 2.51 0 0 1-.26-.95h.95c.04.29.13.54.26.74.13.2.3.35.51.45.21.1.45.15.73.15.24 0 .45-.04.63-.12.18-.08.34-.2.46-.36.13-.15.22-.34.29-.56.07-.22.1-.46.1-.74 0-.25-.03-.48-.1-.69s-.17-.4-.3-.55c-.13-.16-.3-.28-.49-.37s-.42-.13-.67-.13c-.33 0-.58.04-.75.13-.17.09-.34.21-.52.37Z"/></g></svg>',
7215		                14: '<svg data-color="#000000" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 98 42" width="98" height="42"><path d="M24 11c5.52 0 10 4.48 10 10s-4.48 10-10 10-10-4.48-10-10 4.48-10 10-10Z" style="fill:#444"/><path id="Path_521" d="M49 11c5.52 0 10 4.48 10 10s-4.48 10-10 10-10-4.48-10-10 4.48-10 10-10Z" style="opacity:.15; fill:#444;"/><path d="M74 11c5.52 0 10 4.48 10 10s-4.48 10-10 10-10-4.48-10-10 4.48-10 10-10Z" style="opacity:.15; fill:#444;"/><path d="M24.92 17.14V25h-.99v-6.62l-2 .73v-.9l2.84-1.07h.16Z" style="fill:#fff;"/><g><path d="M51.77 24.18V25h-5.12v-.71l2.56-2.85c.32-.35.56-.65.73-.89.17-.25.3-.46.37-.66s.1-.39.1-.6c0-.26-.05-.49-.16-.7-.11-.21-.26-.38-.46-.5s-.45-.19-.74-.19c-.35 0-.64.07-.87.2-.23.13-.4.32-.52.56-.11.24-.17.52-.17.83h-.99c0-.44.1-.84.29-1.21s.48-.66.86-.87.85-.33 1.4-.33c.49 0 .92.09 1.27.26s.62.42.81.73c.19.31.28.68.28 1.1 0 .23-.04.46-.12.7-.08.23-.18.47-.32.7-.13.23-.29.46-.47.69-.18.22-.37.45-.57.67l-2.09 2.27h3.92Z" style="fill:#777;"/></g><g><path d="M73.1 21.42v-.6h.85c.5 0 .91.06 1.23.18.33.12.58.28.77.47.19.2.32.41.4.65s.12.47.12.7c0 .37-.06.69-.19.97-.12.28-.3.52-.52.72-.22.2-.49.34-.79.45s-.63.15-.98.15-.66-.05-.96-.14c-.3-.1-.56-.24-.79-.42-.23-.18-.41-.41-.54-.68s-.19-.58-.19-.93h.99c0 .27.06.51.18.71.12.2.29.36.52.48.22.11.49.17.79.17s.57-.05.79-.16c.22-.11.39-.27.51-.48.12-.21.18-.49.18-.81s-.07-.59-.2-.8a1.23 1.23 0 0 0-.58-.47c-.25-.1-.54-.15-.88-.15h-.71Zm0-.82h.71c.35 0 .63-.06.86-.17s.4-.28.51-.48c.11-.2.17-.43.17-.68 0-.3-.05-.55-.15-.76-.1-.2-.25-.36-.45-.46-.2-.1-.45-.16-.76-.16-.28 0-.53.05-.74.16s-.38.26-.5.46-.18.44-.18.71h-.99c0-.4.1-.76.3-1.09.2-.33.48-.58.85-.78.36-.19.78-.29 1.26-.29s.89.08 1.24.25c.36.17.63.41.83.74.2.33.29.73.29 1.22 0 .2-.05.41-.14.63-.09.22-.23.43-.42.63-.19.19-.44.35-.74.48-.3.12-.67.19-1.1.19h-.85v-.6Z" style="fill:#777;"/></g></svg>',
7216		                15: '<svg data-color="#000000" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 98 42" width="98" height="42"><path d="M38.38 21a2.5 2.5 0 0 1-2.5 2.5h-10a2.5 2.5 0 0 1 0-5h10a2.5 2.5 0 0 1 2.5 2.5"/><path d="M55.76 15.7c.98.98.98 2.56 0 3.54l-7.07 7.07c-.98.98-2.56.98-3.54 0s-.98-2.56 0-3.54l7.07-7.07c.98-.98 2.56-.98 3.54 0" style="isolation:isolate;opacity:.16;"/><path d="M73.89 15.7c.98.98.98 2.56 0 3.54l-7.07 7.07c-.98.98-2.56.98-3.54 0s-.98-2.56 0-3.54l7.07-7.07c.98-.98 2.56-.98 3.54 0" style="isolation:isolate;opacity:.16;"/></svg>',
7217		                16: '<svg data-color="#000000" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 98 42" width="98" height="42"><path d="M39.97 21c0 .55-.45 1-1 1h-14c-.55 0-1-.45-1-1s.45-1 1-1h14c.55 0 1 .45 1 1"/><path d="M57.03 15.34c.39.39.39 1.02 0 1.41l-9.9 9.9a.996.996 0 1 1-1.41-1.41l9.9-9.9a.996.996 0 0 1 1.41 0" style="isolation:isolate;opacity:.2;"/><path d="M73.73 15.34c.39.39.39 1.02 0 1.41l-9.9 9.9a.996.996 0 1 1-1.41-1.41l9.9-9.9a.996.996 0 0 1 1.41 0" style="isolation:isolate;opacity:.2;"/></svg>',
7218		                4: '<svg data-color="#000000" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 98 42" width="98" height="42"><path d="M30 16h10v10H30z"/><path d="M48 18h6v6h-6z" style="opacity:.2;"/><path id="Rectangle_1823" d="M62 18h6v6h-6z" style="opacity:.2;"/></svg>',
7219		                18: '<svg data-color="#000000" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 98 42" width="98" height="42"><path id="Rectangle_1720" d="M33.5 20.5h31v1h-31z" style="opacity:.25;" />
7219<path id="Rectangle_1719" d="M64.5 20.5h31v1h-31z" style="opacity:.25;"/><path id="Rectangle_1718" d="M2.5 20.5h31v1h-31z" /></svg>'
7220		            };
7221		        },
7222		        getPopupSlidePaginationStyleOrder: function() {
7223		            return $.siteBanner.getPopupSlideStyleValues(18);
7224		        },
7225		        getPopupSlidePaginationStylePreviewSvg: function(style) {
7226		            var pageObj = $.siteBanner.getPopupSlidePaginationStyleMap();
7227
7228		            style = String(style || '11');
7229		            if(typeof pageObj[style] == 'undefined') style = '11';
7230
7231		            return pageObj[style] || '';
7232		        },
7233		        getPopupSlidePaginationStyleSvg: function(style, color) {
7234		            var pageObj = $.siteBanner.getPopupSlidePaginationStyleMap(),
7235		                $svg = null;
7236
7237		            style = String(style || '11');
7238		            if(!$.siteBanner.isPopupSlidePaginationStyleValue(style)) style = '11';
7239		            color = color || '#222428';
7240		            $svg = $(pageObj[style] || pageObj['11']).clone();
7241		            $svg.attr('data-color', color);
7242
7243		            return $('<div></div>').append($svg).html();
7244		        },
7245		        getPopupSlidePaginationStyleListHtml: function() {
7246		            var html = '',
7247		                pageObj = $.siteBanner.getPopupSlidePaginationStyleMap();
7248
7249		            $.each($.siteBanner.getPopupSlidePaginationStyleOrder(), function(i, n) {
7250		                html += '<li role="presentation"><a data-value="' + n + '">' + (pageObj[n] || '') + '</a></li>';
7251		            });
7252
7253		            return html;
7254		        },
7255		        isPopupSlideMobilePreviewModal: function(modal) {
7256		            var $modal = $(modal);
7257
7258		            return ($modal.closest('#el-siteConfig .sc-popupBanner.m').length > 0 || ($modal.closest('#el-siteConfig .sc-popupBanner').length > 0 && $('#el-siteConfig[data-fn="banner"] .sc-device-wrap > li[data-device="m"]').hasClass('active')));
7259		        },
7260		        isPopupSlideMobileRenderModal: function(modal) {
7261		            var $modal = $(modal);
7262
7263		            return ($.siteBanner.isPopupSlideMobilePreviewModal($modal) || ($modal.closest('.cl-popupBanner').length > 0 && $.siteBanner.getPopupSli
7263deMobileArrowSize() > 0));
7264		        },
7265		        getPopupSlideMobileArrowSize: function(width) {
7266		            var w = Number(width || $(window).width() || $('body').width() || 0);
7267
7268		            if(w > 768 || w < 1) return 0;
7269		            if(w >= 721) return 52;
7270		            if(w >= 621) return 51;
7271		            if(w >= 521) return 50;
7272		            if(w >= 421) return 49;
7273		            return 48;
7274		        },
7275		        getPopupSlideArrowIconRenderSize: function(modal, fallback) {
7276		            var $modal = $(modal),
7277		                size = Number($.siteBanner.getPopupSlideControlSizeValue(fallback, '64')),
7278		                mobileSize = 0;
7279
7280		            if($.siteBanner.isPopupSlideMobilePreviewModal($modal)) return 36;
7281		            if($modal.closest('.cl-popupBanner').length) {
7282		                mobileSize = $.siteBanner.getPopupSlideMobileArrowSize();
7283		                if(mobileSize > 0) return mobileSize;
7284		            }
7285
7286		            return size;
7287		        },
7288				        getPopupSlidePaginationRenderSize: function(modal, fallback, style) {
7289				            var $modal = $(modal),
7290				                styleString = String(style || $modal.attr('data-slidepaginationstyle') || (($modal.attr('data-slidepagination') == 'dot') ? '1' : '11')),
7291				                compactMobileStyles = ['9','10','11','12','13','14'],
7292				                isCompactMobileStyle = ($.inArray(styleString, compactMobileStyles) > -1);
7293
7294				            if($.siteBanner.isPopupSlideMobilePreviewModal($modal)) return (isCompactMobileStyle) ? '28' : '40';
7295				            if($.siteBanner.isPopupSlideMobileRenderModal($modal)) return (isCompactMobileStyle) ? '40' : '52';
7296
7297				            return $.siteBanner.getPopupSlideControlSizeValue(fallback, '52');
7298				        },
7299		        updatePopupSlideArrowIcons: function(modal, style, color) {
7300		            var $modal = $(modal),
7301		                arrowSize = $.siteBanner.getPopupSlideControlSizeValue($modal.attr('data-slidearrowsize') || $.siteBanner.getPopupSlideCssValue($modal, '--popup-slide-arrow-icon-size', '64'), '64'),
7302		                arrowIconSize = $.siteBanner.getPopupSlideArrowIconRenderSize($modal, arrowSize),
7303		                prevSvgHtml = $.siteBanner.getPopupSlideArrowStyleSvg(style, color, arrowIconSize),
7304		                nextSvgHtml = $.siteBanner.getPopupSlideArrowStyleSvg(style, color, arrowIconSize);
7305
7306		            $modal.find('.banner-slide-arrow > .banner-slide-prev').html(prevSvgHtml)
7307		                .find('.banner-slide-arrow-icon').attr({'width':arrowIconSize,'height':arrowIconSize}).css({
7308		                    'width': arrowIconSize + 'px',
7309		                    'height': arrowIconSize + 'px',
7310		                    'transform': '',
7311		                    'transform-origin': ''
7312		                });
7313		            $modal.find('.banner-slide-arrow > .banner-slide-next').html(nextSvgHtml)
7314		                .find('.banner-slide-arrow-icon').attr({'width':arrowIconSize,'height':arrowIconSize}).css({
7315		                    'width': arrowIconSize + 'px',
7316		                    'height': arrowIconSize + 'px',
7317		                    'transform': '',
7318		                    'transform-origin': ''
7319		                });
7320		        },
7321		        applyPopupSlideControlSize: function(modal, arrowSize, paginationSize) {
7322		            var $modal = $(modal),
7323		                modalEl = $modal.get(0),
7324					                aSize = Number($.siteBanner.getPopupSlideControlSizeValue(arrowSize, '64')),
7325					                arrowIconSize = $.siteBanner.getPopupSlideArrowIconRenderSize($modal, aSize),
7326					                mobileArrowBoxSize = ($.siteBanner.isPopupSlideMobilePreviewModal($modal)) ? 36 : (($modal.closest('.cl-popupBanner').length) ? $.siteBanner.getPopupSlideMobileArrowSize() : 0),
7327							                pSize = Number($.siteBanner.getPopupSlideControlSizeValue(paginationSize, '52')),
7328							                paginationStyleValue = $modal.attr('data-slidepaginationstyle') || (($modal.attr('data-slidepagination') == 'dot') ? '1' : '11'),
7329							                pRenderSize = Number($.siteBanner.getPopupSli
7329dePaginationRenderSize($modal, pSize, paginationStyleValue)),
7330						                isMobilePaginationRender = $.siteBanner.isPopupSlideMobileRenderModal($modal),
7331				                arrowBoxSize = 76,
7332				                pRatio = pSize / 52,
7333						                pRenderRatio = pRenderSize / 52,
7334				                paginationSizeMap = {
7335				                    '28': { width: 32, height: 18, fontSize: 12 },
7336				                    '40': { width: 38, height: 23, fontSize: 14 },
7337				                    '52': { width: 50, height: 28, fontSize: 15 },
7338			                    '64': { width: 52, height: 30, fontSize: 16 },
7339			                    '76': { width: 56, height: 32, fontSize: 18 }
7340				                },
7341				                paginationStyle = paginationSizeMap[String(pSize)] || paginationSizeMap['52'],
7342						                paginationMobileStyle = paginationSizeMap[String(pRenderSize)] || paginationSizeMap['52'],
7343				                paginationWidth = paginationStyle.width,
7344				                paginationHeight = paginationStyle.height,
7345				                paginationPaddingY = 0,
7346				                paginationPaddingX = 0,
7347			                paginationFontSize = paginationStyle.fontSize,
7348			                paginationDotSize = Math.max(Math.round(7 * pRatio), 4),
7349			                paginationGap = Math.max(Math.round(6 * pRatio), 4);
7350
7351			            if(!modalEl) return;
7352			            $(modal).attr({'data-slidearrowsize':String(aSize), 'data-slidepaginationsize':String(pSize)});
7353			            modalEl.style.setProperty('--popup-slide-arrow-size', arrowBoxSize + 'px');
7354			            modalEl.style.setProperty('--popup-slide-arrow-margin-top', '-' + Math.round(arrowBoxSize / 2) + 'px');
7355					            modalEl.style.setProperty('--popup-slide-arrow-icon-size', aSize + 'px');
7356					            modalEl.style.setProperty('--popup-slide-arrow-tablet-size', arrowBoxSize + 'px');
7357					            modalEl.style.setProperty('--popup-slide-arrow-tablet-margin-top', '-' + Math.round(arrowBoxSize / 2) + 'px');
7358					            modalEl.style.setProperty('--popup-slide-arrow-tablet-icon-size', aSize + 'px');
7359				            if(mobileArrowBoxSize > 0) {
7360				                modalEl.style.setProperty('--popup-slide-arrow-mobile-size', mobileArrowBoxSize + 'px');
7361				                modalEl.style.setProperty('--popup-slide-arrow-mobile-margin-top', '-' + (mobileArrowBoxSize / 2) + 'px');
7362				                modalEl.style.setProperty('--popup-slide-arrow-mobile-icon-size', mobileArrowBoxSize + 'px');
7363				            } else {
7364				                modalEl.style.removeProperty('--popup-slide-arrow-mobile-size');
7365				                modalEl.style.removeProperty('--popup-slide-arrow-mobile-margin-top');
7366				                modalEl.style.removeProperty('--popup-slide-arrow-mobile-icon-size');
7367				            }
7368				            $modal.find('.banner-slide-arrow-icon').attr({'width':String(arrowIconSize),'height':String(arrowIconSize)}).css({'width':arrowIconSize + 'px','height':arrowIconSize + 'px'});
7369			            modalEl.style.setProperty('--popup-slide-pagination-width', paginationWidth + 'px');
7370			            modalEl.style.setProperty('--popup-slide-pagination-height', paginationHeight + 'px');
7371			            modalEl.style.setProperty('--popup-slide-pagination-padding', paginationPaddingY + 'px ' + paginationPaddingX + 'px');
7372				            modalEl.style.setProperty('--popup-slide-pagination-font-size', paginationFontSize + 'px');
7373				            modalEl.style.setProperty('--popup-slide-pagination-dot-size', paginationDotSize + 'px');
7374				            modalEl.style.setProperty('--popup-slide-pagination-gap', paginationGap + 'px');
7375					            modalEl.style.setProperty('--slider-page-size', pRenderSize + 'px');
7376				            modalEl.style.setProperty('--slider-nav-size', arrowIconSize + 'px');
7377				            if(isMobilePaginationRender) {
7378				                modalEl.style.setProperty('--popup-slide-pagination-mobile-width', paginationMobileStyle.width + 'px');
7379				                modalEl.style.setProperty('--popup-slide-pagination-mobile-height', paginationMobileStyle.height + 'px');
7380				                modalEl.style.setProperty('--popup-slide-pagination-mobile-padding', '0');
7381				                modalEl.style.setProperty('--popup-slide-pagination-mobile-font-size', paginationMobileStyle.fontSize + 'px');
7382				                modalEl.style.setProperty('--popup-slide-pagination-mobile-dot-size', Math.max(Math.round(7 * pRenderRatio), 4) + 'px');
7383				                modalEl.style.setProperty('--popup-slide-pagination-mobile-gap', Math.max(Math.round(6 * pRenderRatio), 4) + 'px');
7384				            } else {
7385				                modalEl.style.removeProperty('--popup-slide-pagination-mobile-width');
7386				                modalEl.style.removeProperty('--popup-slide-pagination-mobile-height');
7387				                modalEl.style.removeProperty('--popup-slide-pagination-mobile-padding');
7388				                modalEl.style.removeProperty('--popup-slide-pagination-mobile-font-size');
7389				                modalEl.style.removeProperty('--popup-slide-pagination-mobile-dot-size');
7390				                modalEl.style.removeProperty('--popup-slide-pagination-mobile-gap');
7391				            }
7392			        },
7393		        setPopupSlide: function(isSC) {
7394	            var selector = (isSC) ? '#el-siteConfig .sc-popupBanner' : '.cl-popupBanner',
7395	                $banner = $(selector);
7396
7397	            $.siteBanner.bindPopupSlideEvents();
7398	            $.siteBanner.stopPopupSlideRolling(selector);
7399
7400	            $banner.find('> .banner-modal').each(function() {
7401	                var $modal = $(this),
7402	                    isSlide = ($modal.attr('data-viewtype') == 'slide'),
7403	                    isAuto = (($modal.attr('data-slideauto') || ((typeof $.siteBanner.popup != 'undefined') ? $.siteBanner.popup.slide_auto : 'OFF')) != 'OFF'),
7404	                    isScPopupPanelOpen = (isSC && $('#el-siteConfig[data-fn="banner"] #popup-banner-accordion .panel-banner-item.open').length > 0) ? true : false,
7405	                    $items = $modal.find('> ul > li.banner-box:not(.hide)'),
7406	                    total = $items.length;
7407
7408	                if(!isSlide) {
7409	                    $modal.find('> ul > li.banner-box').removeClass('active').css('display', '');
7410	                    $modal.find('.banner-slide-pagination').empty();
7411	                    return;
7412	                }
7413		                if(total < 1) {
7414		                    $modal.find('.banner-slide-arrow').addClass('hide');
7415		                    $modal.find('.banner-slide-pagination').addClass('hide').empty();
7416		                    return;
7417		                }
7418
7419		                $.siteBanner.applyPopupSlideControlSize($modal, $modal.attr('data-slidearrowsize'), $modal.attr('data-slidepaginationsize'));
7420		                $.siteBanner.updatePopupSlideArrowIcons($modal, $modal.attr('data-slidearrowstyle') || '1', $.siteBanner.getPopupSlideCssValue($modal, '--popup-slide-arrow-color', '#ffffff'));
7421		                if($modal.attr('data-slide-moving')) $.siteBanner.finishPopupSlide($modal);
7422		                $.siteBanner.showPopupSlide($modal, Number($modal.attr('data-slide-index') || 0), 0);
7423
7424			                if(total >
7424 1 && isAuto && !isScPopupPanelOpen) $.siteBanner.startPopupSlideRollingModal($modal);
7425		            });
7426	        },
7427	        getPopupSlideCssValue: function(modal, key, fallback) {
7428	            var $modal = $(modal),
7429	                modalEl = $modal.get(0),
7430	                val = '';
7431
7432	            if(modalEl && window.getComputedStyle) val = window.getComputedStyle(modalEl).getPropertyValue(key);
7433	            if(!val) val = $modal.css(key);
7434	            val = $.trim(val || '');
7435
7436	            return val || fallback;
7437	        },
7438			        applyPopupSlideControlColors: function(modal) {
7439			            var $modal = $(modal),
7440			                arrowColor = $.siteBanner.getPopupSlideCssValue($modal, '--popup-slide-arrow-color', '#ffffff'),
7441		                paginationColor = $.siteBanner.getPopupSlideCssValue($modal, '--popup-slide-pagination-color', '#ffffff'),
7442		                paginationActiveColor = $.siteBanner.getPopupSlideCssValue($modal, '--popup-slide-pagination-active-color', '#000000');
7443
7444		            $modal.find('.banner-slide-arrow > button').css('background-color', '');
7445		            $modal.find('.banner-slide-arrow-icon').each(function() {
7446		                $.siteBanner.setPopupSvgColor(this, arrowColor);
7447		            });
7448
7449		            $modal.find('.banner-slide-pagination').css({'color': '', 'background-color': ''});
7450		            $modal.find('.banner-slide-pagination .active').css('color', '');
7451			            $modal.find('.banner-slide-dot').css('background-color', '');
7452			            $modal.find('.banner-slide-dot.active').css('background-color', '');
7453			        },
7454		        placePopupSlideControls: function(modal, item) {
7455		            var $modal = $(modal),
7456			                $item = $(item),
7457			                $body = $item.find('.banner-body').eq(0),
7458			                $content = $item.find('> .banner-content').eq(0),
7459			                $imageArea = $body.find('.banner-img').eq(0),
7460			                $arrow = $modal.find('.banner-slide-arrow').eq(0),
7461			                $pagination = $modal.find('.banner-slide-pagination').eq(0),
7462			                imageHeight = ($imageArea.length) ? $imageArea.outerHeight() : 0,
7463			                imageTop = ($imageArea.length) ? $imageArea.position().top : 0,
7464			                bodyHeight = ($body.length) ? $body.outerHeight() : 0,
7465			                contentHeight = ($content.length) ? $content.outerHeight() : 0,
7466			                arrowTop = (imageHeight > 0) ? (imageTop + (imageHeight / 2)) : ((bodyHeight || contentHeight) / 2);
7467
7468		            if(!$body.length) return;
7469		            if(arrowTop > 0) $body.get(0).style.setProperty('--popup-slide-arrow-top', arrowTop + 'px');
7470		            if($arrow.length) $body.append($arrow);
7471		            if($pagination.length) $body.append($pagination);
7472		        },
7473		        getPopupSlideSpeedValue: function(modal) {
7474		            var $modal = $(modal),
7475		                speed = $modal.attr('data-slidespeed') || ((typeof $.siteBanner.popup != 'undefined') ? $.siteBanner.popup.slide_speed : '3');
7476
7477	            speed = String(speed || '3');
7478	            if($.inArray(speed, ['1','2','3','4','5']) < 0) speed = '3';
7479
7480	            return speed;
7481	        },
7482	        getPopupSlideDelay: function(modal) {
7483	            var stopTime = $.siteBanner.getPopupSlideTimeValue(modal, 'data-slidestoptime', 'slide_stop_time', ''),
7484	                fallbackStopTime = '3';
7485
7486	            if(!stopTime) {
7487	                var speed = $.siteBanner.getPopupSlideSpeedValue(modal),
7488	                    delayMap = {
7489	                    '1': 7000,
7490	                    '2': 5000,
7491	                    '3': 3000,
7492	                    '4': 2000,
7493	                    '5': 1200
7494	                };
7495	                fallbackStopTime = String(Math.max(Math.round((delayMap[speed] || delayMap['3']) / 1000), 1));
7496	                stopTime = $.siteBanner.getPopupSlideTimeValue(modal, 'data-slidestoptime', 'slide_stop_time', fallbackStopTime);
7497	            }
7498
7499			            return $.siteBanner.getPopupSlideDuration(modal) + (Number(stopTime) * 1000);
7500			        },
7501				        updatePopupSlidePaginationState: function(pagination, style, index, total) {
7502				            var $pagination = $(pagination),
7503				                styleString = String(style || '11'),
7504				                bulletStyles = ['1','2','3','4','5','6','7','8','9','10','14','15','16','17','18'],
7505				                pageNumberStyles = ['9','10','14'],
7506				                dynamicBulletStyles = ['2','4'],
7507				                isDynamicBulletStyle = ($.inArray(styleString, dynamicBulletStyles) > -1),
7508				                $widthWrap = $pagination.find('> .swiper-pagination-width').eq(0),
7509				                $dots = (styleString == '18') ? $pagination.find('> span.banner-slide-dot') : $widthWrap.find('> span.banner-slide-dot'),
7510				                $indicator = $pagination.find('> .nav-indicator').eq(0),
7511				                dynamicMainBullets = 1,
7512				                dynamicWindowLength = dynamicMainBullets + 4,
7513				                dynamicBulletsLength = Math.min(total, dynamicWindowLength),
7514				                firstIndex = index,
7515				                lastIndex = index,
7516				                midIndex = index,
7517				                bulletSize = 0,
7518				                bulletsOffset = 0,
7519				                indicatorWidth = 100,
7520				                animateState = ($pagination.attr('data-popup-slide-pagination-ready') == '1'),
7521				                stateToken = Number($pagination.data('popupSlidePaginationFrame') || 0) + 1,
7522				                updates = [],
7523				                applyState,
7524				                i = 0,
7525				                dotClass = '',
7526				                num = '';
7527
7528				            if(!$pagination.length || $.inArray(styleString, bulletStyles) < 0 || $dots.length != total) return false;
7529				            if(styleString == '18' && !$indicator.length) return false;
7530
7531				            if(isDynamicBulletStyle && total > 0) {
7532				                bulletSize = $dots.eq(0).outerWidth(true) || parseInt($dots.eq(0).css('width'), 10) || 0;
7533				                if(bulletSize > 0 && $widthWrap.length) {
7534				                    bulletsOffset = (((bulletSize * dynamicBulletsLength) - bulletSize) / 2) - (midIndex * bulletSize);
7535				                    $pagination.css('width', (bulletSize * dynamicWindowLength) + 'px');
7536				                    $widthWrap.css('width', (bulletSize * dynamicWindowLength) + 'px');
7537				                }
7538				            } else {
7539				                $pagination.css('width', '');
7540				                if($widthWrap.length) $widthWrap.css('width', '');
7541				                $dots.css('left', '');
7542				            }
7543
7544				            for(i = 0; i < total; i++) {
7545				                dotClass = 'banner-slide-dot swiper-pagination-bullet';
7546				                if(i == index) dotClass += ' swiper-pagination-bullet-active active';
7547				                if(isDynamicBulletStyle) {
7548				                    if(i >= firstIndex && i <= lastIndex) dotClass += ' swiper-pagination-bullet-active-main';
7549				                    if(i == firstIndex - 1) dotClass += ' swiper-pagination-bullet-active-prev';
7550				                    if(i == firstIndex - 2) dotClass += ' swiper-pagination-bullet-active-prev-prev';
7551				                    if(i == lastIndex + 1) dotClass += ' swiper-pagination-bullet-active-next';
7552				                    if(i == lastIndex + 2) dotClass += ' swiper-pagination-bullet-active-next-next';
7553				                }
7554				                num = (i + 1);
7555				                if($.inArray(styleString, pageNumberStyles) > -1 && num < 10 && styleString != '14') num = '0' + num;
7556				                $dots.eq(i).attr('data-index', i).text(($.inArray(styleString, pageNumberStyles) > -1) ? num : '');
7557				                updates.push({el:$dots.get(i), className:dotClass});
7558				            }
7559
7560				            $pagination.attr('data-popup-slide-pagination-ready', '1');
7561				            $pagination.data('popupSlidePaginationFrame', stateToken);
7562				            applyState = function() {
7563				                var j = 0;
7564				                if(Number($pagination.data('popupSlidePaginationFrame')) !== stateToken) return;
7565				                for(j = 0; j < updates.length; j++) {
7566				                    if(!updates[j].el) continue;
7567				                    updates[j].el.className = updates[j].className;
7568				                    if(isDynamicBulletStyle && bulletSize > 0) updates[j].el.style.left = bulletsOffset + 'px';
7569				                    else updates[j].el.style.left = '';
7570				                }
7571				                if(styleString == '18') {
7572				                    indicatorWidth = (total > 0) ? (100 / total) : 100;
7573				                    $indicator.css({'width':indicatorWidth + '%','height':'2px','transform':'translateX(' + (index * 100) + '%)'});
7574				                }
7575				            };
7576
7577				            if(animateState && typeof window != 'undefined' && window.requestAnimationFrame) window.requestAnimationFrame(applyState);
7578				            else applyState();
7579
7580				            return true;
7581				        },
7582				        getPopupSlideDuration: function(modal, isManual) {
7583				            return 1000;
7584				        },
7585	        getPopupSlideTimeValue: function(modal, attr, stateKey, fallback) {
7586	            var $modal = $(modal),
7587	                val = $modal.attr(attr) || ((typeof $.siteBanner.popup != 'undefined') ? $.siteBanner.popup[stateKey] : '') || fallback || '';
7588
7589	            val = String(val || '').replace(/[^0-9]/g, '');
7590	            if(val == '') return '';
7591	            if(Number(val) < 1) val = '1';
7592	            if(Number(val) > 10) val = '10';
7593
7594		            return val;
7595		        },
7596		        getPopupSlidePaginationHtml: function(style, index, total) {
7597		            var html = '',
7598		                i = 0,
7599		                num = '',
7600		                bulletClass = '',
7601		                pageNumberStyles = ['9','10','14'],
7602		                fractionStyle = ($.inArray(String(style), ['11','12','13']) > -1),
7603		                dynamicBulletStyles = ['2','4'],
7604		                isDynamicBulletStyle = false,
7605		                prevIndex = -1,
7606		                nextIndex = -1,
7607		                indicatorWidth = 100,
7608		                arrowSvg = '<svg viewBox="0 0 20 20" width="20" height="20"><path d="M13.76 18a.47.47 0 0 1-.33-.14L5.9 10.33a.483.483 0 0 1 0-.67l7.53-7.53c.18-.18.48-.18.67 0s.18.48 0 .67L6.9 10l7.2 7.2c.18.18.18.48 0 .67-.09.08-.21.13-.34.13z" /></svg>';
7609
7610		            style = String(style || '11');
7611		            if(!$.siteBanner.isPopupSlidePaginationStyleValue(style)) style = '11';
7612		            isDynamicBulletStyle = ($.inArray(style, dynamicBulletStyles) > -1);
7613		            if(isDynamicBulletStyle && total > 1) {
7614		                prevIndex = index - 1;
7615		                nextIndex = index + 1;
7616		            }
7617
7618		            if(fractionStyle) {
7619		                html = '<div class="fraction-capsule">';
7620		                if(style == '12') {
7621		                    html += '<div class="fraction-numbers"><span class="swiper-pagination-current">' + (index + 1) + '</span><span class="separator">/</span><span class="swiper-pagination-total">' + total + '</span></div>';
7622		                    html += '<div class="fraction-nav"><div class="custom-nav-btn prev banner-slide-prev">' + arrowSvg + '</div><div class="nav-divider"></div><div class="custom-nav-btn next banner-slide-next">' + arrowSvg + '</div></div>';
7623		                } else {
7624		                    html += '<span class="swiper-pagination-current">' + (index + 1) + '</span><span class="separator">/</span><span class="swiper-pagination-total">' + total + '</span>';
7625		                }
7626		                html += '</div>';
7627		                return html;
7628		            }
7629
7630		            if(style != '18') html += '<div class="swiper-pagination-width">';
7631		            for(i = 0; i < total; i++) {
7632		                bulletClass = 'banner-slide-dot swiper-pagination-bullet';
7633		                if(i == index) {
7634		                    bulletClass += ' swiper-pagination-bullet-active active';
7635		                    if(isDynamicBulletStyle) bulletClass += ' swiper-pagination-bullet-active-main';
7636		                } else if(isDynamicBulletStyle && i == prevIndex) {
7637		                    bulletClass += ' swiper-pagination-bullet-active-prev';
7638		                } else if(isDynamicBulletStyle && i == nextIndex) {
7639		                    bulletClass += ' swiper-pagination-bullet-active-next';
7640		                } else if(isDynamicBulletStyle && i == prevIndex - 1) {
7641		                    bulletClass += ' swiper-pagination-bullet-active-prev-prev';
7642		                } else if(isDynamicBulletStyle && i == nextIndex + 1) {
7643		                    bulletClass += ' swiper-pagination-bullet-active-next-next';
7644		                }
7645		                num = (i + 1);
7646		                if($.inArray(style, pageNumberStyles) > -1 && num < 10 && style != '14') num = '0' + num;
7647		                html += '<span class="' + bulletClass + '" data-index="' + i + '">' + (($.inArray(style, pageNumberStyles) > -1) ? num : '') + '</span>';
7648		            }
7649		            if(style != '18') html += '</div>';
7650		            if(style == '18') {
7651		                indicatorWidth = (total > 0) ? (100 / total) : 100;
7652		                html += '<div class="nav-indicator" style="width:' + indicatorWidth + '%;height:2px;transform:translateX(' + (index * 100) + '%);"></div>';
7653		            }
7654
7655		            return html;
7656		        },
7657			        showPopupSlide: function(modal, index, direction, isManual) {
7658			            var $modal = $(modal),
7659			                $ul = $modal.find('> ul'),
7660		                $items = $modal.find('> ul > li.banner-box:not(.hide)'),
7661		                total = $items.length;
7662
7663		            if(!isManual && $modal.attr('data-slide-moving')) return;
7664		            if(total < 1) {
7665		                $modal.removeAttr('data-slide-moving');
7666		                return;
7667		            }
7668		            if(index < 0) index = total - 1;
7669		            if(index >= total) index = 0;
7670
7671	            var $activeItem = $items.eq(index),
7672	                $currentItem = $items.filter('.active').eq(0),
7673	                hasCurrent = ($currentItem.length > 0 && $currentItem.get(0) !== $activeItem.get(0)),
7674	                activeItemWidth = 0,
7675	                basePosition = {top:0, left:0};
7676
7677	            if(typeof direction == 'undefined') direction = 1;
7678	            if(!hasCurrent) direction = 0;
7679
7680		            if(!hasCurrent) {
7681			                $items.removeClass('active sliding').css({'display':'', 'position':'', 'top':'', 'left':'', 'z-index':''});
7682			                $items.find('> .banner-content, .banner-body > a').css('left', '');
7683			                $activeItem.addClass('active').css('display', 'block');
7684			                $modal.removeAttr('data-slide-moving');
7685			            }
7686
7687		            var $controlItem = (hasCurrent) ? $currentItem : $activeItem,
7688		                $controlBody = $controlItem.find('.banner-body').eq(0),
7689		                modalOffset = $modal.offset() || {top:0, left:0},
7690	                bodyOffset = ($controlBody.length) ? $controlBody.offset() : $controlItem.offset(),
7691	                bodyPosition = {
7692	                    top: ((bodyOffset && typeof bodyOffset.top != 'undefined') ? bodyOffset.top : modalOffset.top) - modalOffset.top,
7693	                    left: ((bodyOffset && typeof bodyOffset.left != 'undefined') ? bodyOffset.left : modalOffset.left) - modalOffset.left
7694	                },
7695	                bodyWidth = (($controlBody.length) ? $controlBody.outerWidth() : 0) || $controlItem.outerWidth() || parseInt($controlItem.css('width')),
7696	                bodyHeight = (($controlBody.length) ? $controlBody.outerHeight() : 0) || $controlItem.outerHeight();
7697
7698		            activeItemWidth = bodyWidth;
7699		            $.siteBanner.placePopupSlideControls($modal, $controlItem);
7700		            if(activeItemWidth > 0 && $modal.get(0)) {
7701		                $modal.get(0).style.setProperty('--popup-slide-control-width', activeItemWidth + 'px');
7702		                $modal.get(0).style.setProperty('--popup-slide-control-left', bodyPosition.left + 'px');
7703	                $modal.get(0).style.setProperty('--popup-slide-control-top', (bodyPosition.top + (bodyHeight / 2)) + 'px');
7704	            }
7705
7706				            var paginationStyle = $modal.attr('data-slidepaginationstyle') || (($modal.attr('data-slidepagination') == 'dot') ? '1' : '11'),
7707				                paginationType = $.siteBanner.getPopupSlidePaginationTypeByStyle(paginationStyle),
7708				                paginationSize = $.siteBanner.getPopupSlideControlSizeValue($modal.attr('data-slidepaginationsize'), '52'),
7709				                paginationRenderSize = $.siteBanner.getPopupSlidePaginationRenderSize($modal, paginationSize, paginationStyle),
7710				                paginationHtml = $.siteBanner.getPopupSlidePaginationHtml(paginationStyle, index, total),
7711				                $paginationWrap = $modal.find('.banner-slide-pagination').eq(0),
7712				                $pagination = $paginationWrap.find('> .slider-pagination-popup').eq(0);
7713
7714			            $modal.attr('data-slidepagination', paginationType);
7715			            if($paginationWrap.length && !$pagination.length) {
7716			                $paginationWrap.addClass('el_popup_slide_pagination').empty().append('<div class="slider-pagination-popup"></div>');
7717			                $pagination = $paginationWrap.find('> .slider-pagination-popup').eq(0);
7718					            }
7719				            $paginationWrap.toggleClass('hide', total < 2 || $modal.attr('data-slidepaginationdisplay') == 'OFF');
7720				            $pagination.attr({'data-style': paginationStyle, 'data-size': paginationRenderSize + 'px'});
7721				            $pagination.toggleClass('swiper-pagination-bullets-dynamic', $.inArray(String(paginationStyle), ['2','4']) > -1);
7722					            if(!$.siteBanner.updatePopupSlidePaginationState($pagination, paginationStyle, index, total)) {
7723					                $pagination.html(paginationHtml).removeAttr('data-popup-slide-pagination-ready');
7724					                if(!$.siteBanner.updatePopupSlidePaginationState($pagination, paginationStyle, index, total)) $pagination.attr('data-popup-slide-pagination-ready', '1');
7725					            }
7726					            $modal.find('.banner-slide-arrow').toggleClass('hide', total < 2 || $modal.attr('data-slidearrow') != 'ON' || paginationStyle == '12');
7727	            $.siteBanner.applyPopupSlideControlColors($modal);
7728
7729	            basePosition = (hasCurrent) ? $currentItem.position() : $activeItem.position();
7730	            var paginationHeight = $paginationWrap.outerHeight() || 0,
7731	                paginationWidth = $paginationWrap.outerWidth() || 0,
7732	                paginationTop = bodyPosition.top + bodyHeight - paginationHeight - 15,
7733	                paginationLeft = bodyPosition.left + ((bodyWidth - paginationWidth) / 2),
7734	                paginationRight = ($modal.innerWidth() || 0) - (bodyPosition.left + bodyWidth) + 15;
7735
7736	            if($modal.get(0)) {
7737	                $modal.get(0).style.setProperty('--popup-slide-pagination-top', paginationTop + 'px');
7738	                $modal.get(0).style.setProperty('--popup-slide-pagination-left', paginationLeft + 'px');
7739	                $modal.get(0).style.setProperty('--popup-slide-pagination-right', paginationRight + 'px');
7740	            }
7741	            if(hasCurrent && total > 1) {
7742			                var moveWidth = activeItemWidth * ((direction < 0) ? -1 : 1),
7743			                    slideDuration = $.siteBanner.getPopupSlideDuration($modal, isManual),
7744		                    slideEasing = (typeof $.easing != 'undefined' && typeof $.easing.easeInOutQuart == 'function') ? 'easeInOutQuart' : 'swing',
7745		                    $currentBody = $currentItem.find('.banner-body').eq(0),
7746		                    $currentSlide = $currentBody.find('> a').eq(0),
7747		                    $activeSlide = $activeItem.find('.banner-body > a').eq(0),
7748			                    $slideClone = null,
7749			                    finishPopupSlide = function() {
7750			                        $currentItem.removeClass('active sliding').css({'display':'', 'position':'', 'top':'', 'left':'', 'z-index':''});
7751			                        $currentItem.find('> .banner-content, .banner-body > a').css({'left':'', 'position':'', 'z-index':''});
7752			                        $activeItem.removeClass('sliding').addClass('active').css({'display':'block', 'position':'', 'top':'', 'left':'', 'z-index':''});
7753			                        $activeItem.find('> .banner-content, .banner-body > a').css({'left':'', 'position':'', 'z-index':''});
7754			                        $.siteBanner.placePopupSlideControls($modal, $activeItem);
7755			                        $modal.removeAttr('data-slide-moving');
7756			                    };
7757			                if(!$currentSlide.length) $currentSlide = $currentItem.find('> .banner-content');
7758			                if(!$activeSlide.length) $activeSlide = $activeItem.find('> .banner-content');
7759
7760			                $modal.attr('data-slide-moving', isManual ? 'manual' : 'auto');
7761			                $ul.stop(true, true);
7762		                $items.not($currentItem).not($activeItem).removeClass('active sliding').css({'display':'', 'position':'', 'top':'', 'left':'', 'z-index':''});
7763		                $items.not($currentItem).not($activeItem).find('> .banner-content, .banner-body > a').css({'left':'', 'position':'', 'z-index':''});
7764		                $items.find('.banner-body > .banner-slide-clone').remove();
7765		                $activeItem.stop(true, true).removeClass('active sliding').css({'display':'', 'position':'', 'top':'', 'left':'', 'z-index':''});
7766		                $activeItem.find('> .banner-content, .banner-body > a').css({'left':'', 'position':'', 'z-index':''});
7767		                $currentItem.stop(true, true).addClass('active').css({'display':'block', 'position':'relative', 'top':'auto', 'left':0, 'z-index':2});
7768		                if(!$currentBody.length || !$currentSlide.length || !$activeSlide.length) {
7769		                    finishPopupSlide();
7770		                } else {
7771		                    $slideClone = $activeSlide.clone(false, false).addClass('banner-slide-clone');
7772		                    $slideClone.removeAttr('id').find('[id]').removeAttr('id');
7773		                    $slideClone.css({'position':'absolute', 'top':0, 'left':moveWidth + 'px', 'width':bodyWidth + 'px', 'height':bodyHeight + 'px', 'margin':0, 'z-index':1, 'pointer-events':'none'});
7774		                    $currentBody.append($slideClone);
7775		                    $currentSlide.stop(true, true).css({'position':'relative', 'left':0, 'z-index':1}).animate({'left':(-moveWidth) + 'px'}, slideDuration, slideEasing);
7776		                    $slideClone.stop(true, true).animate({'left':'0px'}, slideDuration, slideEasing, function() {
7777		                        $currentSlide.css({'left':'', 'position':'', 'z-index':''});
7778		                        $slideClone.remove();
7779		                        finishPopupSlide();
7780		                    });
7781		                }
7782		            }
7783
7784		            $modal.attr('data-slide-index', index).attr('data-slide-total', total);
7785		        },
7786		        finishPopupSlide: function(modal) {
7787		            var $modal = $(modal),
7788		                $items = $modal.find('> ul > li.banner-box:not(.hide)'),
7789		                total = $items.length,
7790		                index = Number($modal.attr('data-slide-index') || 0),
7791		                $activeItem = null;
7792
7793		            if(total < 1) return;
7794		            if(index < 0) index = total - 1;
7795		            if(index >= total) index = 0;
7796
7797		            $items.stop(true, true);
7798		            $items.find('.banner-body > .banner-slide-clone').remove();
7799		            $items.find('> .banner-content, .banner-body > a').stop(true, true).css({'left':'', 'position':'', 'z-index':''});
7800		            $items.removeClass('active sliding').css({'display':'', 'position':'', 'top':'', 'left':'', 'z-index':''});
7801
7802		            $activeItem = $items.eq(index);
7803		            $activeItem.addClass('active').css('display', 'block');
7804		            $.siteBanner.placePopupSlideControls($modal, $activeItem);
7805		            $modal.attr('data-slide-index', index).attr('data-slide-total', total).removeAttr('data-slide-moving');
7806		        },
7807		        isPopupSlideManualMoving: function(modal) {
7808		            return ($(modal).attr('data-slide-moving') == 'manual');
7809		        },
7810		        nextPopupSlide: function(modal, direction, isManual) {
7811		            var $modal = $(modal),
7812		                index = Number($modal.attr('data-slide-index') || 0);
7813
7814		            $.siteBanner.showPopupSlide($modal, index + direction, direction, isManual);
7815		        },
7816		        startPopupSlideRollingModal: function(modal) {
7817		            var $modal = $(modal),
7818		                isSlide = ($modal.attr('data-viewtype') == 'slide'),
7819		                isAuto = (($modal.attr('data-slideauto') || ((typeof $.siteBanner.popup != 'undefined') ? $.siteBanner.popup.slide_auto : 'OFF')) != 'OFF'),
7820		                isScPopupPanelOpen = ($modal.closest('#el-siteConfig[data-fn="banner"] .sc-popupBanner').length > 0 && $('#el-siteConfig[data-fn="banner"] #popup-banner-accordion .panel-banner-item.open').length > 0) ? true : false,
7821		                total = $modal.find('> ul > li.banner-box:not(.hide)').length,
7822		                seq = null,
7823		                slideDelay = 0;
7824
7825		            if(!isSlide || !isAuto || total < 2 || $modal.attr('data-slide-seq') || isScPopupPanelOpen) return;
7826
7827		            slideDelay = $.siteBanner.getPopupSlideDelay($modal);
7828		            seq = setInterval(function() {
7829		                $.siteBanner.nextPopupSlide($modal, 1, false);
7830		            }, slideDelay);
7831
7832		            $modal.attr('data-slide-seq', seq);
7833		            if(typeof $.siteBanner.popup != 'undefined') {
7834		                if(typeof $.siteBanner.popup.slide_seqs == 'undefined') $.siteBanner.popup.slide_seqs = [];
7835		                $.siteBanner.popup.slide_seqs.push(seq);
7836		            }
7837		        },
7838		        stopPopupSlideRollingModal: function(modal) {
7839		            var $modal = $(modal),
7840		                seq = $modal.attr('data-slide-seq'),
7841		                seqArr = (typeof $.siteBanner.popup != 'undefined' && typeof $.siteBanner.popup.slide_seqs != 'undefined') ? $.siteBanner.popup.slide_seqs : [],
7842		                nextSeqArr = [];
7843
7844		            if(seq) {
7845		                clearInterval(Number(seq));
7846		                $modal.removeAttr('data-slide-seq');
7847		            }
7848		            $.each(seqArr, function(i, rollingSeq) {
7849		                if(seq && String(rollingSeq) == String(seq)) {
7850		                    clearInterval(rollingSeq);
7851		                } else {
7852		                    nextSeqArr.push(rollingSeq);
7853		                }
7854		            });
7855		            if(typeof $.siteBanner.popup != 'undefined') $.siteBanner.popup.slide_seqs = nextSeqArr;
7856		        },
7857		        stopPopupSlideRolling: function(selector) {
7858		            var $modal = (selector) ? $(selector).find('.banner-modal') : $('.sc-popupBanner .banner-modal, .cl-popupBanner .banner-modal'),
7859		                seqArr = (typeof $.siteBanner.popup != 'undefined' && typeof $.siteBanner.popup.slide_seqs != 'undefined') ? $.siteBanner.popup.slide_seqs : [];
7860
7861	            $modal.each(function() {
7862	                var seq = $(this).attr('data-slide-seq');
7863	                if(seq) clearInterval(seq);
7864	                $(this).removeAttr('data-slide-seq');
7865	            });
7866
7867	            $.each(seqArr, function(i, seq) {
7868	                clearInterval(seq);
7869	            });
7870
7871	            if(typeof $.siteBanner.popup != 'undefined') $.siteBanner.popup.slide_seqs = [];
7872	        },
7873	        setBandRolling: function() {
7874	            if($.siteBanner.band.paused) return false;
7875
7876            var bannerEL = $('.cl-bandBanner[data-seq="'+$.siteBanner.band.seqs[$.siteBanner.band.seqs.length - 1]+'"]');
7877            if(bannerEL.length == 0) return false;
7878            var bannerUL = bannerEL.find('.banner-modal > ul'),
7879                banner_h = $.siteBanner.getBandHeight(),
7880                banner_l = bannerUL.children('.banner-box:not(.hide)').length;
7881
7882            bannerUL.animate({ top: -banner_h+'px' }, 1000, 'easeInOutQuart', function() {
7883                $(this).append($(this).find('li.banner-box:not(.hide)').eq(0).clone().wrapAll('<li />').parent().html());
7884
7885                $(this).find('li.banner-box:not(.hide)').eq(0).remove();
7886                $(this).css('top', 0);
7887            });
7888        },
7889        stopBandRolling: function() {
7890            var seq = ($('.cl-bandBanner').length > 0) ? $('.cl-bandBanner').attr('data-seq') : 0,
7891                seq_arr = (typeof $.siteBanner.band != 'undefined' && typeof $.siteBanner.band.seqs != 'undefined') ? $.siteBanner.band.seqs : [];
7892
7893            if(seq) clearInterval(seq);
7894            $.each(seq_arr, function(i,v) {
7895                clearInterval(v);
7896            });
7897
7898            if(seq_arr.length > 0) {
7899                $.siteBanner.band.seqs = [];
7900                $.siteBanner.band.paused = false;
7901            }
7902        },
7903    }
7904
7905    $.fixedContact = {
7906        init: function($el) {
7907            // console.log('fixedContact init');
7908            let sid = (typeof property != 'undefined')? property.SID : SID;
7909            let settings = (typeof property != 'undefined')? property.SETTINGS : SETTINGS;
7910            let onoff = (typeof $.cookie('fixedcontact-' + sid) != 'undefined')? $.cookie('fixedcontact-' + sid) : 'on';
7911            let device = ($('body').width() > 768) ? 'pc' : 'mobile';
7912
7913            $el.addClass('el-fixedcontact');
7914            if(onoff == 'off') $el.addClass('down');
7915            
7916            if($.fnav.checkFnavON()) {
7917                if(typeof settings.qm_onoff == 'undefined') $el.addClass('has-fnav');
7918            }
7919
7920            if(typeof settings.viewportMode != 'undefined' && settings.vpMode_onoff===true && $('.mobilepc_ch').length > 0) {
7921                $el.addClass('has-vpmode');
7922            }
7923
7924            setTimeout(function(){
7925                $.fixedContact.addBtn($el);
7926            }, 100);
7927        },
7928        addBtn: function($el) {
7929            let bgcolor = $el.css('background-color');
7930            let bgimg = $el.css('background-image');
7931            let bgPos = $el.css('background-position');
7932            let btnBackground = 'background-color:'+bgcolor+';';
7933            let btnHTML = '<div class="fixedcontact-onoff hand" style="' + btnBackground + '"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" width="20" height="20"><path d="M10 13.7 3.6 7.4l.8-.8 5.6 5.7 5.6-5.7.8.8-6.4 6.3z"/></svg></div>';
7934            $el.append(btnHTML);
7935
7936            if(PAGE_MODE != 'c') {                
7937                $(document).off('click', '.fixedcontact-onoff');
7938                $(document).on('click', '.fixedcontact-onoff', function(){
7939                    let sid = property.SID;
7940                    let date = new Date();
7941                    
7942                    date.setTime(date.getTime() + 6*60*60*1000); // 6h
7943                    $('.el-fixedcontact').toggleClass('down');
7944                    
7945                    if($('.el-fixedcontact').hasClass('down')) {
7946                        $.cookie('fixedcontact-' + sid, 'off', { expires: date, path : '/' });
7947                    } else {
7948                        $.cookie('fixedcontact-' + sid, 'on', { expires: date, path : '/' });
7949                    }
7950
7951                    let scrollTop = $(window).scrollTop(),
7952                        device_type = ($('body').width() > 768) ? 'pc' : 'mobile',
7953                        gotoTop_position = $(window).height() - $('#goto-top').outerHeight() - $('#goto-top').position().top,
7954                        el_fixedheight = $('.element.el-fixedcontact').innerHeight(),
7955                        el_fixedonoff = 22,
7956                        el_fixedblocktotalHeight = el_fixedheight + el_fixedonoff,
7957                        music_position = (($('#cl-music-player-icon').length > 0)) ? Number($('#cl-music-player-icon').css('bottom').replace(/px/gi,'')) : 0,
7958                        quickmenu_position = (($(`.quick-menu-${sid}.quickmenu`).length > 0)) ? Number($(`.quick-menu-${sid}.quickmenu`).css('bottom').replace(/px/gi,'')) : 0;
7959                    
7960                        if($('.el-fixedcontact').hasClass('down')) {                           
7961                            if(device_type=='pc') $('#goto-top').css('bottom',gotoTop_position - el_fixedheight);
7962                            if(typeof $.quickmenu['quickmenu'] != 'undefined' && $.quickmenu['quickmenu']['img_type'][device_type]!='bottom_default') $(`.quick-menu-${sid}.quickmenu`).css('bottom',quickmenu_position - el_fixedheight);	
7963                            if($('#cl-music-player-icon').length > 0) $('#cl-music-player-icon, #cl-music-container').css('bottom',music_position - el_fixedheight);	                            
7964                        } else {
7965                            if(device_type=='pc') $('#goto-top').css('bottom',gotoTop_position + el_fixedheight);
7966                            if(typeof $.quickmenu['quickmenu'] != 'undefined' && $.quickmenu['quickmenu']['img_type'][device_type]!='bottom_default') $(`.quick-menu-${sid}.quickmenu`).css('bottom',quickmenu_position + el_fixedheight);	
7967                            if($('#cl-music-player-icon').length > 0) $('#cl-music-player-icon, #cl-music-container').css('bottom',music_position + el_fixedheight);	
7968                        }
7969                });
7970
7971                $.fixedContact.checkPosition($('.el-fixedcontact'));
7972
7973                $(window).on('scroll', function() {
7974                    $.fixedContact.checkPosition($('.el-fixedcontact'));
7975                });
7976            }
7977        },
7978        checkPosition: function($el) {
7979            if(PAGE_MODE != 'c' && $el.length > 0) {
7980                let isNotFixed = $el.hasClass('notfixed');
7981                let scrollTop = $(window).scrollTop();
7982                let windowHeight = $(window).height();
7983                let documentHeight = $(document).height();
7984                let footerTop = ($('.el-footer').length > 0 && $('.el-footer').hasClass('hide') == false)? $('.el-footer').offset().top : documentHeight - $el.outerHeight();
7985                if($el.hasClass('has-fnav')) footerTop -= 53;
7986                let distanceScrolled = (isNotFixed)? Math.max(0, scrollTop + windowHeight - footerTop + $el.outerHeight()) : Math.max(0, scrollTop + windowHeight - footerTop);
7987                // console.log('windowHeight', windowHeight);
7988                // console.log('scrollTop', scrollTop);
7989                // console.log('footerTop', footerTop);
7990                // console.log('documentHeight', documentHeight);
7991                // console.log('distanceScrolled', distanceScrolled);
7992
7993                if (distanceScrolled > 0 && !isNotFixed) {
7994                    $el.addClass('notfixed');
7995                } else if (distanceScrolled <= 0 && isNotFixed) {
7996                    $el.removeClass('notfixed');
7997                }
7998            }
7999        }
8000    }
8001
8002    // $(".element").removeInlineCss("color font-size font-weight");
8003    jQuery.fn.removeInlineCss = function (properties) {
8004        if (properties == null) return this.removeAttr('style');
8005        properties = properties.split(/\s+/);
8006        return this.each(function () {
8007            for (var i = 0; i < properties.length; i++)
8008                this.style.removeProperty(properties[i])
8009        });
8010    }
8011
8012    jQuery.fn.refreshRootCss = function(property_key) {
8013        var isAll = (typeof property_key == 'undefined' || property_key == '') ? true : false;
8014
8015        // property_key == '--menu-height'
8016        var mh = getMenuHeight(),
8017            bh = $.siteBanner.getBandHeight();
8018        this.each(function() {
8019            if(!$(this).is('[data-el^="el_"]') || !$(this).is('[data-type="gallery"][data-type2="premium"]')) return true;
8020
8021            if(isAll || property_key == '--menu-height') {
8022                var __target = $(this).attr('data-el'),
8023                    __menu_height = getComputedStyle(document.querySelector('.'+__target)).getPropertyValue('--menu-height');
8024                if(typeof __menu_height != 'undefined' && __menu_height) document.querySelector('.'+__target).style.setProperty('--menu-height', (mh+bh)+'px', null);
8025            }
8026        });
8027    }
8028
8029    //mobile정보 가져오기
8030    var mrequest_uri = location.pathname + location.search;
8031    function getMobileInfo(data) {        
8032        var page = location.pathname.split('/')[1],
8033            mb = data.mb,
8034            paidUser = data.paidUser,
8035            settings_url = data.settings_url,
8036            sid = data.sid,
8037            valid_plan = data.valid_plan,
8038            site_nickname =  (typeof $('.site-username').text() != 'undefined' && $('.site-username').text()) ? $('.site-username').text() : data.site_nickname,
8039            site_profile = (typeof $('#dashboard-image-top image').attr('xlink:href') != 'undefined' && $('#dashboard-image-top image').attr('xlink:href')) ? $('#dashboard-image-top image').attr('xlink:href') : data.site_profile,
8040            umprofile = data.umprofile,
8041            newCount = data.newCount,
8042            checkGabia = (data.service.indexOf('gabia') > -1) ? true : false;
8043
8044        mb.mb_id = (mb.mb_id) ? mb.mb_id : mb.um_id;
8045
8046        if(mb.mb_id){
8047            var empty = (mb.mb_id) ? '' : 'empty',
8048                newMessage = (newCount == 0) ? false : true,
8049                badge = newMessage ? "<span class='badge'></span>" : "";
8050
8051            var adminhtml = (mb.mb_level >= 10) ? '<li><a href="/adm" target="_blank">Admin</a></li>' : '',
8052                mypage = (checkGabia) ? '/dashboard' : '/mypage',
8053                uadminmypage = (data.is_uadmin == false) ? mypage : 'javascript:;',
8054                siteum = (data.is_uadmin == false) ? '' : 'siteUM',
8055                mypage = (data.is_uadmin == false) ? '' : 'mypage',
8056                dashboarduadmin = (data.is_uadmin == false) ? '/' : '/_admin/dashboard', 
8057                marketinguadmin = (data.is_uadmin == false) ? '/marketing' : '/_admin/marketing';
8058
8059
8060                
8061
8062            var str = '<div class="nav navbar-nav navbar-right">\
8063                            <div class="mobile-menu">\
8064                                    <div class="m-myinfo">\
8065                                        <div class="profile_left">\
8066                                            <label class="m-profile hand '+umprofile+'" data-user-img="'+site_profile+'" data-user-plan="'+paidUser+'" data-user-um="'+umprofile+'">\
8067                                                <svg viewBox="0 0 40 40" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" >\
8068                                                <pattern id="m-dashboard-image-top" patternUnits="userSpaceOnUse" width="60" height="60">\
8069                                                    <image xlink:href='+site_profile+' x="-10" width="60" height="40"></image>\
8070                                                </pattern><circle cx="20" cy="20" r="20" fill="url(#m-dashboard-image-top)"></circle></svg>\
8071                                            </label>\
8072                                            <div class="inner-box hand">\
8073                                                <span class="name-text m-profile m-text-size">'+site_nickname+'</span>\
8074                                            </div>\
8075                                        </div>\
8076                                        <div class="profile_right">';
8077                                            if(data.is_uadmin) {
8078                                                str += '<div class="mlogout siteUM"><a href="javascript:;" class="logout">'+$.lang[LANG]['header.logout']+'</a></div>';
8079                                            } else {
8080                                                str += '<div class="mlogout"><a href="/member/login/out">'+$.lang[LANG]['header.logout']+'</a></div>';
8081                                            }
8082                                str +=  '</div>\
8083                                    </div>\
8084                                    <div class="mMymenu-wrap"><ul class="mMymenu">'; 
8085                                    var newCountlink = (data.is_uadmin == false) ? '/' : '/_admin';
8086                                            str +=  '<li class="newCount prorightmenu">\
8087                                                    <a href="'+newCountlink+'" class='+empty+'><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 18 18" width="18px" height="18px"><path d="M16 16.5V9c0-3.6-2.75-6.58-6.25-6.96V0h-1.5v2.04C4.75 2.42 2 5.4 2 9v7.5H0V18h2 14 2v-1.5H16zM3.5 16.5V9c0-3.03 2.47-5.5 5.5-5.5s5.5 2.47 5.5 5.5v7.5H3.5z"/></svg>'+badge+'<span class="menu-title">'+$.lang[LANG]['header.bell']+'</span></a>\
8088                                                </li>\
8089                                                <li class="m-mypage prorightmenu '+siteum+'"><a href="'+uadminmypage+'" class="'+mypage+'"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 17 18" width="17px" height="18px"><path d="M11.55 10.08C13.03 9.09 14 7.41 14 5.5 14 2.46 11.54 0 8.5 0 5.46 0 3 2.46 3 5.5c0 1.91 0.97 3.59 2.45 4.58C2.27 11.31 0 14.4 0 18h1.5c0-3.86 3.14-7 7-7s7 3.14 7 7H17C17 14.4 14.73 11.31 11.55 10.08zM4.5 5.5c0-2.21 1.79-4 4-4s4 1.79 4 4c0 2.21-1.79 4-4 4S4.5 7.71 4.5 5.5z"/></svg>\
8090                                                <span class="menu-title">'+$.lang[LANG]['header.mypage']+'</span></a></li>';
8091                                        
8092                                        if(!checkGabia) str += '<li class="m-langselect prorightmenu"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 18 18" width="18px" height="18px"><path d="M9 0C4.03 0 0 4.03 0 9c0 4.97 4.03 9 9 9s9-4.03 9-9C18 4.03 13.97 0 9 0zM15.33 5h-2.75c-0.27-1.2-0.65-2.25-1.11-3.07C13.08 2.49 14.43 3.58 15.33 5zM11.5 9c0 0.9-0.07 1.74-0.17 2.5H6.67C6.57 10.74 6.5 9.9 6.5 9s0.07-1.74 0.17-2.5h4.65C11.43 7.26 11.5 8.1 11.5 9zM9 16.5c-0.57 0-1.48-1.29-2.03-3.5h4.07C10.48 15.21 9.57 16.5 9 16.5zM6.97 5C7.52 2.79 8.43 1.5 9 1.5s1.48 1.29 2.03 3.5H6.97zM6.53 1.93C6.07 2.75 5.69 3.8 5.42 5H2.67C3.57 3.58 4.92 2.49 6.53 1.93zM1.94 6.5h3.22C5.06 7.29 5 8.13 5 9s0.06 1.71 0.16 2.5H1.94C1.66 10.72 1.5 9.88 1.5 9S1.66 7.28 1.94 6.5zM2.67 13h2.75c0.27 1.2 0.65 2.25 1.11 3.07C4.92 15.51 3.57 14.42 2.67 13zM11.47 16.07c0.47-0.82 0.85-1.87 1.11-3.07h2.75C14.43 14.42 13.08 15.51 11.47 16.07zM16.06 11.5h-3.22C12.94 10.71 13 9.87 13 9s-0.06-1.71-0.16-2.5h3.22C16.34 7.28 16.5 8.12 16.5 9S16.34 10.72 16.06 11.5z"/></svg>\
8093                                            <span class="menu-title">'+$.lang[LANG]['header.changeLang']+'</span></li>';
8094                                        str += '</ul></div>\
8095                                    <ul class="dropdown-menu" role="menu">'+adminhtml+
8096                                        '<li><a href="'+dashboarduadmin+'"  class="myhome-icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 18 16"  width="18px" height="16px"><path d="M9 0L0 7.03V16h6 6 6V7L9 0zM7.5 14.5v-4h3v4H7.5zM16.5 14.5H12V9H6v5.5H1.5V7.76L9 1.9l7.5 5.83V14.5z"/></svg>'+$.lang[LANG]['mobile.menu.title.mysite']+'</a></li>';
8097                                    
8098                                    var supportlink = (checkGabia) ? 'https://creatorlink-gabia.com/support' : ((LANG == 'ko') ? 'https://supportcenter.creatorlink.net/creatorlink/' : 'https://supportcenter.creatorlink.net/creatorlink-support-center'),
8099                                        helplink = (checkGabia) ? 'https://creatorlink.gabia.com/consult' : '#helpdeskopen',
8100                                        helptext = (checkGabia) ? $.lang[LANG]['mobile.menu.title.gabia.gotocts'] : $.lang[LANG]['mobile.menu.title.gotocts'],
8101                                        is_uadminMember = (data.is_uadmin) ? '_admin' : 'manager',
8102                                        memberlink = '/'+is_uadminMember+'/member/list',
8103                                        siteNotice = (valid_plan=='' || $.inArray(valid_plan['type'], ['BN','SM']) == -1) ? 'siteNotice("manager");' : '',
8104                                        kakaositeNotice = "",
8105                                        kakaotalkuadmin = (data.is_uadmin == false ) ? '/notificationtalkmail' : '/_admin/notificationtalkmail';
8106
8107                                    if(data.is_uadmin) helplink = (checkGabia) ? 'https://creatorlink.gabia.com/consult' : '#helpdeskopen';
8108
8109                                    str += '<li class="m_memberlist"><a href="'+memberlink+'">'+$.lang[LANG]['mobile.menu.title.memberlist']+'</a></li>';
8110
8111                                    if(LANG == 'ko' && (!checkGabia || (checkGabia && valid_plan['type'] == 'SM'))) {
8112                                        var applySm = (valid_plan['type'] == 'SM') ? '' : 'siteNotice(\'shopping\')',
8113                                            collapsed = (valid_plan['type'] == 'SM') ? 'collapsed' : '',
8114                                            smHide = ((valid_plan['type'] == 'BN') && (data.is_uadmin==true)) ? 'hide' : '';
8115
8116                                        str += '\
8117                                        <li class="collapsed mshoppingtab '+smHide+'" data-toggle="collapse" data-target=".mshopping_menu" aria-expanded="true">\
8118                                            <a type="button" class="collapsed hand">' + $.lang[LANG]['mobile.menu.title.shopping'] + '</a>\
8119                                        ';
8120                                        
8121                                        var admin_url = (data.is_uadmin == false) ? '' : '/_admin';
8122                                            
8123                                        str +=  '\
8124                                            <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10px" height="10px"><polygon points="9 2 5 6 1 2 0 3 4 7 5 8 6 7 10 3 "></polygon></svg>\
8125                                        </li>\
8126                                        <ul class="mshopping_menu collapse">\
8127                                            <li><a href="'+admin_url+'/shopping/product_search/order">'+$.lang[LANG]['mobile.menu.title.shopping.order']+'</a></li>\
8128                                            <li><a href="'+admin_url+'/shopping/product_search/cancel">'+$.lang[LANG]['mobile.menu.title.shopping.cancel']+'</a></li>\
8129                                            <li><a href="'+admin_url+'/shopping/product_search/return">'+$.lang[LANG]['mobile.menu.title.shopping.refund']+'</a></li>\
8130                                            <li><a href="'+admin_url+'/shopping/product_search/exchange">'+$.lang[LANG]['mobile.menu.title.shopping.change']+'</a></li>\
8131                                            <li><a href="'+admin_url+'/shopping/question_list/P">'+$.lang[LANG]['mobile.menu.title.shopping.qna']+'</a></li>\
8132                                            <li><a href="'+admin_url+'/shopping/product_search/all">'+$.lang[LANG]['mobile.menu.title.shopping.all']+'</a></li>\
8133                                            <li><a href="'+admin_url+'/shopping/statistics">'+$.lang[LANG]['mobile.menu.title.shopping.statistics']+'</a></li>\
8134                                            <li>
8134<a href="'+admin_url+'/shopping/point">'+$.lang[LANG]['mobile.menu.title.shopping.point']+'</a></li>\
8135                                            <li><a href="'+admin_url+'/shopping/coupon">'+$.lang[LANG]['mobile.menu.title.shopping.coupon']+'</a></li>\
8136                                            <li><a href="'+admin_url+'/shopping/setting/W">'+$.lang[LANG]['mobile.menu.title.shopping.setting']+'</a></li>\
8137                                        </ul>';
8138                                    }
8139
8140                                    var slog_li = '\
8141                                        <li><a href="'+admin_url+'/slog">'+$.lang[LANG]['mobile.menu.title.slog']+'</a></li>\
8142                                    ';
8143
8144                                    if(valid_plan) {
8145                                        
8146                                        var pageactive = (page == 'settings') ? 'active' : '',
8147                                            settingslink = (page == 'settings') ? '#' : settings_url,
8148                                            helpbox = (data.is_uadmin == false) ? '<li><a href="'+helplink+'">'+helptext+'</a></li>' : ((data.su_eadmin == false) ? '' : '<li><a href="'+helplink+'">'+helptext+'</a></li>'),
8149                                            settingHide = (data.is_uadmin == true && data.su_eadmin == false) ? 'hide' : '';
8150
8151                                        str += '<li class="m_marketing '+settingHide+'"><a href="'+marketinguadmin+'">'+$.lang[LANG]['mobile.menu.title.marketing']+'</a></li>';
8152                                             if(!checkGabia) str += '<li class=m_kakao " onClick="'+kakaositeNotice+'"><a href="'+kakaotalkuadmin+'">'+$.lang[LANG]['mobile.menu.title.kakao']+'</a></li>';
8153                                                str += '<li class="'+settingHide+'"><a href="'+settings_url+'">'+$.lang[LANG]['mobile.menu.title.settings']+'</a></li>\
8154                                        ';
8155                                        if(!checkGabia && data.is_uadmin == false) str += '<li class="m_plan '+settingHide+'"><a href="/plan">'+$.lang[LANG]['mobile.menu.title.plan.billing']+'</a></li>';
8156                                        if(valid_plan['type'] == 'SM' && LANG == 'ko') str += slog_li;
8157                                        if(!checkGabia &&  LANG == 'ko' && data.is_uadmin == false) {
8158                                            str += `
8159                                                <li><a href="/edu">${$.lang[LANG]['mobile.menu.logout.title.edu']}</a></li>
8160                                            `;
8161                                            // <li><a href="/production">${$.lang[LANG]['mobile.menu.logout.title.production']} <span class="newicon">New</span></a></li>
8162                                        }
8163
8164                                        if(data.is_uadmin == false) str +='<li><a href="'+supportlink+'">'+$.lang[LANG]['mobile.menu.title.supportcenter']+'</a></li>';
8165                                        if(!checkGabia && data.is_uadmin == false)str += '<li><a href="/notice">'+$.lang[LANG]['mobile.menu.title.notice']+'</a></li>';
8166                                        str += helpbox;
8167                                    }
8168
8169                            str +=  '</ul>\
8170                                </div>\
8171                        </div>'; 
8172                $('.m-header_user').empty().prepend(str);
8173        }
8174        return data;        
8175    }
8176
8177    $.mobileToggleMenu = {
8178        set : function() {
8179            var request_uri = location.pathname + location.search;
8180            var returnData = '';
8181
8182            $.ajax({
8183                type: 'POST',
8184                data: { type:'get', sid:(typeof SID!='undefined' && SID? SID : '') },
8185                dataType: 'json',
8186                url: '/template/getMobileMenu',   
8187                async:false,
8188                success : function(data) {
8189                    returnData = getMobileInfo(data);
8190                }
8191            }); 
8192
8193            $.mobileToggleMenu.clickEvnt();
8194
8195            return returnData;
8196            
8197        },
8198        setSignIn : function() {
8199            var langkor = (LANG=='ko') ? '':'hide',
8200                langen = (LANG=='en') ? '' : 'hide',
8201                str = '<div class="nav navbar-nav navbar-right signinwrap">\
8202                        <div class="mobile-menu">\
8203                                <div class="m-myinfo">\
8204                                    <div class="profile_left signinwrap_logo">\
8205                                        <div class="inner-box hand">\
8206                                            <a href="/">\
8207                                            <svg viewBox="0 0 168 38" role="img" class="logo-svg logo-b" data-attach="true" alt="Creatorlink logo"><path class="st11" d="M70.71 12.36c-3.48 0-5.9 2.19-5.9 5.34v4.11c0 3.34 2.17 5.25 5.96 5.25 2.06 0 3.98-0.58 5.41-1.64l0.14-0.11 -1.03-1.95 -0.2 0.1c-1.67 0.85-2.74 1.15-4.11 1.15 -2.23 0-3.23-0.87-3.23-2.83v-0.94h8.62v-3.08C76.37 14.13 74.52 12.36 70.71 12.36zM73.52 18.45h-5.77v-0.92c0-1.91 1.53-2.78 2.96-2.78 2.02 0 2.81 0.78 2.81 2.78V18.45z"/><path class="st11" d="M84.38 12.36c-1.52 0-3.34 0.55-4.87 1.47l-0.17 0.1 1.11 1.95 0.19-0.1c1.41-0.69 2.48-0.98 3.59-0.98 2.22 0 2.93 0.51 2.93 2.1v1.29h-3.64c-3.09 0-4.65 1.47-4.65 4.37 0 1.22 0.39 2.33 1.09 3.12 0.76 0.85 1.84 1.3 3.12 1.3 0.09 0 0.18 0 0.26-0.01 1.37-0.06 2.71-0.51 3.97-0.99l0.04 0.79h2.76v-9.76C90.11 13.76 88.39 12.36 84.38 12.36zM87.17 23.79l-0.01 0c-0.83 0.32-1.87 0.72-3.2 0.73h-0.06c-1.46 0-2.08-0.6-2.08-2.01 0-1.37 0.55-1.92 1.89-1.92h3.47V23.79z"/><path class="st11" d="M101.06 24.31c-0.95 0.23-1.63 0.33-2.26 0.33 -1.16 0-1.27-0.36-1.27-1.31v
8207-8.47h3.9l0-2.22h-3.9V9.26l-2.94 0.01v3.38h-2.56v2.22h2.56v8.86c0 2.31 1.18 3.34 3.82 3.34 1.04 0 2.14-0.18 3.11-0.52l0.17-0.06 -0.4-2.23L101.06 24.31z"/><path class="st11" d="M109.95 12.36c-3.88 0-6.11 1.96-6.11 5.36v3.97c0 3.41 2.23 5.36 6.11 5.36 3.88 0 6.11-1.96 6.11-5.36v-3.97C116.06 14.32 113.84 12.36 109.95 12.36zM113.12 21.78c0 1.89-1.04 2.8-3.17 2.8 -2.13 0-3.17-0.92-3.17-2.8v-4.14c0-1.89 1.04-2.8 3.17-2.8 2.13 0 3.17 0.92 3.17 2.8V21.78z"/><path class="st11" d="M59.07 14.72l0.01-2.07H56.3v14.13h2.94v-9.04c1.75-1.89 4.2-3.24 4.2-3.24l-1.4-1.84C62.04 12.65 60.26 13.76 59.07 14.72z"/><path class="st11" d="M121.93 14.72l0.01-2.07h-2.77v14.13h2.94v-9.04c1.75-1.89 4.2-3.24 4.2-3.24l-1.4-1.84C124.91 12.65 123.12 13.76 121.93 14.72z"/><path class="st11" d="M51.54 22.93c-0.96 1.11-2.12 1.66-3.56 1.66 -2.13 0-3.17-0.92-3.17-2.8v-4.14c0-1.89 1.04-2.8 3.17-2.8 1.73 0 2.83 0.77 3.68 1.52l0.13 0.12 1.99-1.39 -0.13-0.17c-0.76-0.95-2.5-2.55-5.67-2.55 -3.88 0-6.11 1.96-6.11 5.36v3.97c0 3.41 2.23 5.36 6.11 5.36 3.03 0 4.76-1.58 5.68-2.91l0.13-0.18 -2.13-1.18L51.54 22.93z"/><rect x="128.71" y="6.68" class="st11" width="1.2" height="20.07"/><rect x="134.41" y="12.69" class="st11" width="1.2" height="14.06"/><rect x="134.41" y="8.29" class="st11" width="1.2" height="2.18"/><path class="st11" d="M148.67 13.44c-1.68-0.98-5.06-0.52-7.21 0.71V12.5h-1.2v14.25h1.2V15.33c1.74-1.3 5.26-1.79 6.61-1 1.38 0.81 1.38 2.37 1.38 2.43v9.99h1.2v-9.99C150.65 16.67 150.63 14.59 148.67 13.44z"/><polygon class="st11" points="158.27 18.97 164.05 12.69 162.6 12.69 156 19.89 156 6.68 154.8 6.68 154.8 26.75 156 26.75 156 21.44 157.54 19.77 163.6 26.75 165 26.75 "/><path class="st11" d="M3 10.79L3 10.79l0 16.42 14.22 8.21 14.22-8.21V10.79L17.22 2.58 3 10.79zM26.7 13.53L26.7 13.53 26.7 13.53l-4.74 2.74h0l-4.74-2.74 -4.74 2.74v5.47l4.74 2.74 4.74-2.74 4.74 2.74 -9.48 5.47 -9.48-5.47V13.53l9.48-5.47L26.7 13.53 26.7 13.53z"/></svg>\
8208                                            </a>\
8209                                        </div>\
8210                                    </div>\
8211                                    <div class="profile_right msignin">\
8212                                        <a href="/member/login" class="mlogin-text" id="m_login_btn_head">'+$.lang[LANG]['mobile.menu.signin']+'</button>\
8213                                    </div>\
8214                                </div>\
8215                                <ul class="dropdown-menu" role="menu">';   
8216                            str += '<li><a href="/upgrade/site" class="logoutmenu">'+$.lang[LANG]['mobile.menu.logout.title.plan']+'</a></li>\
8217                                    <li><a href="/template" class="logoutmenu">'+$.lang[LANG]['mobile.menu.logout.title.template']+'</a></li>\
8218                                    <li><a href="/bestlist" class="logoutmenu">'+$.lang[LANG]['mobile.menu.logout.title.bestsite']+'</a></li>';
8219                                   if(LANG == 'ko') str += '<li><a href="/mainfunction" class="logoutmenu">'+$.lang[LANG]['mobile.menu.logout.title.mainfunc']+'</a></li>';
8220                                   if(LANG == 'ko') str += '<li><a href="/edu" class="logoutmenu edu">'+$.lang[LANG]['mobile.menu.logout.title.edu']+'</a></li>';
8221                                   if(LANG == 'ko') str += '<li><a href="/production" class="logoutmenu production">'+$.lang[LANG]['mobile.menu.logout.title.production']+'</a></li>';
8222
8223                        // str += '</ul>\ 
8224                        //         <div class="mchange-lang">\
8225                        //             //<img src="https://storage.googleapis.com/i.addblock.net/lang_kor.png" class="lang-ch '+langkor+'" data-attach="true" alt="Creatorlink logo">\
8226                        //             //<img src="https://storage.googleapis.com/i.addblock.net/lang_eng.png" class="lang-ch '+langen+'" data-attach="true" alt="Creatorlink logo">\
8227                        //             <div class="lang-ch '+langkor+'">KR</div>\
8228                        //             <div class="lang-ch '+langen+'">EN</div>\
8229                        //         </div>\
8230                        //     </div>\
8231                        str += '</ul>\
8232                                <div class="mchange-lang">\
8233                                    <div class="hand lang-ch '+langkor+'">KR</div>\
8234                                    <div class="hand lang-ch '+langen+'">EN</div>\
8235                                </div>\
8236                            </div>\
8237                    </div>';    
8238
8239            $('.m-header_user').prepend(str);   
8240
8241            $.mobileToggleMenu.clickEvnt();
8242        },
8243        mobileResize : function(data) {
8244            getMobileInfo(data);
8245            $.mobileToggleMenu.clickEvnt();
8246        },
8247        clickEvnt : function() {
8248            $('.navbar-toggle').click(function() {
8249                $.mobileToggleMenu.open();
8250                $('.m-header_user').css('left','0');
8251                $('html').css({'overflow': 'hidden'});
8252            });
8253            $('.m-langselect,.lang-ch').on('click',function(){  
8254                $.mobileToggleMenu.langSelect(mrequest_uri);
8255            });
8256            /*$('.applySm').click(function(){
8257                $(this).showModalFlat('INFORMATION', '쇼핑 기능은 심플쇼핑 요금제로 이용이 가능합니다.<br>심플쇼핑 신청 페이지로 이동할까요?', true, true, function() {
8258                    location.href = '/shoppingevent';
8259                }, 'cancel', '이동','mUpgradeSmModal');
8260            });*/
8261            $('.mshopping_menu').on('show.bs.collapse',function(e){
8262                $('.mshoppingtab,.mshoppingtab > a').css('background-color','#eeeff3');
8263                $('.mshoppingtab svg').remove();
8264                $('.mshoppingtab > a ').prepend('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10px" height="10px"><polygon points="1 8 5 4 9 8 10 7 6 3 5 2 4 3 0 7 "/></svg>');
8265            });
8266            $('.mshopping_menu').on('hide.bs.collapse',function(e){
8267                $('.mshoppingtab,.mshoppingtab > a').css('background-color','inherit');
8268                $('.mshoppingtab svg').remove();
8269                $('.mshoppingtab > a ').prepend('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10px" height="10px"><polygon points="9 2 5 6 1 2 0 3 4 7 5 8 6 7 10 3 "/></svg>');
8270            });
8271
8272            $('#loginModal').on('show.bs.modal', function(e) {
8273                $.mobileToggleMenu.close();
8274            });
8275            $('#loginModal').on('shown.bs.modal', function(e) {
8276                $('html').css({'overflow': 'inherit'});
8277            });  
8278        },
8279        open : function (){
8280            var height = window.outerHeight;
8281
8282            $('#nav.default-nav .header .navbar-header a.navbar-toggle,#nav.default-nav .header .navbar_right').css('zIndex','99');
8283            $('.mobile-detail-popup.billhead,.mobile-detail-popup.helphead').css('height', '100%');
8284            $('.m-headermenu').remove();
8285            $('.m-headerClose').addClass('in');
8286            $('.m-headerClose').removeClass('hide');
8287            $.mobileToggleMenu.scrollheight();
8288
8289            $(window).resize(function (){
8290                $.mobileToggleMenu.scrollheight();
8291            });
8292            $('.m-headerClose').click(function(){
8293                $.mobileToggleMenu.close();
8294                $('html').css({'overflow': 'inherit'});
8295            });
8296        },
8297        close : function() {
8298            $('.m-headermenu').remove();
8299            $('.m-header_user').css('left','-100%');
8300            $('.m-headerClose').removeClass('in');
8301            $('.mobile-detail-popup.billhead,.mobile-detail-popup.helphead').css('height', 'auto');
8302            $('#nav.default-nav .header .navbar_right').css('zIndex','');
8303            $('#nav.default-nav .header .navbar-header a.navbar-toggle').css('zIndex','120');
8304        },
8305        langSelect : function(request_uri) {
8306            $('.m-headermenu').remove();
8307            $('.m-header_user.menu').css('left','-100%');
8308            $('.m-headerClose').addClass('hide');
8309            $('#nav.default-nav .header .navbar-header a.navbar-toggle').css('zIndex','120');
8310
8311            var dashlang = (LANG == 'ko') ? 'ko' : 'en',
8312                html = "<ul class='dashlang-wrap'>\
8313                            <li class='dashlang-select'>\
8314                                <a href='/lang/switchLanguage/korean"+request_uri+"'><p class='mdash-lang'>한국어 (KO)</p>\
8315                                <span class='cl-icon cl-check-lang "+(dashlang == 'ko' ? 'cl_icon_checked04' : 'cl_icon_unchecked04')+"' data-lang='ko'></span></a>\
8316                            </li>\
8317                            <li class='dashlang-select'>\
8318                                <a href='/lang/switchLanguage/english"+request_uri+"'><p class='mdash-lang'>English (EN)</p>\
8319                                <span class='cl-icon cl-check-lang "+(dashlang == 'en' ? 'cl_icon_checked04' : 'cl_icon_unchecked04')+"' data-lang='en'></span></a>\
8320                            </li>\
8321                        </ul>";
8322
8323            $('.m-dashboard').showModalFlat('',html,false,false,'','','','changelang');
8324            $('.modal-dialog.changelang').parents('.modal-default').attr('id','changelangModal');
8325
8326            $('#changelangModal').on('show.bs.modal', function(e) {
8327                $('.dashlang-select > a').click(function() {
8328                    var datalang = $('.dashlang-select .cl-check-lang').attr('data-lang');
8329
8330                    $('.cl-check-lang').each(function () {
8331                        $(this).addClass('cl_icon_checked04').removeClass('cl_icon_unchecked04');
8332                    });
8333                    $(this).addClass('cl_icon_unchecked04').removeClass('cl_icon_checked04');
8334                });
8335            });
8336
8337            $('#changelangModal').on('hide.bs.modal', function(e) {
8338                $('#nav.default-nav .header .navbar_right').css('zIndex','');
8339                $('#nav.default-nav .header .navbar-header a.navbar-toggle').css('zIndex','120');
8340            });
8341        },
8342        upgradePopup : function(){
8343            $(this).showModalFlat('INFORMATION', '쇼핑 기능은 쇼핑 요금제로 이용이 가능합니다.<br>쇼핑 요금제 신청 페이지로 이동할까요?', true, true, function() {
8344                location.href = '/shoppingevent';
8345            }, 'cancel', '이동','mUpgradeSmModal');
8346        },
8347        scrollheight : function() {
8348            var menuheight = $(window).height()-146;
8349            $('.m-header_user .mobile-menu .dropdown-menu').css('height',menuheight);
8350        }
8351    }
8352
8353    $.notSupported = {
8354        isPremiumBlock: function(type,type2,feature) {
8355            if(typeof type == 'undefined') type = '';
8356            if(typeof type2 == 'undefined') type2 = '';
8357            if(typeof feature == 'undefined') feature = '';
8358
8359            return ( type2 == 'premium'
8360                    || feature == 'premium'
8361                    || $.inArray(type, ['latest','form','sync','review']) > -1
8362                    || (type == 'forum' && $.inArray(type2, ['faq','qna']) > -1)
8363                ) ? true : false; 
8364        },
8365        check: function(type,type2,feature) {
8366            if(typeof type == 'undefined') type = '';
8367            if(typeof type2 == 'undefined') type2 = '';
8368            if(typeof feature == 'undefined') feature = '';
8369            if(typeof fn == 'undefined') fn = '';
8370
8371            if(!type && !type2 && !feature) return false;
8372
8373            var tmp_plan = (typeof property != 'undefined') ? property.VALIDPLAN : VALIDPLAN,
8374                tmp_plantype = (typeof property != 'undefined') ? property.VALIDTYPE : VALIDTYPE,
8375                checkFree = (!tmp_plan || tmp_plantype == 'PK') ? true : false,
8376                checkSM = (tmp_plan && tmp_plantype == 'SM') ? true : false,
8377                checkBN = (tmp_plan && tmp_plantype == 'BN') ? true : false,
8378                checkPremium = $.notSupported.isPremiumBlock(type,type2,feature);
8379            
8380            var ns_val = false;
8381            if(checkFree) {
8382                if(checkPremium) ns_val = true;
8383            } else {
8384                if(!checkSM && $.inArray(type, ['review']) > -1) ns_val = true;
8385                if(!checkBN && !checkSM && $.inArray(type2, ['franchise map', 'franchise bar', 'mwd']) > -1) ns_val = true;
8386            }
8387
8388            if(type == 'calendar') {
8389                if(!checkBN && !checkSM && $.inArray(type2, ['mwd']) > -1) ns_val = true;
8390            }
8391
8392            return ns_val;
8393        },
8394        set: function(sid, id, mode, upgrade) {
8395            
8396            if(typeof id == 'undefined' || !id || $('[data-id="' + id + '"]:is(.element, .reorderBlock)').length == 0) return false;
8397     
8398            var nsEl = $('[data-id="' + id + '"]:is(.element, .reorderBlock)'),
8399                checkSlim = (nsEl.height() < 351) ? true : false,
8400                n_service = (typeof PAGE_MODE != 'undefined' && PAGE_MODE=='c') ? SERVICE : property.SERVICE, 
8401                page_mode = (typeof PAGE_MODE != 'undefined' && PAGE_MODE=='c') ? 'config' : 'render', 
8402                is_gabia = (n_service.indexOf('gabia') > -1) ? '.gabia' : '',
8403                title_str = (mode=='video' && !upgrade) ? $.lang[LANG]['config.premium.not-supported.block.video.'+page_mode+'.gfycat'] : $.lang[LANG]['config.premium.not-supported.block'];
8404            var nsTitle = title_str;
8405            switch(mode) {
8406                case 'calendar':
8407                case 'contact':
8408                    nsTitle = $.lang[LANG]['config.premium.not-supported.block.BN' + is_gabia]
8409                    break;
8410                case 'review':
8411                    nsTitle = $.lang[LANG]['config.premium.not-supported.block.SM' + is_gabia]
8412                    break;
8413                default:
8414                    nsTitle = title_str
8415                    break;
8416            }
8417            var ns_html = `
8418                    <div class="cl-ns-wrap" data-blockmode="${mode}">
8419                        <div class="cl-ns-title">${nsTitle}</div>
8420                        <div class="cl-ns-bottom">
8421                            ${ (upgrade) ? `<a class="cl-ns-btn color-b" href="${ 
8422                                                (n_service.indexOf('gabia') > -1) ? 'https://www.gabia.com/mygabia/service' : `/upgrade/site/${sid}` 
8423                                            }" target="_blank">${ $.lang[LANG]['config.premium.not-supported.block.btn.upgrade'] }</a>` : '' 
8424                            }
8425                            <span class="cl-ns-btn color-w" onclick="elDelete(${id})">${$.lang[LANG]['config.premium.not-supported.block.btn.delete']}</span></div>
8426                        </div>
8427                    </div>
8428                `;
8429
8430            if(checkSlim) nsEl.addClass('cl-ns-slim');
8431            else nsEl.removeClass('cl-ns-slim');
8432
8433            nsEl.addClass('cl-not-supported');
8434            nsEl.each(function() {
8435                if($(this).find('.cl-ns-wrap').length > 0) $(this).find('.cl-ns-wrap').replaceWith(ns_html);
8436                else $(this).append(ns_html);
8437            });
8438        },
8439        unset: function(id) {
8440            if(typeof id == 'undefined' || !id || $('[data-id="' + id + '"]:is(.element, .reorderBlock)').length == 0) return false;
8441
8442            var nsEl = $('[data-id="' + id + '"]:is(.element, .reorderBlock)');
8443            nsEl.removeClass('cl-not-supported cl-ns-slim');
8444            nsEl.find('.cl-ns-wrap').remove();
8445        }
8446    }
8447
8448
8449    $.resource = {
8450        init : function() {
8451            var freeSearch = {'type' : '', 'page' : 1, 'text' : '', 'total' : 0},
8452                fileDrag = false,
8453                depfolderClick = false,
8454                isFEdit = false,
8455                mouseX, mouseY,
8456                dragTooltipModal = $();
8457
8458            var getResourceTooltip = function() {
8459                var $tooltip = $('#resource-tooltip-runtime');
8460                if($tooltip.length) return $tooltip;
8461
8462                var $sourceTooltip = $('.resource-tooltip').first();
8463                var tooltipHtml = '<div id="resource-tooltip-runtime" class="resource-tooltip"><img src="" alt="image move to folder"><span class="count">1</span></div>';
8464
8465                if($sourceTooltip.length) {
8466                    tooltipHtml = $('<div>').append($sourceTooltip.clone().attr('id', 'resource-tooltip-runtime').show()).html();
8467                }
8468
8469                $tooltip = $(tooltipHtml);
8470                $('body').append($tooltip);
8471
8472                return $tooltip;
8473            };
8474
8475            var hideResourceTooltip = function() {
8476                getResourceTooltip().stop(true, true).hide().removeClass('multiple');
8477            };
8478
8479            var moveResourceTooltip = function() {
8480                if(!fileDrag) return;
8481
8482                var $tooltip = getResourceTooltip();
8483                if(!$tooltip.length) return;
8484
8485                $tooltip.css({
8486                    'top': mouseY + 14,
8487                    'left': mouseX + 14
8488                });
8489            };
8490
8491            var updateResourceTooltip = function($item, forceShow) {
8492                if(!$item || !$item.length) return;
8493
8494                var $modal = $item.closest('.modal.in'),
8495                    $tab = $modal.find('.modal-resourcebox .tab-content > .tab-pane.active'),
8496                    $tooltip = getResourceTooltip(),
8497                    $selected = $tab.find('ul.files .fitem.ui-selected'),
8498                    $selectedBox = $tab.find('.resource-selected-ul'),
8499                    $sourceItem = ($selected.length > 0) ? $selected.first() : $item.closest('.fitem'),
8500                    str_count = $selectedBox.children('li').length || $selected.length || 1,
8501                    str_img = $sourceItem.find('.fitem-img').attr('src') || $item.find('.fitem-img').attr('src') || '';
8502
8503                if(!$modal.length || !$tooltip.length || !$sourceItem.length || !str_img) return;
8504
8505                dragTooltipModal = $modal;
8506
8507                $tooltip.toggleClass('multiple', str_count > 1)
8508                    .find('img').attr('src', str_img).end()
8509                    .find('.count').text(str_count);
8510
8511                moveResourceTooltip();
8512
8513                if(forceShow || !$tooltip.is(':visible')) {
8514                    $tooltip.stop(true, true).fadeIn(80);
8515                }
8516            };
8517
8518            $(document)
8519                .off('mousemove.resourceTooltip mouseup.resourceTooltip')
8520                .on('mousemove.resourceTooltip', function(e) {
8521                    mouseX = (typeof e.clientX != 'undefined') ? e.clientX : e.pageX;
8522                    mouseY = (typeof e.clientY != 'undefined') ? e.clientY : e.pageY;
8523
8524                    if(fileDrag) moveResourceTooltip();
8525                })
8526                .on('mouseup.resourceTooltip', function() {
8527                    if(!fileDrag) return;
8528                    hideResourceTooltip();
8529                    fileDrag = false;
8530                    dragTooltipModal = $();
8531                    $('#nestableFolder .fli').removeClass('drag-selected');
8532                });
8533
8534            $('.modal-resourcebox ul.files').on('scroll', function(e) {
8535                var thisResourceTab = $(this).parents('.modal').find('.modal-resourcebox .tab-content > .tab-pane.active'),
8536                    thisResourceFiles = thisResourceTab.find('ul.files'),
8537                    rmode = thisResourceTab.attr('id').replace(/storage$/gi,''),
8538                    fsort = thisResourceTab.find('.resource-ctrl-sort select').val(),
8539                    fsearch = thisResourceTab.find('.resource-search-stx').val(),
8540                    is_icon_hybrid_scroll = (rmode == 'icon' && typeof isIconStorageHybridMode == 'function' && isIconStorageHybridMode()),
8541                    scroll_load_offset = (is_icon_hybrid_scroll && typeof ICON_STORAGE_LOAD_TRIGGER_OFFSET != 'undefined') ? ICON_STORAGE_LOAD_TRIGGER_OFFSET : 100;
8542
8543                if((this.scrollTop + this.clientHeight) > (this.scrollHeight - scroll_load_offset)) {
8544                    var fitem_cnt = thisResourceFiles.find('.fitem').length;
8545                    if(rmode == 'my' || rmode == 'icon') {
8546                        if(is_icon_hybrid_scroll) {
8547                            if(typeof canLoadMoreIconStorageCategory != 'function' || !canLoadMoreIconStorageCategory()) return;
8548                            if(typeof appendIconStorageListProgress == 'function') appendIconStorageListProgress(thisResourceFiles);
8549                            else if(thisResourceFiles.find('.listprogress').length == 0) thisResourceFiles.append('<li class="listprogress"><svg version="1.1" xmlns="http://www.w3.org/svg/2000" viewBox="0 0 30 30" width="60" style="width:30px; height: 30px;"><circle cy="15" cx="15" r="14" style="stroke:#00baff;"></circle></svg></li>');
8550                            loadNextIconStorageCategoryPage();
8551                            return;
8552                        }
8553                        if (fitem_cnt == cTotal) return;
8554                    } else if(rmode == 'free') {
8555                        if($.inArray(freeSearch.type, ['search','favor','used']) > -1 && freeSearch.total != 0) {
8556                            if(fitem_cnt == freeSearch.total) return false;
8557                        }
8558                    }
8559
8560                    if(thisResourceFiles.find('.listprogress').length == 0) {
8561                        thisResourceFiles.append('<li class="listprogress">
8561<svg version="1.1" xmlns="http://www.w3.org/svg/2000" viewBox="0 0 30 30" width="60" style="width:30px; height: 30px;"><circle cy="15" cx="15" r="14" style="stroke:#00baff;"></circle></svg></li>');  
8562                        if(rmode == 'my' || rmode == 'icon') {
8563                            cPage = cPage + 1;
8564                            resourceGetPage(cPage,SFOLDER_ACTIVE,fsort,fsearch);
8565                        } else if(rmode == 'free') {
8566                            getFreeImage(freeSearch.page,freeSearch.type,freeSearch.text);
8567                        }
8568                        
8569                    }
8570                }
8571
8572                if($(this).parents('.modal').find('.modal-resourcebox ul.files').data('uiSelectableScroll') && $(this).parents('.modal').find('.modal-resourcebox ul.files').data('uiSelectableScroll').dragged)
8573                    $(this).parents('.modal').find('.modal-resourcebox ul.files').data('uiSelectableScroll')._updateUi({ doUpdateHelper: true });
8574            })
8575
8576            $(document)
8577                .on('click', '.resourcebox-frame .view-original', function(e) {
8578                    e.preventDefault();
8579                    e.stopPropagation();
8580                    // thisResourceZoomable.empty();
8581
8582                    var thisResourceFrame = $('.resourcebox-frame #rframe'),
8583                        thisResourceSlide = thisResourceFrame.find('.slide').eq(0);
8584                        thisResourceZoomable = thisResourceFrame.find('.zoomable');
8585                        thisResourceOrgBtn = $(this);
8586
8587                    thisResourceOrgBtn.toggleClass('fullscreen');
8588                    var ww = $(window).width() - 8,
8589                        cw = thisResourceSlide.find('.slide-content').width(),
8590                        scale = (thisResourceOrgBtn.hasClass('fullscreen')) ? (ww / cw).toFixed(15) : 1;
8591
8592                    setSlideIconTooltip('.resourcebox-frame #rframe');
8593                    if(thisResourceOrgBtn.hasClass('dblclick')) thisResourceOrgBtn.removeClass('dblclick');
8594                    else thisResourceOrgBtn.tooltip('show');
8595                    setSlideImgScale(thisResourceSlide, scale);
8596                })
8597                .on('dblclick', '.resourcebox-frame .slide-content', function(e) {
8598                    var thisResourceFrame = $('.resourcebox-frame #rframe'),
8599                        thisResourceOrgBtn = thisResourceFrame.find('.view-original');
8600                    
8601                    thisResourceOrgBtn.addClass('dblclick');
8602                    thisResourceOrgBtn.click();
8603                })
8604                .on('click', '.resourcebox-frame [class*="zoom-"]', function(e) {
8605                    var thisResourceFrame = $('.resourcebox-frame #rframe'),
8606                        thisResourceSlide = thisResourceFrame.find('.slide').eq(0),
8607                        thisResourceOrgBtn = thisResourceFrame.find('.view-original'),
8608                        scale = thisResourceFrame.find('.zoomable img').attr('data-scale');
8609                    if(scale === undefined) scale = 1;
8610
8611                    if($(this).hasClass('zoom-in')) {
8612                        thisResourceOrgBtn.removeClass('disabled').addClass('fullscreen');
8613                        scale = Number(scale) + 0.5;
8614                    } else {
8615                        if(scale > 1) scale = Number(scale) - 0.5;
8616                        if(scale < 1) scale = 1;
8617                        if(scale == 1) {
8618                            thisResourceOrgBtn.removeClass('fullscreen');
8619                        }
8620                    }
8621                    
8622                    setSlideIconTooltip('.resourcebox-frame #rframe');
8623                    setSlideImgScale(thisResourceSlide, scale);
8624                });
8625
8626            $('#el-fileupload, #el-iconstorage')
8627                .on('show.bs.modal', function(e) {
8628                    var parentDocument = $(window.parent.document),
8629                        $detail_modal = parentDocument.find('.product-detail-modal');
8630                    if($detail_modal.length) $detail_modal.addClass('overlap');                    
8631
8632                    var thisResourceTab = $(this).find('.modal-resourcebox .tab-content > .tab-pane.active'),
8633                        thisResourceFiles = thisResourceTab.find('ul.files'),
8634                        rmode = thisResourceTab.attr('id').replace(/storage$/gi,''),
8635                        fsort = thisResourceTab.find('.resource-ctrl-sort select').val(),
8636                        fsearch = thisResourceTab.find('.resource-search-stx').val(),
8637                        forceIconStorageInitialLoad = false;
8638
8639                    if($(this).attr('id') == 'el-iconstorage') {
8640                        if(typeof resetIconStorageDefaultState == 'function') resetIconStorageDefaultState();
8641                        thisResourceTab = $('#iconstorage');
8642                        thisResourceFiles = thisResourceTab.find('ul.files');
8643                        thisResourceFiles.empty().addClass('ready');
8644                        rmode = 'icon';
8645                        fsort = 'total';
8646                        fsearch = '';
8647                        forceIconStorageInitialLoad = true;
8648                    }
8649                
8650                    ADD = false;
8651                    UPLOAD = 0;
8652                    UPLOADED = 0;
8653                    PROGRESS = 0;
8654
8655                    var checkProperty = $(this).find('.modal-resourcebox .resource-useit').eq(0).attr('data-property');
8656                    if(rmode == 'my' && checkProperty == 'flink-change') {
8657                        rmode = 'file';
8658                        thisResourceTab = $('#filestorage');
8659                        thisResourceFiles = thisResourceTab.find('ul.files');
8660                    }
8661
8662                    var checkReady = forceIconStorageInitialLoad || thisResourceFiles.hasClass('ready');
8663                    if(checkReady) {
8664                        cPage = 1;
8665                        fsort = (rmode == 'icon') ? 'total' : 'date_desc';
8666                        fsearch = '';
8667                    }
8668                    $.resource.modalInit();
8669                    if(checkReady) resourceGetPage(1,SFOLDER_ACTIVE,fsort,fsearch);
8670
8671                    if(rmode == 'my') {
8672                        thisResourceTab.find('.selectpicker + .btn.dropdown-toggle').attr('title','');
8673                        if(thisResourceTab.find('.fli.active').length == 0) thisResourceTab.find('.fli[data-id="all"]').click();
8674                    }
8675
8676                    $(this).find('.modal-resourcebox .resource-useit').removeClass('clicked');
8677                })
8678                .on('hide.bs.modal', function(e) {
8679                    var parentDocument = $(window.parent.document),
8680                        $detail_modal = parentDocument.find('.product-detail-modal');
8681                    if($detail_modal.length) $detail_modal.removeClass('overlap');                    
8682                    $.resource.setMystorageFolder('nodrag',false);
8683                    if($('#nestableFolder .fli[data-id="clEmptyFolder"]').length > 0 ) {//new folder name_input open
8684                        $('#nestableFolder .fli[data-id="clEmptyFolder"]').remove();
8685                        isFEdit = false;
8686                    }
8687                    if($('#nestableFolder .fli .dd-fln').find('input').length > 0 ) { //edit folder name_input open
8688                        $('#nestableFolder .fli .dd-fln').find('input').val('').closest('li.fli').find('.fln-group').remove();
8689                        isFEdit = false;
8690                    }
8691                    if($('#nestableFolder .fli.active').length > 0) {
8692                        if($('#nestableFolder').scrollTop() > $('#nestableFolder .fli.active').position().top) {
8693                            $('#nestableFolder').scrollTop($('#nestableFolder .fli.active').position().top);
8694                        }
8695                    }
8696    
8697                    if($('#el-property [data-loop-type="matrix"] .attach-thumb[data-toggle="modal"]').length > 0 ) { //clear matrix loop item - modal toggle
8698                        var idx =  $('#el-property [data-loop-type="matrix"] .attach-thumb[data-toggle="modal"]').attr('idx');
8699                        $('#el-property [data-loop-type="matrix"] .attach-thumb[data-toggle="modal"]').removeAttr('data-toggle');
8700    
8701                        if(!$('#el-property [data-loop-type="matrix"] .ui-sortable').children().first().hasClass('active')) 
8702                            $('#el-property [data-loop-type="matrix"] .ui-sortable').children().first().click();
8703                    }
8704    
8705                    if(typeof selectEL != 'undefined' && selectEL && typeof $('.'+selectEL).attr('data-parallax') != "undefined" && $('.'+selectEL).attr('data-parallax')) {
8706                        $('#prop-method-background').attr('data-target','');
8707                    }
8708    
8709                    $('#mystorage .add-folder').attr('data-content','').popover('hide');
8710                    $(this).find('.resource-useit').show();
8711                    selectCount = 0;
8712                })
8713                .on('hidden.bs.modal', function(e) {
8714                    if(typeof isEDIT != 'undefined' && isEDIT === false) editEL = '';
8715                    $(this).find('.resource-useit').removeClass('clicked');
8716                    $.resource.modalOpenSET(false);
8717                })
8718                .on('mousemove', function(e) {
8719                    mouseX = (typeof e.clientX != 'undefined') ? e.clientX : e.pageX;
8720                    mouseY = (typeof e.clientY != 'undefined') ? e.clientY : e.pageY;
8721                    if(fileDrag && $(this).is(':not(.flink-fileupload)')) moveResourceTooltip();
8722                })
8723                .on('mouseup', '.resource-files-content', function(e) {
8724                    hideResourceTooltip();
8725                    fileDrag = false;
8726                    dragTooltipModal = $();
8727                });
8728
8729
8730            
8731            /* modal-resourcebox 00__common */
8732            $('.modal-resourcebox')
8733                .on('click', '#btn-resourcebox-fullwidth', function(e) {
8734                    $(this).closest('#el-fileupload').toggleClass('full-width');
8735                })
8736                .on('change', '.resource-ctrl-layout select', function(e) {
8737                    $(this).next('.btn.dropdown-toggle').attr('title','');
8738                    var thisResourceFiles = $(this).closest('.tab-pane.active').find('ul.files'),
8739                        layout = $(this).val();
8740    
8741                    thisResourceFiles.attr('data-layout', layout);
8742                })
8743                .on('change', '.resource-ctrl-sort select', function(e) {
8744                    $(this).next('.btn.dropdown-toggle').attr('title','');
8745                    var thisResourceTab = $(this).closest('.tab-pane.active');
8746                    if(thisResourceTab.find('ul.files').hasClass('empty') || thisResourceTab.find('ul.files .resource-empty-area').length > 0) return false;
8747                    else thisResourceTab.find('.resource-search-btn').click();
8748                })
8749                .on('keyup', '.resource-search-stx', function(e) {
8750                    var keyCode = e.keyCode;
8751                    if(keyCode == 13) $(this).closest('.resource-search-group').find('.resource-search-btn').click();
8752                })
8753                .on('focusin', '.resource-search-stx', function() {
8754                    var $input = $(this);
8755                    if($input.closest('#iconstorage').length > 0 && typeof setIconStorageSearchState == 'function') {
8756                        var hasSearch = $input.val().trim() !== '';
8757                        setIconStorageSearchState(hasSearch, hasSearch);
8758                    }
8759                })
8760                .on('focusout', '.resource-search-stx', function() {
8761                    var $input = $(this);
8762                    if($input.closest('#iconstorage').length > 0 && typeof setIconStorageSearchState == 'function') {
8763                        setTimeout(function() {
8764                            var hasSearch = $input.val().trim() !== '';
8765                            setIconStorageSearchState(hasSearch, hasSearch);
8766                        }, 0);
8767                    }
8768                })
8769                .on('click', '.resource-search-btn', function(e) {
8770                    var thisSearchBtn = $(this),
8771                        thisSearchInput = thisSearchBtn.closest('.resource-search-group').find('.resource-search-stx'),
8772                        rmode = thisSearchBtn.attr('id').replace(/\-resource\-search$/gi,''),
8773                        fsearch = thisSearchInput.val().trim(),
8774                        fsort = (rmode == 'my') ? thisSearchBtn.closest('.resource-row').find('.resource-ctrl-sort select').val() : '';
8775    
8776                    if(thisSearchBtn.hasClass('clicked')) return false;
8777                    thisSearchBtn.addClass('clicked');
8778                    thisSearchBtn.data('fsearch', fsearch);
8779    
8780                    if(rmode == 'my' || rmode == 'icon') {
8781                        thisSearchInput.val(fsearch);
8782                        UPLOAD = 0;
8783                        UPLOADED = 0;
8784                        PROGRESS = 0;
8785                        cPage = 1;
8786                        if(rmode == 'icon') {
8787                            var icon_type = (typeof getIconStorageType == 'function') ? getIconStorageType() : ($('#iconstorage .icon_type.active').attr('data-icontype') || 'default');
8788                            if(typeof normalizeIconStorageType == 'function') icon_type = normalizeIconStorageType(icon_type);
8789                            if(typeof setIconStorageSearchState == 'function') setIconStorageSearchState(fsearch !== '', fsearch !== '');
8790                            fsort = fsearch ? 'total' : $('#iconstorage .resource-category-group').find('.fitem-category.active').attr('data-category');
8791                            if(fsearch) {
8792                                var iconResourceFiles = $('#iconstorage ul.files');
8793                                if(typeof appendIconStorageListProgress == 'function') {
8794                                    iconResourceFiles.empty();
8795                                    appendIconStorageListProgress(iconResourceFiles);
8796                                } else if(iconResourceFiles.find('.listprogress').length == 0) {
8797                                    iconResourceFiles.empty().append('<li class="listprogress">
8797<svg version="1.1" xmlns="http://www.w3.org/svg/2000" viewBox="0 0 30 30" width="60" style="width:30px; height: 30px;"><circle cy="15" cx="15" r="14" style="stroke:#00baff;"></circle></svg></li>');
8798                                }
8799                                setTimeout(function() {
8800                                    if(thisSearchInput.val().trim() != fsearch) {
8801                                        thisSearchBtn.removeClass('clicked');
8802                                        return;
8803                                    }
8804                                    resourceGetPage(1,SFOLDER_ACTIVE,fsort,fsearch);
8805                                }, 30);
8806                                return false;
8807                            }
8808                        }
8809                        resourceGetPage(1,SFOLDER_ACTIVE,fsort,fsearch);
8810                    } else if(rmode == 'free') {
8811                        if(fsearch == '') {
8812                            freeSearch.type = 'new';
8813                            freeSearch.page = 1;
8814                            freeSearch.text = '';
8815                            freeSearch.total = -1;
8816                            $.resource.modalContentInit('free');
8817                            $('#freestorage .resource-folderlist li[data-type="new"]').addClass('active').siblings().removeClass('active');
8818                            $('#freestorage ul.files').attr('data-type','new');
8819                            getFreeImage(freeSearch.page,freeSearch.type);
8820                            return false;
8821                        }
8822                        $('#freestorage .resource-useit').removeClass('active');
8823                        $('#freestorage ul.files, #freestorage .resource-selected-ul').empty();
8824                        $('#freestorage .resource-search-total').text('');
8825                        $('#freestorage ul.files').append('<li class="listprogress"><svg version="1.1" xmlns="http://www.w3.org/svg/2000" viewBox="0 0 30 30" width="60" style="width:30px; height: 30px;"><circle cy="15" cx="15" r="14" style="stroke:#00baff;"></circle></svg></li>');
8826                        $('#freestorage .resource-folderlist li').removeClass('active');
8827
8828                        freeSearch.type = 'search';
8829                        freeSearch.page = 1;
8830                        freeSearch.text = fsearch;
8831                        freeSearch.total = 0;
8832                        
8833                        $.getJSON('/template/translate/' + encodeURIComponent(fsearch), function(data) {
8834                            if($('#freestorage .resource-search-stx').val().trim() != fsearch) {
8835                                thisSearchBtn.removeClass('clicked');
8836                                if(freeSearch.text == fsearch) $('#freestorage ul.files .listprogress').remove();
8837                                return false;
8838                            }
8839                            var search = (data && data.data && data.data.translations && data.data.translations[0] && data.data.translations[0].translatedText) ? data.data.translations[0].translatedText : fsearch;
8840                            freeSearch.text = fsearch;
8841                            getFreeImage(freeSearch.page,freeSearch.type,search);
8842                        }).fail(function() {
8843                            if($('#freestorage .resource-search-stx').val().trim() != fsearch) {
8844                                thisSearchBtn.removeClass('clicked');
8845                                if(freeSearch.text == fsearch) $('#freestorage ul.files .listprogress').remove();
8846                                return false;
8847                            }
8848                            freeSearch.text = fsearch;
8849                            getFreeImage(freeSearch.page,freeSearch.type,fsearch);
8850                        });
8851                    }
8852                }).on('input', '.resource-search-stx', function() {
8853                    var $input = $(this);
8854                    var $searchBtn = $input.closest('.resource-search-group').find('.resource-search-btn');
8855                    if($input.closest('#iconstorage').length > 0 && typeof setIconStorageSearchState == 'function') {
8856                        var hasIconSearch = $input.val().trim() !== '';
8857                        setIconStorageSearchState(hasIconSearch, hasIconSearch);
8858                        if(hasIconSearch && $searchBtn.data('fsearch') != $input.val().trim()) {
8859                            var iconResourceFiles = $('#iconstorage ul.files');
8860                            if(typeof appendIconStorageListProgress == 'function') {
8861                                iconResourceFiles.empty();
8862                                appendIconStorageListProgress(iconResourceFiles);
8863                            } else if(iconResourceFiles.find('.listprogress').length == 0) {
8864                                iconResourceFiles.empty().append('<li class="listprogress">
8864<svg version="1.1" xmlns="http://www.w3.org/svg/2000" viewBox="0 0 30 30" width="60" style="width:30px; height: 30px;"><circle cy="15" cx="15" r="14" style="stroke:#00baff;"></circle></svg></li>');
8865                            }
8866                        }
8867                    }
8868                    clearTimeout($input.data('searchTimer'));
8869                    if($searchBtn.data('fsearch') != $input.val().trim()) {
8870                        $searchBtn.removeClass('clicked');
8871                    }
8872
8873                    $input.data('searchTimer', setTimeout(function () {
8874                        $searchBtn.trigger('click');
8875                    }, 400));
8876                })
8877                .on('scroll', 'ul.files', function(e) {
8878                })
8879                .on('mousedown', 'ul.files', function(e) {
8880                    var thisResourceTab = $(this).closest('.tab-pane.active'),
8881                        thisResourceFiles = $(this),
8882                        thisResourceSelected = thisResourceTab.find('.resource-selected-ul'),
8883                        rmode = thisResourceTab.attr('id').replace(/storage$/gi,'');
8884
8885                    if(rmode == 'my' && isFEdit) thisResourceTab.find('#nestableFolder .fln-group .btn-fln-cancel').click();
8886
8887                    if(e.shiftKey) {
8888                        thisResourceSelected.children('li').each(function () {
8889                            var set_key = (rmode == 'free') ? 'id' : 'seq',
8890                                set_val = $(this).attr('data-'+set_key);
8891                            if(thisResourceFiles.find('.ui-selected .fitem-ctrl > ul[data-' + set_key + '="' + set_val + '"]').length == 0) {
8892                                thisResourceFiles.find('.fitem-ctrl > ul[data-' + set_key + '="' + set_val + '"]').closest('.fitem').addClass('ui-selected');
8893                            }
8894                        });
8895                    } else {
8896                        if(!e.ctrlKey && !$(e.target).hasClass('.ui-selected')) {
8897                            $(e.target).removeClass('ui-selected');
8898                        }
8899                    }
8900                })
8901                .on('click', '.fitem', function(e) {
8902                    var thisResourceTab = $(this).closest('.tab-pane.active'),
8903                        thisResourceSelected = thisResourceTab.find('.resource-selected-ul'),
8904                        rmode = thisResourceTab.attr('id').replace(/storage$/gi,'');
8905
8906                    if(e.ctrlKey || e.shiftKey) {
8907                        if($(this).hasClass('ui-selected')) {
8908                            $(this).removeClass('ui-selected');
8909                            var unset_key = (rmode == 'free') ? 'id' : 'seq',
8910                                unset_val = $(this).find('.fitem-ctrl > ul').attr('data-'+unset_key);
8911                            thisResourceSelected.children('li[data-' + unset_key + '="' + unset_val + '"]').remove();
8912                        }
8913
8914                        setResourceSelectedBox(rmode);
8915                    }
8916                })
8917                .on('click', '.fitem-ctrl-imgview', function(e) {
8918                    var thisResourceTab = $(this).closest('.tab-pane.active'),
8919                        thisResourceCtrlImgview = $(this);
8920
8921                    $('.modal-resourcebox .fitem-ctrl-imgview').removeAttr('href').removeAttr('data-gallery');
8922                    $('.resourcebox-frame').html('\
8923                            <div id="rframe" class="blueimp-gallery blueimp-gallery-controls" data-start-slideshow="false" data-slideshow-interval="5000">\
8924                                <div class="slides"></div>\
8925                                <div class="zoomable hide"></div>\
8926                                <h3 class="title"></h3>\
8927                                <ul class="ctrls">\
8928                                    <li>\
8929                                        <a class="view-original" data-toggle="tooltip" data-placement="bottom" data-html="true" data-original-title="' + $.lang[LANG]['gallery.slide.tooltip.view-fullscreen'] + '">\
8930                                            <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 27 27" width="27" height="27"><g><path d="M1 4.12v18.75h25V4.12H1zm23.5 17.26h-22V5.62h22v15.76z"/><path d="M8.03 18.19h1.56V8.81H6.47v1.57h1.56zM12.72 10.38h1.56v1.56h-1.56zM12.72 15.06h1.56v1.56h-1.56zM18.19 18.19h1.56V8.81h-3.13v1.57h1.57z"/></g></svg>\
8931                                            <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 27 27" width="27" height="27"><path d="M24.03 4.03 24 4V3h-1l-.03-.03-.03.03H13.5v1.5h7.94L4.5 21.44V13.5H3v9.44l-.03.03L3 23v1h1l.03.03.03-.03h9.44v-1.5H5.56L22.5 5.56v7.94H24V4.06z"/></svg>\
8932                                        </a>\
8933                                    </li>\
8934                                    <li><a class="zoom-out disabled" data-toggle="tooltip" data-placement="bottom" data-html="true" data-original-title="' + $.lang[LANG]['gallery.slide.tooltip.zoom-out'] + '"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 23 23" width="23" height="23"><g><path d="m23 21.98-6.16-6.16a9.566 9.566 0 0 0 2.32-6.24C19.17 4.29 14.88 0 9.58 0S0 4.29 0 9.58s4.29 9.58 9.58 9.58c2.39 0 4.57-.88 6.24-2.32L21.98 23 23 21.98zM1.44 9.58c0-4.49 3.65-8.15 8.15-8.15 4.49 0 8.15 3.65 8.15 8.15s-3.65 8.15-8.15 8.15-8.15-3.66-8.15-8.15z"></path><path d="M5.75 8.86h7.67v1.44H5.75z"></path></g></svg></a></li>\
8935                                    <li><a class="zoom-in" data-toggle="tooltip" data-placement="bottom" data-html="true" data-original-title="' + $.lang[LANG]['gallery.slide.tooltip.zoom-in'] + '"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">
8935<path d="M24 22.94l-6.42-6.42C19.08 14.76 20 12.49 20 10c0-5.52-4.48-10-10-10S0 4.48 0 10s4.48 10 10 10c2.49 0 4.76-0.92 6.52-2.42L22.94 24 24 22.94zM1.5 10c0-4.69 3.81-8.5 8.5-8.5 4.69 0 8.5 3.81 8.5 8.5s-3.81 8.5-8.5 8.5C5.31 18.5 1.5 14.69 1.5 10z"/><polygon points="10.75 6 9.25 6 9.25 9.25 6 9.25 6 10.75 9.25 10.75 9.25 14 10.75 14 10.75 10.75 14 10.75 14 9.25 10.75 9.25 "/></svg></a></li>\
8936                                    <li><a class="close"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 22 22" width="22" height="22"><polygon points="22 1.06 20.94 0 11 9.94 1.06 0 0 1.06 9.94 11 0 20.94 1.06 22 11 12.06 20.94 22 22 20.94 12.06 11 "/></svg></a><li>\
8937                                </ul>\
8938                            </div>\
8939                    ');
8940                    thisResourceCtrlImgview.attr('href', $(this).attr('data-url')).attr('data-gallery','#rframe');
8941                })
8942                .on('mouseenter', '.resource-selected-ul > li', function(e) {
8943                    $(this).find('.selected-hover').show();
8944                })
8945                .on('mouseleave', '.resource-selected-ul > li', function(e) {
8946                    $(this).find('.selected-hover').hide();
8947                })
8948                .on('click', '.resource-selected-ul > li > .selected-hover', function(e) {
8949                    $(this).popover('destroy');
8950
8951                    var thisResourceTab = $(this).closest('.tab-pane.active'),
8952                        thisResourceFiles = thisResourceTab.find('ul.files'),
8953                        thisResourceSelected = thisResourceTab.find('.resource-selected-ul'),
8954                        rmode = thisResourceTab.attr('id').replace(/storage$/gi,'');
8955    
8956                    $(this).closest('li').fadeOut(300,function() {
8957                        var del_key = (rmode == 'free') ? 'id' : 'seq',
8958                            del_val = $(this).attr('data-'+del_key);
8959                        $(this).remove();
8960    
8961                        thisResourceFiles.find('.fitem.ui-selected .fitem-ctrl > ul[data-' + del_key + '="' + del_val + '"]').closest('.fitem').removeClass('ui-selected');
8962                        setResourceSelectedBox(rmode);
8963                    });
8964    
8965                    if(thisResourceSelected.children('li').length == 1) {
8966                        thisResourceTab.find('.resource-useit').removeClass('active');
8967                    }
8968                });
8969
8970            var folderSearchTimer = null;
8971            $('.modal-resourcebox')
8972            // Enter키로 즉시 필터
8973            .on('keyup', '.folder-search-stx', function(e){
8974                var keyCode = e.keyCode;
8975                if(keyCode == 13) $(this).closest('.folder-search-group').find('.folder-search-btn').trigger('click');
8976            })
8977
8978            // 타이핑 멈추면 자동 필터(0.3~0.5초 추천)
8979            .on('input', '.folder-search-stx', function(){
8980                var $input = $(this);
8981                clearTimeout(folderSearchTimer);
8982                folderSearchTimer = setTimeout(function(){
8983                    $input.closest('.folder-search-group').find('.folder-search-btn').trigger('click');
8984                }, 300);
8985            })
8986
8987            .on('click', '.folder-search-stx', function(){
8988                $('#nestableFolder .fli[data-id="clEmptyFolder"]').remove();
8989                $('#nestableFolder .btn-fln-cancel').trigger('click');
8990                isFEdit = false;
8991            })
8992
8993            // 버튼 클릭 시 필터링 실행
8994            .on('click', '.folder-search-btn', function(){
8995                var $group = $(this).closest('.folder-search-group');
8996                var q = $group.find('.folder-search-stx').val().trim().toLowerCase();
8997
8998                var $items = $('#nestableFolder .dd-list.fll > .fli');
8999
9000                // 비어있으면 전체 표시
9001                if(q === ''){
9002                    if(isFEdit) {
9003                        var $cancelBtn = $('#nestableFolder .fln-group .btn-fln-cancel');
9004                        if($cancelBtn.length > 0) $cancelBtn.trigger('click');
9005                    }
9006
9007                    $('#nestableFolder .fli[data-id="clEmptyFolder"]').remove();
9008                    isFEdit = false;
9009                    $.resource.setMystorageFolder('nodrag',false);
9010                    $items.show();
9011                    return;
9012                }
9013
9014                $items.each(function(){
9015                    var $li = $(this);
9016
9017                    if($li.hasClass('fli-first')) { $li.show(); return; }
9018                    // 폴더명 텍스트(번역 들어가는 span이라도 text()는 나옵니다)
9019                    var name = $li.find('.dd-fln').text().trim().toLowerCase();
9020
9021                    // "all" 같은 특수 항목은 항상 보이게 하고 싶으면 아래처럼 예외처리 가능
9022                    // if($li.hasClass('fli-first')) { $li.show(); return; }
9023
9024                    $li.toggle(name.indexOf(q) !== -1);
9025                });
9026            });
9027
9028            /* modal-resourcebox 01__mystorage */
9029            var mystorageFolderEdit = function(ddfl) {
9030                var myResourceFolderlist = $('#mystorage #nestableFolder'),
9031                    edit_fli = ddfl.closest('li.fli'),
9032                    fln_group_css = (myResourceFolderlist.find('.dd-list.fll').height() >= myResourceFolderlist.height() && $.browser.safari == undefined) ? 'style="max-width: 173px;"' : '',
9033                    fln_input_css = (myResourceFolderlist.find('.dd-list.fll').height() >= myResourceFolderlist.height() && $.browser.safari == undefined) ? 'style="max-width: 136px;"' : '',
9034                    checkAdd = (edit_fli.attr('data-id') == 'clEmptyFolder') ? true : false,
9035                    beforeFln = (checkAdd) ? '' : edit_fli.attr('data-id');
9036
9037                if(beforeFln.length > 0) beforeFln = beforeFln.replace(/-/g,' ');
9038
9039                var input_html = '\
9040                    <div class="fln-group input-group" ' + fln_group_css + '>\
9041                        <input class="fln-input form-control" type="text" value="' + beforeFln + '"  ' + fln_input_css + '/>\
9042                        <span class="input-group-btn"><button class="btn-fln-save btn btn-default btn-primary" type="button"><i class="fa fa-check"></i></button></span>\
9043                        <div class="btn-fln-cancel"><i class="fa fa-times"></i></div>\
9044                    </div>\
9045                    ';
9046
9047                $(input_html).appendTo(edit_fli.find('.dd-fln'));
9048                if(edit_fli.find('.fln-input').is(':not(:focus)')) edit_fli.find('.fln-input').focus();
9049
9050                $.resource.setMystorageFolder('nodrag',true);
9051            }
9052
9053            var mystorageFolderUpdate = function(prevText,newText) {
9054                $.ajax({
9055                    type: 'POST',
9056                    url: '/template/resource/update-ffolder',
9057                    data: { sid: SID, prevffolder: prevText, newffolder: newText },
9058                    async: true,
9059                    success: function(data) {
9060                        checkError(data);
9061                    }
9062                });
9063            }
9064
9065            var getNextMystorageFolderId = function() {
9066                var maxId = 0;
9067
9068                if (SFOLDER && Array.isArray(SFOLDER) && SFOLDER.length) {
9069                    $.each(SFOLDER, function(_, folder) {
9070                        var id = parseInt(folder && folder.id, 10);
9071                        if (!isNaN(id) && id > maxId) maxId = id;
9072                    });
9073                }
9074
9075                $('#nestableFolder .fli').each(function() {
9076                    var id = parseInt($(this).attr('data-fid'), 10);
9077                    if (!isNaN(id) && id > maxId) maxId = id;
9078                });
9079
9080                return maxId + 1;
9081            }
9082
9083            var mystorageFileDelete = function(file,seq,callback) {
9084                if(CANCEL) return true;
9085                $.ajax({
9086                    type: 'POST',
9087                    url: '/template/resource/delete',
9088                    data: { s: file, sid: SID, seq: seq },
9089                    async: true,
9090                    success: function(data) {
9091                        checkError(data);
9092                        if(typeof callback == 'function') {
9093                            callback();
9094                        }
9095                    }
9096                });
9097            }
9098
9099            $('.modal-resourcebox')
9100                .on('click', 'a[href="#mystorage"]', function(e) {
9101                    setResourceSelectedBox('my');
9102                    if(isFEdit) $('#nestableFolder .fln-group .btn-fln-cancel').click();
9103                });
9104
9105            $('.modal-resourcebox #mystorage')
9106                .on('scroll touchmove mousewheel', '#nestableFolder', function(e) {
9107                    if(isFEdit || $(this).find('.fln-group.input-group').length > 0) {
9108                        e.preventDefault();
9109                        return false;
9110                    }
9111                    var myResourceTab = $(this).closest('.tab-pane.active'),
9112                        myResourceFolderlist = $(this);
9113
9114                    if(myResourceTab.find('.dd-header .popover.in').length > 0) {
9115                        var inputEL = myResourceFolderlist.find('.fln-input'),
9116                            checkScroll = (myResourceFolderlist.find('.dd-list.fll').height() >= myResourceFolderlist.height()) ? true : false,
9117                            offset = myResourceTab.find('.dd-header').outerHeight() + 3,
9118                            top = (checkScroll) ? inputEL.closest('li').position().top - myResourceFolderlist.scrollTop() : inputEL.offset().top - myResourceFolderlist.offset().top;
9119                        myResourceTab.find('.dd-header .popover.in').css('top', offset + top);
9120                    }
9121                })
9122                .on('mouseup', '#nestableFolder .fli', function(e) {
9123                    var fliFolder = $('#nestableFolder'),
9124                        fliResourceTab = $(this).closest('.tab-pane.active'),
9125                        fliResourceFiles = fliResourceTab.find('ul.files'),
9126                        fliResourceSelected = fliResourceTab.find('.resource-selected-ul'),
9127                        rmode = fliResourceTab.attr('id').replace(/storage$/gi,''),
9128                        fsort = fliResourceTab.find('.resource-ctrl-sort select').val(),
9129                        fsearch = fliResourceTab.find('.resource-search-stx').val();
9130
9131                    if(fileDrag) {
9132                        fliResourceFiles.find('.fitem .fitem-visual').removeClass('ui-selected');
9133                        fliFolder.find('.fli').removeClass('drag-selected');
9134    
9135                        // selected-files 파일을 $.post로 보내고 리스트 페이지 갱신
9136                        var prevffolder = [], fsizes = [], fseqs = [],
9137                            targetffolder = $(this).attr('data-id');
9138
9139                        fliResourceSelected.children('li').each(function() {
9140                            prevffolder.push($(this).attr('data-ffolder')); 
9141                            fsizes.push(parseInt($(this).find('p.selected-file-size .size').text()));
9142                            fseqs.push($(this).attr('data-seq'));
9143                        });
9144    
9145                        if(SID) {
9146                            var activeffolder = fliFolder.find('.fli.active').attr('data-id'),
9147                                r_pages = Number(fliResourceTab.find('.resource-paging .pagination').attr('data-pages')),
9148                                r_page = Number(fliResourceTab.find('.resource-paging .pagination li.active').text()),
9149                                r_file_cnt = fliResourceFiles.find('.fitem').length;
9150    
9151                            $.post('/template/resource/update-fmove', { sid: SID, fseqs: fseqs, targetffolder: targetffolder }, function (data) {
9152                                checkError(data);
9153                                $.each(fseqs, function(i,v) {
9154                                    if(prevffolder[i] != targetffolder) {
9155                                        if(prevffolder[i] != 'all') $.resource.setMystorageFolder('set_fli_state', {'count': -1, 'size': -fsizes[i], ffolder: prevffolder[i], state: 'move'});
9156                                        if(targetffolder != 'all') $.resource.setMystorageFolder('set_fli_state', {'count': 1, 'size': fsizes[i], ffolder: targetffolder, state: 'move'});
9157                                    }
9158                                });
9159                                updateOutputFolder($('#nestableFolder').data('output', $('#nestableFolder-output')));
9160    
9161                                r_page = ((r_file_cnt - fseqs.length) == 0 && r_pages<=r_page && SFOLDER_ACTIVE) ? r_page-1 : r_page;
9162                                r_page = 1;
9163                                cPage = 1;
9164                                resourceGetPage(r_page,SFOLDER_ACTIVE,fsort,fsearch);
9165                                
9166                                fliResourceFiles.find('.fitem .resource-image.ui-selected').removeClass('ui-selected');
9167                                fliResourceFiles.find('.fitem.ui-selected').removeClass('ui-selected');
9168                                fliResourceSelected.empty();
9169                                setResourceSelectedBox(rmode);
9170                            }, 'json');
9171                        }
9172                    }
9173                })
9174                .on('mouseenter', '#nestableFolder .fli', function(e) {
9175                    $('#nestableFolder .fli').removeClass('drag-selected');
9176                    if(fileDrag) {
9177                        $(this).addClass('drag-selected');
9178                    }
9179                })
9180                .on('mouseleave', '#nestableFolder .fli', function(e) {
9181                    $(this).removeClass('drag-selected').siblings().removeClass('drag-selected');
9182                })
9183                .on('click', '#nestableFolder .fli:not(.active)', function(e) {
9184                    if( isFEdit ||
9185                        $(e.target).is('.fln-input, .fli-hover, [class*="btn-fln-"]')
9186                    ) { return; }
9187
9188                    if($(this).parents('.fll').length == 2) depfolderClick = true;
9189                    if($(this).parents('.fll').length == 1 && depfolderClick) {
9190                        depfolderClick = false;
9191                        return;
9192                    } else {
9193                        $(this).addClass('active').siblings('.fli').removeClass('active');
9194                        SFOLDER_ACTIVE = ($(this).attr('data-id')!='all') ? $(this).attr('data-id') : '';
9195                        cPage = 1;
9196                        
9197                        var myResourceTab = $('#mystorage'),
9198                            fsort = myResourceTab.find('.resource-ctrl-sort select').val();
9199                        myResourceTab.find('.resource-search-stx').val('');
9200                        resourceGetPage(1,SFOLDER_ACTIVE,fsort,'');
9201                    }
9202                })
9203                .on('click', '#nestableFolder .fli .dd-fle', function(e) {
9204                    if(isFEdit) { return; }
9205                    if($(this).parent().closest('.fli').index() > 0) {
9206                        isFEdit = true;
9207                        mystorageFolderEdit($(this));
9208                    }
9209                })
9210                .on('click', '#nestableFolder .fli .dd-fln .btn-fln-cancel', function(e) {
9211                    $('#mystorage .add-folder').attr('data-content','').popover('hide');
9212                    if($(this).closest('li.fli').attr('data-id') == 'clEmptyFolder') $(this).closest('li.fli').remove();
9213                    else {
9214                        $(this).closest('.dd-fln').find('.fln-group').remove();
9215                        $(this).remove();
9216                    }
9217                    isFEdit = false;
9218                    $.resource.setMystorageFolder('nodrag',false);
9219                    if($('#nestableFolder .fll .fli.active').length == 0) $('#nestableFolder .fli').eq(0).click();
9220                })
9221                .on('click', '#nestableFolder .fli .dd-flf', function (e) {
9222                    e.preventDefault();
9223                    e.stopPropagation();
9224
9225                    var $item = $(this).closest('.dd-item');
9226                    var $fav = $(this);
9227
9228                    var fid = String($item.attr('data-fid') || '').trim();
9229                    
9230                    var raw = $('#nestableFolder-output').val();
9231                    if (!raw || raw.trim().length === 0 || raw === '[]') {
9232                        raw = (SFOLDER && Array.isArray(SFOLDER) && SFOLDER.length) ? JSON.stringify(SFOLDER) : '[]';
9233                        $('#nestableFolder-output').val(raw);
9234                    }
9235
9236                    var data = [];
9237                    var next = null;
9238                    if (SFOLDER && Array.isArray(SFOLDER) && SFOLDER.length) {
9239                        data = $.extend(true, [], SFOLDER);
9240                    } else {
9241                        try { data = JSON.parse(raw); } catch (err) { data = []; }
9242                    }
9243
9244                    if (!data.length || !fid) return false;
9245
9246                    $.each(data, function (i, folder) {
9247                        if (String(folder.id) !== fid) return true;
9248
9249                        var cur = String(folder.favorite || '0');
9250                        next = (cur === '1') ? '0' : '1';
9251                        folder.favorite = next;
9252                        return false;
9253                    });
9254
9255                    if (next === null) return false;
9256
9257                    $item.attr('data-favorite', next);
9258                    $fav.attr('data-fav', next).html((next === '1') ? clSVG('pin', 12, 12) : clSVG('pin_blank', 12, 12));
9259
9260                    // 3) output 갱신 + SFOLDER 갱신
9261                    SFOLDER = data;
9262                    $('#nestableFolder-output').val(JSON.stringify(data));
9263                    var nextVal = sortFolderFavoritesTop();
9264                    if (!nextVal || nextVal === '[]') {
9265                        nextVal = JSON.stringify(SFOLDER);
9266                        $('#nestableFolder-output').val(nextVal);
9267                    }
9268
9269                    // 4) 서버 저장
9270                    if (SID) {
9271                        $.ajaxSetup({ async: false });
9272                        $.post('/template/update/type/folder', { s: nextVal, id: SID }, function (res) {
9273                            checkError(res);
9274                        }, 'json');
9275                    }
9276
9277                    return false;
9278                })
9279                .on('click', '#nestableFolder .fli .dd-fln .btn-fln-save', function(e) {
9280                    var myResourceTab = $(this).closest('.tab-pane.active'),
9281                        myResourceFiles = myResourceTab.find('ul.files'),
9282                        myResourceFolderlist = myResourceTab.find('#nestableFolder'),
9283                        myResourceFolderItem = $(this).closest('li.fli'),
9284                        checkPageReload = myResourceFolderItem.hasClass('active'),
9285                        fsort = myResourceTab.find('.resource-ctrl-sort select').val(),
9286                        fsearch = myResourceTab.find('.resource-search-stx').val(),
9287                        inputEL = $(this).closest('.fln-group').find('.fln-input'),
9288                        regExp = /[\{\}\[\]\/!?.,;:|\)*~`^\-_+<>@\#$%&\\\=\(\'\"]/gi,
9289                        err_str = '',
9290                        checkAdd = (myResourceFolderItem.attr('data-id') == 'clEmptyFolder') ? true : false,
9291                        beforeFln = (checkAdd) ? '' : myResourceFolderItem.attr('data-id'),
9292                        afterFln = inputEL.val().trim();
9293
9294                    if(afterFln.length == 0) {
9295                        err_str = $.lang[LANG]['editor.resource.regExp.empty'];
9296                    } else if(afterFln == 'clEmptyFolder') {
9297                        err_str = $.lang[LANG]['editor.resource.regExp.clEmptyFolder'];
9298                    } else if(checkEmojis(afterFln)) {
9299                        err_str = $.lang[LANG]['config.unable.emoji'];
9300                    } else if(regExp.test(afterFln)) {
9301                        err_str = $.lang[LANG]['editor.resource.regExp.specialchar'];
9302                    } else if($('#nestableFolder .fli[data-id="'+afterFln.replace(/ /g,'-')+'"]').length > 0 && beforeFln != afterFln.replace(/ /g,'-')) {
9303                        err_str = $.lang[LANG]['editor.resource.regExp.overlap'];
9304                    } else if(afterFln.length > 20) {
9305                        err_str = $.lang[LANG]['editor.resource.regExp.maximum'];
9306                    } else { 
9307                        err_str = '';
9308                    }
9309
9310                    afterFln = afterFln.replace(/ /g,'-');
9311                    if(err_str!=''){
9312                        inputEL.focus();
9313                        myResourceTab.find('.add-folder').attr('data-content',err_str).popover('show');
9314
9315                        var checkScroll = (myResourceFolderlist.find('.dd-list.fll').height() >= myResourceFolderlist.height()) ? true : false,
9316                            offset = myResourceTab.find('.dd-header').outerHeight() + 3,
9317                            top = (checkScroll) ? inputEL.closest('li').position().top - myResourceFolderlist.scrollTop() : inputEL.offset().top - myResourceFolderlist.offset().top;
9318                        myResourceTab.find('.dd-header .popover.in').css('top', offset + top);
9319                    } else { 
9320                        myResourceTab.find('.add-folder').attr('data-content','').popover('hide');
9321
9322                        if(checkAdd) {
9323                            var newFid = parseInt(myResourceFolderItem.attr('data-fid'), 10);
9324                            if(isNaN(newFid) || newFid < 1) {
9325                                myResourceFolderItem.attr('data-fid', getNextMystorageFolderId());
9326                            }
9327                        }
9328
9329                        inputEL.closest('.fli').attr('data-id',afterFln).find('[attr-id]').attr('attr-id',afterFln);
9330                        inputEL.closest('.dd-fln').html(afterFln.replace(/-/g,' '));
9331                        updateOutputFolder($('#nestableFolder').data('output', $('#nestableFolder-output')));
9332                        mystorageFolderUpdate(beforeFln,afterFln);
9333
9334                        if(checkPageReload) {
9335                            SFOLDER_ACTIVE = afterFln;
9336                            resourceGetPage(1,SFOLDER_ACTIVE,fsort,fsearch);
9337                        } else {
9338                            myResourceFiles.find('.fitem .data-ffolder ul[data-ffolder="'+beforeFln+'"]').each(function() {
9339                                $(this).attr('data-ffolder',afterFln);
9340                            })
9341                        }
9342
9343                        isFEdit = false;
9344                        $.resource.setMystorageFolder('nodrag',false);
9345                    }
9346                })
9347                .on('keyup', '#nestableFolder .fli .dd-fln .fln-input', function(e) {
9348                    if(e.keyCode == 13) $(this).closest('.fln-group').find('.btn-fln-save').click();
9349                })
9350                .on('click', '#nestableFolder .fli .dd-fld', function(e) {
9351                    if(isFEdit) { return; }
9352                    if($('#nestableFolder .fll > .fli').length < 2) { return false; }
9353
9354                    isFEdit = true;
9355                    $.resource.setMystorageFolder('nodrag',true);
9356                    var myResourceTab = $('#mystorage'),
9357                        myResourceFiles = myResourceTab.find('ul.files'),
9358                        myResourceSelected = myResourceTab.find('.resource-selected-ul'),
9359                        myResourceFolderItem = $(this).closest('li.fli'),
9360                        checkPageReload = (myResourceFolderItem.hasClass('active') || $('#nestableFolder .fli[data-id="all"]').hasClass('active')) ? true : false,
9361                        fsort = myResourceTab.find('.resource-ctrl-sort select').val(),
9362                        fsearch = myResourceTab.find('.resource-search-stx').val();
9363
9364                    var fli_count = myResourceFolderItem.find('.dd-flc').attr('attr-count');
9365                    fli_count = (typeof fli_count != 'undefined' && /^[0-9]*$/.test(fli_count)) ? fli_count * 1 : 0;
9366                    if(fli_count > 0) {
9367                        var prevffolder = myResourceFolderItem.attr('data-id');
9368                        var modal_str = '\
9369                                <div class="popup-info edit-link-info">'+$.lang[LANG]['editor.resource.folder.delete.confirm']+'</div>\
9370                                <ul class="duplicate-gallery-content delete-folder">\
9371                                    <li class="link-type active">\
9372                                        <div class="delete">\
9373                                            ' + clSVG('checkbox_active',20,20,false) + '\
9374                                            <h5>'+$.lang[LANG]['editor.resource.folder.delete.folderOnly']+'</h5>\
9375                                        </div>\
9376                                    </li>\
9377                                    <li class="link-type">\
9378                                        <div class="delete-with-resource">\
9379                                            ' + clSVG('checkbox_active',20,20,false) + '\
9380                                            <h5>'+$.lang[LANG]['editor.resource.folder.delete.all']+'</h5>\
9381                                        </div>\
9382                                    </li>\
9383                                </ul>\
9384                        ';
9385
9386                        var modal = $(this).showModalFlat($.lang[LANG]['editor.resource.folder.delete'], modal_str, true, true, function() {
9387                            var checked = $('.link-type.active').find('div').attr('class');
9388
9389                            $.ajaxSetup({ async : true });
9390                            if(checked == 'delete-with-resource') {
9391                                checkPageReload = true;
9392                                $.post('/template/resource/get-folder-resource', { sid: SID, prevffolder: prevffolder }, function (data) {         
9393                                    checkError(data);
9394
9395                                    var files = data.files;
9396                                    var fileDeleteModal = $(this).showModalFlat($.lang[LANG]['config.common.resource.delete.title'],$.lang[LANG]['config.common.resource.delete'], true, true, function() {
9397                                        fileDeleteModal.modal('hide');
9398                                        $.progressON();
9399                                        var seqs = [], sizes = [], ffolders = [];
9400                                        $.each(files, function(idx, f){
9401                                            seqs.push(f.seq);
9402                                            sizes.push(f.file_size);
9403                                            ffolders.push(f.file_folder);
9404                                        });
9405                                        var total = files.length,
9406                                            deleting = '',
9407                                            progress = 0;
9408                                            loading = '<i class="fa fa-circle-o-notch fa-spin fa-3x fa-fw"></i> ';
9409                                            done = 0; deleting = $('p.fitem-name[data-seq="' + seqs[0] + '"]').text();
9410                                        $('.progressModal .info1').html(loading + deleting);
9411
9412                                        $.each(files,function(i,f) {
9413                                            var t = setTimeout(function() {
9414                                                if(CANCEL) {
9415                                                    if(ABORT) {
9416                                                        resourceGetPage(1,SFOLDER_ACTIVE,fsort,fsearch);
9417                                                        updateOutputFolder($('#nestableFolder').data('output', $('#nestableFolder-output')));
9418                                                        ABORT = false;
9419                                                        $.progressOFF();
9420                                                    }
9421                                                    i=0; return false;
9422                                                }
9423                                                mystorageFileDelete(f.file_name, f.seq, function() {
9424                                                    done++;
9425                                                    progress = parseInt((done / total) * 100,10);
9426                                                    $('.file-upload-progress .progress-bar').css('width',progress + "%");
9427                                                    $('.progressModal .info2').text(done.toString() + ' / ' + total.toString());
9428                                                    
9429                                                    $.resource.setMystorageFolder('set_fli_state', {'count': -1, 'size': -sizes[i], ffolder: 'all', state: 'delete'});
9430                                                    if(ffolders[i] != '' && ffolders[i] != 'all') {
9431                                                        $.resource.setMystorageFolder('set_fli_state', {'count': -1, 'size': -sizes[i], ffolder: ffolders[i], state: 'delete'});
9432                                                    }                       
9433
9434                                                    if(total == done) {
9435                                                        myResourceFolderItem.addClass('deleted');
9436                                                        setTimeout(function() {
9437                                                            modal.modal('hide');
9438                                                        },500);
9439                                                    } else {
9440                                                        deleting = $('p.fitem-name[data-seq="' + seqs[i+1] + '"]').text();
9441                                                        $('.progressModal .info1').html(loading + deleting);
9442                                                    }
9443                                                });
9444                                            },500*i);
9445                                        });
9446                                    },'cancel','ok','modal-over-1 cl-cmmodal cl-s-btn cl-common-notice w560',false);
9447                                    
9448                                }, 'json');
9449                            } else { //폴더만 삭제
9450                                $.processON('delete folder...');
9451                                var deferred = $.Deferred();
9452                                $.post('/template/resource/delete-folder-only', { sid: SID, prevffolder: prevffolder }, function (data) {
9453                                    checkError(data);
9454                                    myResourceFolderItem.addClass('deleted');
9455                                    modal.modal('hide');
9456                                });
9457                            }
9458                            
9459                        }, 'cancel', $.lang[LANG]['editor.resource.folder.delete.btn.delete'], 'modal-over-1 cl-cmmodal cl-s-btn w560 cl-p0 confirm-resource-folder-delete agreement-duplicate-contents', false, '', '', function() {
9460                            isFEdit = false;
9461                            $.resource.setMystorageFolder('nodrag',false);
9462
9463                            if($('.progressModal').length > 0) $.progressOFF();
9464                            if($('.processModal').length > 0) $.processOFF();
9465                            if(myResourceTab.find('#nestableFolder .fli.deleted').length > 0) {
9466                                myResourceTab.find('#nestableFolder .fli.deleted').remove();
9467                                updateOutputFolder($('#nestableFolder').data('output', $('#nestableFolder-output')));
9468
9469                                myResourceFiles.find('.fitem.ui-selected').removeClass('ui-selected');
9470                                myResourceSelected.children('li').remove();
9471                                if(checkPageReload) $('#nestableFolder .fll > .fli').first().removeClass('active').click();
9472                            }
9473                        });
9474                    } else {
9475                        var checkModal = $(this).showModalFlat($.lang[LANG]['editor.resource.folder.delete'], $.lang[LANG]['editor.resource.folder.delete.check'], true, true, function() {
9476                            myResourceFolderItem.remove();
9477                            updateOutputFolder($('#nestableFolder').data('output', $('#nestableFolder-output')));
9478                            checkModal.modal('hide');
9479                        }, 'cancel', 'ok', 'cl-p130 cl-cmmodal cl-s-btn w560 cl-p0 zindex1042', false, '', '', function() {
9480                            isFEdit = false;
9481                            $.resource.setMystorageFolder('nodrag',false);
9482
9483                            if(checkPageReload) $('#nestableFolder .fll > .fli').first().removeClass('active').click();
9484                            $.processOFF();
9485                        });
9486                    }
9487                })
9488                .on('click', '.add-folder', function(e) {
9489                    $('.add-folder').attr('data-content','').popover('hide');
9490                    var myResourceFolderlist = $('#mystorage #nestableFolder'),
9491                        myResourceFolderAdd = $(this);
9492
9493                    if(isFEdit || myResourceFolderlist.find('.fln-input').length > 0) {
9494                        if(myResourceFolderlist.find('.fln-input').length > 0) myResourceFolderlist.find('.fln-input').focus();
9495                        isFEdit = true;
9496                        $.resource.setMystorageFolder('nodrag',true);
9497                        return; 
9498                    }
9499                    var checkPlan = (typeof property == 'undefined') ? ((typeof VALIDPLAN == 'undefined') ? $.gallery.valid_plan : VALIDPLAN) : property.VALIDPLAN,
9500                        checkPlanType = (typeof property == 'undefined') ? ((typeof VALIDTYPE == 'undefined') ? $.gallery.valid_type : VALIDTYPE) : property.VALIDTYPE,
9501                        checkFREE = (!checkPlan || checkPlanType == 'PK') ? true : false;
9502                    var checkMaximum = (    (!checkFREE && myResourceFolderlist.find('.fli').length > 500) || 
9503                                            (checkFREE && myResourceFolderlist.find('.fli').length > 50)
9504                                        ) ? true : false;
9505                    if(checkMaximum) {
9506                        var max_msg = (!checkFREE) ? $.lang[LANG]['editor.resource.folder.maximum'] : $.lang[LANG]['editor.resource.folder.maximum.free'];
9507                        var max_modal = $(this).showModalFlat($.lang[LANG]['config.information'], max_msg, true, false,'','close', 'ok', 'cl-cmmodal cl-s-btn w560 cl-p70 cl-p0', false, '', function() {
9508                            max_modal.closest('.flat-modal').next('.modal-backdrop').attr('style','z-index: 1041!important;');
9509                        });
9510                        return;
9511                    } else {
9512                        isFEdit = true;
9513
9514                        if(myResourceFolderlist.find('.fli[data-id="clEmptyFolder"]').length > 0) {
9515                            myResourceFolderlist.find('.fli[data-id="clEmptyFolder"]').find('.dd-fln').val('');
9516                        } else {
9517                            var add_folder = $.resource.getMystorageFolderHtml('clEmptyFolder', 0, 0, getNextMystorageFolderId());
9518                            myResourceFolderlist.find('.fll').append(add_folder);
9519                        }
9520
9521                        var input_html = '\
9522                            <div class="fln-group input-group">\
9523                                <input class="fln-input form-control" type="text"/>\
9524                                <span class="input-group-btn"><button class="btn-fln-save btn btn-default btn-primary" type="button"><i class="fa fa-check"></i></button></span>\
9525                                <div class="btn-fln-cancel"><i class="fa fa-times"></i></div>\
9526                            </div>\
9527                            ';
9528
9529                        $(input_html).appendTo(myResourceFolderlist.find('.fli[data-id="clEmptyFolder"] .dd-fln')).find('.fln-input').focus();
9530                        if(myResourceFolderlist.find('.dd-list.fll').height() >= myResourceFolderlist.height() && $.browser.safari == undefined) {
9531                            myResourceFolderlist.find('.dd-fln').find('.fln-group').css('max-width','182px');
9532                            myResourceFolderlist.find('.dd-fln').find('.fln-input').css('max-width','155px');
9533                            myResourceFolderlist.scrollTop(2000);
9534                        }
9535                        $.resource.setMystorageFolder('nodrag',true);
9536                    }
9537                })
9538                .on('click', '#mystorageUploadBtn', function(e) {
9539                    var myResourceTab = $('#mystorage'),
9540                        fsort = myResourceTab.find('.resource-ctrl-sort select').val(),
9541                        fsearch = myResourceTab.find('.resource-search-stx').val(),
9542                        ffolder = (SFOLDER_ACTIVE) ? SFOLDER_ACTIVE : 'all';
9543
9544                    $.uploadON();
9545                    $(this).fileupload({
9546                        url: '/template/resource/upload/ffolder/'+ffolder,
9547                        dataType: 'json',
9548                        pasteZone: null,
9549                        dropZone: null,
9550                        async: true,
9551                        prependFiles: true,
9552                        sequentialUploads: true,
9553                        add: function(e,data) {
9554                            var r = $.upload_add(e,data,'image');
9555                            if(r.submit) {
9556                                var jqXHR = data.submit();
9557                                UPLOAD++;
9558                            } else {
9559                                data.context.find('.loading').html('<i class="fa fa-times error"></i>');
9560                                data.context.find('.ing').addClass('error').text(r.err);
9561                            }
9562
9563                            $('.uploadModal .upload-cancel .btn, .uploadModal .upload-close').off('click').on('click', function(e) {
9564                                if(jqXHR != undefined) jqXHR.abort();
9565                                data.context.fadeOut().remove();
9566                                $('.uploadModal #file-upload-progress').css('width','0%');
9567                                $.uploadOFF();
9568                                UPLOAD = 0;
9569                                UPLOADED = 0;
9570                                PROGRESS = 0;
9571
9572                                updateOutputFolder($('#nestableFolder').data('output', $('#nestableFolder-output')));
9573                                resourceGetPage(1,SFOLDER_ACTIVE,fsort,fsearch);
9574                            });
9575                        },
9576                        progress: function(e, data) {
9577                            $.upload_progress(e,data);
9578                        },                        
9579                        done: function (e, data) {
9580                            $.upload_done(e,data);
9581                            UPLOADED++;
9582
9583                            var isSuccess = (typeof data._response.result != 'undefined' && typeof data._response.result.error != 'undefined') ? false : true;
9584                            if(isSuccess) {
9585                                var add_fls = parseFloat(data.files[0].size / 1024).toFixed(2);
9586
9587                                $.resource.setMystorageFolder('set_fli_state', {'count': 1, 'size': add_fls, ffolder: 'all', state: 'upload'});
9588                                if(SFOLDER_ACTIVE != '') $.resource.setMystorageFolder('set_fli_state', {'count': 1, 'size': add_fls, ffolder: SFOLDER_ACTIVE, state: 'upload'});    
9589                            }
9590
9591                            if(UPLOADED && data.context.find('.error').length == 0) {
9592                                //$.uploadON(UPLOADED + " / " + UPLOAD + "<br>images creating...");
9593                                if(UPLOAD==UPLOADED) {
9594                                    setTimeout(function() {
9595                                        $.uploadOFF();
9596                                        UPLOAD = 0;
9597                                        UPLOADED = 0;
9598                                        PROGRESS = 0;
9599
9600                                        updateOutputFolder($('#nestableFolder').data('output', $('#nestableFolder-output')));
9601                                        resourceGetPage(1,SFOLDER_ACTIVE,'date_desc','');
9602                                    },1000);
9603                                }
9604                            }
9605                        },
9606                        progressall: function (e, data) {
9607                            $.upload_progressall(e,data);
9608                        },
9609                        start : function(e, data) {
9610                            $.upload_start(e,data);
9611                            progress1 = 0; progress2 = 0; PROGRESS = 0;
9612                        },
9613                        dragover : function(e, data) {
9614                            e.preventDefault();
9615                        }
9616                    }
9616).prop('disabled', !$.support.fileInput)
9617                        .parent().addClass($.support.fileInput ? undefined : 'disabled');
9618                })
9619                .on('mousedown', '.fitem', function(e) {
9620                    mouseX = (typeof e.clientX != 'undefined') ? e.clientX : e.pageX;
9621                    mouseY = (typeof e.clientY != 'undefined') ? e.clientY : e.pageY;
9622
9623                    if($(this).hasClass('ui-selected')) {
9624                        fileDrag = true;
9625                        updateResourceTooltip($(this), true);
9626                    } else {
9627                        fileDrag = false;
9628                        dragTooltipModal = $();
9629                        hideResourceTooltip();
9630                    }
9631                })
9632                .on('mouseup', '.fitem', function(e) {
9633                    if($(this).closest('.tab-pane.active').find('#nestableFolder').length > 0) $(this).closest('.tab-pane.active').find('#nestableFolder .fli').removeClass('drag-selected');
9634                    hideResourceTooltip();
9635                    fileDrag = false;
9636                    dragTooltipModal = $();
9637                })
9638                .on('mousemove', '.fitem', function(e) {
9639                    mouseX = (typeof e.clientX != 'undefined') ? e.clientX : e.pageX;
9640                    mouseY = (typeof e.clientY != 'undefined') ? e.clientY : e.pageY;
9641                    if(fileDrag) updateResourceTooltip($(this), false);
9642                })
9643                .on('click', '.fitem-ctrl-del', function(e) {
9644                    var delResourceTab = $(this).closest('.tab-pane.active'),
9645                        delResourceFiles = delResourceTab.find('ul.files'),
9646                        delResourceSelected = delResourceTab.find('.resource-selected-ul'),
9647                        fsort = delResourceTab.find('.resource-ctrl-sort select').val(),
9648                        fsearch = delResourceTab.find('.resource-search-stx').val(),
9649                        file    = $(this).closest('ul').attr('data-source'),
9650                        seq     = $(this).closest('ul').attr('data-seq'),
9651                        size    = $(this).closest('ul').attr('data-fsize'),
9652                        ffolder = $(this).closest('ul').attr('data-ffolder');
9653
9654                    var modal = $(this).showModalFlat($.lang[LANG]['config.common.resource.delete.title'],$.lang[LANG]['config.common.resource.delete'], true, true, function() {
9655                        $.processON('Deleting the image(s)...');
9656                        modal.modal('hide');
9657                        delResourceFiles.find('.fitem p.fitem-name[data-seq="' + seq + '"]').remove();
9658                        delResourceSelected.children('li[data-seq="' + seq + '"]').remove();
9659                        if(delResourceSelected.length == 0) delResourceTab.find('.resource-useit').removeClass('active');
9660
9661                        mystorageFileDelete(file,seq,function() {
9662                            $.resource.setMystorageFolder('set_fli_state', {'count': -1, 'size': -size, ffolder: 'all', state: 'delete'});
9663                            if(ffolder != '' && ffolder != 'all') {
9664                                $.resource.setMystorageFolder('set_fli_state', {'count': -1, 'size': -size, ffolder: ffolder, state: 'delete'});
9665                            }
9666                            updateOutputFolder($('#nestableFolder').data('output', $('#nestableFolder-output')));
9667
9668                            resourceGetPage(1,SFOLDER_ACTIVE,fsort,fsearch);
9669                            $.processOFF();
9670                        });
9671
9672                    },'cancel','ok','modal-over-1 cl-cmmodal cl-s-btn cl-common-notice w560',false);
9673                })
9674                .on('click', '.resource-ctrl-deletes', function(e) {
9675                    var myResourceTab = $('#mystorage'),
9676                        myResourceFiles = myResourceTab.find('ul.files'),
9677                        myResourceSelected = myResourceTab.find('.resource-selected-ul'),
9678                        fsort = myResourceTab.find('.resource-ctrl-sort select').val(),
9679                        fsearch = myResourceTab.find('.resource-search-stx').val();
9680    
9681                    if(myResourceSelected.children('li').length==0) return;
9682    
9683                    var r_pages = Number(myResourceTab.find('.resource-paging .pagination').attr('data-pages')),
9684                        r_page = Number($('.resource-paging .pagination li.active').text()),
9685                        r_file_cnt = myResourceFiles.find('.fitem').length;
9686                        
9687                    var modal = $(this).showModalFlat($.lang[LANG]['config.common.resource.delete.title'],$.lang[LANG]['config.common.resource.delete'], true, true, function() {
9688                        modal.modal('hide');
9689                        $.progressON();              
9690                        var files = [], seqs = [], sizes = [], ffolders = [];
9691                        myResourceSelected.children('li').each(function () {
9692                            files.push($(this).attr('data-source'));
9693                            seqs.push($(this).attr('data-seq'));
9694                            sizes.push($(this).find('.selected-file-size .size').text());
9695                            ffolders.push($(this).attr('data-ffolder'));
9696                        });
9697    
9698                        myResourceSelected.empty();
9699                        myResourceTab.find('.resource-useit').removeClass('active');
9700    
9701                        var total = files.length, deleting = '', progress = 0; loading = '<i class="fa fa-circle-o-notch fa-spin fa-3x fa-fw"></i> ';
9702                            done = 0; deleting = myResourceFiles.find('p.fitem-name[data-seq="' + seqs[0] + '"]').text();
9703                        $('.progressModal .info1').html(loading + deleting);
9704    
9705                        $.each(files,function(i,v) {
9706                            var t = setTimeout(function() {
9707                                if(CANCEL) {
9708                                    if(ABORT) {
9709                                        updateOutputFolder($('#nestableFolder').data('output', $('#nestableFolder-output')));
9710                                        resourceGetPage(1,SFOLDER_ACTIVE,fsort,fsearch);
9711                                        ABORT = false;
9712                                        $.progressOFF();
9713                                    }
9714                                    i=0; return false;
9715                                }
9716    
9717                                mystorageFileDelete(v,seqs[i],function() {
9718                                    done++;
9719                                    progress = parseInt((done / total) * 100,10);
9720                                    $('.file-upload-progress .progress-bar').css('width',progress + "%");
9721                                    $('.progressModal .info2').text(done.toString() + ' / ' + total.toString());
9722
9723                                    $.resource.setMystorageFolder('set_fli_state', {'count': -1, 'size': -sizes[i], ffolder: 'all', state: 'delete'});
9724                                    if(ffolders[i] != '' && ffolders[i] != 'all') {
9725                                        $.resource.setMystorageFolder('set_fli_state', {'count': -1, 'size': -sizes[i], ffolder: ffolders[i], state: 'delete'});
9726                                    }
9727
9728                                    if(total == done) {
9729                                        r_page = ((r_file_cnt-files.length) == 0 && r_pages<=r_page) ? r_page-1 : r_page;
9730                                        r_page = 1;
9731                                        setTimeout(function() {
9732                                            updateOutputFolder($('#nestableFolder').data('output', $('#nestableFolder-output')));
9733                                            resourceGetPage(r_page,SFOLDER_ACTIVE,fsort,fsearch);
9734                                            $.progressOFF();
9735                                        },1000);
9736                                    } else {
9737                                        deleting = myResourceFiles.find('p.fitem-name[data-seq="' + seqs[i+1] + '"]').text();
9738                                        $('.progressModal .info1').html(loading + deleting);
9739                                    }
9740                                });
9741                            },500*i);
9742                        });
9743    
9744                    },'cancel','ok','modal-over-1 cl-cmmodal cl-s-btn cl-common-notice w560',false);
9745                })
9746                .on('click', '.resource-ctrl-downloads', function(e) {
9747                    var myResourceTab = $('#mystorage'),
9748                        myResourceFiles = myResourceTab.find('ul.files'),
9749                        myResourceSelected = myResourceTab.find('.resource-selected-ul');
9750
9751                    var files = [], seqs = [], sizes = [], ffolders = [], file_path = [], org_name = [];
9752
9753                    if(myResourceSelected.children('li').length == 0) {
9754                        return false;
9755                    } else if(myResourceSelected.children('li').length == 1) {
9756                        var seq = $(myResourceSelected.children('li')[0]).data('seq');
9757                        $('ul[data-seq="' + seq + '"] .fitem-ctrl-down').get(0).click();
9758                        return false;
9759                    }
9760
9761                    myResourceSelected.children('li').each(function () {
9762                        var src = getServeImage($(this).attr('data-source'), 0, 'https:' + RESOURCE + '/' + SID);
9763                        var file_name = $(this).find('.selected-file-title').text();
9764                        file_path.push(src);
9765                        org_name.push(file_name);
9766                    });
9767                    $.processON($.lang[LANG]['editor.resource.batchdownload']);
9768                    setTimeout(function() {
9769                        $.ajax({
9770                            url:'/template/resource/batch-download',
9771                            type:'post',
9772                            async: true,
9773                            data:{
9774                                'file_path': file_path,
9775                                'org_name': org_name
9776                            },
9777                            dataType:'json',
9778                            success:function(data) {
9779                                var filename = data.filename;
9780                                var base64Data = data.filedata;
9781                                if(!base64Data) return false;
9782
9783                                var binaryString = atob(base64Data);
9784                                var len = binaryString.length;
9785                                var bytes = new Uint8Array(len);
9786                                for (let i = 0; i < len; i++) {
9787                                    bytes[i] = binaryString.charCodeAt(i);
9788                                }
9789
9790                                // Blob 객체 생성
9791                                var blob = new Blob([bytes], { type: 'application/zip' });
9792
9793                                // Blob URL 생성
9794                                var url = URL.createObjectURL(blob);
9795
9796                                // 다운로드 링크 생성 및 클릭하여 파일 다운로드
9797                                var a = document.createElement('a');
9798                                a.href = url;
9799                                a.download = filename;
9800                                document.body.appendChild(a);
9801                                a.click();
9802
9803                                // 링크 제거
9804                                document.body.removeChild(a);
9805                                URL.revokeObjectURL(url);
9806                            }, 
9807                            complete:function() {
9808                                $.processOFF();
9809                            }
9810                        });
9811                    });
9812                });
9813
9814
9815            $('#mystorage #nestableFolder').nestable({
9816                    maxDepth: 1,
9817                    handleClass: 'dd-handle',
9818                    noDragClass: 'fl-nodrag',
9819                })
9820                .on('changing', function(e) {
9821                    if(isFEdit || $(this).find('.fln-group.input-group').length > 0) {
9822                        e.preventDefault();
9823                        return false;
9824                    }
9825
9826                    sortFolderFavoritesTop();
9827                    updateOutputFolder($('#nestableFolder').data('output', $('#nestableFolder-output')));
9828                });
9829
9830            $('#mystorage ul.files').selectableScroll({
9831                options:{
9832                    scrollSnapX: 120,
9833                    scrollSnapY: 120,
9834                    scrollAmount: 5
9835                },
9836                filter: '.fitem',
9837                cancel: 'i, .ui-selected, .fitem-ctrl',
9838                start: function(event, ui) {
9839                    $('#mystorage ul.files').addClass('__file_selecting');
9840                },
9841                selecting: function(event, ui) {
9842                },
9843                stop: function(event, ui) {
9844                    $('#mystorage ul.files').removeClass('__file_selecting');
9845                },
9846                selected: function(event, ui) {
9847                    if($(ui.selected).is('.fitem')) {
9848                        var myResourceTab = $('#mystorage'),
9849                            myResourceSelected = myResourceTab.find('.resource-selected-ul'),
9850                            file_seq = $(ui.selected).find('.fitem-ctrl > ul').attr('data-seq');
9851                        
9852                        if(typeof file_seq != 'undefined' && myResourceSelected.find('li[data-seq="'+file_seq+'"]').length == 0) {
9853                            var magic = $(ui.selected).find('p.fitem-name').attr('data-magic'),
9854                                file = $(ui.selected).find('p.fitem-name').attr('data-source'),
9855                                file_path = RPATH + '60/' + file,
9856                                full_path = (magic == '') ? file_path : magic+'=s60-c',
9857                                ffolder = $(ui.selected).find('.fitem-ctrl > ul').attr('data-ffolder'),
9858                                file_title = $(ui.selected).find('p.fitem-name').attr('data-original-title'),
9859                                file_size = $(ui.selected).find('p.fitem-size .size').attr('data-size'),
9860                                file_width = $(ui.selected).find('p.fitem-size .width').text(),
9861                                file_height = $(ui.selected).find('p.fitem-size .height').text(),
9862                                selected_file_name = (magic) ? magic : file;
9863                            
9864                            myResourceSelected.append('<li data-source="' + file + '" data-ffolder="' + ffolder + '" data-seq="'+file_seq+'" data-size="'+file_size+'"><img src="' + full_path + '"><div class="selected-hover">&times;<p class="selected-file-name">' + selected_file_name + '</p><p class="selected-file-title">' + file_title + '</p><p class="selected-file-size"><span class="size">' + file_size + '</span><span class="width">' + file_width + '</span><span class="height">' + file_height + '</span></p></div></li>');
9865                        }
9866                    }
9867                    setResourceSelectedBox('my');
9868                },
9869                unselected: function(event, ui) {
9870                    if($(ui.unselected).is('.fitem')) {
9871                        if(!event.ctrlKey && !event.shiftKey) {
9872                            $('#mystorage .resource-selected-ul').empty();
9873                        }
9874                    }
9875                    setResourceSelectedBox('my');
9876                }
9877            });
9878
9879
9880            /* modal-resourcebox 02__freestorage */
9881            var freestorageFitemHtml = function(src,profile,name,link,color,full,raw,down,width,height,id,type,i) {
9882                
9883                var fitem_ctrl_star = (type != 'used') ? '<li><span class="fitem-ctrl-star '+((type=='favor') ? 'active' : '')+'"><svg class="active" viewBox="0 0 16 16" width="16" hegiht="16"><path d="m14.5 6.52-4.52-.88L8 1.5 6.02 5.64l-4.52.88 3.11 3.25-.57 4.73L8 12.43l3.96 2.07-.57-4.73z"/></svg><svg viewBox="0 0 16 16" width="16" hegiht="16"><path d="m8 3.82 1.08 2.25.22.45.49.1 2.73.53-1.85 1.93-.33.34.06.47.34 2.84-2.28-1.19L8 11.3l-.46.24-2.28 1.19.34-2.84.06-.47-.33-.34-1.84-1.93 2.73-.53.49-.1.22-.45L8 3.82M8 1.5 6.02 5.64l-4.52.88 3.11 3.25-.57 4.73L8 12.43l3.96 2.07-.57-4.73 3.11-3.25-4.52-.88L8 1.5z"/></svg></span></li>' : '',
9884                    fitem_str = '\
9885                    <li class="fitem" data-idx="' + i + '">\
9886                        <div class="fitem-wrap">\
9887                            <div class="fitem-visual">\
9888                                <div class="fitem-thumb">\
9889                                    <div class="fitem-mold"><img src="https://storage.googleapis.com/i.addblock.net/sample/sns_cm_1.png"/></div>\
9890                                    <img class="fitem-img" src="' + src + '">\
9891                                </div>\
9892                                <div class="fitem-ctrl">\
9893                                    <ul data-color="' + color + '" data-username="' + name + '" data-raw="' + raw + '" data-full="' + full + '" data-small="' + src + '" data-down="' + down + '" data-userlink="' + link + '" data-width="' + width + '" data-height="' + height + '" data-id="' + id + '">\
9894                                        <li><a class="fitem-ctrl-imgview" data-url="' + full + '" data-img-original="ON"><svg viewBox="0 0 13 13" width="13" height="13">
9894<path d="M5.14 1c2.28 0 4.14 1.86 4.14 4.14 0 2.28-1.86 4.14-4.14 4.14S1 7.43 1 5.14C1 2.86 2.86 1 5.14 1m0-1C2.3 0 0 2.3 0 5.14s2.3 5.14 5.14 5.14 5.14-2.3 5.14-5.14S7.98 0 5.14 0z"/><path d="M12.5 13a.47.47 0 0 1-.35-.15L8.22 8.92c-.2-.2-.2-.51 0-.71s.51-.2.71 0l3.93 3.93c.2.2.2.51 0 .71-.1.1-.23.15-.36.15z"/></svg></a></li>\
9895                                        ' + fitem_ctrl_star + '\
9896                                    </ul>\
9897                                </div>\
9898                            </div>\
9899                            <div class="fitem-content visible-layout-grid">\
9900                                <p class="fitem-username">Photo by <a href="' + link + '?utm_source=creatorlink&utm_medium=referral&utm_campaign=api-credit" target="_blank">' + name + '</a></p>\
9901                                <p class="fitem-size"><span class="width">'+width+'</span><span class="height">'+height+'</span></p>\
9902                            </div>\
9903                        </div>\
9904                    </li>\
9905                ';
9906
9907                return fitem_str;
9908            }
9909
9910            var rePaintFavor = function() {
9911                var $org = $('#freestorage .fitem'),
9912                    $items = {};
9913
9914                for(var i=0; i<$org.length; i++) {
9915                    var $i = $('#freestorage .fitem[data-idx="' + i + '"]');
9916                    $items[i] = $i.clone();
9917                    $i.remove();
9918                }
9919
9920                $.each($items, function(i,v) {
9921                    $('#freestorage ul.files').append($(this));
9922                });
9923            }
9924
9925            var getFreeImage = function(page,type,stx,collection) {
9926                type = (typeof type == 'undefined') ? 'new' : type;
9927                stx = (typeof stx == 'undefined') ? '' : stx;
9928                page = (typeof page == 'undefined') ? 1 : page;
9929                collection = (typeof collection == 'undefined') ? '' : collection;
9930                if(type == 'new') {
9931                    dest = '/template/free/new/photos';
9932                } else if(type == 'favor') {
9933                    dest = '/template/favorite/list/type/F';
9934                } else if(type == 'search') {
9935                    dest = '/template/free/search/' + encodeURIComponent(stx);
9936                } else if(type == 'used') {
9937                    dest = '/template/favorite/list/type/U';
9938                }
9939
9940                if(page>1) dest = dest + '/page/' + page;
9941
9942                var freeResourceTab = $('#freestorage'),
9943                    freeResourceFiles = freeResourceTab.find('ul.files'),
9944                    freeResourceSelected = freeResourceTab.find('.resource-selected-ul');
9945
9946                $.ajax({
9947                    type: 'GET',
9948                    url: dest,
9949                    dataType: 'json',
9950                    async:true,
9951                    success : function(data) {
9952                        var photos;
9953                        if(freeSearch.type == 'new') {
9954                            if(data.photos != null) {
9955                                photos = data.photos;    
9956                            } else photos = [];
9957                        } else {
9958                            photos = (data.photos && data.photos.results) ? data.photos.results : [];
9959                        }
9960
9961                        if(photos) {
9962                            if(photos.length==0 || photos == null) {
9963                                $.resource.modalFilesEmpty(freeResourceFiles, 'No results found');
9964                            } else {
9965                                freeResourceFiles.find('.listprogress').remove();
9966                                $.each(photos, function(i,v) {
9967                                    var tpl = freestorageFitemHtml(v.urls.small, v.user.profile_image.small, v.user.username, v.user.links.html, v.color, v.urls.full, v.urls.raw,v.links.download, v.width, v.height, v.id, freeSearch.type, i);
9968                                    freeResourceFiles.append(tpl);
9969                                });
9970
9971                                freeResourceFiles.selectable({ 
9972                                    filter: '.fitem',
9973                                    cancel: 'i, .ui-selected, .fitem-username, .fitem-ctrl',
9974                                    start: function(event, ui) {
9975                                        freeResourceFiles.addClass('__file_selecting');
9976                                    },
9977                                    selecting: function(event, ui) {
9978                                    },
9979                                    stop: function(event, ui) {
9980                                        freeResourceFiles.removeClass('__file_selecting');
9981                                    },
9982                                    selected: function(event, ui) {
9983                                        if($(ui.selected).is('.fitem')) {
9984                                            var freeResourceTab = $('#freestorage'),
9985                                                freeResourceSelected = freeResourceTab.find('.resource-selected-ul'),
9986                                                file_id = $(ui.selected).find('.fitem-ctrl > ul').attr('data-id');
9987
9988                                            if(typeof file_id != 'undefined' && freeResourceSelected.children('li[data-id="'+file_id+'"]').length == 0) {
9989                                                var file_small = $(ui.selected).find('.fitem-ctrl > ul').attr('data-small'),
9990                                                    urls = new getLocation(file_small),
9991                                                    file = (urls.pathname).replace('/',''),
9992                                                    file_path = 'https://' + urls.host + urls.pathname + '?ixlib=rb-0.3.5&q=80&fm=jpg&crop=face&cs=tinysrgb&w=60&h=60&fit=crop',
9993                                                    tmp_image = 'https://' + urls.host + urls.pathname + '?ixlib=rb-0.3.5&q=85&fm=jpg&crop=entropy&cs=srgb',
9994                                                    file_width = $(ui.selected).find('.fitem-ctrl > ul').attr('data-width'),
9995                                                    file_height = $(ui.selected).find('.fitem-ctrl > ul').attr('data-height');
9996
9997                                                freeResourceSelected.append('<li data-source="' + file + '" data-id="' + file_id + '"><img src="' + file_path + '"><div class="selected-hover">&times;<p class="selected-file-name">' + file + '</p><p class="selected-file-title">' + file + '</p><p class="selected-file-size"><span class="size">0</span><span class="width">' + file_width + '</span><span class="height">' + file_height + '</span></p><p class="selected-file-tmp">' + tmp_image + '</p></div></li>');
9998                                            }
9999                                        }
10000                                        setResourceSelectedBox('free');
10001                                    },
10002                                    unselected: function(event, ui) {
10003                                        if($(ui.unselected).is('.fitem')) {
10004                                            if(!event.ctrlKey && !event.shiftKey) {
10005                                                freeResourceSelected.empty();
10006                                            }
10007                                        }
10008                                        setResourceSelectedBox('free');
10009                                    }
10010                                });
10011                                if((freeSearch.type == 'search' || freeSearch.type == 'favor' || freeSearch.type == 'used') && data.photos && typeof data.photos.total 
10011!= 'undefined') freeSearch.total = data.photos.total;
10012                                freeSearch.page = freeSearch.page + 1;
10013
10014                                freeResourceTab.find('.resource-search-total').text('');
10015                                if(data.photos && typeof data.photos.total != 'undefined' && freeSearch.type == 'search') {
10016                                    if(data.photos.total > 0) freeResourceTab.find('.resource-search-total').text(Number(data.photos.total).format());
10017                                }
10018
10019                            }                
10020                        } else {
10021                            $.resource.modalFilesEmpty(freeResourceFiles, 'Error get photo list');
10022                        }
10023                    },
10024                    error: function() {
10025                        $.resource.modalFilesEmpty(freeResourceFiles, 'Error get photo list');
10026                    },
10027                    complete: function() {
10028                        freeResourceTab.find('.resource-search-btn').removeClass('clicked');
10029                        freeResourceFiles.removeClass('ready');
10030                        freeResourceFiles.find('.listprogress').remove();
10031                    }
10032                });
10033
10034            }
10035                
10036            $('.modal-resourcebox')
10037                .on('click', 'a[href="#freestorage"]', function(e) {
10038                    $('#freestorage ul.files .listprogress').remove();
10039                    setResourceSelectedBox('free');
10040
10041                    var freeResourceTab = $('#freestorage'),
10042                        freeResourceFolderlist = freeResourceTab.find('.resource-folderlist'),
10043                        freeResourceFiles = freeResourceTab.find('ul.files'),
10044                        freeResourceSelected = freeResourceTab.find('.resource-selected-ul');
10045
10046                    if(freeResourceFiles.hasClass('ready')) {
10047                        if(freeResourceFolderlist.children('li.active').length == 0) {
10048                            freeResourceFolderlist.children('li').click(function(e) {
10049                                var flTab = $(this),
10050                                    fl_type = (typeof flTab.attr('data-type') != 'undefined') ? flTab.attr('data-type') : '',
10051                                    fb_type = (typeof freeResourceFiles.attr('data-type') != 'undefined') ? freeResourceFiles.attr('data-type') : '',
10052                                    checkReload = (fl_type == '' || fl_type != fb_type) ? true : false;
10053
10054                                flTab.addClass('active').siblings().removeClass('active');
10055                                if(checkReload) {
10056                                    freeSearch.type = fl_type;
10057                                    freeSearch.page = 1;
10058                                    freeSearch.total = -1;
10059                                    $.resource.modalContentInit('free');
10060                                    getFreeImage(freeSearch.page,freeSearch.type);
10061                                    freeResourceFiles.attr('data-type',fl_type);
10062                                }
10063
10064                                if(fl_type == 'favor') {
10065                                    var items = freeResourceFiles.find('.fitem').length;
10066                                    if(freeSearch.total == items) return;
10067                                }
10068
10069                                freeResourceSelected.empty();
10070                                setResourceSelectedBox('free');
10071                            });
10072
10073                            freeSearch.type = 'new';
10074                            freeSearch.page = 1;
10075                            freeSearch.total = -1;
10076                            $.resource.modalContentInit('free');
10077                            freeResourceFolderlist.children('li[data-type="new"]').addClass('active').siblings().removeClass('active');
10078                            getFreeImage(freeSearch.page,freeSearch.type);
10079                        }
10080                    }
10081                });
10082
10083            $('.modal-resourcebox #freestorage')
10084                .on('click', '.fitem-ctrl-star', function(e) {
10085                    var $i = $(this).closest('ul'),
10086                        $star = $(this),
10087                        image = {
10088                            'id' : $i.attr('data-id'),
10089                            'width' : $i.attr('data-width'),
10090                            'height' : $i.attr('data-height'),
10091                            'username' : $i.attr('data-username'),
10092                            'userlink' : $i.attr('data-userlink'),
10093                            'raw' : $i.attr('data-raw'),
10094                            'full' : $i.attr('data-full'),
10095                            'small' : $i.attr('data-small'),
10096                            'down' : $i.attr('data-down'),
10097                            'color' : $i.attr('data-color'),
10098                            'onoff': ($star.hasClass('active')) ? 'OFF' : 'ON',
10099                        },
10100                        $item = $star.closest('.fitem');
10101    
10102                    $.post('/template/favorite/image', { image : image },  function(data) {
10103                        if(data.type == 'insert') {
10104                            $star.addClass('active');
10105                        } else if(data.type == 'delete') {
10106                            $star.removeClass('active');
10107                            if(freeSearch.type == 'favor') {
10108                                var idx = $item.attr('data-idx');
10109                                $('#freestorage .fitem').each(function() {
10110                                    var cidx = $(this).attr('data-idx');
10111                                    if(cidx == idx) $(this).remove();
10112                                    if(idx < cidx) $(this).attr('data-idx',Number(cidx)-1);
10113                                });
10114                                freeSearch.total = freeSearch.total -1;
10115                                rePaintFavor();
10116                            }
10117                        }
10118                    },'json');
10119                });
10120
10121
10122            /* modal-resourcebox 03__filestorage */
10123            $('.modal-resourcebox #filestorage')
10124                .on('click', '#filestorageUploadBtn', function(e) {
10125                    if($('.flink-error-modal').length > 0) {
10126                        e.preventDefault();
10127                        return false;
10128                    }
10129                    var checkPlan = (typeof property == 'undefined') ? ((typeof VALIDPLAN == 'undefined') ? $.gallery.valid_plan : VALIDPLAN) : property.VALIDPLAN,
10130                        checkPType = (typeof property == 'undefined') ? ((typeof VALIDTYPE == 'undefined') ? $.gallery.valid_type : VALIDTYPE) : property.VALIDTYPE,
10131                        flink_cnt = $('#filestorage .flink-capacity .flink-cnt').text(),
10132                        flink_max = $('#filestorage .flink-capacity .flink-max').text(),
10133                        reg_max = /^[0-9]+$/,
10134                        error_str = '';
10135
10136                    if(!checkPlan || checkPType == 'PK') error_str = $.lang[LANG]['editor.link.file.upgrade'];
10137                    else if(reg_max.test(flink_cnt) && Number(flink_cnt) >= Number(flink_max)) {
10138                        error_str = $.lang[LANG]['editor.link.file.maximum'];
10139                        error_str = error_str.replace('@maximum', flink_max);
10140                    }
10141                    if(error_str) {
10142                        var errorModal = $(this).showModalFlat($.lang[LANG]['config.information'], error_str, true, false,'','ok', '', 'cl-p130 cl-cmmodal cl-s-btn w560 cl-p0 cl-okbtn-pbt70 flink-error-modal').css('z-index','1044');
10143                        errorModal.closest('.flat-modal').addClass('z-1044');
10144                        return false;
10145                    }
10146
10147                    $.uploadON();
10148                    $(this).fileupload({
10149                        url: '/down/flink/upload/sid/' + SID,
10150                        dataType: 'json',
10151                        pasteZone: null,
10152                        async: true,
10153                        cache: false,
10154                        prependFiles: true,
10155                        sequentialUploads: true,
10156                        add: function(e,data) {
10157                            var r = $.upload_add(e,data,'flink');
10158
10159                            if(r.submit) {
10160                                var jqXHR = data.submit();
10161                                UPLOAD++;
10162                            } else {
10163                                data.context.find('.loading').html('<i class="fa fa-times error"></i>');
10164                                data.context.find('.ing').addClass('error').text(r.err);
10165                            }
10166
10167                            $('.uploadModal .upload-cancel .btn, .uploadModal .upload-close').off('click').on('click', function(e) {
10168                                if(jqXHR != undefined) jqXHR.abort();
10169                                data.context.fadeOut().remove();
10170                                $('.uploadModal #file-upload-progress').css('width','0%');
10171                                $.uploadOFF();
10172                                UPLOAD = 0;
10173                                UPLOADED = 0;
10174                                PROGRESS = 0;
10175
10176                                resourceGetPage(1,SFOLDER_ACTIVE,'date_desc','');
10177                            });
10178                        },
10179                        progress: function(e, data) {
10180                            $.upload_progress(e,data);
10181                        },                        
10182                        done: function (e, data) {
10183                            if(typeof data.result.error != 'undefined' && data.result.error) {
10184                                $('.uploadModal .upload-header h1').html($.lang[LANG]['editor.upload.title.1']);
10185                                $('.uploadModal .upload-content .upload-cancel .btn-default').text($.lang[LANG]['config.close']);
10186                                $('.file-upload-progress .progress-bar').css('width','0%');
10187                                $('.uploadModal .info1, .uploadModal .info2').addClass('hide');
10188
10189                                data.context.find('.progress-bar').css('width','0%');
10190                                data.context.find('.loading').html('<i class="fa fa-times error"></i>');
10191                                data.context.find('.ing').addClass('error').text(data.result.error);
10192                                return false;
10193                            }
10194                            
10195                            $.upload_done(e,data);
10196                            UPLOADED++;
10197                            
10198                            if(UPLOADED) {
10199                                if(UPLOAD==UPLOADED) {
10200                                    setTimeout(function() {
10201                                        $.uploadOFF();
10202                                        UPLOAD = 0;
10203                                        UPLOADED = 0;
10204                                        PROGRESS = 0;
10205    
10206                                        resourceGetPage(1,SFOLDER_ACTIVE,'date_desc','');
10207                                    },1000);
10208                                }
10209                            }
10210                        },
10211                        progressall: function (e, data) {
10212                            $.upload_progressall(e,data);
10213                        },
10214                        start : function(e, data) {
10215                            $.upload_start(e,data);
10216                            progress1 = 0; progress2 = 0; PROGRESS = 0;
10217                        },
10218                        dragover : function(e) {
10219                            e.preventDefault();
10220                            e.stopPropagation();
10221                        },
10222                        drop : function(e) {
10223                            e.preventDefault();
10224                            e.stopPropagation();
10225                        },
10226                    }
10226).prop('disabled', !$.support.fileInput)
10227                        .parent().addClass($.support.fileInput ? undefined : 'disabled');
10228
10229                })
10230                .on('click', '.fitem', function(e) {
10231                    $(this).toggleClass('selected').siblings().removeClass('selected');
10232                    if($(this).hasClass('selected')) $('#filestorage .resource-useit').addClass('active');
10233                    else $('#filestorage .resource-useit').removeClass('active');
10234                })
10235                .on('click', '.fitem-ctrl-del', function(e) {
10236                    $(this).closest('.fitem').addClass('selected');
10237                    var selectedFlink = $('#filestorage ul.files .fitem.selected'),
10238                        file = selectedFlink.find('p.fitem-name').attr('data-source'),
10239                        id = selectedFlink.find('p.fitem-name').attr('data-seq');
10240                    if(typeof file == 'undefined' || typeof id == 'undefined') return false;
10241                    var modal = $(this).showModalFlat($.lang[LANG]['config.flink.resource.delete'],$.lang[LANG]['config.flink.resource.delete.str'], true, true, function() {
10242
10243                        selectedFlink.remove();
10244                        $.processON('Deleting the file(s)...');
10245                        modal.modal('hide');
10246                        $('.resource-useit').removeClass('active');
10247
10248                        $.ajax({
10249                            type: 'POST',
10250                            url: '/down/flink/delete',
10251                            data: { s: file, id: id },
10252                            dataType: 'json',
10253                            async: true,
10254                            success: function(data) {
10255                                if(typeof data.error != 'undefined' && data.error) {
10256                                    $(this).showModalFlat('ERROR',data.error,true,false,'','ok');
10257                                    return false;
10258                                }
10259                                resourceGetPage(1,SFOLDER_ACTIVE,'date_desc','');
10260                                $.processOFF();
10261                            }
10262                        });
10263
10264                    },'cancel','ok','modal-over-1 cl-cmmodal cl-s-btn cl-common-notice w560',false);
10265                    modal.closest('.modal-over-1').addClass('z-1044');
10266                });
10267
10268            $('.modal-resourcebox a[href="#iconstorage"]')
10269                .click(function(e) { 
10270                    var thisResourceTab = $('#iconstorage'),
10271                        icon_type = (typeof getIconStorageInitialType == 'function') ? getIconStorageInitialType() : 'google';
10272
10273                    if(typeof resetIconStorageDefaultState == 'function') {
10274                        resetIconStorageDefaultState();
10275                    } else {
10276                        thisResourceTab.find('.icon_type[data-icontype="' + icon_type + '"]').addClass('active').siblings('.icon_type').removeClass('active');
10277                        thisResourceTab.find('.resource-search-stx').val('');
10278                    }
10279                    $.processON();
10280                    if(typeof setIconStorageMaterialState == 'function') setIconStorageMaterialState(icon_type);
10281                    getIconImage('total', icon_type);
10282            });
10283        },
10284        modalOpenSET: function(open) {
10285            $('.modal-resourcebox .nav-tabs li').removeClass('disabled');
10286            var property = (open) ? $('.modal-resourcebox .resource-useit').eq(0).attr('data-property') : '';
10287            if(!open) $('.modal-resourcebox .resource-useit').removeAttr('data-property');
10288
10289            if(open) {
10290                switch(property) {
10291                    case 'flink-change':
10292                        $('#mystorage,#freestorage').removeClass('active').removeClass('in');
10293                        $('.modal#el-fileupload').css('z-index','1043');
10294                        $('#el-fileupload').addClass('flink-fileupload');
10295                        $('#el-fileupload').find('.modal-header h4').html($.lang[LANG]['editor.resource.file']);
10296                        $('#el-fileupload .nav-tabs li:nth-child(3) a').click();
10297                        $('#el-fileupload .nav-tabs li:not(:nth-child(3))').addClass('disabled');
10298                        break;
10299
10300                    case 'popup-change':
10301                        $('.modal#el-fileupload').css('z-index','1043');
10302                        $('#el-fileupload').addClass('popup-fileupload');
10303                        break;
10304
10305                    case 'upload-badge-image':
10306                        $('.modal#el-fileupload').css('z-index','1044');
10307                        break;
10308            
10309                    default:
10310                        $('#filestorage').removeClass('active').removeClass('in');
10311                        $('.modal#el-fileupload').css('z-index','1041');
10312                        $('#el-fileupload').removeClass('flink-fileupload');
10313                        $('#el-fileupload').removeClass('popup-fileupload');
10314                        $('#el-fileupload').find('.modal-header h4').html($.lang[LANG]['editor.resource.title']);
10315            
10316                        if($('#el-fileupload .nav-tabs li:nth-child(3)').hasClass('active')) $('#el-fileupload .nav-tabs li:nth-child(1) a').click();
10317                        $('#el-fileupload .nav-tabs li:nth-child(3)').addClass('disabled');
10318                        break;
10319                }
10320            } else {
10321                $('.modal#el-fileupload').css('z-index','1041');
10322                $('#el-fileupload').removeClass('flink-fileupload');
10323                $('#el-fileupload').removeClass('popup-fileupload');
10324                $('#el-fileupload').find('.modal-header h4').html($.lang[LANG]['editor.resource.title']);
10325        
10326                if($('#el-fileupload .nav-tabs li:nth-child(3)').hasClass('active')) $('#el-fileupload .nav-tabs li:nth-child(1) a').click();
10327                $('#el-fileupload .nav-tabs li:nth-child(3)').addClass('disabled');
10328                $('#filestorage').removeClass('active').removeClass('in');
10329            }
10330        },
10331        modalInit: function() {
10332            $('#progress .progress-bar').css({'width' : '0%', 'padding-right' : '0px'}).text('');
10333            $('.modal-resourcebox .resource-useit').removeClass('active');
10334            $('.modal-resourcebox .resource-selected-ul').empty();
10335            $('.modal-resourcebox .resource-ctrl-selectedinfo .count').text(0).closest('label').hide();
10336            $('.modal-resourcebox .resource-ctrl-btns').removeClass('active');
10337            $('.modal-resourcebox .fitem').removeClass('ui-selected');
10338            $.resource.modalOpenSET(true);
10339        },
10340        modalContentInit: function(mode) {
10341            if(typeof mode == 'undefined' || !mode) mode = 'my';
10342
10343            $('#'+mode+'storage .resource-useit').removeClass('active');
10344            $('#'+mode+'storage .resource-search-stx').val('');
10345            $('#'+mode+'storage ul.files, #'+mode+'storage .resource-selected-ul').empty();
10346
10347            if(mode == 'free') {
10348                $('#freestorage .resource-search-total').text('');
10349                if($('#freestorage ul.files .listprogress').length == 0) {
10350                    $('#freestorage ul.files').append('<li class="listprogress"><svg version="1.1" xmlns="http://www.w3.org/svg/2000" viewBox="0 0 30 30" width="60" style="width:30px; height: 30px;"><circle cy="15" cx="15" r="14" style="stroke:#00baff;"></circle></svg></li>');
10351                }
10352            }
10353        },
10354        modalFilesEmpty: function(ulFiles,empty_str) {
10355            if(ulFiles.length > 0) {
10356                empty_str = (typeof empty_str != 'undefined' && empty_str) ? empty_str : 'No results';
10357                ulFiles.addClass('empty').empty();
10358                ulFiles.append('\
10359                    <li class="resource-empty-area">\
10360                        <div class="resource-empty">\
10361                            <div class="img-wrap"><img src="//storage.googleapis.com/i.addblock.net/config/fa_resource_img_icon.png" alt="image storage" /></div>\
10362                            <p>' + empty_str + '</p>\
10363                        </div>\
10364                    </li>\
10365                ');
10366
10367                if(ulFiles.closest('.resource-container').find('.resource-search-btn').length > 0) ulFiles.closest('.resource-container').find('.resource-search-btn').removeClass('clicked');
10368                ulFiles.closest('.tab-pane.active').find('ul.files').removeClass('ready');
10369                ulFiles.closest('.tab-pane.active').find('.listprogress').remove();
10370            }
10371        },
10372        getMystorageFlc: function() {
10373            var check_ffolder = (SFOLDER_ACTIVE != '') ? SFOLDER_ACTIVE : 'all',
10374                ftotal = -1;
10375            
10376            $.each(SFOLDER, function(i, o) {
10377                if(o.name == check_ffolder) {
10378                    ftotal = o.fcount;
10379                    return false;
10380                }
10381            })
10382
10383            return ftotal;
10384        },
10385        getMystorageFolderHtml: function(flname, flcount, flsize, fid, flfavorite) {
10386            if(!flname) return '';
10387
10388            var checkAdd = (flname == 'clEmptyFolder') ? true : false,
10389                fln_val = flname.replace(/-/g,' '),
10390                fln_tooltip = (!checkAdd && flname.length > 6) ? ' data-toggle="tooltip" data-placement="top" data-original-title="' + flname + '"' : '',
10391                flc = (/^[0-9]*$/.test(flcount)) ? flcount * 1 : 0,
10392                fls = (/^[0-9.]*$/.test(flsize)) ? flsize * 1 : 0,
10393                fls_obj = formatFileSize(fls, 2, 'obj'),
10394                flf = (String(flfavorite) === '1') ? 1 : 0,
10395                favIcon = (flf === 1) ? clSVG('pin', 12, 12) : clSVG('pin_blank', 12, 12);
10396
10397            return '\
10398                <li class="dd-item fli" data-id="' +  flname + '" data-fid="'+ fid +'" data-favorite="'+ flf +'">\
10399                    <div class="fli-wrap dd-handle">\
10400                        ' + clSVG('move_handle', 20, 20, true, 'dd-icon cl-icon cl-handle') + '\
10401                        ' + clSVG('folder', 16, 12, true, 'dd-icon cl-icon cl-folder') + clSVG('folder_open', 16, 12, true, 'dd-icon cl-icon cl-folder-open') + '\
10402                        <span class="dd-fln fl-nodrag" ' + fln_tooltip + '>' + fln_val + '</span>\
10403                        <span class="dd-flc" attr-count="' + flc + '">' + flc + '</span>\
10404                        <span class="dd-fls fli-hidden" attr-size="' + fls + '" attr-size-unit="' + fls_obj['unit'] + '">' + fls_obj['val'] + '</span>\
10405                        <span class="dd-fle fli-hover fl-nodrag" attr-id="' + flname + '">' + clSVG('pencil', 12, 12) + '</span>\
10406                        <span class="dd-fld fli-hover fl-nodrag" attr-id="' + flname + '">' + clSVG('delete', 12, 12) + '</span>\
10407                        <span class="dd-flf fli-hover fl-nodrag" attr-id="' + flname + '" data-fav="'+ flf +'">' + favIcon + '</span>\
10408                    </div>\
10409                </li>\
10410            ';
10411        },
10412        setMystorageFolder: function(mode, val) {
10413            var myResourceTab = $('#mystorage'),
10414                myResourceFolderlist = myResourceTab.find('#nestableFolder');
10415
10416            switch(mode) {
10417                case 'set_fll':
10418                    myResourceFolderlist.removeClass('ready');
10419                    // myResourceFolderlist.nestable('init');
10420                    // if(typeof val != 'undefined' && val !== null && val.length > 0) SFOLDER = val;
10421                    $.each(SFOLDER, function (i, o) {
10422                        if(o['name'] == 'clEmptyFolder') return true;
10423    
10424                        if(i == 0) {
10425                            var flc = (/^[0-9]*$/.test(o['fcount'])) ? o['fcount'] * 1 : 0,
10426                                fls = (/^[0-9.]*$/.test(o['fsize'])) ? o['fsize'] * 1 : 0,
10427                                fls_obj = formatFileSize(fls, 2, 'obj');
10428    
10429                            myResourceFolderlist.find('.fli[data-id="all"] .dd-flc').attr('attr-count',flc).text(flc);
10430                            myResourceFolderlist.find('.fli[data-id="all"] .dd-fls').attr({'attr-size':fls, 'attr-size-unit':fls_obj['unit']}).text(fls_obj['val']);
10431                            return true;
10432                        }
10433    
10434                        if(myResourceFolderlist.find('.fli[data-id="' + o['name'] + '"]').length > 0) return true;
10435                        var add_folder = $.resource.getMystorageFolderHtml(o['name'], o['fcount'], o['fsize'], o['id'], o['favorite']);
10436                            myResourceFolderlist.find('.fll').append(add_folder);
10437                    });
10438
10439                    sortFolderFavoritesTop();
10440
10441                    // if(SFOLDER_ACTIVE != '' && SFOLDER_ACTIVE != myResourceFolderlist.find('.fll.active').attr('data-id')) myResourceFolderlist.find('.fli[data-id="' + SFOLDER_ACTIVE + '"]').addClass('active');
10442                    break;
10443
10444                case 'set_fli_state':
10445                    var is_change = (val.ffolder == 'all' && val.state == 'move') ? false : true;
10446
10447                    if(is_change) {
10448                        var flc = $('#nestableFolder .fli[data-id="'    + val.ffolder +'"]').find('.dd-flc').attr('attr-count'),
10449                            fls = $('#nestableFolder .fli[data-id="'+ val.ffolder +'"]').find('.dd-fls').attr('attr-size'),
10450                            new_flc = val.count * 1,
10451                            new_fls = val.size * 1;
10452
10453                        flc = (/^[0-9]*$/.test(flc)) ? flc * 1 : 0;
10454                        new_flc += flc;
10455                
10456                        fls = (/^[0-9.]*$/.test(fls)) ? fls * 1 : 0;
10457                        new_fls += fls;
10458
10459                        var fls_obj = (new_flc < 1) ? {'val': 0, 'unit': 'Bytes'} : formatFileSize(new_fls, 2, 'obj');
10460                        $('#nestableFolder .fli[data-id="'+ val.ffolder +'"]').find('.dd-flc').attr('attr-count',new_flc).text(new_flc);
10461                        $('#nestableFolder .fli[data-id="'+ val.ffolder +'"]').find('.dd-fls').attr({'attr-size':new_fls, 'attr-size-unit':fls_obj['unit']}).text(fls_obj['val']);
10462                    }
10463                    break;
10464
10465                case 'nodrag':
10466                    if(val) {
10467                        myResourceFolderlist.find('*').addClass('fl-nodrag');
10468                        myResourceFolderlist.find('.fli-wrap').removeClass('dd-handle');
10469                    } else {
10470                        myResourceFolderlist.find('.fl-nodrag:not(:is(.dd-fln, .fli-hover))').removeClass('fl-nodrag');
10471                        myResourceFolderlist.find('.fli:not(.fli-first) .fli-wrap').addClass('dd-handle');
10472                    }
10473                    break;
10474
10475                default:
10476                    break;
10477            }
10478        },
10479        open: function() {
10480            $('#el-fileupload').modal('show');
10481        },
10482        close: function() {
10483            $('#el-fileupload').modal('hide');
10484            $('.uploadModal').remove();
10485        },
10486        selected: function() {
10487            var selected = new Array(),
10488                rmode = (myStorageActive()) ? 'my' : 'free',
10489                thisResourceSelected = $('#'+rmode+'storage .resource-selected-ul');
10490
10491            thisResourceSelected.children('li').each(function() {
10492                selected.push($(this).find('p.selected-file-name').text());
10493            });
10494
10495            return selected;
10496        },
10497    }
10498
10499    $.category = {
10500        delete : [],
10501        moveHandle : function() {
10502            return clSVG('move_handle', 20, 20, true, 'cl-sort-handle');
10503        },
10504        deleteHandle : function() {
10505            return '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" width="20" height="20"><g><g><path d="M13.12 5.88v-2H6.89v2H3.87v1.25h1v6.88c0 1.17.95 2.12 2.12 2.12h6c1.17 0 2.12-.95 2.12-2.12V7.13h1V5.88h-3Zm-1.24 0H8.15v-.75h3.73zm1.12 9H7c-.48 0-.87-.39-.88-.88V7.12h7.75V14c0 .48-.39.87-.88.88m-2.11-7h1.25v6.25h-1.25zm-3 0h1.25v6.25H7.88z"/></g></g></svg>';
10506        },
10507        init : function() {
10508            $(document).on('click', '#prod-category-text', function(e) { 
10509                e.stopPropagation();
10510                if($('.category-wrap').hasClass('open')) {
10511                    $('.category-lists').slideUp(200, function() {
10512                        $('.category-wrap').removeClass('open');    
10513                    }); 
10514                } else {
10515                    $('.category-wrap').toggleClass('open');
10516                    $('.category-lists').slideDown(200); 
10517                }
10518            });
10519            $(document).on('click','.form-ctrl-button.category, .gallery-ctrl-category', function(e) { 
10520                e.stopPropagation();
10521                var s = $(this).attr('data-category');
10522                $.category.open(s); 
10523            });
10524            $(document).on('click','.cl-category-modal-close',function(e) { $.category.close(); });
10525            $(document).on('mousedown', '.prod-option-move', function(){
10526               $(this).closest('.prod-option-list').css('overflow-y', 'auto');
10527            });
10528            $(document).on('mouseup', '.prod-option-move', function(){
10529               $(this).closest('.prod-option-list').css('overflow-y', '');
10530            });
10531            $(document).on('blur','.edit-option-title input', function(e) {
10532                // 중복값 체크
10533                checkDuplicateOptionName($(this));
10534            });
10535
10536            $(document).on('focus', '.edit-option-quantity .option-price-quantity', function() {
10537                $(this).attr('data-before_val', Number(removeCommas($(this).val())));
10538                // var cnt = Number(removeCommas($(this).val()));
10539                // if(cnt == 0)
10540                // if($(this).closest('.prod-option-edit').find('.edit-option-select .option-price-status-str').attr('data-val') == 'O') {
10541                //     $(this).closest('.prod-option-edit').find('.edit-option-select .option-price-status-select [data-val="S"]').click();
10542                // }
10543            }).on('input', '.edit-option-quantity .option-price-quantity', function() {
10544                var before_val = Number(removeCommas($(this).attr('data-before_val')));
10545                var cnt = Number(removeCommas($(this).val()));
10546                if(cnt > 9999) {
10547                    alert('최대 입력 수량은 9,999 입니다.');
10548                    cnt = 9999;
10549                    $(this).val(addCommas('9999'));
10550                }
10551                if(before_val == 0 && cnt > 0 && $(this).closest('.prod-option-edit').find('.edit-option-select .option-price-status-str').attr('data-val') == 'O') {
10552                    $(this).closest('.prod-option-edit').find('.edit-option-select .option-price-status-select [data-val="S"]').click();
10553                } else if(cnt == 0 && $(this).closest('.prod-option-edit').find('.edit-option-select .option-price-status-str').attr('data-val') == 'S') {
10554                    $(this).closest('.prod-option-edit').find('.edit-option-select .option-price-status-select [data-val="O"]').click();
10555                }
10556            }).on('keydown', '.edit-option-quantity .option-price-quantity', function(e) {
10557                var is_number_key = (e.keyCode >= 48 && e.keyCode <= 57) || (e.keyCode >= 96 && e.keyCode <= 105);
10558                var value = String(removeCommas($(this).val()));
10559                var has_selection = this.selectionStart !== this.selectionEnd;
10560
10561                if(is_number_key && !e.ctrlKey && !e.metaKey && !e.altKey && !e.shiftKey && value.length >= 4 && !has_selection) {
10562                    e.preventDefault();
10563                    alert('최대 입력 수량은 9,999 입니다.');
10564                    $(this).val(addCommas('9999')).trigger('input');
10565                }
10566            }).on('paste', '.edit-option-quantity .option-price-quantity', function(e) {
10567                var clipboard = e.originalEvent && e.originalEvent.clipboardData;
10568                var value = clipboard ? clipboard.getData('text').replace(/[^0-9]/g, '') 
10568: '';
10569                var current_value = String(removeCommas($(this).val()));
10570                var selected_value = $(this).val().substring(this.selectionStart, this.selectionEnd).replace(/[^0-9]/g, '');
10571                var result_length = current_value.length - selected_value.length + value.length;
10572
10573                if(value !== '' && result_length > 4) {
10574                    e.preventDefault();
10575                    alert('최대 입력 수량은 9,999 입니다.');
10576                    $(this).val(addCommas('9999')).trigger('input');
10577                }
10578            });
10579
10580            $(document).on('click','.prod-option-title, .prod-option-price, .prod-option-quantity, .prod-option-status, .prod-option-desc, .prod-option-require', function(e) {
10581                e.stopPropagation();
10582                var submit = true;
10583                var parent = $(this).closest('.prod-option');
10584                $('.prod-option-item').each(function () {
10585                    $(this).closest('li').removeClass('err');
10586                });
10587                
10588                if($('.prod-option-edit').length <= 2) {
10589                    $('.edit-option-delete').addClass('hide');
10590                } else {
10591                    $('.edit-option-delete').removeClass('hide');
10592                }
10593
10594                if($('.prod-option-list .prod-option-item.hide').length) {
10595                    $.each($('.prod-option-item.hide'), function(i,v) {
10596                        var $opt_price_input = $(v).parent().find('.prod-option-edit .edit-option-price input');
10597                        limitProductOptionPriceInput($opt_price_input);
10598
10599                        var opt_title = $(v).parent().find('.prod-option-edit .edit-option-title input').val(),
10600                            opt_desc = $(v).parent().find('.prod-option-edit .edit-option-desc input').val(),
10601                            opt_price = $opt_price_input.val(),
10602                            opt_quantity = $(v).parent().find('.prod-option-edit .edit-option-quantity input').val(),
10603                            opt_status = $(v).parent().find('.prod-option-edit .option-price-status-str').attr('data-val'),
10604                            opt_text_require = $(v).parent().find('.prod-option-edit .option-require-str').attr('data-val');
10605
10606                        $(v).closest('li').removeClass('err');
10607                        if(product_options.advanced == 'false') {
10608                            if(opt_title.length == 0) {
10609                                $(v).closest('li').addClass('err').find('.edit-option-title input');
10610                                submit = false;
10611                                return true;
10612                            }
10613                        }
10614                        switch(opt_status) {
10615                            case "S" : str = '판매'; break;
10616                            case "O" : str = '품절'; break;
10617                            case "H" : str = '숨김'; break;
10618                            default : str = '판매'; break;
10619                        }
10620                        var check;
10621                        // if(opt_text_require == 'TR') {
10622                        //     check = "\
10623                        //         <span>필수</span>\
10624                        //         <svg class='active' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' width='16' height='16'>\
10625                        //         <path d='M13 0H3C1.34 0 0 1.34 0 3v10c0 1.66 1.34 3 3 3h10c1.66 0 3-1.34 3-3V3C16 1.34 14.66 0 13 0zM13.03 6.03l-5.5 5.5C7.38 11.68 7.19 11.75 7 11.75s-0.38-0.07-0.53-0.22l-3.5-3.5c-0.29-0.29-0.29-0.77 0-1.06s0.77-0.29 1.06 0L7 9.94l4.97-4.97c0.29-0.29 0.77-0.29 1.06 0S13.32 5.74 13.03 6.03z'/>\
10626                        //         </svg>";
10627                        // } else {
10628                        //     check = "\
10629                        //         <span>필수</span>\
10630                        //         <svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' width='16' height='16'>\
10631                        //         <path d='M13 0H3C1.3 0 0 1.3 0 3v10c0 1.7 1.3 3 3 3h10c1.7 0 3-1.3 3-3V3C16 1.3 14.7 0 13 0zM15 13c0 1.1-0.9 2-2 2H3c-1.1 0-2-0.9-2-2V3c0-1.1 0.9-2 2-2h10c1.1 0 2 0.9 2 2V13z'/>\
10632                        //         </svg>";
10633                        // }
10634                        var soption = String(opt_price);
10635                        if(soption.replace('+','') == '' || soption.replace('-','') == '') opt_price = 0;
10636                        opt_price = removeCommas(opt_price);
10637                        opt_quantity = removeCommas(opt_quantity);
10638                        if (!opt_quantity) opt_quantity = 0;
10639                        if (!opt_price || isNaN(opt_price) === true) o
10639pt_price = 0;
10640
10641                        opt_quantity = (opt_quantity * 1);
10642                        opt_price = (opt_price * 1);
10643
10644                        var abs_price = Math.abs(opt_price),
10645                            str_price = addCommas(abs_price.toString()),
10646                            str_quantity = addCommas(opt_quantity.toString());
10647
10648                        $(v).find('.prod-option-title').text(opt_title);
10649                        $(v).find('.prod-option-desc').text(opt_desc);
10650                        $(v).find('.prod-option-price').text(str_price).attr('data-option-price',opt_price);
10651                        $(v).find('.prod-option-quantity').text(opt_quantity);
10652                        $(v).find('.prod-option-status').text(str).attr('data-val',opt_status);
10653                        $(v).find('.prod-option-require').html(check).attr('data-val',opt_status);
10654                        $(v).parent().find('.prod-option-edit').addClass('hide');
10655                        $(v).removeClass('hide');
10656
10657                        // 다른 옵션 input 선택시 기존 값 0됨
10658                        // if(opt_price < 0) {
10659                        //     $(this).find('.prod-option-price').text(str_price);
10660                        //     $(this).find('.prod-option-price').find('.prod-option-price').addClass('minus');
10661                        // } else {
10662                        //     $(this).find('.prod-option-price').text(str_quantity);
10663                        //     $(this).find('.prod-option-price').find('.prod-option-price').removeClass('minus');
10664                        // }
10665                    });
10666                }
10667
10668                var title = $(this).parent().find('.prod-option-title').text(),
10669                    title_html = $(this).parent().find('.prod-option-title').html(),
10670                    desc = $(this).parent().find('.prod-option-desc').text(),
10671                    price = $(this).parent().find('.prod-option-price').attr('data-option-price'),
10672                    quantity = $(this).parent().find('.prod-option-quantity').text(),
10673                    status = $(this).parent().find('.prod-option-status').attr('data-val'),
10674                    text_require = $(this).parent().find('.prod-option-require').attr('data-val'),
10675                    $title = $(this).parent().siblings('.prod-option-edit').find('.edit-option-title input'),
10676                    $title_html = $(this).parent().siblings('.prod-option-edit').find('.edit-option-title'),
10677                    $desc = $(this).parent().siblings('.prod-option-edit').find('.edit-option-desc input'),
10678                    $price = $(this).parent().siblings('.prod-option-edit').find('.edit-option-price input'),
10679                    $quantity = $(this).parent().siblings('.prod-option-edit').find('.edit-option-quantity input'),
10680                    $status = $(this).parent().siblings('.prod-option-edit').find('.option-price-status-str'),
10681                    $text_require = $(this).parent().siblings('.prod-option-edit').find('.option-require-str');
10682      
10683                if(price == 'NaN') price = 0;
10684                switch(status) {
10685                    case "S" : str = '판매'; break;
10686                    case "O" : str = '품절'; break;
10687                    case "H" : str = '숨김'; break;
10688                    default : str = '판매'; break;
10689                }
10690                price = removeCommas(price);
10691                quantity = removeCommas(quantity);
10692                if (!quantity) quantity = 0;
10693                if (!price || isNaN(price)) price = 0;
10694
10695                price = (price * 1);
10696                quantity = (quantity * 1);
10697
10698                if(product_options.advanced == 'true') {
10699                    $title_html.html(title_html);
10700                } else {
10701                    $title.val(title);
10702                }
10703                $desc.val(desc);
10704                $price.val(addCommas(price.toString()));
10705                $quantity.val(addCommas(quantity.toString()));
10706                $status.text(str).attr('data-val', status);
10707                // $text_require.html(check).attr('data-val', text_require);
10708
10709                $(this).parent().addClass('hide');
10710                $(this).parent().siblings('.prod-option-edit').removeClass('hide');
10711                if($(this).hasClass('prod-option-title')) $title.focus();
10712                if($(this).hasClass('prod-option-price')) $price.focus();
10713                if($(this).hasClass('prod-option-quantity')) $quantity.focus();
10714            });
10715
10716            $(document).on('keydown', '.edit-option-title input, .options-input', function(e) {
10717                var keyCode = e.keyCode,
10718                    shiftKey =  e.shiftKey;
10719                
10720                if(keyCode == 222) 
10721                    if(shiftKey) return false;
10722
10723                if(keyCode == 191 || keyCode == 111) {
10724                    if(shiftKey) return;
10725                    e.stopPropagation();
10726                    return false;
10727                }
10728
10729                if($(this).hasClass('options-input')) {
10730                    var value = $(this).val(),
10731                        last = value.split("").pop();
10732                    if(last == "," && keyCode == 188) {
10733                        alert('옵션 값을 알맞게 입력해주세요');
10734                        return false;
10735                    }
10736                }
10737            });
10738
10739            $(document).on('keyup keydown click','.edit-option-title input, .edit-option-desc input, .edit-option-price input, .edit-option-quantity input',function(e) {
10740                e.stopPropagation();
10741                var keyCode = e.keyCode || e.which,
10742                    eType = e.type,
10743                    target = e.target,
10744                    $title = $(this).parents('.form-wrap').find('.edit-option-title input'),
10745                    $desc = $(this).parents('.form-wrap').find('.edit-option-desc input'),
10746                    $price = $(this).parents('.form-wrap').find('.edit-option-price input'),
10747                    $quantity = $(this).parents('.form-wrap').find('.edit-option-quantity input'),
10748                    $status = $(this).parents('.form-wrap').find('.option-price-status-str'),
10749                    $text_require = $(this).parents('.form-wrap').find('.option-price-status-str');
10750
10751                if(eType == 'keydown' && keyCode == 13) e.preventDefault(); //enter submit 방지
10752                limitProductOptionPriceInput($price);
10753
10754                var price = removeCommas($price.val())*1,
10755                    quantity = removeCommas($quantity.val())*1;
10756
10757                var $li = $(this).parents('li');
10758
10759                if(price < 0) {
10760                    $li.find('.prod-option-price').text(Math.abs(price));
10761                    $li.find('.prod-option-price').addClass('minus');
10762                } else {
10763                    $li.find('.prod-option-price').text(price);
10764                    $li.find('.prod-option-price').removeClass('minus');
10765                }
10766
10767                var abs_price = Math.abs(price),
10768                    str_price = addCommas(abs_price.toString()),
10769                    str_quantity = addCommas(quantity.toString());
10770
10771                $li.find('.prod-option-title').text($title.val());
10772                $li.find('.prod-option-desc').text($desc.val());
10773                $li.find('.prod-option-price').text(str_price);
10774                $li.find('.prod-option-price').attr('data-option-price', price);
10775                $li.find('.prod-option-quantity').text(str_quantity);
10776                $li.find('.prod-option-status').text($status.text());
10777
10778                var submit = false;
10779                var isDuplicate = true;
10780                if(eType == 'click' && !$(target).is('.prod-option-list') && !$(target).is('input')) { //다른 옵션 클릭 시 입력
10781                    isDuplicate = checkDuplicateOptionName($title);
10782                    submit = true;   
10783                }
10784
10785                if(eType == 'keyup') {
10786                    if(keyCode == 13) {
10787                        isDuplicate = checkDuplicateOptionName($title);
10788                        e.preventDefault();
10789                        submit = true;  
10790                    }
10791
10792                    if($('.switch-quantity').prop('checked') == true) { //재고관리 on
10793                        if(keyCode == 9 && !$('.option-price-number').is(':focus') && !$('.option-price-quantity').is(':focus')) { //tab
10794                            isDuplicate = checkDuplicateOptionName($title);
10795                            submit = true;
10796                        }
10797                    } else { //재고관리 off
10798                        if(keyCode == 9 && !$('.option-price-number').is(':focus')) { //tab
10799                            isDuplicate = checkDuplicateOptionName($title);
10800                            submit = true;
10801                        }
10802                    }  
10803                }
10804
10805                if(submit && isDuplicate == false) {
10806                    shoppingSetOption($('.prod-option-item.hide'));
10807                }          
10808            });
10809
10810            $(document).on('click', function(e) {
10811                if(!$(e.target).is('.prod-discount-unit-select') && $(e.target).closest('.prod-discount-unit-select').length == 0) {
10812                    $('.discount-unit-select').hide();
10813                }
10814                if(!$(e.target).is('.prod-option-list')) {
10815                    shoppingSetOption($('.prod-option-item.hide'));
10816                }
10817
10818                if($('.prod-modal').has(e.target).length) {
10819                    if(!$('.delivery-template-list').has(e.target).length && $('.delivery-template-list').get(0) != e.target && !$('#delivery_template_seq').has(e.target).length && $('#delivery_template_seq').get(0) != e.target) {
10820                        $('.delivery-template-list').slideUp(200);
10821                        $('#delivery_template_seq.open').removeClass('open');
10822                    }
10823
10824                    if(!$('#prod-category-lists').has(e.target).length && $('#prod-category-lists').get(0) != e.target && !$('#prod-category-text').has(e.target).length && $('#prod-category-text').get(0) != e.target) {
10825                        $('#prod-category-lists').slideUp(200);
10826                        $('.category-wrap.open').removeClass('open');
10827                    }
10828                }
10829            });
10830
10831            $(document).on('click', '#delivery_template_seq:not(.limit-disabled)', function() {
10832                $(this).toggleClass('open');
10833                if($(this).hasClass('open')) {
10834                    $('.delivery-template-list').slideDown(200);
10835                } else {
10836                    $('.delivery-template-list').slideUp(200);
10837                }
10838            });
10839
10840            $(document).on('input', '#product_weight', function(e) {
10841                var val = $(this).val().replace(/,/g, '');
10842                if(val.indexOf('.') > -1 && val.indexOf('.') < val.length-4) {
10843                    val = Number((Math.floor(Number(val) * 1000) / 1000).toFixed(3));
10844                }
10845
10846                if(Number(val) > 100) {
10847                    val = number_format(100);
10848                }
10849
10850                $(this).val(val);
10851            }).on('blur', '#product_weight', function() {
10852                var val = $(this).val().replace(/,/g, '');
10853                if(val.indexOf('.') > -1 && val.indexOf('.') == val.length-1) {
10854                    $(this).val(number_format(val.replace(/\./g, '')));
10855                }
10856            });
10857
10858            $(document).on('click', '.btn-delivery-template-setting', function() {
10859                var shopping_url = $(this).data('shopping_url');
10860                deliveryTemplateListModal(shopping_url, function() {
10861                    $.processON();
10862                    var site = (typeof SID == 'undefined') ? property.SID : SID,
10863                        // page = (typeof PAGE == 'undefined') ? ((typeof PROD_PAGE == 'undefined') ? property.PAGE : PROD_PAGE) : PAGE,
10864                        pid = (typeof selectID == 'undefined') ? null : selectID,
10865                        id = $('#prod-no').val();
10866                    setTimeout(function() {
10867                        $.ajax({
10868                            url: '/template/products/',
10869                            data: { type:'get', sid:site, id:id, pid:pid },
10870                            dataType: 'json',
10871                            type: 'POST',
10872                            async: false,
10873                            cache: false,
10874                            success: function (data) {
10875                                if(data.error != 'undefined' && data.error) {
10876                                    alert(data.error);
10877                                    return false;
10878                                }
10879                                var i = data.item,
10880                                    url = (typeof RESOURCE == 'undefined') ? property.RESOURCE : RESOURCE,
10881                                    folder = '', f = '';
10882
10883                                var delivery_template_str = '';
10884                                if(i.delivery_template) {
10885                                    $.each(i.delivery_template, function(k, v) {
10886                                        var template_desc = '';
10887                                        template_desc += '(';
10888                                        template_desc += $.lang[LANG]['shopping.delivery.template.mix_yn.' + v.mix_yn.toLowerCase()];
10889                                        var delivery_type_arr = v.delivery_type.split(',');
10890                                        var delivery_type_str = '';
10891                                        $.each(delivery_type_arr, function(idx, delivery_type) {
10892                                            if(delivery_type_str) delivery_type_str += ', ';
10893                                            delivery_type_str += $.lang[LANG]['shopping.delivery.template.delivery_type.' + delivery_type.toLowerCase()];
10894                                        });
10895                                        if(delivery_type_str) 
10896                                            template_desc += ' / ' + delivery_type_str;
10897                                        
10898                                        if(delivery_type_arr.indexOf('DELIVERY') > -1) {
10899                                            template_desc += ' / ' + $.lang[LANG]['shopping.delivery.' + v.delivery_company.toLowerCase()];
10900                                        }
10901
10902                                        template_desc += ' / ' + $.lang[LANG]['shopping.delivery.template.price_type.' + v.price_type.toLowerCase()];
10903
10904                                        if(v.price_type == 'FIX') {
10905                                            template_desc += '(' + number_format(v.delivery_fee) + '원)';
10906                                        } else if(v.price_type == 'QUANTITY' || v.price_type == 'WEIGHT') {
10907                                            var price_type_detail = v.price_type_detail ? JSON.parse(v.price_type_detail) : {};
10908                                            
10909                                            if(price_type_detail.method == 'DIFFERENTIAL') {
10910                                                var detail = '';
10911                                                if(price_type_detail.detail) {
10912                                                    $.each(price_type_detail.detail, function(i, j) {
10913                                                        var value = Object.keys(j);
10914                                                        var price = Object.values(j);
10915
10916                                                        if(v.price_type == 'QUANTITY') {
10917                                                            if(i < 2) {
10918                                                                if(detail) detail += ', ';
10919                                                                detail += value + '개 이상(' + number_format(price) + '원)';
10920                                                            }
10921                                                        } else if(v.price_type == 'WEIGHT') {
10922                                                            if(i < 2) {
10923                                                                if(detail) detail += ', ';
10924                                                                detail += value + 'Kg 이상(' + number_format(price) + '원)';
10925                                                            }
10926                                                        }
10927                                                    });
10928                                                }
10929                                                if(template_desc) {
10930                                                    detail = '(차등 / ' + detail + ')';
10931                                                    template_desc += detail;
10932                                                }
10933                                            } else if(price_type_detail.method == 'REPEAT') {
10934                                                var detail = '';
10935                                                var value = Object.keys(price_type_detail.detail);
10936                                                var price = Object.values(price_type_detail.detail);
10937
10938                                                if(v.price_type == 'QUANTITY') {
10939                                                    detail += value + '개 구매시마다 ' + number_format(price) + '원 반복 부과';
10940                                                } else if(v.price_type == 'WEIGHT') {
10941                                                    detail += value + 'Kg마다 ' + number_format(price) + '원 반복 부과';
10942                                                }
10943
10944                                                if(detail) {
10945                                                    detail = '(반복 / ' + detail + ')';
10946                                                    template_desc += detail;
10947                                                }
10948                                            }
10949                                        }
10950
10951                                        if(v.additional_yn == 'Y') {
10952                                            template_desc += ' / 도서산간 지역 추가 배송비 (제주 ' + number_format(v.additional_jeju_price) + '원, 제주 외 도서산간 ' + number_format(v.additional_land_price) + '원)';
10953                                        }
10954
10955                                        template_desc += ' / ' + $.lang[LANG]['shopping.delivery.template.pay_type.' + v.pay_type.toLowerCase()];
10956
10957                                        if(v.free_condition_yn == 'Y') {
10958                                            template_desc += ' / ' + number_format(v.free_condition) + '원 이상 무료 배송';
10959                                        }
10960
10961                                        if(v.make_to_order_yn == 'Y') {
10962                                            template_desc += ' / 주문 확인 후 ' + v.due_date + '일 후 배송 예정';
10963                                        }
10964                                        if(v.install_fee_yn == 'Y') {
10965                                            template_desc += ' / 별도 설치비 있음';
10966                                        }
10967                                        template_desc += ')';
10968
10969                                        delivery_template_str += '\
10970                                        <li data-val="' + v.seq + '" data-weight="' + (v.price_type == 'WEIGHT' ? 'true' : 'false') + '">\
10971                                            <input type="radio" id="delivery_template_seq_' + v.seq + '" name="delivery_template_seq" value="' + v.seq + '" />\
10972                                            <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 18 18" width="18" height="18"><path d="M9 0a9 9 0 1 0 .001 18.001A9 9 0 0 0 9 0zm0 17c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"></path></svg><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 18 18" width="18" height="18"><path d="M9 0a9 9 0 1 0 .001 18.001A9 9 0 0 0 9 0zm0 17c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"></path><circle cx="9" cy="9" r="6"></circle></svg>\
10973                                            <label for="delivery_template_seq_' + v.seq + '">\
10974                                                <span class="template-name">' + v.name + '</span>\
10975                                                <span class="template-desc">' + template_desc + '</span>\
10976                                            </label>\
10977                                        </li>';
10978                                    });
10979                                }
10980
10981                                $('.option-delivery-template-select').html(delivery_template_str);
10982
10983                                if(typeof i.delivery_template_seq != 'undefined' && i.delivery_template_seq) {
10984                                    $('.option-delivery-template-select input[name="delivery_template_seq"][value="' + i.delivery_template_seq + '"]').prop('checked', true);
10985
10986                                    $('.option-delivery-template-str').html($('.option-delivery-template-select li[data-val="' + i.delivery_template_seq + '"] label').html());
10987
10988                                    if($('.option-delivery-template-select li[data-val="' + i.delivery_template_seq + '"]').data('weight') == false) {
10989                                        $('.product-weight').hide();
10990                                        $('#product_weight').val('');
10991                                    } else {
10992                                        $('.product-weight').show();
10993                                        $('#product_weight').val(number_format(i.p.product_weight) + 'kg');
10994                                    }
10995                                } else {
10996                                    $('.option-delivery-template-select input[name="delivery_template_seq"]:first').prop('checked', true).change();
10997                                }
10998                            },
10999                            complete: function() {
11000                                $.processOFF();
11001                            }
11002                        });
11003                    });
11004                });
11005            });
11006
11007            // $(document).off('click','.prod-option-add');
11008            $(document).on('click','.prod-option-add', addProductOption);
11009
11010            $(document).on('click', '.cl_etc_state_check', function () {
11011                $('.cl_etc_state_check').each(function () {
11012                    $(this).removeClass('active');
11013                });
11014
11015                $(this).addClass('active');
11016                var val = $(this).attr('data-val');
11017                $('#etc-date-state').val(val);
11018
11019                switch(val) {
11020                    case 'Y':
11021                        $('.etc-setting').removeClass('hide');
11022                        $('.time-setting').addClass('hide');
11023                        break;
11024                    case 'T':
11025                        $('.etc-setting').removeClass('hide');
11026                        $('.time-setting').removeClass('hide');
11027                        break;
11028                    default:
11029                        $('.etc-setting').addClass('hide');
11030                        break;
11031                }
11032            });
11033        
11034            $(document).on('click', '.cl_etc_status_check', function () {
11035                $('.cl_etc_status_check').each(function () {
11036                    $(this).removeClass('active');
11037                });
11038
11039                $(this).addClass('active');
11040                var val = $(this).attr('data-val');
11041
11042                $('#etc-date-status').val(val);
11043            });
11044        
11045            // $(document).on('click', '.cl_etc_week_check', function () {
11046            //     $('.cl_etc_week_check').each(function () {
11047            //         $(this).removeClass('active');
11048            //     });
11049
11050            //     $(this).addClass('active');
11051            //     var val = $(this).attr('data-val');
11052            //     $('#etc-date-week').val(val);
11053            //     exceptPicker.disabledDays = null;
11054            //     if(val == 'W') {
11055            //         exceptPicker.disabledDays = [0, 6];
11056            //     } else if(val == 'K') {
11057            //         exceptPicker.disabledDays = [1, 2, 3, 4, 5];
11058            //     } else {
11059            //         exceptPicker.disabledDays = null;
11060            //     }
11061            //     //exceptPicker.generateDates(true);
11062            //     exceptPicker.setSelectedDates($('#etc-start-date-txt').val(), 'start');
11063            //     exceptPicker.setSelectedDates($('#etc-end-date-txt').val(), 'end');
11064            //     setExceptPicker();
11065            // });
11066        
11067            // $(document).on('click', '.cl_etc_date_time', function () {
11068            //     $('.cl_etc_date_time').each(function () {
11069            //         $(this).removeClass('active');
11070            //     });
11071
11072            //     $(this).addClass('active');
11073            //     var startDate = $(this).attr('data-start_date');
11074            //     var endDate = $(this).attr('data-end_date');
11075            //     $('#etc-start-date-txt').val(startDate);
11076            //     $('#etc-end-date-txt').val(endDate);
11077            //     //exceptPicker.generateDates(true);
11078            //     exceptPicker.setSelectedDates(startDate, 'start');
11079            //     exceptPicker.setSelectedDates(endDate, 'end');
11080            //     setExceptPicker();
11081            // });
11082
11083            $(document).on('click', '.cl_product_state_check', function (e) {
11084                var state = $(this).attr('for');
11085                var cnt = $('.prod-option[data-option_mode="normal"] .prod-option-list > li').length;
11086                var tax = $('#tax').attr('data-total-tax');
11087                var productNumber = $('#prod-no').val();
11088                var status = true;
11089
11090                var current = $('input[name="product_state"]:checked').val();
11091                if(current == "N" && product_options.advanced == 'true') {
11092                    if(e.originalEvent != 'undefined' && (state == 'download-product' || state == 'etc-product')) {
11093                        var str = (state == 'download-product') ? '다운로드' : '기타무형';
11094                        if(confirm(str + ' 상품은 고급설정을 지원하지 않아 등록된 옵션정보가 초기화 됩니다. 상품 유형을 변경하시겠습니까?') == false) return false;
11095                        else {
11096                            $('.options-config').hide();
11097                            resetOptions();
11098                        }
11099                    }
11100                }
11101                // console.log(state);
11102                if(state != 'normal-product') {
11103                    $('.delivery-template, .product-weight, .brand, .unit-pricing').hide();
11104                }
11105
11106                if (state == "download-product") { //다운로드상품 선택
11107                    //입력옵션 비활성화
11108                    $('.prod-option[data-option_mode="text"]').addClass('hide');
11109                    $('#text-option').prop('checked', false).closest('.newcheckbox').hide();
11110                    //추가옵션 비활성화
11111                    $('.prod-option[data-option_mode="additional"]').addClass('hide');
11112                    $('#additional-option').prop('checked', false).closest('.newcheckbox').hide();
11113
11114                    if($('.prod-option-tab .prod-option.hide').length == 3) { //탭 모두 비활성화일때
11115                        $('.prod-option-tab').addClass('hide');
11116                        if($('.switch-quantity').is(":checked") == true) {
11117                            $('.quantity-label').removeClass('on');
11118                        }
11119                    }
11120                    
11121                    $('#state-append').fadeIn(0);
11122                    $('#etc-calendar').hide();
11123                    if ($('#normal-option').is(':checked') === false) { //일반옵션 없음
11124                        if ($('.real-file-name').length < 1) {
11125                            $('.switch-product[value="off"]').prop('checked', true);
11126                            $('#status-append').fadeOut(0);
11127                            $('#sale-calendar').hide();
11128                        }
11129                        var html = '<div class="form-group" id="product-state">\
11130                                        <input type="file" id="upload-file" name="files">\
11131                                        <div class="product-state-box" id="add-upload-check">\
11132                                            <div class="product-upload">\
11133                                                <div class="title">파일 업로드</div>\
11134                                                <div class="download-contents">\
11135                                                    <span class="cl_icon_upload02" data-cnt="0">업로드</span>\
11136                                                    <div id="none-option-file">\
11137                                                    </div>\
11138                                                </div>\
11139                                            </div>\
11140                                            <div class="download-setting">\
11141                                                <div class="title">다운로드<br>한도설정';
11142                                                /*html += '<span class="cl-icon cl_icon_info01"></span>';*/
11143                                                html += '</div>\
11144                                                <div id="download-contents">\
11145                                                    <div class="input-box">\
11146                                                        <div class="title">기간 제한</div>\
11147                                                        <div class="textbox">\
11148                                                            <input type="text" numberOnly class="download-input" id="download-date" value="1" maxlength="90">\
11149                                                            <span>일</span>\
11150                                                        </div>\
11151                                                    </div>\
11152                                                    <div class="input-box">\
11153                                                        <div class="title">횟수 제한</div>\
11154                                                        <div class="textbox">\
11155                                                            <input type="text" numberOnly class="download-input" id="download-count" value="1" maxlength="10">\
11156                                                            <span>회</span>\
11157                                                        </div>\
11158                                                    </div>\
11159                                                </div>\
11160                                            </div>\
11161                                        </div>\
11162                                    </div>';
11163                        // console.log(html);            
11164                        $('#product-state').remove();
11165                        $('#state-append').append(html);
11166                        
11167                        $('.prod-option[data-option_mode="normal"] .prod-option-list > li').each(function () {
11168                            var $checkTag = $(this).children('.product-status');
11169                            if ($checkTag.hasClass('product-status') === false) {
11170                                var item = '<div class="form-group product-status">\
11171                                            <div class="product-state-box">\
11172                                                <div class="product-upload">\
11173                                                    <div class="title">파일 업로드</div>\
11174                                                    <div class="download-contents">\
11175                                                        <span class="cl_icon_upload02" data-cnt="0">업로드</span>\
11176                                                        <div class="file-box-list" id="file-box-0"></div>\
11177                                                    </div>\
11178                                                </div>\
11179                                            </div>\
11180                                        </div>';
11181                                fileUpdateCnt++;
11182
11183                                $(this).append(item);
11184                            } else {
11185                                var $loadTag = $('.prod-option[data-option_mode="normal"] .prod-option-list > li').eq(0).find('.download-contents div');
11186                                // console.log($loadTag.html());
11187                                $('#none-option-file').html($loadTag.html());
11188                            }
11189                        });
11190                    } else { //다운로드 외 다른상품
11191                        var html = '<div class="form-group" id="product-state">\
11192                                        <input type="file" id="upload-file" name="files" data-cnt="'+fileUpdateCnt+'">\
11193                                        <div class="product-state-box" id="add-upload-check">\
11194                                            <div class="download-setting">\
11195                                                <div class="title">다운로드<br>한도설정';
11196                                                /*html += '<span class="cl-icon cl_icon_info01"></span>';*/
11197                                                html += '</div>\
11198                                                <div class="download-contents">\
11199                                                    <div class="input-box">\
11200                                                        <div class="title">기간 제한</div>\
11201                                                        <div class="textbox">\
11202                                                            <input type="text" numberOnly class="download-input" id="download-date" value="1" maxlength="90">\
11203                                                            <span>일</span>\
11204                                                        </div>\
11205                                                    </div>\
11206                                                    <div class="input-box">\
11207                                                        <div class="title">횟수 제한</div>\
11208                                                        <div class="textbox">\
11209                                                            <input type="text" numberOnly class="download-input" id="download-count" value="1" maxlength="10">\
11210                                                            <span>회</span>\
11211                                                        </div>\
11212                                                    </div>\
11213                                                </div>\
11214                                            </div>\
11215                                        </div>\
11216                                    </div>';
11217
11218                        $('#product-state').remove();
11219                        $('#state-append').append(html);
11220
11221                        $('.prod-option[data-option_mode="normal"] .prod-option-list > li').each(function () {
11222                            var $checkTag = $(this).children('.product-status');
11223                            var option_mode = $(this).closest('.prod-option').attr('data-option_mode');
11224                            var name = $(this).find('.prod-option-title').text();
11225                           
11226                            if ($checkTag.hasClass('product-status') === false && option_mode == 'normal') {
11227                                var item = '<div class="form-group product-status">\
11228                                            <div class="product-state-box">\
11229                                                <div class="product-upload">\
11230                                                    <div class="title">파일 업로드</div>\
11231                                                    <div class="download-contents">\
11232                                                    <span class="cl_icon_upload02" data-cnt="'+fileUpdateCnt+'">업로드</span>';
11233                                                    if (name == 'noneOption') item += '<div class="file-box-list" id="file-box-0">';
11234                                                    else item += '<div class="file-box-list" id="file-box-'+fileUpdateCnt+'">';
11235                                                    item += '</div>\
11236                                                    </div>\
11237                                                </div>\
11238                                            </div>\
11239                                        </div>';
11240                                fileUpdateCnt++;
11241
11242                                $(this).find('.prod-option-status').text('품절').attr('data-val', 'O');
11243                                $(this).find('.option-price-status-str').text('품절').attr('data-val', 'O');
11244
11245                                $(this).append(item);
11246                            }
11247                        });
11248                    }
11249                    fileUpdateCnt++;
11250                } else {
11251                    if($('#product-state').length == 0) {
11252                        $('#text-option').closest('.newcheckbox').show();
11253                        $('#additional-option').closest('.newcheckbox').show();
11254                    }
11255                    
11256                    if (productNumber) {
11257                        var admin_url = (uadmin == 'um')? '/_admin':'';
11258                        $.ajax({
11259                            url: admin_url + '/shopping/download_list_check',
11260                            type: 'post',
11261                            dataType: 'json',
11262                            data: {'product_number': productNumber, 'option_seq': 0},
11263                            success: function (data) {
11264                                if (data.code == 'fail') {
11265                                    alert(data.message);
11266                                    status = false;
11267                                    return false;
11268                                }
11269                            }
11270                        });
11271                    }
11272
11273                    if (status == false) return false;
11274
11275                    if (cnt > 0) {
11276                        var checkFile = $('.file-name').length;
11277                        if (checkFile > 0) {
11278                            if (confirm('상품 유형을 변경할 경우 옵션에 등록된 파일이 삭제됩니다.\n계속하시겠습니까?') === true) {
11279                                $('#product-state').remove();
11280                                $('.product-status').remove();
11281                            } else return false;
11282                        } else {
11283                            $('#product-state').remove();
11284                            $('.product-status').remove();
11285                        }
11286                    } else {
11287                        $('#product-state').remove();
11288                        $('.product-status').remove();
11289                    }
11290                    
11291                    if (state=='normal-product' && taxUse != 'TG03' && $('#product-state').length == 0) {
11292                        $('.options-config').show();
11293                        $('#state-append').fadeOut(0);  
11294                    }
11295                    else {
11296                        $('#state-append').fadeIn(0);
11297                    }
11298
11299                    if (state == "etc-product") {
11300                        $('#etc-calendar').show();
11301                    } else {
11302                        $('#etc-calendar').hide();
11303                    }
11304
11305                    if (state == 'normal-product') {
11306                        if(!$('.delivery-template-list').find('[data-val]').find('input[name="delivery_template_seq"]:checked').length) {
11307                            $('.delivery-template-list').find('[data-val]:first').find('input[name="delivery_template_seq"]').prop('checked', true).change();
11308                        }
11309                        $('.delivery-template, .brand, .unit-pricing').show();
11310                    }
11311                }
11312
11313                if(state != 'normal-product') {
11314                    $('.options-config').hide();
11315                    $('.culture-benefit').hide();
11316                    $('#pccc-yn').hide();
11317                } else {
11318                    $('.options-config').show();
11319                    $('.culture-benefit').show();
11320                    $('#pccc-yn').show();
11321                }
11322
11323                if(state != 'download-product') {
11324                    if($('#product-state').length == 0) {
11325                        $('#text-option').closest('.newcheckbox').show();
11326                        $('#additional-option').closest('.newcheckbox').show();
11327                    }
11328                }
11329                
11330                $('.cl_product_state_check').each(function () {
11331                    $(this).children('.cl-icon').removeClass('cl_icon_check02_on').removeClass('cl_icon_check02_off').addClass('cl_icon_check02_off');
11332                    $(this).removeClass('active');
11333                });
11334
11335                $(this).children('.cl-icon').removeClass('cl_icon_check02_off').addClass('cl_icon_check02_on');
11336
11337                $(this).addClass('active');
11338
11339                if(typeof updateNpayButtonSettingState == 'function') updateNpayButtonSettingState(state);
11340            });
11341            
11342            /* product.add.html common tooltip  ******/
11343            $(document).on('mouseenter', '.cl-tooltip-info', function () {
11344                var info_type = ($(this).attr('data-infotype')) ? $(this).attr('data-infotype') : '';
11345                $('.cl-prod-info.'+info_type+'-info').fadeIn(100);
11346            }).on('mouseleave', '.cl-tooltip-info', function () {
11347                var info_type = ($(this).attr('data-infotype')) ? $(this).attr('data-infotype') : '';
11348                $('.cl-prod-info.'+info_type+'-info').fadeOut(100);
11349            });
11350
11351            $(document).on('mouseenter', '.cl-pccc-info', function () {
11352                $('.cl-prod-info.pccc-info').fadeIn(100);
11353            }).on('mouseleave', '.cl-pccc-info', function () {
11354                $('.cl-prod-info.pccc-info').fadeOut(100);
11355            });
11356
11357            $(document).on('mouseenter', '.cl-culture-benefit-info', function () {
11358                $('.cl-prod-info.culture-benefit-info').fadeIn(100);
11359            }).on('mouseleave', '.cl-culture-benefit-info', function () {
11360                $('.cl-prod-info.culture-benefit-info').fadeOut(100);
11361            });
11362
11363            $(document).on('mouseenter', '.cl-discount-info', function () {
11364                $('.cl-prod-info.discount-info').fadeIn(100);
11365            }).on('mouseleave', '.cl-discount-info', function () {
11366                $('.cl-prod-info.discount-info').fadeOut(100);
11367            });
11368
11369            $(document).on('mouseenter', '.cl-grade-info', function () {
11370                $('.cl-prod-info.grade-info').fadeIn(100);
11371            }).on('mouseleave', '.cl-grade-info', function () {
11372                $('.cl-prod-info.grade-info').fadeOut(100);
11373            });
11374
11375            $(document).on('mouseenter', '.cl-status-info', function () {
11376                $('.cl-prod-info.status-info').fadeIn(100);
11377            }).on('mouseleave', '.cl-status-info', function () {
11378                $('.cl-prod-info.status-info').fadeOut(100);
11379            });
11380
11381            $(document).on('mouseenter', '.cl-open-info', function () {
11382                $('.cl-prod-info.open-info').fadeIn(100);
11383            }).on('mouseleave', '.cl-open-info', function () {
11384                $('.cl-prod-info.open-info').fadeOut(100);
11385            });
11386
11387            $(document).on('mouseenter', '.cl-product-info', function () {
11388                $('.cl-prod-info.product-info').fadeIn(100);
11389            }).on('mouseleave', '.cl-product-info', function () {
11390                $('.cl-prod-info.product-info').fadeOut(100);
11391            });
11392
11393            $(document).on('mouseenter', '.cl-option-info', function () {
11394                $('.cl-prod-info.option-info').fadeIn(100);
11395            }).on('mouseleave', '.cl-option-info', function () {
11396                $('.cl-prod-info.option-info').fadeOut(100);
11397            });
11398
11399            $(document).on('mouseenter', '.cl-text-option-info', function () {
11400                $('.cl-prod-info.text-option-info').fadeIn(100);
11401            }).on('mouseleave', '.cl-text-option-info', function () {
11402                $('.cl-prod-info.text-option-info').fadeOut(100);
11403            });
11404
11405            $(document).on('mouseenter', '.cl-prod-info-notice', function () {
11406                $('.cl-prod-info.cl-prod-info-notice').fadeIn(100);
11407            }).on('mouseleave', '.cl-prod-info-notice', function () {
11408                $('.cl-prod-info.cl-prod-info-notice').fadeOut(100);
11409            });
11410
11411            $(document).on('click', '.cl_icon_close:not(.dashboard-visit-date)', function () {
11412                var checkCnt = $(this).attr('data-cnt');
11413                var productNumber = $(this).attr('data-pn');
11414                var seq = ($('#normal-option').is(':checked'))? $(this).attr('data-seq') : 0;
11415                var file = $(this).attr('data-file');
11416                var $parentFile = $(this).parent().parent();
11417                var $closeFile = $(this).parent();
11418                var $this = $(this);
11419                var admin_url = (uadmin == 'um')? '/_admin' : '';
11420
11421                if (productNumber!=='null' && productNumber!==undefined && seq!=='null' && seq!==undefined) {   
11422                    $.ajax({
11423                        url: admin_url + '/shopping/download_list_check',
11424                        type: 'post',
11425                        dataType: 'json',
11426                        data: {'product_number': productNumber, 'option_seq': seq},
11427                        success: function (data) {
11428                            if (data.code == 'fail') {
11429                                alert(data.message);
11430                                return false;
11431                            } else {
11432                                if (confirm(data.message) === true) {
11433                                    $.processON('Deleting File...');
11434                                    $.ajax({
11435                                        type: 'POST',
11436                                        url: admin_url + '/shopping/file_delete',
11437                                        data: { s: file, seq: seq},
11438                                        async: true,
11439                                        success: function(data) {
11440                                            checkError(data);
11441                                            if (checkCnt || checkCnt == 0) {
11442                                                $closeFile.remove();
11443                                                $('.file-name-'+checkCnt).remove();
11444                                                    $this.parent().parent().parent().parent().parent().parent().find('.prod-option-status').text('품절').attr('data-val', 'O');
11445                                                    $this.parent().parent().parent().parent().parent().parent().find('.option-price-status-str').text('품절').attr('data-val', 'O');
11446
11447                                            } else $closeFile.remove();
11448                                            
11449                                            var $fileCnt = $parentFile.find('.file-name');
11450                                            if ($fileCnt.length < 1) {
11451                                                if ($('#none-option-file').length > 0) {
11452                                                    $('.switch-product[value="off"]').prop('checked', true);
11453                                                    $('#status-append').fadeOut(0);
11454                                                    $('#sale-calendar').hide();
11455                                                }
11456                                                $.ajax({
11457                                                    url: admin_url + '/shopping/file_zero',
11458                                                    type: 'post',
11459                                                    data: {'product_number': productNumber}
11460                                                });
11461                                            }
11462
11463                                            $.processOFF();
11464                                        }
11465                                    });
11466                                }
11467                            }
11468                        }
11469                    });
11470                } else {
11471                    $.processON('Deleting File...');
11472                    $.ajax({
11473                        type: 'POST',
11474                        url: admin_url + '/shopping/file_delete',
11475                        data: {s: file},
11476                        async: true,
11477                        success: function(data) {
11478                            checkError(data);
11479                            if (checkCnt || checkCnt == 0) {
11480                                $closeFile.remove();
11481                                $('.file-name-'+checkCnt).remove();
11482                            } else $closeFile.remove();
11483                                            
11484                            var $fileCnt = $parentFile.find('.file-name');
11485                            if ($fileCnt.length < 1) {
11486                                $('.switch-product[value="off"]').prop('checked', true);
11487                                $('#status-append').fadeOut(0);
11488                                $('#sale-calendar').hide();
11489                            }
11490
11491                            $.processOFF();
11492                        }
11493                    });
11494                }
11495            });
11496
11497            $(document).on('click', '.cl_icon_upload02', function () {
11498                var cnt = $(this).attr('data-cnt'),
11499                    fileCnt = 0;
11500                $('#file-box-'+cnt).find('.real-file-name').each(function () {fileCnt++;});
11501                if ($('#none-option-file').find('.real-file-name').length > 0 || $('#none-option-file').find('.none-real-file-name').length > 0) fileCnt++;
11502
11503                if (fileCnt >= 1) {
11504                    // alert('파일은 1개만 업로드 가능합니다.\n여러 파일ì
11504„ 업로드할 경우 압축 파일을 이용해 주세요.');
11505                    var modal = $(this).showModalFlat('','파일은 1개만 업로드 가능합니다.\n여러 파일을 업로드할 경우 압축 파일을 이용해 주세요.',true,false,'','ok','','cl-cmmodal cl-s-btn w560 cl-p130 cl-t80 cl-modal cl-none-title cl-close-btn','','',function() {
11506                        $(document).on('keydown', function(e) {
11507                            if(e.keyCode == 27) modal.modal('hide');
11508                        });
11509                    });
11510                    return false;
11511                }
11512
11513                $thisUploadCheck = $(this);
11514                $('#product-state').find('input[type="file"]').attr('data-cnt', cnt).click();
11515            });
11516
11517            $(document).on('click', '#upload-file', function (data) {
11518                var sid = (typeof SID == 'undefined') ? property.SID : SID
11519                    uid = '',
11520                    cnt = $(this).attr('data-cnt');
11521                $.uploadON();
11522                var route = (CONFIG_URL) ? '/_admin' : '';
11523                $(this).fileupload({
11524                    url: route + '/shopping/image_upload/type/file/sid/'+sid+'/uid/'+uid,
11525                    dataType: 'json',
11526                    pasteZone: null,
11527                    async: true,
11528                    change: function(e, data) {
11529                        var ext = ['zip', 'txt', 'pdf', 'docx', 'xlsx', 'xls', 'csv', 'ppt', 'pptx', 'gif', 'jpg', 'jpeg', 'png', 'ico', 'webp', 'hwp', 'mp3', 'wav', 'wma', 'mp4'];
11530                        var extAry = data.fileInput[0]['files'][0]['name'].split(".");
11531                        if (ext.indexOf(extAry[extAry.length - 1]) == -1) {
11532                            alert('지원하지 않는 파일 형식이거나 파일이 손상되어 업로드할 수 없습니다. 확인 후 다시 시도해 주시기 바랍니다.');
11533                            return false;
11534                        }
11535
11536                        var maxSize  = 1024 * 1024 * 512;
11537                        var fileSize = data.fileInput[0]['files'][0]['size'];
11538                        if (fileSize > maxSize) {
11539                            alert($.lang[LANG]['editor.upload.max.500'] + $.lang[LANG]['editor.upload.max.2']);
11540                            return false;
11541                        }
11542                    },
11543                    add: function(e, data) {
11544                        $('.uploadModal').show();
11545                        var submit = true, err = '';                        
11546                        var ext = ['zip', 'txt', 'pdf', 'docx', 'xlsx', 'xls', 'csv', 'ppt', 'pptx', 'gif', 'jpg', 'jpeg', 'png', 'ico', 'webp', 'hwp', 'mp3', 'wav', 'wma', 'mp4'];
11547                        var extAry = data.fileInput[0]['files'][0]['name'].toLowerCase().split('.');
11548                        if (ext.indexOf(extAry[extAry.length - 1]) == -1) {
11549                            err = $.lang[LANG]['editor.upload.error.ext'];
11550                            submit = false;
11551                        }
11552
11553                        var maxSize  = 1024 * 1024 * 512;
11554                        var fileSize = data.fileInput[0]['files'][0]['size'];
11555                        if (fileSize > maxSize) {
11556                            err = $.lang[LANG]['editor.upload.max.500'] + $.lang[LANG]['editor.upload.max.2'];
11557                            submit = false;
11558                        }
11559                        $('#loading').css('left','-100%');
11560
11561                        var fileSize = (data.files[0].size/1024/1024).toFixed(1) + 'MB';
11562                        var tpl = '<div class="file">\
11563                            <div class="progress"><div class="progress-bar"></div></div>\
11564                            <div class="progress-info"><span class="file-name">' + data.files[0].name + '</span><span class="file-size">' + fileSize + '</span><span class="ing">' + $.lang[LANG]['editor.upload.response'] + '</span></div>\
11565                            <div class="preview"></div>\
11566                            </div>';
11567                        data.context = $(tpl).insertBefore($('.uploadModal .upload-content .upload-cancel'));
11568                        data.context.find('.preview').addClass('not_image');
11569                        if(submit) {
11570                            var jqXHR = data.submit();
11571                            UPLOAD++;
11572                        } else {
11573                            data.context.find('.loading').html('<i class="fa fa-times error"></i>');
11574                            data.context.find('.ing').addClass('error').text(err);
11575                        }
11576
11577                        $('.uploadModal .upload-cancel .btn, .uploadModal .upload-close').off('click').on('click', function(e) {
11578                            if(jqXHR != undefined) jqXHR.abort();
11579                            data.context.fadeOut().remove();
11580                            $('.uploadModal #file-upload-progress').css('width','0%');
11581                            $.uploadOFF();
11582                            UPLOAD = 0;
11583                            UPLOADED = 0;
11584                            PROGRESS = 0;
11585                        });
11586
11587                    },
11588                    progress: function(e, data) {
11589                        var rate = (data.bitrate/1024).toFixed(1) + ' kbps';
11590                        var progress = parseInt((data.loaded / data.total) * 100, 10);
11591                        if(typeof data.context != 'undefined') {
11592                            data.context.find('.res').text(data.bitrate);
11593                            data.context.find('.progress-bar').css('width',progress + "%");
11594                            data.context.find('.ing').text(progress + "%");
11595                            data.context.find('.rate').text(rate);
11596                            if(progress == 100) {
11597                                data.context.find('.ing').text($.lang[LANG]['editor.upload.response']);
11598                            }
11599                        }
11600                    },                        
11601                    done: function(e, data) {
11602                        if(typeof data.result.error != 'undefined' && data.result.error) {
11603                            alert(data.result.error);
11604                            $.uploadOFF();
11605                            UPLOAD = 0;
11606                            UPLOADED = 0;
11607                            PROGRESS = 0;
11608                            return;
11609                        }
11610                        var fileSize = data.result.file_size, unit = 'KB';
11611
11612                        if (fileSize >= 1000) {
11613                            fileSize = fileSize / 1000;
11614                            fileSize = fileSize.toFixed(2);
11615                            unit = 'MB';
11616                            if (fileSize >= 1000) {
11617                                fileSize = fileSize / 1000;
11618                                fileSize = fileSize.toFixed(2);
11619                                unit = 'GB';
11620                            }
11621                        }
11622
11623                        var fileName = data.result.client_name, totalByte = 0, strFileName = '';
11624                        if (!fileName) {
11625                            alert('업로드 도중 오류가 발생했습니다. 다시 시도해 주세요.\n지속적으로 문제가 발생한다면 관리자에게 문의해 주세요.');
11626                            $.uploadOFF();
11627                            UPLOAD = 0;
11628                            UPLOADED = 0;
11629                            PROGRESS = 0;
11630                            return false;
11631                        }
11632                        
11633                        var fn_lastIndex = fileName.lastIndexOf('.');
11634                        var file = [fileName.slice(0, fn_lastIndex), fileName.slice(fn_lastIndex + 1)];
11635                        var fileLen = file[0].length;
11636                        for (var i=0;i<fileLen;i++) {
11637                            oneChar = file[0].charAt(i);
11638                            if (escape(oneChar).length > 4) {
11639                                totalByte += 2;
11640                            } else {
11641                                totalByte++;
11642                            }
11643
11644                            if (totalByte > 10) {
11645                                strFileName += '..';
11646                                break;
11647                            }
11648
11649                            strFileName += oneChar;
11650                        }
11651                        strFileName = strFileName+"."+file[(file.length - 1)];
11652                        var splitUrl = data.result.full_path.split('/');
11653                        var fileCnt = $('.file-name').length;
11654
11655                        var file = '<div class="file-name file-name-'+fileCnt+'">\
11656                                        <span class="real-file-name">'+fileName+'</span>\
11657                                        <span class="file-name-detail" title="'+fileName+'">'+strFileName+'</span>\
11658                                        <span class="file-size">'+fileSize+unit+'</span>\
11659                                        <span class="cl-icon cl_icon_close" data-cnt="'+fileCnt+'" data-file="'+splitUrl[8]+'" data-pn="'+closeProductNumber+'"></span>\
11660                                        <span class="file-url">'+data.result.full_path+'</span>\
11661                                    </div>';
11662
11663                        // console.log(file);
11664                        var licnt = $('.prod-option-list > li').length;
11665                        if ($thisUploadCheck.parent().parent().find('#none-option-file').length <= 0) {
11666                            $thisUploadCheck.parent().parent().parent().parent().parent().find('.prod-option-status').text('판매').attr('data-val', 'S');
11667                            $thisUploadCheck.parent().parent().parent().parent().parent().find('.option-price-status-str').text('판매').attr('data-val', 'S');
11668                        }
11669                        if ($('#normal-option').is(':checked') === false) {
11670                            var noneFile = '<div class="none-file-name">\
11671                                            <span class="none-real-file-name">'+fileName+'</span>\
11672                                            <span class="none-file-name-detail" title="'+fileName+'">'+strFileName+'</span>\
11673                                            <span class="none-file-size">'+fileSize+unit+'</span>\
11674                                            <span class="cl-icon cl_icon_close" data-cnt="'+fileCnt+'" data-file="'+splitUrl[8]+'" data-pn="'+closeProductNumber+'"></span>\
11675                                            <span class="none-file-url">'+data.result.full_path+'</span>\
11676                                        </div>';
11677                            // console.log('file-box-cnt: '+cnt);
11678
11679                            $('[id^="file-box-"]:first').append(file);
11680                            $('#none-option-file').append(noneFile);
11681                        } else {
11682                            $('#file-box-'+cnt).append(file);
11683                        }
11684                        // console.log(noneFile);
11685                        progress1 = parseInt(UPLOADED / UPLOAD * 100,10);
11686                        PROGRESS = progress1 + progress2;
11687                        $('.file-upload-progress .progress-bar').css({
11688                            'width' : PROGRESS + '%',
11689                            'text-align' : 'right',
11690                            'padding-right' : '5px'
11691                        }).text(PROGRESS + '% ');
11692
11693                        UPLOADED++;
11694                        if(UPLOADED) {
11695                            //$.uploadON(UPLOADED + " / " + UPLOAD + "<br>images creating...");
11696                            if(UPLOAD==UPLOADED) {
11697                                UPLOAD = 0;
11698                                UPLOADED = 0;
11699                                PROGRESS = 0;
11700
11701                                $('.file-upload-progress .progress-bar').css({
11702                                    'width' :  PROGRESS + '%',
11703                                    'padding-right' : '0px'
11704                                }).text('');
11705                            }
11706                        }
11707
11708                        $.uploadOFF();
11709                    },
11710                    progressall: function(e, data) {
11711                        var total = (data.total/1024/1024).toFixed(1) + 'MB';
11712                        $('.uploadModal .info1').text($.lang[LANG]['editor.upload.size.total'] + total);
11713                        $('.uploadModal .info2').text((UPLOADED+1) + ' / ' + UPLOAD.toString());
11714                        var progress = parseInt((data.loaded / data.total) * 100, 10);
11715                        $('.file-upload-progress .progress-bar').css('width',progress + "%");
11716                    },
11717                    start : function(e, data) {
11718                        $('.uploadModal .upload-header h1').text($.lang[LANG]['editor.upload.title.2']);
11719                        $('.uploadModal .upload-content .upload-cancel .btn-default').text($.lang[LANG]['config.cancel']);
11720                        progress1 = 0; progress2 = 0; PROGRESS = 0;
11721                    },
11722                    dragover : function(e, data) {
11723                        e.preventDefault();
11724                    }
11725                }).prop('disabled', !$.support.fileInput)
11726                    .parent().addClass($.support.fileInput ? undefined : 'disabled');
11727            });
11728
11729            $(document).on('keyup', '#download-date', function () {
11730                var $this_val = strReplace($(this).val(), ',', '');
11731                if ($this_val != '') {
11732                    if ($this_val > 90) {
11733                        // alert('기간 제한은 최소 1일에서 최대 90일입니다.');
11734                        $(this).blur();
11735                        var modal = $(this).showModalFlat('','기간 제한은 최소 1일에서 최대 90일입니다.',true,false,'','ok','','cl-cmmodal cl-s-btn w560 cl-p130 cl-t80 cl-modal cl-none-title cl-close-btn','','',function() {
11736                            $(document).on('keydown', function(e) {
11737                                if(e.keyCode == 27) modal.modal('hide');
11738                            });
11739                        });
11740                        $(this).val(90);
11741                        return false;
11742                    }
11743
11744                    if ($this_val < 1) {
11745                        // alert('기간 제한은 최소 1일에서 최대 90일입니다.');
11746                        $(this).blur();
11747                        var modal = $(this).showModalFlat('','기간 제한은 최소 1일에서 최대 90일입니다.',true,false,'','ok','','cl-cmmodal cl-s-btn w560 cl-p130 cl-t80 cl-modal cl-none-title cl-close-btn','','',function() {
11748                            $(document).on('keydown', function(e) {
11749                                if(e.keyCode == 27) modal.modal('hide');
11750                            });
11751                        });
11752                        $(this).val(1);
11753                        return false;
11754                    }
11755                }
11756            });
11757
11758            $(document).on('focusout', '#download-date', function () {
11759                var $this_val = strReplace($(this).val(), ',', '');
11760                if ($this_val == '') {
11761                    // alert('기간 제한은 최소 1일에서 최대 90일입니다.');
11762                    $(this).blur();
11763                    var modal = $(this).showModalFlat('','기간 제한은 최소 1일에서 최대 90일입니다.',true,false,'','ok','','cl-cmmodal cl-s-btn w560 cl-p130 cl-t80 cl-modal cl-none-title cl-close-btn','','',function() {
11764                        $(document).on('keydown', function(e) {
11765                            if(e.keyCode == 27) modal.modal('hide');
11766                        });
11767                    });
11768                    $(this).val(1);
11769                    return false;
11770                }
11771            });
11772
11773            $(document).on('keyup', '#download-count', function () {
11774                var $this_val = strReplace($(this).val(), ',', '');
11775                if ($this_val != '') {
11776                    if ($this_val > 10) {
11777                        // alert('다운로드 횟수는 최소 1회에서 최대 10회입니다.');
11778                        $(this).blur();
11779                        var modal = $(this).showModalFlat('','다운로드 횟수는 최소 1회에서 최대 10회입니다.',true,false,'','ok','','cl-cmmodal cl-s-btn w560 cl-p130 cl-t80 cl-modal cl-none-title cl-close-btn','','',function() {
11780                            $(document).on('keydown', function(e) {
11781                                if(e.keyCode == 27) modal.modal('hide');
11782                            });
11783                        });
11784                        $(this).val(10);
11785                        return false;
11786                    }
11787
11788                    if ($this_val < 1) {
11789                        // alert('다운로드 횟수는 최소 1회에서 최대 10회입니다.');
11790                        $(this).blur();
11791                        var modal = $(this).showModalFlat('','다운로드 횟수는 최소 1회에서 최대 10회입니다.',true,false,'','ok','','cl-cmmodal cl-s-btn w560 cl-p130 cl-t80 cl-modal cl-none-title cl-close-btn','','',function() {
11792                            $(document).on('keydown', function(e) {
11793                                if(e.keyCode == 27) modal.modal('hide');
11794                            });
11795                        });
11796                        $(this).val(1);
11797                        return false;
11798                    }
11799                }
11800            });
11801
11802            $(document).on('focusout', '#download-count', function () {
11803                var $this_val = strReplace($(this).val(), ',', '');
11804                if ($this_val == '') {
11805                    // alert('다운로드 횟수는 최소 1회에서 최대 10회입니다.');
11806                    $(this).blur();
11807                    var modal = $(this).showModalFlat('','다운로드 횟수는 최소 1회에서 최대 10회입니다.',true,false,'','ok','','cl-cmmodal cl-s-btn w560 cl-p130 cl-t80 cl-modal cl-none-title cl-close-btn','','',function() {
11808                        $(document).on('keydown', function(e) {
11809                            if(e.keyCode == 27) modal.modal('hide');
11810                        });
11811                    });
11812                    $(this).val(1);
11813                    return false;
11814                }
11815            });
11816
11817            $(document).on('click','.option-price-status-str', function(e) {
11818                e.stopPropagation();
11819                var check = $(this).attr('data-val');
11820                if($(this).hasClass('open')) {
11821                    $(this).next().slideUp(200, function() {
11822                        $('.option-price-status-str').removeClass('open');    
11823                    }); 
11824                } else {
11825                    $(this).addClass('open');
11826                    $(this).next().find('li').removeClass('active');
11827                    $(this).next().find('li[data-val="' + check + '"]').addClass('active');
11828                    $(this).next().slideDown(200); 
11829                }
11830
11831            });
11832
11833            // $(document).on('change', '.option-require-str input', function(){
11834            //     var $option_li = $(this).closest('li');
11835            //     if($(this).is(':checked')) {
11836            //         $option_li.find('.option-require-str').attr('data-val', 'TR');
11837            //         $option_li.find('.prod-option-require').attr('data-val', 'TR');
11838            //     } else {
11839            //         $option_li.find('.option-require-str').attr('data-val', 'T');
11840            //         $option_li.find('.prod-option-require').attr('data-val', 'T');
11841            //     }
11842            // });
11843
11844            $(document).on('click', '.option-price-status-select li', function(e) {
11845                e.stopPropagation();
11846                $('.option-price-status-select li').removeClass('active');
11847                $(this).addClass('active');
11848                var str = $(this).text(),
11849                    val = $(this).attr('data-val');
11850
11851                $(this).parents('.edit-option-select').find('.option-price-status-str').text(str).attr('data-val',val).removeClass('open');
11852                $(this).parents('li').find('.prod-option-status').text(str).attr('data-val',val);
11853
11854                $(this).parent().slideUp(200);
11855            });
11856
11857            $(document).on('change', '.option-delivery-template-select input[name="delivery_template_seq"]', function(e) {
11858                e.stopPropagation();
11859                var str = $(this).parent('li').find('label').html(),
11860                    val = $(this).val();
11861
11862                $('#delivery_template_seq').html(str);
11863
11864                if($(this).parent('li').data('weight') == true) {
11865                    $('.product-weight').show();
11866                } else {
11867                    $('.product-weight').hide();
11868                    $('#product_weight').val('');
11869                }
11870                $('.delivery-template-list').slideUp(200);
11871                $('#delivery_template_seq').removeClass('open');
11872                $('.prod-modal').scrollTop($('.prod-modal').scrollTop() + $('.form-wrap.delivery-template').offset().top - $('.prod-modal .prod-header').outerHeight())
11873            });
11874
11875            $(document).on('click','.edit-option-delete', function(e) { 
11876                var $option = $(this),
11877                    // seq = ($('#normal-option').is(':checked'))? $(this).attr('data-seq') : 0,
11878                    seq = $(this).attr('data-seq'),
11879                    sid = (typeof SID == 'undefined') ? property.SID : SID;
11880                    option_mode = $option.closest('.prod-option').attr('data-option_mode'),
11881                    fileName = $option.closest('li').find('.real-file-name').text();
11882                var status = true;
11883                var productNumber = $('#prod-no').val();
11884                var admin_url = (uadmin == 'um')? '/_admin' : '';
11885
11886                if (option_mode == "normal" && seq!==undefined && productNumber && fileName) {
11887                    $.ajax({
11888                        url: admin_url + '/shopping/download_list_check',
11889                        type: 'post',
11890                        dataType: 'json',
11891                        data: {'product_number': productNumber, 'option_seq': seq},
11892                        success: function (data) {
11893                            if (data.code == 'fail') {
11894                                alert(data.message);
11895                                status = false;
11896                                return false;
11897                            }
11898                        }
11899                    });
11900                }
11901                
11902                if (status == false) return false;
11903                var modal = $(this).showModalFlat($.lang[LANG]['config.information'], '선택한 옵션을 삭제하시겠습니까?', true, true, function() {
11904                    if(typeof seq != "undefined" || seq) {
11905                        var deleted = ($('#options-delete-list').val()) ? $('#options-delete-list').val().split(",") : [];
11906                            deleted.push(seq);
11907                        // var deleted_items = [...new Set(deleted)];
11908                        var deleted_items = deleted.filter(onlyUnique);
11909                        $('#options-delete-list').val(deleted_items.join(","));
11910                        $option.parents('li').remove(); 
11911
11912                        var liTotal = 0;
11913                        $('.prod-option-list > li').each(function () { liTotal++; });
11914                        if (liTotal < 2) $('.plus-price').addClass('hide');
11915                    } else {
11916                        var optionMode = $option.closest('.prod-option').attr('data-option_mode');
11917                        $option.parents('li').remove(); 
11918
11919                        var liTotal = 0;
11920                        $('.prod-option-list > li').each(function () { liTotal++; });
11921                        if (liTotal < 2) $('.prod-str-price').text('');
11922                    }
11923
11924                    if($('.switch-quantity').is(":checked") == true) {
11925                        if($('#normal-option').is(':checked') === true) {
11926                            // $('#prod-quantity').attr('readonly','true').removeClass('hide').attr('placeholder','옵션에서 재고 관리');
11927                            $('.quantity-label').addClass('on');
11928                            $('.plus-quantity').removeClass('hide');
11929                        } else if($('#normal-option').is(':checked') === false && $('#additional-option').is(':checked') === true) {
11930                            $('.quantity-label').removeClass('on');
11931                            $('#prod-quantity').removeAttr('readonly').removeClass('hide');
11932                            $('.plus-quantity').removeClass('hide');
11933                        } else {
11934                            $('.quantity-label').removeClass('on');
11935                            $('#prod-quantity').removeAttr('readonly').removeClass('hide');
11936                            $('.plus-quantity').addClass('hide');
11937                        }
11938                    } else {
11939                        $('.quantity-label').removeClass('on');
11940                        $('.switch-quantity').parents('.form-wrap').addClass('disabled');
11941                        $('#prod-quantity').addClass('hide');
11942                        $('.prod-option-quantity, .prod-plus-quantity, .edit-option-quantity').hide();
11943                        $('.plus-quantity').addClass('hide');
11944                    }
11945
11946                    // var normalCnt = $('.prod-option[data-option_mode="normal"] .prod-option-list > li').length;
11947                    if ($('#normal-option').is(':checked') === false) {
11948                        var html = '\
11949                        <div class="product-upload">\
11950                            <div class="title">파일 업로드</div>\
11951                            <div class="download-contents">\
11952                                <span class="cl_icon_upload02" data-cnt="'+fileUpdateCnt+'">업로드</span>\
11953                                <div id="none-option-file"></div>\
11954                            </div>\
11955                        </div>\
11956                        ';
11957
11958                        fileUpdateCnt++;
11959
11960                        $('#add-upload-check').prepend(html);
11961                        if ($('#none-option-file').length > 0) {
11962                            $('.switch-product[value="off"]').prop('checked', true);
11963                            $('#status-append').fadeOut(0);
11964                            $('#sale-calendar').hide();
11965                        }
11966                    }
11967
11968                    if(LUX && (productNumber < 0 || !productNumber || productNumber >= 1000000000) && option_mode == 'normal' && $('.prod-option[data-option_mode="'+option_mode+'"] .prod-option-list > li').length == 1) {
11969                        addProductOption('normal');    
11970                    }
11971
11972                    var cnt = $('.prod-option[data-option_mode="'+option_mode+'"] .prod-option-list > li').length;
11973                    if(option_mode == 'normal') {
11974                        if(cnt == 1) {
11975                            $('.prod-option[data-option_mode="normal"]').addClass('hide');
11976                            $('#normal-option').prop('checked', false);
11977                        }
11978                    } else {
11979                        if(cnt == 0) {
11980                            $('.prod-option[data-option_mode="'+option_mode+'"]').addClass('hide');
11981                            $('#'+option_mode+'-option').prop('checked', false);
11982                        }
11983                        if(option_mode == 'text' && cnt < 7) {
11984                            $('.prod-option[data-option_mode="text"] > .prod-option-add').removeClass('disabled');
11985                        }
11986                    }
11987
11988                    if($('.prod-option-tab .prod-option.hide').length == 3) {
11989                        $('.prod-option-tab').addClass('hide');
11990                    }
11991                    if($('.prod-option-edit').length <= 2) {
11992                        $('.edit-option-delete').addClass('hide');
11993                    } else {
11994                        $('.edit-option-delete').removeClass('hide');
11995                    }
11996
11997                    modal.modal('hide');
11998                },'cancel', 'ok', 'cl-p130 cl-cmmodal cl-s-btn w560 cl-p0');            
11999            });
12000            $(document).on('click','.category-lists li', function(e) { 
12001                e.stopPropagation();
12002                $(this).toggleClass('active'); 
12003                var selected = $('.category-lists li.active').map(function() {
12004                    return $(this).text();
12005                }).get().join(', ');
12006                selected = (selected.length==0) ? '카테고리를 선택하세요' : selected;
12007                $('#prod-category-text').text(selected);
12008            });
12009            $(document).on('click','.category-wrap', function(e) { 
12010                var txt = $(this).find('.category-text').text(),
12011                    selected = $.map(txt.split(","), $.trim);
12012                
12013                $.each($('.category-lists li'), function(i,v) {
12014                    var s = $.trim($(this).text());
12015                    if(selected.indexOf(s) > -1) {
12016                        $(this).addClass('active');
12017                    }
12018                });
12019                // $('.category-lists').slideToggle(); 
12020            });
12021            /*--------- move -------------*/
12022            $(document).on('click','.category-title', function() {
12023                var submit = true;
12024                if($('.category-move.delete').length) {
12025                    $.each($('.category-move.delete'), function(i,v) {
12026                        $(this).removeClass('delete').html($.category.moveHandle());
12027                        var txt = $(this).parents('li').find('.category-input').val();
12028                        if(txt.length == 0) {
12029                            submit = false;
12030                            return true;
12031                        }
12032                        $(this).parents('li').find('.category-title').text(txt).removeClass('hide');
12033                    });
12034                }
12035
12036                if(submit) {
12037                    var v = $(this).text();
12038                    if(!$(this).hasClass('hide')) {
12039                        $(this).addClass('hide');
12040                        $(this).siblings('.form-wrap').find('.category-input').val(v).focus();
12041                    }
12042                    $(this).parents('li').find('.category-move').addClass('delete').html($.category.deleteHandle());
12043                }
12044            });
12045            $(document).on('focus', '.category-input', function(e) {
12046                var submit = true;
12047                if($('.category-move.delete').length) {
12048                    $.each($('.category-move.delete'), function(i,v) {
12049                        $(this).removeClass('delete').html($.category.moveHandle());
12050                        var txt = $(this).parents('li').find('.category-input').val();
12051                        if(txt.length == 0) {
12052                            submit = false;
12053                            return true;
12054                        }
12055                        $(this).parents('li').find('.category-title').text(txt).removeClass('hide');
12056                    });
12057                }
12058
12059                $(this).parents('li').find('.category-move').addClass('delete').html($.category.deleteHandle());
12060            });
12061            $(document).on('keyup', '.category-input', function(e) {
12062                var keyCode = e.keyCode,
12063                    search = $(this).val().trim(),
12064                    v = $(this).val().trim();
12065
12066                $(this).parents('.form-wrap').siblings('.category-title').text(v);
12067                if(checkEmojis(v)) {
12068                    e.preventDefault();
12069                    errorEmojisModal('10002');
12070                    return false;
12071                }
12072                if(v.length==0) return false;
12073                if(keyCode == 13) {
12074                    if($.category.check()) {
12075                        // alert('카테고리명 중복입니다');
12076                        var modal = $(this).showModalFlat('','카테고리명 중복입니다',true,false,'','ok','','cl-cmmodal cl-s-btn w560 cl-p130 cl-t80 cl-modal cl-none-title cl-close-btn','','',function() {
12077                            $(document).on('keydown', function(e) {
12078                                if(e.keyCode == 27) modal.modal('hide');
12079                            });
12080                        });
12081                        return false;
12082                    }
12083                    $(this).parents('.form-wrap').siblings('.category-title').removeClass('hide');
12084                    $(this).parents('.form-wrap').siblings('.category-move').removeClass('delete').html($.category.moveHandle());
12085                }
12086            });
12087            $(document).on('blur', '.category-input', function(e) {
12088                if(checkEmojis($(this).val().trim())) {
12089                    e.preventDefault();
12090                    var focus_input = $(this);
12091                    errorEmojisModal('10002');
12092                }
12093            });
12094
12095            $(document).on('click','.item-add', function() {
12096                if($(this).closest('.category-edit').find('li:not(.item-add) .category-title.hide').length > 0) {
12097                    $(this).closest('.category-edit').find('li:not(.item-add) .category-title.hide').eq(0).closest('li').find('.form-wrap .form-group input.category-input').focus();
12098                    return false;
12099                }
12100
12101                $('.category-edit li:last-child').before($('<li><div class="form-wrap"><div class="form-group"><input type="text" class="category-input" required="required"/><label for="input" class="control-label">'+ $.lang[LANG]['editor.block.gallery.category.edit.name'] +'</label><i class="bar"></i></div></div><div class="category-move delete">' + $.category.deleteHandle() + '</div><div class="category-title hide"></div></li>'));
12102                $('.category-input:last-child').focus();
12103            });
12104            $(document).on('click','.category-move.delete', function(e) {
12105                if($(this).closest('.category-edit').children('li:not(.item-add)').length <= 1) {
12106                    $(this).showModalFlat($.lang[LANG]['config.information'], $.lang[LANG]['editor.gallery.category.delete.last'], true, false, '', 'ok','', 'cl-cmmodal cl-s-btn w560 cl-p130 cl-p0 cl-okbtn-pbt70 category-error', false, '', function() {
12107                        $('.modal-dialog.category-error').closest('.flat-modal').next('.modal-backdrop').attr('style','z-index: 10001!important;');
12108                        $('.modal-dialog.category-error').closest('.modal').attr('style','display: block; z-index: 10002;'); 
12109                    });
12110                    return false;
12111                }
12112
12113                ($.category.delete).push($(this).next().text());
12114                $(this).parents('li').find('.category-input').val('');
12115                $(this).parents('li').remove();
12116            });
12117            $(document).on('click','.prod-button .modal-close', function(e) { $.products.close(); });
12118            $(document).on('click','.category-modal .cl-category-modal-ok', function(e) {
12119                var change = [];
12120                var del = $.category.delete;
12121                var categoryRegexp =  /[\[\]|,'"<>{}\/\\:;%&@$!*?\^]/;
12122                var checkRegexp = false;
12123                var checkMin = false;
12124                var checkMax = false;
12125
12126                var category_lists = $('.category-edit .category-title').map(function(){
12127                    var org = $(this).attr('data-org'),
12128                        val = $(this).text().trim();
12129
12130                    if(val.length < 1) checkMin = true;
12131                    if(val.length > 20) checkMax = true;
12132
12133                    if(org != val) change.push(org + '|' + val);
12134                    if(val != '') { 
12135                        if(categoryRegexp.test(val)) checkRegexp = true;
12136                        
12137                        return val;
12138                    }
12139                }).get();
12140
12141                var error_str = '';
12142                if(checkMin)            error_str = $.lang[LANG]['board.enter-min-chars.1'];
12143                else if(checkMax)       error_str = $.lang[LANG]['board.enter-max-chars'];
12144                else if(checkRegexp)    error_str = $.lang[LANG]['board.allowed-chars'];
12145
12146                if(error_str.length > 0) {
12147                    $(this).showModalFlat($.lang[LANG]['config.information'], error_str, true, false, '', 'ok','', 'cl-cmmodal cl-s-btn w560 cl-p130 cl-p0 cl-okbtn-pbt70 category-error', false, '', function() {
12148                        $('.modal-dialog.category-error').closest('.flat-modal').next('.modal-backdrop').attr('style','z-index: 10001!important;');
12149                        $('.modal-dialog.category-error').closest('.modal').attr('style','display: block; z-index: 10002;'); 
12150                    });
12151                    return false;
12152                }
12153
12154                if(checkEmojis(category_lists.toString())) {
12155                    e.preventDefault();
12156                    errorEmojisModal('10002');
12157                    return false;
12158                }
12159
12160                if($.category.check()) {
12161                    // alert('카테고리명 중복입니다');
12162                    var modal = $(this).showModalFlat('','카테고리명 중복입니다',true,false,'','ok','','cl-cmmodal cl-s-btn w560 cl-p130 cl-t80 cl-modal cl-none-title cl-close-btn','','',function() {
12163                        $(document).on('keydown', function(e) {
12164                            if(e.keyCode == 27) modal.modal('hide');
12165                        });
12166                    });
12167                    return false;
12168                }
12169
12170                var $category = $('#prod-category-text');
12171                var cate = ($category.text().trim()) ? $category.text().trim().split(', ') : [];
12172
12173                if(cate.length && del.length) {
12174                    $.each(del, function(i,v) {
12175                        var idx = cate.indexOf(v);
12176                        if(idx > -1) cate.splice(idx, 1)
12177                    });
12178                    $category.text(cate.join(', '));
12179                }
12180
12181                if(cate.length && change.length) {
12182                    $.each(change, function(i,v) {
12183                        var s = v.split('|');
12184                        var idx = cate.indexOf(s[0]);
12185                        if(idx > -1) cate[idx] = s[1];
12186                    });
12187                    $category.text(cate.join(', '));
12188                }
12189                if($category.text() == '') $category.text('카테고리를 선택하세요');
12190                
12191                var pid = ($('.prod-modal').length) ? $('#prod-pid').val() : $('.gallery-ctrl-category').attr('data-pid'),
12192                    gid = $('#prod-no').val();
12193
12194                $.post('/template/gallery/category', { sid : SID, s : category_lists, mode : 'block', seq : pid, gid : gid, change : change, del : del }, function(r) {
12195                    if(typeof r.error !='undefined' && r.error) {
12196                        alert(r.error);
12197                        return false;
12198                    }
12199
12200                    $('#prod-category-lists ul, .toolbar-category .item-submenu').empty();
12201                    $('.gallery-category li.category-text').remove();
12202                    var s = '';
12203                    $.each(category_lists, function(i,v) {
12204                        var li_str = '<li>' + v + '</li>',
12205                            li_str2 = '<li class="category-text">' + v + '</li>';
12206                        s = s + li_str;
12207                        $('#prod-category-lists ul').append(li_str);
12208                        $('.toolbar-category .item-submenu').append(li_str);
12209                        $('.gallery-category .gallery-category-onoff').before(li_str2);
12210                    });
12211                    $.gallery.cates = s;
12212                    $('#prod-category, .gallery-ctrl-category, .gallery-modal').attr('data-category',category_lists.toString());
12213
12214
12215                    $category = $('#prod-category-text');
12216                    var cate = ($category.text().trim()) ? $category.text().trim().split(', ') : [];
12217                    $.each($('.category-lists li'), function(i,v) {
12218                        // IE ERROR_includes__H.20210603
12219                        // if(cate.includes($(this).text())) $(this).addClass('active');
12220                        if($.inArray($(this).text(),cate) > -1) $(this).addClass('active');
12221                    });
12222                    $.category.close();
12223                    if($('.gallery-modal').hasClass('shopping') && $('.prod-modal.cl-p-modal').length == 0) $.gallery.show($.gallery.block_id,1,$.gallery.category);
12224                    $.gallery.update = true;
12225
12226                }, 'json');
12227            });
12228        },
12229        open : function(s) {
12230            if($('.cl-category-modal-backdrop').length >0) $('.cl-category-modal-backdrop').remove();
12231            var text = (typeof s != 'string') ? [] : s.split(',');
12232            var $backdrop = $('<div class="cl-category-modal-backdrop"></div>'),
12233                $title = $('<h1 class="category-modal-title">' + $.lang[LANG]['editor.block.gallery.category.edit.title'] + '</h1>'),
12234                $modal = $('<div class="cl-category-modal cl-p-modal category-modal"></div>'),
12235                $lists = $('<ul class="category-edit"></ul>'),
12236                $item_add = $('<li class="item-add"></li>');
12237                $modal_footer = $('<div class="cl-category-modal-footer"><div class="cl-category-modal-close">' + $.lang[LANG]['editor.cancel'] + '</div><div class="cl-category-modal-ok">' + $.lang[LANG]['config.save'] + '</div></div>');
12238
12239            $.each(text, function(i,v) {
12240                var item = "\
12241                    <li>\
12242                        <div class='form-wrap'>\
12243                            <div class='form-group'>\
12244                                <input type='text' class='category-input' required='required' value='" + v + "'>\
12245                                <label for='input' class='control-label'>"+ $.lang[LANG]['editor.block.gallery.category.edit.name'] +"</label><i class='bar'></i>\
12246                            </div>\
12247                        </div>\
12248                        <div class='category-move'>" + $.category.moveHandle() + "</div>\
12249                        <div class='category-title' data-org='" + v + "'>" + v + "</div>\
12250                    </li>\
12251                ";
12252                $lists.append($(item));
12253            });
12254
12255            // $('.category-edit').append($(item));
12256
12257            $lists.append($item_add);
12258            $modal.append($title).append($lists).append($modal_footer);
12259            $backdrop.append($modal);
12260            $('body').append($backdrop);
12261            $backdrop.fadeIn(500);
12262            $('.category-edit').sortable({
12263                handle : ".category-move .cl-sort-handle"
12264            });
12265        },
12266        close : function() {
12267            $('.cl-category-modal-backdrop').fadeOut(500, function() { $(this).remove(); });
12268        },
12269        check : function() {
12270            var category = $.category.list(),
12271                // set_category = new Set(category);
12272                set_category = category.filter(onlyUnique);
12273
12274            // IE ERROR (filter)
12275            // check = category.filter((s => v => s.has(v) || !s.add(v))(new Set)); 
12276
12277            // 변경 없이 저장시 중복 체크 이슈 생김
12278            // return (category.length !== set_category.size) ? true : false;
12279            return (category.toString() !== set_category.toString()) ? true : false;
12280        },
12281        list : function() {
12282            var category_lists = $('.category-edit .category-title').map(function(){
12283                var org = $(this).attr('data-org'),
12284                    val = $(this).text().trim();
12285                if($(this).text().trim()) {
12286                    return $(this).text().trim();
12287                }
12288            }).get();
12289            return category_lists;            
12290        }
12291    }
12292
12293
12294    $.shoppingmall = {        
12295        orderStatusDetailsModal: function(sid, pnum, onum, ognum, kind) {
12296            if(typeof sid == "undefined" || typeof pnum == "undefined" || typeof onum == "undefined" || typeof kind == "undefined") {
12297                alert('정보가 올바르지 않습니다');
12298                return false;
12299            }
12300
12301            $.post('/_check_order', { sid:sid, pnum:pnum, onum:onum, ognum:ognum,mode:'kind/'+kind }, function(data) {
12302
12303                if(typeof data.error != "undefined" && data.error) {
12304                    $(this).showModalFlat('ERROR', data.error, true, false, '', 'close');
12305                    return false;
12306                }
12307                var c_data = data.r,
12308                    status = c_data.odata.reason_d_status,
12309                    kind_str = c_data.odata.kind_str,
12310                    product_status_str = c_data.odata.product_status_str,
12311                    payClass = c_data.odata.class;
12312                   
12313                    option_name = (typeof c_data.pdata.option != "undefined" && c_data.pdata.option) ? c_data.pdata.option : '',
12314                    etc_str = (typeof c_data.pdata.etc_date != "undefined" && c_data.pdata.etc_date) ? '<br><span class="osd-gray">선택일자: '+c_data.pdata.etc_date+'</span>' : '',
12315
12316                    // option_str = (option_name) ? '<br><span class="osd-gray">옵션: '+option_name+'</span>' : '',
12317                    now_status_html = '',
12318                    delivery_info = c_data.pay_info.delivery,
12319                    option_title = (c_data.pdata.option_type == 'A') ? '추가옵션: ' + (c_data.pdata.option_group ? c_data.pdata.option_group + ': ' : '') : '옵션: ';
12320                if(option_name) {
12321                    option_str = (c_data.pdata.option_text_str)? '<br><span class="osd-gray">' + option_title + option_name+' / '+c_data.pdata.option_text_str+'</span>':'<br><span class="osd-gray">'+ option_title + option_name+'</span>';
12322                } else {
12323                    option_str = (c_data.pdata.option_text_str)? '<br><span class="osd-gray">' + option_title + c_data.pdata.option_text_str + '</span>' : '';
12324                }
12325                if(etc_str) option_str += etc_str;
12326                
12327                if(status.length > 1) {
12328                    var now_title = c_data.odata.product_status_str.replace(/ /g,'').replace('거부재발송','거부'),
12329                        now_msg = (status.indexOf('W') > -1) ? c_data.odata.h_msg : 
12330
12331                        c_data.odata.adm_msg,
12332                        now_msg_html = (jQuery.inArray(status, ['CY','EY','RY']) > -1) ? '' : '\
12333                                <tr>\
12334                                    <td class="label">' + now_title + '사유</td>\
12335                                    <td>' + now_msg + '</td>\
12336                                </tr>\
12337                        ',
12338                        now_msg_date = (jQuery.inArray(status, ['EW','RW']) > -1) ? c_data.odata.h_date : c_data.odata.adm_date;
12339
12340                    now_status_html = '\
12341                        <h6 class="osd-title">' + now_title + '정보</h6>\
12342                        <table class="osd-table">\
12343                            <tbody>\
12344                                <tr>\
12345                                    <td class="label">' + now_title + '일자</td>\
12346                                    <td>' + now_msg_date + '</td>\
12347                                </tr>\
12348                    ';
12349                    if(status != 'CY' && status != 'RY') {
12350                        $.each(delivery_info, function(i, v){
12351                            delivery_info[i] = (v===null)? '':v;
12352                        });
12353                        if(status == 'RD' || status == 'ED' || status == 'EY'|| status == 'ES') {
12354                            if(delivery_info.new_postcode !== '') {
12355                                now_status_html+= '<tr>\
12356                                            <td class="label">배송지1</td>\
12357                                            <td>' + delivery_info.new_postcode + ' ' + delivery_info.new_addr + ' ' + delivery_info.new_addr2 + '</td>\
12358                                        </tr>\
12359                                ';
12360                            }
12361
12362                            if(delivery_info.new_delivery_type) {
12363                                now_status_html += '\
12364                                    <tr>\
12365                                        <td class="label">배송수단</td>\
12366                                        <td>' + $.lang[LANG]['shopping.delivery.template.delivery_type.' + delivery_info.new_delivery_type.toLowerCase()] + '</td>\
12367                                    </tr>\
12368                                '
12369                            }
12370
12371                            if(delivery_info.new_delivery_company) {
12372                                now_status_html+= '\
12373                                        <tr>\
12374                                            <td class="label">배송회사</td>\
12375                                            <td>' + delivery_info.new_delivery_str + '</td>\
12376                                        </tr>';
12377                            }
12378                            if(delivery_info.new_delivery_str != '자가배송' && delivery_info.new_delivery_number != '') {
12379                                now_status_html+= '<tr>\
12380                                            <td class="label">송장번호</td>\
12381                                            <td>' + delivery_info.new_delivery_number + '</td>\
12382                                        </tr>';
12383                            }
12384                        }
12385                        
12386                        now_status_html += now_msg_html;
12387                    }
12388                    now_status_html+= '\
12389                            </tbody>\
12390                        </table>\
12391                    ';
12392                }
12393
12394                var r_requests = (c_data.odata.requests != '')? c_data.odata.requests : '-';
12395                var modal_str = '\
12396                    <div class="osd-body">\
12397                        \
12398                        <h6 class="osd-title">기본정보</h6>\
12399                        <table class="osd-table">\
12400                            <tbody>\
12401                                <tr>\
12402                                    <td class="label">
12402주문번호</td>\
12403                                    <td>' + ognum + '</td>\
12404                                </tr>\
12405                                <tr>\
12406                                    <td class="label">상품명</td>\
12407                                    <td>' + c_data.pdata.name + option_str + '</td>\
12408                                </tr>\
12409                                <tr>\
12410                                    <td class="label">주문수량</td>\
12411                                    <td>' + c_data.odata.quantity + '개</td>\
12412                                </tr>';
12413                                modal_str += '<tr>\
12414                                        <td class="label">'+kind_str+'상태</td>\
12415                                        <td>' + product_status_str + '</td>\
12416                                    </tr>';
12417                                if ((status.indexOf('R') !== -1 || (c_data.odata.p_status != 'W' && status.indexOf('C') !== -1)) && (payClass == '무통장 입금' || payClass == '가상계좌')) {
12418                                    modal_str += '<tr>\
12419                                        <td class="label">환불계좌</td>\
12420                                        <td>' + c_data.odata.return_bank + ' ' + c_data.odata.return_bank_number + '<br>' + c_data.odata.return_bank_name + '</td>\
12421                                    </tr>';
12422                                }
12423                            modal_str += '</tbody>\
12424                        </table>\
12425                        \
12426                        ' + now_status_html +'\
12427                        \
12428                        <h6 class="osd-title">' + kind_str + '요청정보</h6>\
12429                        <table class="osd-table">\
12430                            <tbody>\
12431                                <tr>\
12432                                    <td class="label">' + kind_str + '요청일자</td>\
12433                                    <td>' + c_data.odata.date + '</td>\
12434                                </tr>\
12435                                <tr>\
12436                                    <td class="label">' + kind_str + '요청사유</td>\
12437                                    <td>' + c_data.odata.reason + '</td>\
12438                                </tr>\
12439                                <tr>\
12440                                    <td class="label">상세사유</td>\
12441                                    <td>' + r_requests + '</td>\
12442                                </tr>\
12443                            </tbody>\
12444                        </table>\
12445                        \
12446                    </div>\
12447                    \
12448                    ';
12449
12450                /*
12451                var c_data = data.r,
12452                    status = c_data.odata.d_status,
12453                    kind_str = c_data.odata.kind_str,
12454                    product_status_str = c_data.odata.product_status_str,
12455                    option_name = (typeof c_data.pdata.option != "undefined" && c_data.pdata.option) ? c_data.pdata.option : '',
12456                    option_str = (option_name) ? '<br><span>옵션: '+option_name+'</span>' : '',
12457                    status_str = '',
12458                    response_str = '',
12459                    request_str = '\
12460                        <table class="osd-table">\
12461                            <tbody>\
12462                                <tr>\
12463                                    <td class="label">' + kind_str + '요청사유</td>\
12464                                    <td>' + c_data.odata.reason + '</td>\
12465                                </tr>\
12466                                <tr>\
12467                                    <td class="label">상세사유</td>\
12468                                    <td>' + c_data.odata.requests + '</td>\
12469                                </tr>\
12470                            </tbody>\
12471                        </table>\
12472                    ';
12473
12474                if(jQuery.inArray(status, ['CN','CY','EN','EW','RN','RW']) > -1) {
12475                    var status_str = (status.indexOf('W') > -1) ? c_data.odata.h_msg : c_data.odata.adm_msg,
12476                        status_msg = (jQuery.inArray(status, ['CY']) > -1) ? '' : '\
12477                                <tr>\
12478                                    <td class="label">' + c_data.odata.product_status_str.replace(/ /g,'') + '사유</td>\
12479                                    <td>' + status_str + '</td>\
12480                                </tr>\
12481                    ',
12482                        status_date = (jQuery.inArray(status, ['EW','RW']) > -1) ? c_data.odata.h_date : c_data.odata.adm_date;
12483
12484                    status_str = '\
12485                        <h6 class="osd-title">' + c_data.odata.product_status_str.replace(/ /g,'') + '정보</h6>\
12486                        <table class="osd-table">\
12487                            <tbody>\
12488                                <tr>\
12489                                    <td class="label">' + c_data.odata.product_status_str.replace(/ /g,'') + '일자</td>\
12490                                    <td>' + status_date + '</td>\
12491                                </tr>\
12492                                ' + status_msg + '\
12493                            </tbody>\
12494                        </table>\
12495                    ';
12496                }
12497
12498                if(jQuery.inArray(status, ['EN', 'EW', 'RN', 'RW']) > -1) {
12499                    response_str = '\
12500                                <tr>\
12501                                    <td class="label">' + kind_str + ' ' + c_data.odata.h_kind_str + '사유</td>\
12502                                    <td>' + c_data.odata.h_reason + '</td>\
12503                                </tr>\
12504                                <tr>\
12505                                    <td class="label">상세사유</td>\
12506                                    <td>' + c_data.odata.h_msg + '</td>\
12507                                </tr>\
12508                    ';
12509                }
12510
12511                var modal_str = '\
12512                    <div class="osd-body">\
12513                        \
12514                        <h6 class="osd-title">기본정보</h6>\
12515                        <table class="osd-table">\
12516                            <tbody>\
12517                                <tr>\
12518                                    <td class="label">
12518주문번호</td>\
12519                                    <td>' + onum + '</td>\
12520                                </tr>\
12521                                <tr>\
12522                                    <td class="label">상품명</td>\
12523                                    <td>' + c_data.pdata.name + option_str + '</td>\
12524                                </tr>\
12525                                <tr>\
12526                                    <td class="label">주문수량</td>\
12527                                    <td>' + c_data.odata.quantity + '개</td>\
12528                                </tr>\
12529                                <tr>\
12530                                    <td class="label">' + kind_str + '요청일자</td>\
12531                                    <td>' + c_data.odata.date + '</td>\
12532                                </tr>\
12533                                <tr>\
12534                                    <td class="label">진행상태</td>\
12535                                    <td>' + product_status_str + '</td>\
12536                                </tr>\
12537                                ' + response_str + '\
12538                            </tbody>\
12539                        </table>\
12540                        \
12541                        ' + status_str +'\
12542                        \
12543                        <h6 class="osd-title">' + kind_str + '요청정보</h6>\
12544                        ' + request_str +'\
12545                        \
12546                    </div>\
12547                    \
12548                    ';
12549
12550                */
12551                var osdModal = $(this).showModalFlat(kind_str + ' 상세정보', modal_str, true, false, '', 'ok', '', 'cl-s-order-status-details cl-modal cl-s-btn cover', false);
12552
12553            },'json');
12554
12555        },
12556        shopGradeBenefitModal: function(sid, uid) {
12557            
12558            if(typeof sid == "undefined") {
12559                alert('정보가 올바르지 않습니다');
12560                return false;
12561            }
12562            $.post('_shopgradeMypage', { sid:sid, uid:uid }, function(data) {
12563
12564                if(typeof data.error != "undefined" && data.error) {
12565                    $(this).showModalFlat('ERROR', data.error, true, false, '', 'close');
12566                    return false;
12567                }
12568
12569                var d       = (data && data.data) ? data.data : {};
12570                var grades  = Array.isArray(d.grades) ? d.grades :[];
12571                var current = d.member_grade_id;
12572
12573                // --- 1. 쿠폰 처리를 위해 필요한 변수들 선언 ---
12574                var pol        = (d && Array.isArray(d.policies) && d.policies.length) ? d.policies[0] : null;
12575                var cycleType  = pol ? String(pol.cycle_type) : '2'; // 1=주간, 2=월간
12576                var accMonths  = pol && pol.accumulate_month ? parseInt(pol.accumulate_month, 10) : 6;
12577                var coupons    = (d && Array.isArray(d.coupons)) ? d.coupons :[]; // 서버에서 넘겨받은 쿠폰 리스트
12578
12579                function esc(s){
12580                    s = (s == null) ? '' : String(s);
12581                    return s.replace(/[&<>"']/g, function(m){ return ({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;'}[m]); });
12582                }
12583                function num(n){
12584                    if (n == null || n === '') return '';
12585                    var v = parseFloat(String(n).replace(/[^0-9.-]/g,''));
12586                    if (!isFinite(v)) return '';
12587                    try { return v.toLocaleString('ko-KR'); }
12588                    catch(e){ return String(v).replace(/\B(?=(\d{3})+(?!\d))/g,','); }
12589                }
12590
12591                // 등급 기준
12592                function renderCriteria(g){
12593                    var lines =[];
12594                    if (String(g.grade_seq) === '0') {
12595                        g = $.extend({}, g, { use_auto: '0' });
12596                    }
12597
12598                    if (String(g.use_auto) === '1') {
12599                        var min = g.use_auto_amount_min;
12600                        var max = g.use_auto_amount_max;
12601                        var cnt = g.use_auto_count;
12602
12603                        if (min && max && String(min) !== String(max)) {
12604                            lines.push('구매금액 </br>' + num(min) + '원 이상 ~</br>' + num(max) + '원 미만');
12605                        } else if (min) {
12606                            lines.push('구매금액 ' + num(min) + '원 이상');
12607                        }
12608                        if (cnt && String(cnt) !== '0') {
12609                            lines.push('구매횟수 ' + num(cnt) + '회 이상');
12610                        }
12611                    } else if (String(g.grade_seq) === '0') {
12612                        // 자동 산정 아님 + 최초 등급(가입 시 부여)
12613                        lines.push('회원가입 시 모두 적용');
12614                    }
12615
12616                    return lines.length ? lines.join('<br>') : '-';
12617                }
12618
12619                // 추가 적립
12620                function renderPoint(g){
12621                    if (String(g.reserve_use) !== '1') return '-';
12622
12623                    var t    = String(g.reserve_type || '0'); // 0=%, 1=원
12624                    var val  = g.reserve_value;
12625                    var cap  = g.reserve_max;
12626                    var cond = g.reserve_amount;
12627
12628                    var s = '';
12629                    if (cond) s += num(cond) + '원 이상 결제시 </br>';
12630                    if (t === '0') {
12631                        var p = parseFloat(val);
12632                        s += (isFinite(p) ? p + '%' : '') + ' 적립';
12633                    } else {
12634                        s += (val ? num(val) + '원' : '') + ' 적립';
12635                    }
12636                    if (cap)  s += '</br>(최대 ' + num(cap) + '원)';
12637                    
12638
12639                    return s || '-';
12640                }
12641
12642                // 추가 할인
12643                function renderDiscount(g){
12644                    if (String(g.discount_use) !== '1') return '-';
12645
12646                    var t    = String(g.discount_type || '0'); // 0=%, 1=원
12647                    var val  = g.discount_value;
12648                    var cap  = g.discount_max;
12649                    var cond = g.discount_amount;
12650
12651                    var s = '';
12652                    if (cond) s += num(cond) + '원 이상 결제시 </br>';
12653                    if (t === '0') {
12654                        var base = parseFloat(val);
12655                        var off  = isFinite(base) ? base : null;
12656                        s += (off != null ? off + '%' : '') + ' 할인';
12657                    } else {
12658                        s += (val ? num(val) + '원' : '') + ' 할인';
12659                    }
12660                    if (cap)  s += '</br>(최대 ' + num(cap) + '원)';
12661                    
12662
12663                    return s || '-';
12664                }
12665
12666                function renderDeliveryBenefit(g){
12667                    return String(g.delivery_benefit || '0') === '1' ? '배송비 무료' : '-';
12668                }
12669
12670                // --- 2. 새로 추가된 쿠폰 노출 함수 ---
12671                function renderCoupon(g){
12672                    if (!coupons.length) return '-';
12673
12674                    var gSeq = String(g.seq); // 현재 반복중인 등급의 고유번호
12675                    var matchedCoupons =[];
12676
12677                    // 1) 전체 쿠폰 중 현재 등급(gSeq)이 포함된 쿠폰만 찾기
12678                    for (var i = 0; i < coupons.length; i++) {
12679                        var cp = coupons[i];
12680                        // shopping_grade_seq 에 "80,9" 형태로 들어있으므로 콤마(,)로 분리
12681                        var gradeArr = String(cp.shopping_grade_seq || '').split(',');
12682                        
12683                        if (gradeArr.indexOf(gSeq) !== -1) {
12684                            matchedCoupons.push(cp);
12685                        }
12686                    }
12687
12688                    if (matchedCoupons.length === 0) return '-';
12689
12690                    // 2) 화면에 노출할 텍스트 만들기
12691                    var cycleText = (cycleType === '1') ? '매주' : '매월'; // 지급 주기
12692                    var lines =[];
12693
12694                    for (var j = 0; j < matchedCoupons.length; j++) {
12695                        var c = matchedCoupons[j];
12696                        var val = num(c.sale_value); // 금액(할인수치) 콤마 처리
12697                        var unit = (c.sale_unit === 'A') ? '원' : '%'; 
12698                        var count = c.grade_member_coupon_count;     // 지급 장수
12699
12700                        // 쿠폰 종류에 따른 문구 처리 (배송비 쿠폰 등)
12701                        var benefitName = '할인쿠폰';
12702                        if (c.benefit === 'DELIVERY') {
12703                            benefitName = '배송비무료쿠폰';
12704                            val = ''; // 배송비무료쿠폰은 금액 노출 안 함
12705                            unit = '';
12706                        }
12707
12708                        // 예: "매월 10% 할인쿠폰 2장", "매주 5,000원 할인쿠폰 1장"
12709                        lines.push(cycleText + ' ' + val + unit + ' ' + benefitName + ' ' + count + '장');
12710                    }
12711
12712                    return lines.join('<br>');
12713                }
12714
12715                var rows = '';
12716                for (var i=0; i<grades.length; i++) {
12717                    var g = grades[i] || {};
12718                    var seq = g.seq != null ? parseInt(g.seq, 10) : null;
12719                    var isCur = (current != null && seq != null && current === seq);
12720
12721                    rows += ''
12722                        + '<div class="sgb-row' + (isCur ? ' is-current' : '') + '">'
12723                        + '<div class="sgb-cell sgb-col-name">'
12724                            + esc(g.grade_name || ('등급#' + (seq == null ? '' : seq)))
12725                            + (isCur ? '<span class="sgb-badge">현재 등급</span>' : '')
12726                        + '</div>'
12727                        + '<div class="sgb-cell">' + renderCriteria(g)  + '</div>'
12728                        + '<div class="sgb-cell">' + renderPoint(g)     + '</div>'
12729                        + '<div class="sgb-cell">' + renderDiscount(g)  + '</div>'
12730                        + '<div class="sgb-cell">' + renderDeliveryBenefit(g) + '</div>'
12731                        + '<div class="sgb-cell">' + renderCoupon(g)    + '</div>'
12732                        + '</div>';
12733                }
12734
12735                // 정책 기반 안내문
12736                var benefitNotes = [];
12737                var couponNotes  = [];
12738
12739                if (cycleType === '1') { // 주간
12740                benefitNotes.push('최근 1주일간의 구매 금액을 반영하여 회원 등급이 결정되며 매주 월요일 반영됩니다.');
12741                couponNotes.push('할인쿠폰은 매주 월요일에 지급되며 마이페이지 > 쿠폰에서 확인하실 수 있습니다.');
12742                } else { // 월간(기본)
12743                benefitNotes.push('최근 ' + (accMonths || 6) + '개월 간의 구매 금액을 반영하여 회원 등급이 결정되며 매월 1일 반영됩니다.');
12744                couponNotes.push('할인쿠폰은 매월 1일에 지급되며 마이페이지 > 쿠폰에서 확인하실 수 있습니다.');
12745                }
12746
12747                // 공통 안내(원하면 유지/삭제)
12748                benefitNotes.push('구매 금액은 실결제 금액에 한하여 회원 등급 산정에 반영됩니다.');
12749                benefitNotes.push('실결제 금액은 배송비, 쿠폰, 적립금, 등급 할인가를 제외한 금액입니다.');
12750
12751                // 최종 모달 HTML (헤더는 상단 고정, 하단에 반복 행) — div 기반 테이블
12752                modal_str = '\
12753                <div class="osd-body">\
12754                    <style>\
12755                    .shopgrade-benefit-modal{width:1100px !important;max-width:1100px !important;min-width:1100px !important;}\
12756                    .shopgrade-benefit-modal .modal-content{width:1100px !important;padding:0 !important;box-sizing:border-box;}\
12757                    .shopgrade-benefit-modal .modal-content *:not(.modal-title):not(.sgb-badge):not(svg):not(path){font-size:14px !important;font-weight:normal;}\
12758                    .shopgrade-benefit-modal .modal-content > button.close{position:absolute !important;top:20px !important;right:20px !important;width:16px !important;height:16px !important;margin:0 !important;padding:0 !important;opacity:1 !important;box-sizing:border-box;}\
12759                    .shopgrade-benefit-modal .modal-content > button.close svg{width:16px !important;height:16px !important;}\
12760                    .shopgrade-benefit-modal .modal-title{width:166px !important;height:36px !important;min-height:36px !important;max-height:36px !important;margin:50px auto 40px !important;padding:0 !important;font-size:24px !important;
12760font-weight:normal !important;line-height:36px !important;text-align:center !important;white-space:nowrap;}\
12761                    .shopgrade-benefit-modal .modal-body{width:900px !important;max-width:900px !important;margin:0 auto !important;padding:0 !important;}\
12762                    .shopgrade-benefit-modal .osd-body,.shopgrade-benefit-modal .sgb-wrap,.shopgrade-benefit-modal .sgb-scroller{width:900px;margin:0 auto;padding:0;text-align:left;color:#696c71;box-sizing:border-box;}\
12763                    .shopgrade-benefit-modal .sgb-table{width:900px;border-top:solid 1px var(--color-line-primary);border-bottom:solid 1px var(--color-line-primary);overflow:hidden;box-sizing:border-box;}\
12764                    .shopgrade-benefit-modal .sgb-row{display:grid;grid-template-columns:100px 170px 180px 180px 120px 150px;width:900px;margin:0;padding:0;box-sizing:border-box;}\
12765                    .shopgrade-benefit-modal .sgb-header{height:50px;min-height:50px;color:#222428;border-bottom:solid 1px var(--color-line-primary);}\
12766                    .shopgrade-benefit-modal .sgb-header .sgb-cell{height:50px;min-height:50px;padding:0 0 0 12px;display:flex;align-items:center;color:#222428;line-height:50px;}\
12767                    .shopgrade-benefit-modal .sgb-row:not(.sgb-header){min-height:60px;}\
12768                    .shopgrade-benefit-modal .sgb-cell{position:relative;margin:0;padding:17.5px 0 17.5px 12px;line-height:25px;text-align:left;word-break:keep-all;box-sizing:border-box;}\
12769                    .shopgrade-benefit-modal .sgb-row.is-current{background:#f0f7ff;}\
12770                    .shopgrade-benefit-modal .modal-content .sgb-badge{position:absolute;left:0;top:0;display:block;width:49px;height:16px;margin:0;padding:0;border-radius:0px 0px 5px 0px;background:#4789e7;color:#fff !important;font-size:10px !important;line-height:16px;text-align:center;}\
12771                    .shopgrade-benefit-modal .sgb-notes{width:900px;margin:25px auto 0;padding:0;color:#696c71;box-sizing:border-box;}\
12772                    .shopgrade-benefit-modal .sgb-notes h4{margin:0 0 10px;padding:0;color:#222428;font-size:14px !important;font-weight:500 !important;line-height:20px;}\
12773                    .shopgrade-benefit-modal .sgb-notes h4 + ul + h4{margin-top:25px;}\
12774                    .shopgrade-benefit-modal .sgb-notes ul{margin:0;padding-left:0;list-style:none !important;}\
12775                    .shopgrade-benefit-modal .sgb-notes li{position:relative;margin:0;padding-left:12px;display:block;line-height:20px;color:#696c71;}\
12776                    .shopgrade-benefit-modal .sgb-notes li + li{margin-top:5px;}\
12777                    .shopgrade-benefit-modal .sgb-notes li:before{content:\"\";position:absolute;left:2px;top:9px;width:3px;height:3px;border-radius:50%;background:#696c71;}\
12778                    .shopgrade-benefit-modal .modal-footer{display:flex !important;justify-content:center !important;align-items:center !important;margin-top:40px !important;padding:0 0 249px !important;}\
12779                    .shopgrade-benefit-modal .modal-footer:before,.shopgrade-benefit-modal .modal-footer:after{display:none !important;content:none !important;}\
12780                    .shopgrade-benefit-modal .modal-footer .btn{width:240px !important;height:50px !important;margin:0 !important;padding:0 !important;line-height:50px !important;}\
12781                    @media only screen and (min-width:768px) and (max-width:991px){\
12782                    .shopgrade-benefit-modal,.shopgrade-benefit-modal .modal-content{width:100% !important;min-width:0 !important;max-width:100% !important;}\
12783                    .shopgrade-benefit-modal .modal-body{width:calc(100% - 30px) !important;min-width:0 !important;max-width:calc(100% - 30px) !important;margin-left:auto !important;margin-right:auto !important;}\
12784                    .shopgrade-benefit-modal .osd-body,.shopgrade-benefit-modal .sgb-wrap,.shopgrade-benefit-modal .sgb-scroller,.shopgrade-benefit-modal .sgb-table,.shopgrade-benefit-modal .sgb-row,.shopgrade-benefit-modal .sgb-notes{width:100% !important;min-width:0 !important;max-width:100% !important;}\
12785                    .shopgrade-benefit-modal .sgb-scroller{overflow-x:visible !important;}\
12786                    .shopgrade-benefit-modal .sgb-row{grid-template-columns:90px minmax(0,1fr) minmax(0,1.05fr) minmax(0,1.05fr) minmax(0,.8fr) minmax(0,1fr) !important;}\
12787                    }\
12788                    @media only screen and (max-width:767px){\
12789                    .shopgrade-benefit-modal,.shopgrade-benefit-modal .modal-content{width:100% !important;min-width:0 !important;max-width:100% !important;}\
12790                    .shopgrade-benefit-modal .modal-body{width:calc(100% - 30px) !important;min-width:0 !important;max-width:calc(100% - 30px) !important;margin-left:auto !important;margin-right:auto !important;}\
12791                    .shopgrade-benefit-modal .osd-body,.shopgrade-benefit-modal .sgb-wrap,.shopgrade-benefit-modal .sgb-scroller,.shopgrade-benefit-modal .sgb-notes{width:100% !important;min-width:0 !important;max-width:100% !important;}\
12792                    .shopgrade-benefit-modal .sgb-scroller{overflow-x:auto !important;overflow-y:hidden !important;-webkit-overflow-scrolling:touch;scrollbar-width:thin;}\
12793                    .shopgrade-benefit-modal .sgb-scroller::-webkit-scrollbar{width:10px;height:10px;}\
12794                    .shopgrade-benefit-modal .sgb-table,.shopgrade-benefit-modal .sgb-row{width:900px !important;min-width:900px !important;max-width:none !important;}\
12795                    .shopgrade-benefit-modal .modal-footer .btn{width:300px !important;min-width:300px !important;max-width:300px !important;height:50px !important;min-height:50px !important;max-height:50px !important;line-height:50px !important;}\
12796                    }\
12797                    </style>\
12798                    <div class="sgb-wrap">\
12799                    <div class="sgb-scroller">\
12800                        <div class="sgb-table">\
12801                        <div class="sgb-row sgb-header">\
12802                            <div class="sgb-cell">등급명</div>\
12803                            <div class="sgb-cell">등급 기준</div>\
12804                            <div class="sgb-cell">추가 적립</div>\
12805                            <div class="sgb-cell">추가 할인</div>\
12806                            <div class="sgb-cell">배송 혜택</div>\
12807                            <div class="sgb-cell">쿠폰</div>\
12808                        </div>\
12809                        '+ rows +'\
12810                        </div>\
12811                    </div>\
12812                    <div class="sgb-notes">\
12813                        <h4>등급 혜택 안내</h4>\
12814                        <ul>'+ benefitNotes.map(function(t){return "<li>"+esc(t)+"</li>";}).join('') +'</ul>\
12815                        <h4>쿠폰 안내</h4>\
12816                        <ul>'+ couponNotes.map(function(t){return "<li>"+esc(t)+"</li>";}).join('') +'</ul>\
12817                    </div>\
12818                    </div>\
12819                </div>';
12820                var osdModal = $(this).showModalFlat('회원 등급별 혜택', modal_str, true, false, '', 'ok', '', 'modal-default modal-dialog cl-cmmodal w1100 cover shopgrade-benefit-modal', true);
12821
12822            },'json');
12823
12824        },
12825        orderCancelModal: function(sid, pnum, onum, ognum, status, dStatus, pclass) {
12826            if(typeof sid == "undefined" || typeof pnum == "undefined" || typeof onum == "undefined") {
12827                alert('정보가 올바르지 않습니다');
12828                return false;
12829            }
12830            var escrow = status;
12831            $.post('/_check_order', { sid:sid, pnum:pnum, onum:onum, mode:'cancel', ognum: ognum }, function(data) {
12832                var LUX = false;
12833                if(data.lux) LUX = data.lux;
12834                if(typeof data.error != "undefined" && data.error) {
12835                    $(this).showModalFlat('ERROR', data.error, true, false, '', 'close');
12836                    return false;
12837                }
12838
12839
12840                var c_data = data.r, checkboxNone = '', noneAll = '', noneChecked = '', checkNoneAll = '', checkEscrowFooter = '', checkEscrowClass = '', checkDepositCancel = '';
12841                var checkEscrow = '';
12842                var dtl = c_data.delivery_template_list;
12843                var used_code_coupon = false;
12844                
12845                if (escrow == 'Y') {
12846                    checkboxNone = 'checked';
12847                    noneAll = ' noneAll';
12848                    checkNoneAll = 'fule';
12849                    checkEscrow = '<div class="escrow-warring top-escrow">\
12850                                    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 13" width="15" height="15">\
12851                                        <path fill="#4789e7" d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/>\
12852                                        <rect fill="#4789e7" x="6" y="3" width="1" height="5"/>\
12853                                        <rect fill="#4789e7" x="6" y="9" width="1" height="1"/>\
12854                                    </svg>\
12855                                    에스크로 결제 상품은 취소/반품 요청 시 전체선택만 가능합니다.\
12856                                </div>';
12857
12858                    checkEscrowFooter = '<div class="escrow-warring bottom-escrow">\
12859                                            <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 13" width="15" height="15">\
12860                                                <path fill="#4789e7" d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/>\
12861                                                <rect fill="#4789e7" x="6" y="3" width="1" height="5"/>\
12862                                                <rect fill="#4789e7" x="6" y="9" width="1" height="1"/>\
12863                                            </svg>\
12864                                            에스크로 환불 안내\
12865                                            <div class="escrow-return-info">- 취소처리 시 구매자의 환불정산액에서 취소 수수료(330원)가 차감됩니다.</div>\
12866                                            <div class="escrow-return-info">- 환불정산액은 취소처리 후 1~3영업일 후에 지급됩니다.</div>\
12867                                        </div>';
12868                    checkEscrowClass = 'cl-s-escrow-info';
12869                } else {
12870                    if(c_data.order_status == 'W') {
12871                        checkboxNone = 'checked';
12872                        noneAll = ' noneAll';
12873                        checkNoneAll = 'fule';
12874                        checkDepositCancel = '<div class="modal-comment deposit-cancel-desc">\
12875                                    <div class="desc-box">\
12876                                        <div class="desc-title">입금대기 주문취소 안내</div>\
12877                                        <div class="section">- 입금대기 주문 건은 <span class="cl-red">전체 취소</span>만 가능하며 <span class="cl-red">취소완료</span>로 처리됩니다.</div>\
12878                                        <div class="section">- 전체취소 후 구매를 원하는 상품은 다시 주문해주세요.</div>\
12879                                        <div class="section">- 혹시나 입금을 하신 경우 별도로 문의 주시기 바랍니다.</div>\
12880                                    </div>\
12881                                </div>\
12882                            ';
12883                    }
12884                }
12885
12886                if(c_data.pay_info.coupon_list && c_data.pay_info.coupon_list.length) {
12887                    $.each(c_data.pay_info.coupon_list, function(k, v) {
12888                        if(v.kind == 'C') {
12889                            used_code_coupon = true;
12890                        }
12891                    })
12892                }
12893
12894                if(c_data.order_status != 'W' && used_code_coupon) {
12895                    checkboxNone = 'checked';
12896                    noneAll = ' noneAll';
12897                    checkNoneAll = 'fule';
12898                    checkDepositCancel = '<div class="modal-comment deposit-cancel-desc">\
12899                                <div class="desc-box">\
12900                                    <div class="desc-title">코드쿠폰 사용 주문취소 안내</div>\
12901                                    <div class="section">- 코드쿠폰 사용 주문 건은 <span class="cl-red">전체 취소</span>만 가능합니다.</div>\
12902                                    <div class="section">- 전체취소 후 구매를 원하는 상품은 다시 주문해주세요.</div>\
12903                                </div>\
12904                            </div>\
12905                        ';
12906                }
12907                
12908                var modal_str = '\
12909                    <form name="cancel_form" method="post" action="/_return">\
12910                        <input type="hidden" name="sid" value="' + sid + '">\
12911                        <input type="hidden" name="order_group" id="cancel-order-group" value="' + ognum + '">\
12912                        <input type="hidden" name="order_number" id="cancel-order-number" value="' + onum + '">\
12913                        <input type="hidden" name="extra_charge" id="extra_charge" value="' + data.r.pay_info.extra_charge + '">\
12914                        '+checkEscrow+'\
12915                        <div class="cancel-product-title">\
12916                            <div class="newcheckbox hand">\
12917                                <label>\
12918                                    <input type="checkbox" class="'+noneAll+'" id="product-check" '+checkboxNone+'>\
12919                                    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\
12920                                        <path d="M13 0H3C1.3 0 0 1.3 0 3v10c0 1.7 1.3 3 3 3h10c1.7 0 3-1.3 3-3V3C16 1.3 14.7 0 13 0zM15 13c0 1.1-0.9 2-2 2H3c-1.1 0-2-0.9-2-2V3c0-1.1 0.9-2 2-2h10c1.1 0 2 0.9 2 2V13z"/>\
12921                                    </svg>\
12922                                    <svg class="active" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\
12923                                        <path d="M13 0H3C1.34 0 0 1.34 0 3v10c0 1.66 1.34 3 3 3h10c1.66 0 3-1.34 3-3V3C16 1.34 14.66 0 13 0zM13.03 6.03l-5.5 5.5C7.38 11.68 7.19 11.75 7 11.75s-0.38-0.07-0.53-0.22l-3.5-3.5c-0.29-0.29-0.29-0.77 0-1.06s0.77-0.29 1.06 0L7 9.94l4.97-4.97c0.29-0.29 0.77-0.29 1.06 0S13.32 5.74 13.03 6.03z"/>\
12924                                    </svg>\
12925                                </label>\
12926                            </div>\
12927                            취소요청 상품\
12928                        </div>';
12929                        var my_point = Number(data.r.my_point);
12930                        var gradeDeliveryBenefit = c_data.pay_info && c_data.pay_info.grade_delivery_benefit ? c_data.pay_info.grade_delivery_benefit : {};
12931                        var gradeDeliveryBenefitUsed = String(gradeDeliveryBenefit.used || '').toUpperCase() == 'Y';
12932                        var gradeDeliveryBenefitDiscount = gradeDeliveryBenefitUsed ? Number(gradeDeliveryBenefit.discount_price || 0) : 0;
12933                        var getPointCalcDeliveryPrice = function(deliveryPrice) {
12934                            deliveryPrice = Number(deliveryPrice || 0);
12935                            if(!gradeDeliveryBenefitUsed || gradeDeliveryBenefitDiscount <= 0) return deliveryPrice;
12936
12937                            return Math.max(deliveryPrice - gradeDeliveryBenefitDiscount, 0);
12938                        };
12939
12940                        var weight_template_product = {};
12941                        for (var i=0;i<data.r.odata.length;i++) {
12942                            if(c_data.odata[i].state != 'normal') continue;
12943                            var dts = c_data.odata[i].state == 'normal' ? c_data.odata[i].delivery_template_seq : '';
12944                            if(c_data.odata[i].state == 'normal' && c_data.odata[i].mix_yn != 'Y') dts += '-' + c_data.odata[i].product_number;
12945                            var dt = c_data.odata[i].state == 'normal' ? c_data.odata[i].delivery_type : '';
12946
12947                            if(dtl[dts]['price_type'] == 'WEIGHT') {
12948                                if(!weight_template_product.hasOwnProperty(dts)) weight_template_product[dts] = {};
12949                                if(!weight_template_product[dts].hasOwnProperty(dt)) weight_template_product[dts][dt] = {};
12950                                if(!weight_template_product[dts][dt].hasOwnProperty(c_data.odata[i].product_number)) weight_template_product[dts][dt][c_data.odata[i].product_number] = data.r.odata[i];
12951                            }
12952                            var tooltip = '';
12953                            if(dtl[dts]['price_type'] == 'WEIGHT' || dtl[dts]['price_type'] == 'QUANTITY') {
12954                                if(dtl[dts]['price_type_detail']['method'] == 'DIFFERENTIAL') {
12955                                    if(dtl[dts]['price_type'] == 'QUANTITY') {
12956                                        tooltip += '<li class=\'title\'>수량별 배송비</li>';
12957                                        $(dtl[dts]['price_type_detail']['detail']).each(function(k, detail) {
12958                                            var d_v = Object.keys(detail)[0];
12959                                            var d_p = detail[d_v];
12960                                            tooltip += '<li class=\'item\'>' + d_v + '개 이상 ' + number_format(d_p) + '원</li>';
12961                                        });
12962                                    } else if(dtl[dts]['price_type'] == 'WEIGHT') {
12963                                        tooltip += '<li class=\'title\'>무게별 배송비</li>';
12964                                        $(dtl[dts]['price_type_detail']['detail']).each(function(k, detail) {
12965                                            var d_v = Object.keys(detail)[0];
12966                                            var d_p = detail[d_v];
12967                                            tooltip += '<li class=\'item\'>' + d_v + 'Kg 이상 ' + number_format(d_p) + '원</li>';
12968                                        });
12969                                    }
12970                                } else if(dtl[dts]['price_type_detail']['method'] == 'REPEAT') {
12971                                    if(dtl[dts]['price_type'] == 'QUANTITY') {
12972                                        tooltip += '<li class=\'title\'>수량별 배송비</li>';
12973                                        tooltip += '<li class=\'item\'>' + number_format(dtl[dts]['repeat_value']) + '개 구매시마다 ' + number_format(dtl[dts]['repeat_price']) + '원 반복 부과</li>';
12974                                    } else if(dtl[dts]['price_type'] == 'WEIGHT') {
12975                                        tooltip += '<li class=\'title\'>무게별 배송비</li>';
12976                                        tooltip += '<li class=\'item\'>' + number_format(dtl[dts]['repeat_value']) + 'Kg마다 ' + number_format(dtl[dts]['repeat_price']) + '원 반복 부과</li>';
12977                                    }
12978                                }
12979                                if(tooltip && (dt == 'DELIVERY' || dt == 'DIRECT'))  {
12980                                    if(!LUX) tooltip += '<li class=\'desc\'>추가 상품은 배송비 조건에 반영되지 않습니다.</li>';
12981
12982                                    if(dtl[dts]['price_type'] == 'WEIGHT' && weight_template_product[dts][dt]) {
12983                                        tooltip += '<li class=\'title product-weight\'>상품별 무게</li>';
12984                                        $.each(weight_template_product[dts][dt], function(k, v) {
12985                                            tooltip += '<li class=\'item\'>' + v.product_name + ' : ' + number_format(v.product_weight) + 'kg</li>';
12986                                        });
12987                                    }
12988
12989                                    tooltip = '<ul class=\'delivery-tooltip\'>' + tooltip + '</ul>';
12990                                    dtl[dts]['tooltip'] = tooltip;
12991                                }
12992                            }
12993                        }
12994
12995                        modal_str += '<table class="table product-table">';
12996                        for (var i=0;i<data.r.odata.length;i++) {
12997                            if (c_data.odata[i].d_status == '' || c_data.odata[i].d_status == 'CN') {
12998                                noneChecked = '';
12999                                if (!checkNoneAll) noneAll = '';
13000                            } else {
13001                                if (!checkNoneAll) noneAll = 'noneAll';
13002                                noneChecked = 'noneChecked';
13003                            }
13004                            if (c_data.odata[i].p_status == 'W') {
13005                                if (!checkNoneAll) noneAll = 'noneAll';
13006                                noneChecked = 'noneChecked';
13007                                checkboxNone = 'checked';
13008                            }
13009                            var curr_point = 0;
13010                            var usable_point = 0;
13011                            var refund_point = 0;
13012                            var expired_point = 0;
13013
13014                            if(c_data.odata[i].used_point) {
13015                                curr_point = Math.abs(c_data.odata[i].used_point.point);
13016                                usable_point = Math.abs(c_data.odata[i].used_point.usable_point);
13017                            }
13018
13019                            // if(c_data.odata[i].refund_point) {
13020                            //     refund_point = c_data.odata
13021                            // }
13022
13023                            if(c_data.odata[i].expired_point) {
13024                                expired_point = Math.abs(c_data.odata[i].expired_point.point);
13025                            }
13026
13027
13028                            var dts = c_data.odata[i].state == 'normal' ? c_data.odata[i].delivery_template_seq : '';
13029                            if(c_data.odata[i].state == 'normal' && c_data.odata[i].mix_yn != 'Y') dts += '-' + c_data.odata[i].product_number;
13030                            var dt = c_data.odata[i].state == 'normal' ? c_data.odata[i].delivery_type : '';
13031
13032                            modal_str += '\
13033                            <tr class="cl-s-product-jumbotron clearfix">\
13034                                <td ' + (c_data.odata[i].state != 'normal' ? 'colspan="2"' : '') + '>\
13035                                <div class="newcheckbox hand">\
13036                                    <label>\
13037                                        <input type="checkbox" class="status-checkbox cancel-info-data '+noneAll+' '+noneChecked+'" data-curr_point="' + curr_point + '" data-usable_point="' + usable_point + '" data-expired_point="' + expired_point + '" data-type="'+c_data.pdata[i].state
13037+'" name="order_number_ary[]" value="'+c_data.odata[i].order_number+'" '+checkboxNone+' data-option_type="' + c_data.pdata[i].option_type + '" data-product_number="' + c_data.odata[i].product_number + '" data-mix_yn="' + (c_data.odata[i].state == 'normal' ? c_data.odata[i].mix_yn : '') + '" data-delivery_template_seq="' + (c_data.odata[i].state == 'normal' ? dts : '') + '" data-delivery_type="' + (c_data.odata[i].state == 'normal' ? c_data.odata[i].delivery_type : '') + '" data-quantity="' + c_data.odata[i].quantity + '" data-product_weight="' + (c_data.odata[i].state == 'normal' ? c_data.odata[i].product_weight : 0) + '" data-grade_discount_price="' + (parseInt(c_data.odata[i].grade_discount_price || 0)) + '" data-delivery_price="' +  (c_data.odata[i].state == 'normal' && dtl[dts]['pay_type'] == 'PREPAY' ? c_data.odata[i].delivery_price : 0) + '">\
13038                                        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\
13039                                        <path d="M13 0H3C1.3 0 0 1.3 0 3v10c0 1.7 1.3 3 3 3h10c1.7 0 3-1.3 3-3V3C16 1.3 14.7 0 13 0zM15 13c0 1.1-0.9 2-2 2H3c-1.1 0-2-0.9-2-2V3c0-1.1 0.9-2 2-2h10c1.1 0 2 0.9 2 2V13z"/>\
13040                                        </svg>\
13041                                        <svg class="active" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\
13042                                        <path d="M13 0H3C1.34 0 0 1.34 0 3v10c0 1.66 1.34 3 3 3h10c1.66 0 3-1.34 3-3V3C16 1.34 14.66 0 13 0zM13.03 6.03l-5.5 5.5C7.38 11.68 7.19 11.75 7 11.75s-0.38-0.07-0.53-0.22l-3.5-3.5c-0.29-0.29-0.29-0.77 0-1.06s0.77-0.29 1.06 0L7 9.94l4.97-4.97c0.29-0.29 0.77-0.29 1.06 0S13.32 5.74 13.03 6.03z"/>\
13043                                        </svg>\
13044                                    </label>\
13045                                </div>\
13046                                <div class="cl-s-product-thumb">\
13047                                    <img src="' + c_data.pdata[i].img + '" alt="' + c_data.pdata[i].name + '" class="' + c_data.pdata[i].img_align + '" />\
13048                                </div>\
13049                                <div class="cl-s-product-info">\
13050                                    <h5 class="cl-s-product-title">' + c_data.pdata[i].name + '</h5>\
13051                            ';
13052
13053                            console.log(c_data.odata[i]);
13054
13055                            var price = (Number(c_data.odata[i].sale_price) > 0) ? c_data.odata[i].sale_price : c_data.odata[i].price,
13056                                quantity = Number(c_data.odata[i].quantity),
13057                                optionPrice = c_data.odata[i].price * quantity,
13058                                sum_price = quantity * price,
13059                                option_name = (typeof c_data.pdata[i].option != "undefined" && c_data.pdata[i].option) ? c_data.pdata[i].option : '',
13060                                option_str = '',
13061                                etc_str = (typeof c_data.pdata[i].etc_date != "undefined" && c_data.pdata[i].etc_date) ? '<span class="etc-date">선택일자: '+c_data.pdata[i].etc_date+'</span>' : '',
13062                                option_title = (c_data.pdata[i].option_type == 'A') ? '추가옵션: ' + (c_data.pdata[i].option_group ? c_data.pdata[i].option_group + ': ' : '') : '옵션: ';
13063                            if(option_name) {
13064                                option_str = (c_data.pdata[i].option_text_str) ? '<span class="' + (etc_str ? 'option-name' : '') + '">' + option_title + option_name+' / '+c_data.pdata[i].option_text_str+'</span>' : '<span class="' + (etc_str ? 'option-name' : '') + '">' + option_title + option_name+'</span>';
13065                            } else {
13066                                option_str = (c_data.pdata[i].option_text_str) ? '<span class="' + (etc_str ? 'option-name' : '') + '">' + option_title + c_data.pdata[i].option_text_str+'</span>' : '';
13067                            }
13068                            modal_str += '\
13069                                    <div class="option-str option-check" data-optionPrice="'+optionPrice+'">' + option_str + etc_str + '<span>' + quantity + '개</span><div class="price"><span>
13069' + number_format(optionPrice) + '</span> 원</div></div>\
13070                                </div>\
13071                                </td>\
13072                            ';
13073
13074                            if(c_data.odata[i].state == 'normal') {
13075                                var delivery_cnt = dtl[dts]['dtype'][dt].delivery_cnt;
13076                                if(!dtl[dts]['dtype'][dt].hasOwnProperty('counter')) {
13077                                    dtl[dts]['dtype'][dt]['counter'] = 0;
13078                                }
13079
13080                                dtl[dts]['dtype'][dt]['counter']++;
13081
13082                                if(dtl[dts]['dtype'][dt]['counter'] == 1) {                            
13083                                    modal_str +='\
13084                                        <td rowspan="' + delivery_cnt + '" class="delivery-price"><div>배송비</div><div class="price"><span>';
13085                                    if(dt == 'DELIVERY' || dt == 'DIRECT') {
13086                                        if(dtl[dts]['price_type'] == 'ETC') {
13087                                            modal_str += '별도안내</span>';
13088                                        } else {
13089                                            modal_str += number_format(dtl[dts]['dtype'][dt]['price']) + '</span> 원';    
13090                                        }
13091                                        if(dtl[dts]['pay_type'] == 'DELIVERED') modal_str += '(착불)';
13092
13093                                        if(dtl[dts]['price_type'] == 'FREE_CONDITION') {
13094                                            modal_str += '<div class="price-desc">' + number_format(dtl[dts]['free_condition']) + '원 이상<br>배송비 무료</div>';
13095                                        }
13096                                    } else {
13097                                        modal_str += $.lang[LANG]['shopping.delivery.template.delivery_type.' + dt.toLowerCase()] + '</span>';
13098                                        if(dt == 'QUICK') modal_str += '(착불)';
13099                                    }
13100                                    if(dtl[dts]['tooltip'] && (dt == 'DELIVERY' || dt == 'DIRECT')) {
13101                                        modal_str += '<svg class="cm-popover-info" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 13" width="13" height="13" tabindex="0" data-trigger="hover" data-toggle="popover" fill="#4789e7" data-html="true" data-placement="top" data-content="' + dtl[dts]['tooltip'] + '" data-original-title="" title=""><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"></path><path d="M6.66 3.01C5.61 3.01 4.58 3.5 4.5 4.8c0 0.06-0.01 0.12 0 0.2h1.02c0-0.07 0.01-0.15 0.02-0.23 0.08-0.62 0.52-0.76 1.08-0.76 0.63 0 1.02 0.37 1.02 0.95 -0.01 0.48-0.3 0.87-0.76 1.34C6.21 6.97 6.02 7.37 6 8h0.99C7 7.66 7.04 7.37 7.67 6.75 8.17 6.27 8.7 5.68 8.7 4.87 8.7 3.85 7.89 3.01 6.66 3.01z"></path><rect x="6" y="9" width="1" height="1"></rect></svg>';
13102                                    }
13103                                    modal_str +='</div></td>\
13104                                    ';
13105                                }
13106
13107                                modal_str += '\
13108                                </tr>';
13109
13110                                if(dtl[dts]['dtype'][dt]['counter'] == dtl[dts]['dtype'][dt]['delivery_cnt']) {
13111                                    modal_str += '\
13112                                        <tr class="cl-s-product-jumbotron clearfix delivery-price delivery-price-mobile">\
13113                                            <td><div class="delivery-title">묶음 배송비</div><div class="delivey-price"><span>';
13114
13115                                    if(dtl[dts]['tooltip'] && (dt == 'DELIVERY' || dt == 'DIRECT')) {
13116                                        modal_str += '<svg class="cm-popover-info" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 13" width="13" height="13" tabindex="0" data-trigger="hover" data-toggle="popover" fill="#4789e7" data-html="true" data-placement="top" data-content="' + dtl[dts]['tooltip'] + '" data-original-title="" title=""><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"></path><path d="M6.66 3.01C5.61 3.01 4.58 3.5 4.5 4.8c0 0.06-0.01 0.12 0 0.2h1.02c0-0.07 0.01-0.15 0.02-0.23 0.08-0.62 0.52-0.76 1.08-0.76 0.63 0 1.02 0.37 1.02 0.95 -0.01 0.48-0.3 0.87-0.76 1.34C6.21 6.97 6.02 7.37 6 8h0.99C7 7.
1311666 7.04 7.37 7.67 6.75 8.17 6.27 8.7 5.68 8.7 4.87 8.7 3.85 7.89 3.01 6.66 3.01z"></path><rect x="6" y="9" width="1" height="1"></rect></svg>';
13117                                    }
13118                                    
13119                                    if(dt == 'DELIVERY' || dt == 'DIRECT') {
13120                                        modal_str += number_format(dtl[dts]['dtype'][dt]['price']) + '</span> 원';
13121                                        if(dtl[dts]['pay_type'] == 'DELIVERED') modal_str += '(착불)';
13122                                        if(dtl[dts]['price_type'] == 'FREE_CONDITION') {
13123                                            modal_str += '<div class="price-desc">' + number_format(dtl[dts]['free_condition']) + '원 이상 배송비 무료</div>';
13124                                        }
13125                                    } else {
13126                                        modal_str += $.lang[LANG]['shopping.delivery.template.delivery_type.' + dt.toLowerCase()] + '</span>';
13127                                        if(dt == 'QUICK') modal_str += '(착불)';
13128                                    }
13129
13130                                    modal_str += '</div></td>\
13131                                        </tr>\
13132                                    ';
13133                                }
13134                            }
13135                        }
13136                        modal_str += '</table>';
13137
13138                        modal_str += '<div class="order-cancel-content">\
13139                            <div class="cl-s-form-selector">\
13140                                <select class="selectpicker dropdown" id="cancel-reason" name="reason">\
13141                                    <option value="구매의사 취소">구매의사 취소</option>\
13142                                    <option value="다른 상품 잘못 주문">다른 상품 잘못 주문</option>\
13143                                    <option value="기타">기타</option>\
13144                                </select>\
13145                                <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 8 4" width="8" height="4"><polygon points="0 0 4 4 8 0 "></polygon></svg>\
13146                            </div>\
13147                            <div class="cl-s-form-wrap">\
13148                                <div class="cl-s-form-group input-label-hide">\
13149                                    <textarea class="cl-s-form-control control-textarea" id="cancel-requests" name="requests" maxlength="500" required="required"></textarea>\
13150                                    <label for="input" class="cl-s-control-label">자세한 내용을 적어주세요. (500자 이내)</label>\
13151                                </div>\
13152                            </div>\
13153                        </div>';
13154
13155                        modal_str += '<div class="order-cancel-content">\
13156                            <div class="cancel-info-box">\
13157                                <div class="cancel-info"><span class="cancel-info-title">취소상품 합계</span><span class="cancel-info-price" id="cancel-price">0원</span></div>\
13158                                <div class="cancel-info"><span class="cancel-info-title">취소 배송비 합계</span><span class="cancel-info-price" id="cancel-delivery-price">0원</span></div>\
13159                                <div class="cancel-info"><span class="cancel-info-title">적립금</span><span class="cancel-info-price" id="cancel-point-price">0원</span></div>\
13160                                <div class="cancel-info"><span class="cancel-info-title">쿠폰</span><span class="cancel-info-price" id="cancel-coupon-price">0원</span></div>\
13161                                <div class="cancel-info"><span class="cancel-info-title">등급할인</span><span class="cancel-info-price" id="cancel-grade-discount-price">0원</span></div>\
13162                                <div class="cancel-info"><span class="cancel-info-title cancel-coupon-title"></span><span class="cancel-info-price" id="cancel-coupon-detail"></span></div>\
13163                                <div class="cancel-info-line"></div>\
13164                                <div class="return-total-info"><span class="cancel-info-title">환불 예정금액</span><span class="cancel-info-price"><span id="return-total-price">0</span>원</span></div>\
13165                            </div>'+checkEscrowFooter+'\
13166                        </div>';
13167                        modal_str += checkDepositCancel;
13168
13169                    var status = [];
13170                    for (var i=0;i<c_data.pdata.length;i++) {
13171                        status.push(c_data.pdata[i].p_status);
13172                    }
13173
13174                    if (pclass == '무통장 입금' || pclass == '가상계좌') {
13175                        var returnClass = '';
13176                        if (c_data.return_bank.length > 1 && c_data.return_bank.indexOf('')===-1) returnClass = 'returnDisabled';
13177                        modal_str += '\
13178                            <div class="modal-sub-title">환불 계좌</div>\
13179                            <ul class="qna-writer clearfix">\
13180                                <li class="">\
13181                                    <div class="cl-s-form-wrap '+returnClass+'">\
13182                                        <div class="cl-s-form-group">';
13183                                        if (c_data.return_bank.length > 1 && c_data.return_bank.indexOf('')===-1) modal_str += '<input type="text" class="cl-s-form-control has-value" id="no-bank" name="no_bank" readonly required="required" value="'+c_data.return_bank[1]+'">';
13184                                        else modal_str += '<input type="text" class="cl-s-form-control" id="no-bank" name="no_bank" required="required" value="">';
13185                                        modal_str += '<label for="input" class="cl-s-control-label">은행명</label>\
13186                                        </div>\
13187                                    </div>\
13188                                </li>\
13189                                <li>\
13190                                    <div class="cl-s-form-wrap '+returnClass+'">\
13191                                        <div class="cl-s-form-group">';
13192                                        if (c_data.return_bank.length > 1 && c_data.return_bank.indexOf('')===-1) modal_str += '<input type="text" class="cl-s-form-control has-value" id="no-bank-name" readonly name="no_bank_name" required="required" value="'+c_data.return_bank[2]+'">';
13193                                        else modal_str += '<input type="text" class="cl-s-form-control" id="no-bank-name" name="no_bank_name" required="required">';
13194                                        modal_str += '<label for="input" class="cl-s-control-label">예금주</label>\
13195                                        </div>\
13196                                    </div>\
13197                                </li>\
13198                                <li>\
13199                                    <div class="cl-s-form-wrap '+returnClass+'">\
13200                                        <div class="cl-s-form-group">';
13201                                        if (c_data.return_bank.length > 1 && c_data.return_bank.indexOf('')===-1) modal_str += '<input type="text" class="cl-s-form-control has-value" id="no-bank-number" name="no_bank_number" readonly data-type="email" required="required" value="'+c_data.return_bank[3]+'">';
13202                                        else modal_str += '<input type="text" class="cl-s-form-control" id="no-bank-number" name="no_bank_number" data-type="email" required="required" value="">';
13203                                        modal_str += '<label for="input" class="cl-s-control-label">계좌번호</label>\
13204                                        </div>\
13205                                    </div>\
13206                                </li>\
13207                            </ul>';
13208                        if(status.indexOf('W')===-1) modal_str += '\
13209                            <div class="modal-comment">동일 주문 내 여러 상품을 환불 요청하시는 경우, ì
13209µœì´ˆ 입력한 환불계좌로 일괄 환불처리됩니다.</div>\
13210                        ';
13211                    }
13212
13213                    modal_str += '\
13214                            <div class="modal-comment point-used-desc hide">\
13215                                <div class="desc-box">\
13216                                    <div class="desc-title">적립금 환불 안내</div>\
13217                                    <div class="section">상품(들)을 구매하여 적립된 적립금 <span id="disp_used_point_total" class="point-color"></span>원이 이미 사용되거나 유효기간이 만료되었습니다.</div>\
13218                                    <div class="section">현재 보유 적립금이 <span class="point-color">' + addCommas(my_point) + '</span>원 으로 구매 적립된 적립금 <span id="disp_cancel_after_point" class="point-color"></span>원을 취소 처리할 수 없습니다.</div>\
13219                                    <div class="section">미 취소된 적립금에 대한 처리는 판매자와 협의해주세요.</div>\
13220                                </div>\
13221                                <div class="newcheckbox hand">\
13222                                    <label style="margin-left: 25px;">\
13223                                        <input type="checkbox" class="cancel-agree" />\
13224                                        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\
13225                                            <path d="M13 0H3C1.3 0 0 1.3 0 3v10c0 1.7 1.3 3 3 3h10c1.7 0 3-1.3 3-3V3C16 1.3 14.7 0 13 0zM15 13c0 1.1-0.9 2-2 2H3c-1.1 0-2-0.9-2-2V3c0-1.1 0.9-2 2-2h10c1.1 0 2 0.9 2 2V13z"></path>\
13226                                        </svg>\
13227                                        <svg class="active" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\
13228                                            <path d="M13 0H3C1.34 0 0 1.34 0 3v10c0 1.66 1.34 3 3 3h10c1.66 0 3-1.34 3-3V3C16 1.34 14.66 0 13 0zM13.03 6.03l-5.5 5.5C7.38 11.68 7.19 11.75 7 11.75s-0.38-0.07-0.53-0.22l-3.5-3.5c-0.29-0.29-0.29-0.77 0-1.06s0.77-0.29 1.06 0L7 9.94l4.97-4.97c0.29-0.29 0.77-0.29 1.06 0S13.32 5.74 13.03 6.03z"></path>\
13229                                        </svg>\
13230                                    위 내용을 확인하였습니다.</label>\
13231                                </div>\
13232                                <div class="point-used-cancel-agree-desc">\
13233                                    <svg viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>\
13234                                    적립금 환불 안내에 동의해주세요.\
13235                                </div>\
13236                            </div>\
13237                            ';
13238
13239                    modal_str += '</form>\
13240                ';
13241
13242                var ocModal = $(this).showModalFlat('취소 요청', modal_str,true,true,function () {
13243
13244                    var f = document.cancel_form;
13245                    if(ocModal.find('#cancel-reason').prop('value') == '') {
13246                        // $('#cancel-reason').selectpicker('toggle');
13247                        // return false;
13248                        $('#cancel-reason').closest('.cl-s-form-selector').addClass('empty');
13249                    }
13250
13251                    ocModal.find('.cl-s-form-wrap').each(function() {
13252                        var check_input = $(this).find('.cl-s-form-control'),
13253                            val = check_input.val().trim();
13254
13255                        if(val.length == 0) {
13256                            $(this).removeClass('error').addClass('empty');
13257                            $(this).find('.cl-s-control-label.error').remove();
13258                        } else {
13259                            if($(this).hasClass('error')) {
13260                                check_input.focus();
13261                            }
13262                        }
13263                    });
13264                    var checkCnt = 0;
13265
13266                    $(".status-checkbox").each(function (i, index) {
13267                        if ($(this).is(":checked") === true) {
13268                            checkCnt++;
13269                        }
13270                    });
13271
13272                    if (checkCnt < 1) {
13273                        alert('상품을 1개 이상 선택해 주세요');
13274                        return false;
13275                    }
13276
13277                    if(ocModal.find('.cl-s-form-wrap.empty, .cl-s-form-wrap.error').length > 0) {
13278                        // ocModal.find('.cl-s-form-wrap.empty, .cl-s-form-wrap.error').eq(0).find('.cl-s-form-control').focus();
13279                        return false;
13280                    }
13281
13282                    if(ocModal.find("input[type='checkbox'].cancel-agree:visible").length && ocModal.find("input[type='checkbox'].cancel-agree:visible").length != ocModal.find("input[type='checkbox'].cancel-agree:visible:checked").length) {
13283                        $(".point-used-cancel-agree-desc").show();
13284                        return false;
13285                    } else {
13286                        $(".point-used-cancel-agree-desc").hide();
13287                    }
13288
13289                    $.processON();
13290
13291                    f.submit();
13292                    ocModal.modal('hide');
13293
13294                },'close','등록하기','cl-s-order-cancel cl-modal cl-s-btn cover ' + checkEscrowClass, false, '', function() {
13295                    var totalCnt = 0, totalNomalCheck = 0, nomalCheck = 0, price = 0, deliveryPrice = 0, gradeDiscountPrice = 0,
13296                        $form = $('form[name="cancel_form"]');
13297
13298                    $('.status-checkbox').each(function(i, index) {
13299                        if ($(this).is(":checked") === true) {
13300                            price += ($(this).closest('.cl-s-product-jumbotron').find('.option-check').attr('data-optionPrice') * 1);
13301                            gradeDiscountPrice += Number($(this).data('grade_discount_price') || 0);
13302                            totalCnt++;
13303                            if ($(this).attr('data-type') == 'normal') {
13304                                nomalCheck++;
13305                                var mix_yn = $(this).data('mix_yn');
13306                                var delivery_price = 0;
13307                                var delivery_template_seq = $(this).data('delivery_template_seq');
13308                                var delivery_type = $(this).data('delivery_type');
13309                                if(ocModal.find('input[name="order_number_ary[]"][data-delivery_type="' + delivery_type + '"][data-delivery_template_seq="' + delivery_template_seq + '"]').length == ocModal.find('input[name="order_number_ary[]"][data-delivery_type="' + delivery_type + '"][data-delivery_template_seq="' + delivery_template_seq + '"]:checked').length) {
13310                                    delivery_price = Number($(this).data('delivery_price'));
13311                                }
13312                                deliveryPrice += delivery_price;
13313                            }
13314                        }
13315
13316                        if ($(this).attr('data-type') == 'normal') {
13317                            totalNomalCheck++;
13318                        }
13319                    });
13320
13321                    if(c_data.order_status == 'W') {
13322                        $("#product-check, .status-checkbox").click(function(e){
13323                            return false;
13324                        });
13325                    }
13326                    var product_price = price + getPointCalcDeliveryPrice(deliveryPrice),
13327                        rePayment = parseInt(c_data.pay_info.request.payment.total) - parseInt(c_data.pay_info.request.payment.coupon) - parseInt(c_data.pay_info.request.cancel.total) - parseInt(c_data.pay_info.request.return.total);
13328
13329                    rePayment = (rePayment > 0) ? rePayment : 0;
13330
13331                    // coupon 처리
13332                    var coupon = c_data.pay_info.coupon_list,
13333                        cancel_coupon_price = 0;
13334                    if(coupon.length) {
13335                        var checked_order_number = $('.cancel-info-data:checked').map(function(){ return this.value; }).toArray();
13336
13337                        $.each(coupon, function(i,v) {
13338                            if(checked_order_number.indexOf(v.order_number) > -1 || v.kind == 'C') {
13339                                cancel_coupon_price += parseInt(v.discount_price);
13340
13341                                // 환불금에서 쿠폰처리
13342                                if($('.coupon-detail-info[data-seq="' + v.seq + '"]').length == 0) {
13343                                    $('.cancel-coupon-title').append('<span class="coupon-name coupon-detail-info" data-seq="' + v.seq + '">' + v.coupon_name + '</span>');
13344                                    $('#cancel-coupon-detail').append('<span class="coupon-price coupon-detail-info" data-seq="' + v.seq + '">-' + number_format(parseInt(v.discount_price)) + '원</span>');
13345                                }
13346                            } else {
13347                                $('.coupon-detail-info[data-seq="' + v.seq + '"]').remove();
13348                            }
13349                        });
13350                        // 취소된 쿠폰 저장
13351                    }
13352                    product_price = product_price - parseInt(cancel_coupon_price);
13353                    product_price = product_price - gradeDiscountPrice;
13354                    
13355                    var use_point = (rePayment - product_price > 0) ? 0 : rePayment - product_price;
13356                    product_price = product_price + use_point;
13357
13358                    $('#cancel-price').html(number_format(price)+'원');
13359                    $('#cancel-delivery-price').html(number_format(deliveryPrice)+'원');
13360                    $('#cancel-point-price').html(number_format(use_point)+'원');
13361                    $('#cancel-coupon-price').html(((cancel_coupon_price > 0) ? '-' + number_format(cancel_coupon_price) : '0')+'원');
13362                    $('#cancel-grade-discount-price').html(((gradeDiscountPrice > 0) ? '-' + number_format(gradeDiscountPrice) : '0')+'원');
13363                    $('#return-total-price').html(number_format(product_price));
13364
13365                    $('.cancel-info-data').on('change', function (e) {
13366                        if($(this).hasClass('noneAll')) return;    
13367                        var cancel_after_point = my_point;
13368                        var disp_used_point_total = 0;
13369                        var deliveryPrice = 0;
13370                        var extra_delivery_flag = {};
13371                        var dtl_copy = JSON.parse(JSON.stringify(dtl));
13372
13373
13374                        var product_number = $(this).attr('data-product_number');
13375                        if($(this).attr('data-option_type') != 'A' && !$('input[name="order_number_ary[]"][data-product_number="' + product_number + '"][data-option_type!="A"]:not(:checked)').length) {
13376                            $('input[name="order_number_ary[]"][data-product_number="' + product_number + '"][data-option_type="A"]').prop('checked',true);
13377                        } else if($(this).attr('data-option_type') == 'A' && !$('input[name="order_number_ary[]"][data-product_number="' + product_number + '"][data-option_type!="A"]:not(:checked)').length && !$(this).prop('checked')) {
13378                            $('input[name="order_number_ary[]"][data-product_number="' + product_number + '"][data-option_type!="A"]:last').prop('checked',fal
13378se);
13379                        }
13380
13381                        if($("input[name='order_number_ary[]']:checked").length) {
13382                            coupon.map(function(v,k) {  coupon[k]['apply'] = '' });
13383                            $("input[name='order_number_ary[]']:checked").each(function() {
13384                                cancel_after_point = Number(cancel_after_point) + ((Number($(this).data("expired_point"))) - Number($(this).data("curr_point")));
13385                                disp_used_point_total += ((Number($(this).data("expired_point"))) - Number($(this).data("curr_point")));
13386                                c_ord_num = $(this).val();
13387
13388                                if($(this).data('type') != 'normal' || $(this).data('option_type') == 'A') return;
13389                                var mix_yn = $(this).data('mix_yn');
13390                                var delivery_price = 0;
13391                                var delivery_template_seq = $(this).data('delivery_template_seq');
13392                                var delivery_type = $(this).data('delivery_type');
13393                                var product_weight = $(this).data('product_weight');
13394
13395                                if(delivery_type != 'DELIVERY' && delivery_type != 'DIRECT') return;
13396                                // if(dtl[delivery_template_seq]['price_type'] != 'WEIGHT' && dtl[delivery_template_seq]['price_type'] != 'QUANTITY') {
13397                                if(ocModal.find('input[name="order_number_ary[]"][data-delivery_type="' + delivery_type + '"][data-delivery_template_seq="' + delivery_template_seq + '"]').length == ocModal.find('input[name="order_number_ary[]"][data-delivery_type="' + delivery_type + '"][data-delivery_template_seq="' + delivery_template_seq + '"]:checked').length) {
13398                                    delivery_price = Number($(this).data('delivery_price'));
13399                                    
13400                                    coupon.map(function(v,k) { if(v.order_number == c_ord_num && delivery_price > 0 && v.benefit == 'DELIVERY') coupon[k]['apply'] = '1';  });
13401                                }
13402
13403                                if(dtl[delivery_template_seq]['price_type'] != 'WEIGHT' && dtl[delivery_template_seq]['price_type'] != 'QUANTITY') {
13404                                } else {
13405                                    dtl_copy[delivery_template_seq]['dtype'][delivery_type]['real_weight'] -= Number((Number($(this).data('product_weight')) * Number($(this).data('quantity'))).toFixed(3));
13406                                    dtl_copy[delivery_template_seq]['dtype'][delivery_type]['real_weight'] = Number(dtl_copy[delivery_template_seq]['dtype'][delivery_type]['real_weight'].toFixed(3));
13407                                    dtl_copy[delivery_template_seq]['dtype'][delivery_type]['real_quantity'] -= Number($(this).data('quantity'));
13408
13409                                    if(dtl[delivery_template_seq]['price_type_detail']['method'] == 'REPEAT') {
13410                                        if(dtl[delivery_template_seq]['price_type'] == 'WEIGHT') {
13411                                            dtl_copy[delivery_template_seq]['dtype'][delivery_type]['real_price'] = Math.ceil(dtl_copy[delivery_template_seq]['dtype'][delivery_type]['real_weight'] / dtl[delivery_template_seq]['repeat_value']) * dtl[delivery_template_seq]['repeat_price'];
13412                                        } else if(dtl[delivery_template_seq]['price_type'] == 'QUANTITY') {
13413                                            dtl_copy[delivery_template_seq]['dtype'][delivery_type]['real_price'] = dtl_copy[delivery_template_seq]['dtype'][delivery_type]['real_price'] - Math.ceil(dtl_copy[delivery_template_seq]['dtype'][delivery_type]['real_quantity'] / dtl[delivery_template_seq]['repeat_value']) * dtl[delivery_template_seq]['repeat_price'];
13414                                        }
13415                                        // if()
13416                                    } else if(dtl[delivery_template_seq]['price_type_detail']['method'] == 'DIFFERENTIAL') {
13417                                        if(dtl[delivery_template_seq]['price_type'] == 'WEIGHT') {
13418                                            $.each(dtl[delivery_template_seq]['price_type_detail'].detail, function() {
13419                                                var r_value = Number(Object.keys(this)[0]);
13420                                                var r_price = Number(Object.values(this)[0]);
13421                                                if(dtl_copy[delivery_template_seq]['dtype'][delivery_type]['real_weight'] == 0) {
13422                                                    dtl_copy[delivery_template_seq]['dtype'][delivery_type]['real_price'] = 0;
13423                                                } else if(dtl_copy[delivery_template_seq]['dtype'][delivery_type]['real_weight'] >= r_value) {
13424                                                    dtl_copy[delivery_template_seq]['dtype'][delivery_type]['real_price'] = r_price;
13425                                                }                                                  
13426                                            });
13427                                        } else if(dtl[delivery_template_seq]['price_type'] == 'QUANTITY') {
13428                                            $.each(dtl[delivery_template_seq]['price_type_detail'].detail, function() {
13429                                                var r_value = Number(Object.keys(this)[0]);
13430                                                var r_price = Number(Object.values(this)[0]);
13431                                                if(dtl_copy[delivery_template_seq]['dtype'][delivery_type]['real_quantity'] == 0) {
13432                                                    dtl_copy[delivery_template_seq]['dtype'][delivery_type]['real_price'] = 0;
13433                                                } else if(dtl_copy[delivery_template_seq]['dtype'][delivery_type]['real_quantity'] >= r_value) {
13434                                                    dtl_copy[delivery_template_seq]['dtype'][delivery_type]['real_price'] = r_price;
13435                                                }                                                  
13436                                            });
13437                                        }
13438                                    }
13439                                    if(dtl[delivery_template_seq]['dtype'][delivery_type]['real_price'] > dtl_copy[delivery_template_seq]['dtype'][delivery_type]['real_price'] && dtl_copy[delivery_template_seq]['dtype'][delivery_type]['real_price'] > 0) 
13440                                        extra_delivery_flag[delivery_template_seq+'|'+delivery_type] = true;
13441                                    else 
13442                                        extra_delivery_flag[delivery_template_seq+'|'+delivery_type] = false;
13443                                }
13444                                deliveryPrice += delivery_price;
13445                            });
13446                        }
13447
13448                        $form.find('.extra-delivery-fee-box').remove();
13449
13450                        if(cancel_after_point < 0) {
13451                            $(".point-used-desc #disp_cancel_after_point").html(addCommas(Math.abs(cancel_after_point)));
13452                            $(".point-used-desc #disp_used_point_total").html(addCommas(Math.abs(disp_used_point_total)));
13453                            $(".point-used-desc").removeClass("hide");
13454                        } else {
13455                            $(".point-used-desc").addClass("hide");
13456                            $(".point-used-desc #disp_cancel_after_point").html("");
13457                            $(".point-used-desc #disp_used_point_total").html("");
13458                        }
13459
13460                        var price = 0;
13461                        var gradeDiscountPrice = 0;
13462                        var oLength = $('.option-check').length;
13463                        var totalCnt = 0, totalNomalCheck = 0, nomalCheck = 0;
13464                        
13465                        $form.find('.order-cancel-content.extra-info').remove();
13466
13467                        if ($(this).hasClass('noneAll') === true) {
13468                            if ($(this).hasClass('noneChecked') === true) {
13469                                $(this).prop('checked', false);
13470                            } else {
13471                                $(this).prop('checked', true);
13472                                $(".status-checkbox").each(function () {
13473                                    if ($(this).prop('disabled') !== true) $(this).prop('checked', true);
13474                                });
13475                            }
13476                        }
13477
13478                        $(".status-checkbox").each(function (i, index) {
13479                            if ($(this).is(":checked") === true) {
13480                                price += ($(this).closest('.cl-s-product-jumbotron').find('.option-check').attr('data-optionPrice') * 1);
13481                                gradeDiscountPrice += Number($(this).data('grade_discount_price') || 0);
13482                                totalCnt++;
13483                                if ($(this).attr('data-type') == 'normal') nomalCheck++;
13484                            }
13485
13486                            if ($(this).attr('data-type') == 'normal') totalNomalCheck++;
13487                        });
13488
13489                        var product_price = price + getPointCalcDeliveryPrice(deliveryPrice),
13490                            rePayment = parseInt(c_data.pay_info.request.payment.total) - parseInt(c_data.pay_info.request.cancel.total) - parseInt(c_data.pay_info.request.return.total);
13491
13492                        rePayment = (rePayment > 0) ? rePayment : 0;
13493                        
13494                        // coupon 처리
13495                        var cancel_coupon_price = 0;
13496                        if(coupon.length) {
13497                            var checked_order_number = $('.cancel-info-data:checked').map(function(){ return this.value; }).toArray();
13498                            $.each(coupon, function(i,v) {
13499                                rePayment -= v.discount_price;
13500                                v.apply = (v.apply || v.benefit != 'DELIVERY') ? '1' : '';
13501                                if((checked_order_number.indexOf(v.order_number) > -1 && v.apply) || v.kind == 'C') {
13502                                    cancel_coupon_price += parseInt(v.discount_price);
13503                                    // 환불금에서 쿠폰처리
13504                                    if($('.coupon-detail-info[data-seq="' + v.seq + '"]').length == 0) {
13505                                        $('.cancel-coupon-title').append('<span class="coupon-name coupon-detail-info" data-seq="' + v.seq + '">' + v.coupon_name + '</span>');
13506                                        $('#cancel-coupon-detail').append('<span class="coupon-price coupon-detail-info" data-seq="' + v.seq + '">-' + number_format(parseInt(v.discount_price)) + '원</span>');
13507                                    }
13508                                } else {
13509                                    $('.coupon-detail-info[data-seq="' + v.seq + '"]').remove();
13510                                }
13511                            });
13512                            // 취소된 쿠폰 저장
13513                        }
13514
13515                        product_price = product_price - parseInt(cancel_coupon_price);
13516                        product_price = product_price - gradeDiscountPrice;
13517
13518                        var use_point = (rePayment - product_price > 0) ? 0 : rePayment - product_price;
13519                        product_price = product_price + use_point;
13520
13521                        $('#cancel-price').html(number_format(price)+'원');
13522                        $('#cancel-delivery-price').html(number_format(deliveryPrice)+'원');
13523                        $('#cancel-point-price').html(number_format(use_point)+'원');
13524                        $('#cancel-coupon-price').html(((cancel_coupon_price > 0) ? '-' + number_format(cancel_coupon_price) : '0')+'원');
13525                        $('#cancel-grade-discount-price').html(((gradeDiscountPrice > 0) ? '-' + number_format(gradeDiscountPrice) : '0')+'원');
13526                        $('#return-total-price').html(number_format(product_price));
13527
13528                        var priceSumArr = [];
13529                        var extra_charge_flag = {};
13530                        if(ocModal.find('.cancel-info-data:checked').length) {
13531                            ocModal.find('.cancel-info-data:checked').each(function() {
13532                                if($(this).data('type') != 'normal') 
13533                                    return;
13534
13535                                var dts = $(this).data('delivery_template_seq');
13536                                if(dtl[dts]['price_type'] != 'FREE_CONDITION') return;
13537                                var dt = $(this).data('delivery_type');
13538                                if(dt != 'DELIVERY' && dt != 'DIRECT') return;
13539
13540                                if(!priceSumArr.hasOwnProperty(dts)) {
13541                                    priceSumArr[dts] = [];
13542                                
13543                                }
13544
13545                                if(!priceSumArr[dts].hasOwnProperty(dt)) {
13546                                    priceSumArr[dts][dt] = 0;
13547                                }
13548                                // cancel_after_point = Number(cancel_after_point) + ((Number($(this).data("usable_point")) + Number($(this).data("expired_point"))) - Number($(this).data("curr_point")));
13549                                var selectedPrice = 0;
13550                                selectedPrice = Number($(this).closest('tr').find('[data-optionprice]').data('optionprice'));
13551                                priceSumArr[dts][dt] += selectedPrice;
13552
13553                                if(dtl[dts]['dtype'][dt]['product_price'] - priceSumArr[dts][dt] < dtl[dts]['free_condition'] && dtl[dts]['dtype'][dt]['product_price'] - priceSumArr[dts][dt] > 0 && dtl[dts]['dtype'][dt]['price'] == 0) {
13554                                    extra_charge_flag[dts + '|' + dt] = true;
13555                                } else {
13556                                    extra_charge_flag[dts + '|' + dt] = false;
13557                                }
13558                            });
13559                        }
13560                        
13561                        extra_charge_info($form, 'C', Object.values(extra_charge_flag).indexOf(true) > -1 ? true : false, Object.values(extra_delivery_flag).indexOf(true) > -1 ? true : false);
13562
13563                        if($('input[name="order_number_ary[]"]').length == $('input[name="order_number_ary[]"]:checked').length) $('#product-check').prop('checked', true);
13564                        else $('#product-check').prop('checked', false);
13565                    });
13566
13567                    $(document).on('click', '#product-check', function () {
13568                        var price = 0;
13569                        var deliveryPrice = 0;
13570                        var totalCnt = 0, totalNomalCheck = 0, nomalCheck = 0;
13571                        $form.find('.order-cancel-content.extra-info').remove();
13572                        if ($(this).hasClass('noneAll') === true) {
13573                            $(this).prop('checked', true);
13574                            $(".status-checkbox").each(function () {
13575                                if ($(this).prop('disabled') !== true) $(this).prop('checked', true).change();
13576                            });
13577                        }
13578                        if ($(this).is(":checked") === true) {
13579                            $(".status-checkbox").each(function (i) {
13580                                if ($(this).prop('disabled') !== true) {
13581                                    $(this).prop('checked', true).change();
13582                                }
13583
13584                            });
13585                        } else {
13586                            $(".status-checkbox").each(function () {
13587                                if ($(this).prop('disabled') !== true) $(this).prop('checked', false).change();
13588                            });
13589
13590                            $('#cancel-price').html('0원');
13591                            $('#cancel-delivery-price').html('0원');
13592                            $('#cancel-point-price').html('0원');
13593                            $('#cancel-grade-discount-price').html('0원');
13594                            $('#return-total-price').html('0');
13595                        }
13596                    });
13597
13598                    /* first option setting */
13599                    $('.cl-s-order-cancel .cl-s-form-selector').each(function(e) {
13600                        var checkSelectOption = ($(this).find('select option').length > 0) ? true : false;
13601                        if(checkSelectOption) {
13602                            var selectId = $(this).find('select').attr('id'),
13603                                val = $(this).find('select').children().eq(0).val();
13604                            $(this).find('select').selectpicker({'val':val, dropupAuto:false});
13605                        }
13606                    });
13607
13608                    $('.cl-s-order-cancel .cl-s-form-group').on('click',function(e) {
13609                        if($(e.target).hasClass('cl-s-form-group')) {
13610                            $(e.target).find('.cl-s-form-control:not([type=hidden])').focus();
13611                        }
13612                    });
13613
13614                    $('#cancel-reason').on({
13615                        'show.bs.select': function (e) {
13616                            $(this).closest('.cl-s-form-selector').addClass('active');
13617                        },
13618                        'hidden.bs.select': function(e) {
13619                            $(this).closest('.cl-s-form-selector').removeClass('active');
13620
13621                            if($('#cancel-reason').prop('value') == '') {
13622                                $(this).closest('.cl-s-form-selector').addClass('empty');
13623                            } else {
13624                                $(this).closest('.cl-s-form-selector').removeClass('empty');
13625                            }
13626                        },
13627                        'changed.bs.select': function (e, clickedIndex, newValue, oldValue) {
13628                            // console.log(this.value, clickedIndex, newValue, oldValue);
13629                        }
13630                    });
13631
13632                    $('.cl-s-order-cancel .control-textarea').on({
13633                        focus: function(e) {
13634                            $(this).closest('.cl-s-form-wrap').addClass('active');
13635                        },
13636                        blur: function(e) {
13637                            var val = $(this).val().trim();
13638
13639                            $(this).closest('.cl-s-form-wrap').removeClass('active');
13640                            if(val.length == 0) {
13641                                $(this).closest('.cl-s-form-wrap').removeClass('error').addClass('empty');
13642                                $(this).closest('.cl-s-form-wrap').find('.cl-s-control-label.error').remove();
13643                                return false;
13644                            } else {
13645                                $(this).closest('.cl-s-form-wrap').removeClass('empty');
13646                                var error_str = '';
13647                                if(checkEmojis(val)) error_str = $.lang[LANG]['config.unable.emoji'];
13648                                else if(val.length < 5) error_str = $.lang[LANG]['customsite.validate.message.minlengthto5'];
13649
13650                                if(error_str.length > 0) {
13651                                    $(this).closest('.cl-s-form-wrap').addClass('error');
13652                                    if($(this).parent().find('.cl-s-control-label.error').length > 0) {
13653                                        $(this).parent().find('.cl-s-control-label.error').html(error_str);
13654                                    } else {
13655                                        $(this).after('<label for="input" class="cl-s-control-label error">' + error_str + '</label>');
13656                                    }
13657                                    return false;
13658                                }
13659                            }
13660
13661                            $(this).closest('.cl-s-form-wrap').removeClass('error').removeClass('empty');
13662                            $(this).closest('.cl-s-form-wrap').find('.cl-s-control-label.error').remove();
13663                        }
13664                    });
13665
13666                    $('.cl-s-form-wrap .cl-s-form-control').on({
13667                        focus: function(e) {
13668                            $(this).closest('.cl-s-form-wrap').addClass('active');
13669                        },
13670                        blur: function(e) {
13671                            var val = $(this).val().trim();
13672                            
13673                            $(this).closest('.cl-s-form-wrap').removeClass('active');
13674                            if(val.length == 0) {
13675                                $(this).closest('.cl-s-form-wrap').removeClass('error').addClass('empty');
13676                                $(this).closest('.cl-s-form-wrap').find('.cl-s-control-label.error').remove();
13677                                return false;
13678                            } else {
13679                                $(this).closest('.cl-s-form-wrap').removeClass('empty');
13680
13681                                if(checkEmojis(val)) {
13682                                    $(this).closest('.cl-s-form-wrap').addClass('error');
13683                                    if($(this).parent().find('.cl-s-control-label.error').length > 0) {
13684                                        $(this).parent().find('.cl-s-control-label.error').html($.lang[LANG]['config.unable.emoji']);
13685                                    } else {
13686                                        $(this).after('<label for="input" class="cl-s-control-label error">' + $.lang[LANG]['config.unable.emoji'] + '</label>');
13687                                    }
13688                                    return false;
13689                                }
13690                            }
13691
13692                            $(this).closest('.cl-s-form-wrap').removeClass('error');
13693                            $(this).closest('.cl-s-form-wrap').find('.cl-s-control-label.error').remove();
13694                        }
13695                    });
13696
13697                    if(escrow == 'Y') {
13698                        $('.cancel-info-data').off('change');
13699                    }
13700                
13701                    ocModal.find('[data-toggle="popover"]').popover();
13702                });
13703
13704            },'json');
13705        },
13706        orderReturnExchangeModal: function(sid, pnum, onum, ognum, status, pclass) {
13707            if(typeof sid == 'undefined' || typeof pnum == 'undefined' || typeof onum == 'undefined') {
13708                alert('정보가 올바르지 않습니다');
13709                return false;
13710            }
13711
13712            $.post('/_check_order', { sid:sid, pnum:pnum, onum:onum, mode:'return', ognum: ognum }, function(data) {
13713                var LUX = false;
13714                if(data.lux) LUX = data.lux;
13715
13716                if(typeof data.error != 'undefined' && data.error) {
13717                    $(this).showModalFlat('ERROR', data.error, true, false, '', 'close');
13718                    return false;
13719                }
13720                var c_data = data.r, checkboxNone = '', noneAll = '', noneChecked = '', checkNoneAll = '', checkEscrowFooter = '', checkEscrowClass = '', checkEscrowExchangeFooter = '', checkDepositCancel = '';
13721                
13722                var checkEscrow = '', exchangeCheck = 'N';
13723                var dtl = c_data.delivery_template_list;
13724                var used_code_coupon = false;
13725                
13726                if (status == 'Y') {
13727                    checkboxNone = 'checked';
13728                    noneAll = ' noneAll';
13729                    checkNoneAll = 'fule';
13730                    checkEscrow = '<div class="escrow-warring top-escrow">\
13731                                    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 13" width="15" height="15">\
13732                                        <path fill="#4789e7" d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/>\
13733                                        <rect fill="#4789e7" x="6" y="3" width="1" height="5"/>\
13734                                        <rect fill="#4789e7" x="6" y="9" width="1" height="1"/>\
13735                                    </svg>\
13736                                    에스크로 결제 상품은 취소/반품 요청 시 전체선택만 가능합니다.\
13737                                </div>';
13738
13739                    checkEscrowFooter = '<div class="escrow-warring bottom-escrow">\
13740                                            <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 13" width="15" height="15">\
13741                                                <path fill="#4789e7" d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/>\
13742                                                <rect fill="#4789e7" x="6" y="3" width="1" height="5"/>\
13743                                                <rect fill="#4789e7" x="6" y="9" width="1" height="1"/>\
13744                                            </svg>\
13745                                            에스크로 환불 안내\
13746                                            <div class="escrow-return-info">- 취소처리 시 구매자의 환불정산액에서 취소 수수료(330원)가 차감됩니다.</div>\
13747                                            <div class="escrow-return-info">- 환불정산액은 취소처리 후 1~3영업일 후에 지급됩니다.</div>\
13748                                        </div>';
13749                    checkEscrowClass = 'cl-s-escrow-info';
13750
13751                    checkEscrowExchangeFooter = '\
13752                        <div class="escrow-warring escrow-exchange-warning bottom-escrow" style="display: none;">\
13753                            <div class="escrow-return-info">- 에스크로 결제 상품의 경우, 교환 요청/완료 시에는 반품이 불가능합니다.</div>\
13754                            <div class="escrow-return-info">- 자세한 사항은 판매자의 안내를 따라주세요.</div>\
13755                        </div>\
13756                    ';
13757                }
13758
13759                if(c_data.pay_info.coupon_list && c_data.pay_info.coupon_list.length) {
13760                    $.each(c_data.pay_info.coupon_list, function(k, v) {
13761                        if(v.kind == 'C') {
13762                            used_code_coupon = true;
13763                        }
13764                    })
13765                }
13766
13767                if(used_code_coupon) {
13768                    checkboxNone = 'checked';
13769                    noneAll = ' noneAll';
13770                    checkNoneAll = 'fule';
13771                    checkDepositCancel = '<div class="modal-comment deposit-cancel-desc codecoupon-cancel-desc">\
13772                                <div class="desc-box">\
13773                                    <div class="desc-title">코드쿠폰 사용 주문취소 안내</div>\
13774                                    <div class="section">- 코드쿠폰 사용 주문 건은 <span class="cl-red">전체 반품</span>만 가능합니다.</div>\
13775                                    <div class="section">- 전체 반품 후 구매를 원하는 상품은 다시 주문해주세요.</div>\
13776                                    ' + (c_data.order_status == 'W' ? '<div class="section">- 혹시나 입금을 하신 경우 별도로 문의 주시기 바랍니다.</div>' : '') + '\
13777                                </div>\
13778                            </div>\
13779                        ';
13780                        
13781                    checkEscrowExchangeFooter = '\
13782                    <div class="code-coupon-exchange-warning escrow-warring escrow-exchange-warning bottom-escrow" style="display: none;">\
13783                        <div class="escrow-return-info">- 코드 쿠폰이 적용된 주문건은 교환 접수 시 반품이 불가능합니다.</div>\
13784                        <div class="escrow-return-info">- 자세한 사항은 판매자의 안내를 따라주세요.</div>\
13785                    </div>\
13786                ';
13787                }
13788                
13789                var modal_str = '\
13790                    <form name="re_form" method="post" action="/_return_exchange">\
13791                        <input type="hidden" name="sid" value="' + sid + '">\
13792                        <input type="hidden" name="order_group" id="cancel-order-group" value="' + ognum + '">\
13793                        <input type="hidden" name="order_number" id="cancel-order-number" value="' + onum + '">\
13794                        <input type="hidden" name="m_status" value="M">\
13795                        <div class="cl-s-btn-group-toggle btn-group btn-group-toggle" data-toggle="buttons">\
13796                ';
13797
13798                if(status == 'Y' && data.r.exchange_check == true) {
13799                    modal_str += '\
13800                            <label class="btn btn-secondary disable">\
13801                                <input type="radio" name="status" id="order-radio-return" value="R"> 반품 요청\
13802                            </label>\
13803                            <label class="btn btn-secondary active">\
13804                                <input type="radio" name="status" id="order-radio-exchange" value="E" checked>
13804 교환 요청\
13805                            </label>\
13806                    ';
13807                } else {
13808                    modal_str += '\
13809                            <label class="btn btn-secondary active">\
13810                                <input type="radio" name="status" id="order-radio-return" value="R" checked> 반품 요청\
13811                            </label>\
13812                            <label class="btn btn-secondary">\
13813                                <input type="radio" name="status" id="order-radio-exchange" value="E"> 교환 요청\
13814                            </label>\
13815                    ';
13816                }
13817
13818                modal_str += '\
13819                        </div>\
13820                        '+checkEscrow+'\
13821                        <div class="cancel-product-title">\
13822                            <div class="newcheckbox hand">\
13823                                <label>\
13824                                    <input type="checkbox" class="'+noneAll+'" id="product-check" '+checkboxNone+'>\
13825                                    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\
13826                                        <path d="M13 0H3C1.3 0 0 1.3 0 3v10c0 1.7 1.3 3 3 3h10c1.7 0 3-1.3 3-3V3C16 1.3 14.7 0 13 0zM15 13c0 1.1-0.9 2-2 2H3c-1.1 0-2-0.9-2-2V3c0-1.1 0.9-2 2-2h10c1.1 0 2 0.9 2 2V13z"/>\
13827                                    </svg>\
13828                                    <svg class="active" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\
13829                                        <path d="M13 0H3C1.34 0 0 1.34 0 3v10c0 1.66 1.34 3 3 3h10c1.66 0 3-1.34 3-3V3C16 1.34 14.66 0 13 0zM13.03 6.03l-5.5 5.5C7.38 11.68 7.19 11.75 7 11.75s-0.38-0.07-0.53-0.22l-3.5-3.5c-0.29-0.29-0.29-0.77 0-1.06s0.77-0.29 1.06 0L7 9.94l4.97-4.97c0.29-0.29 0.77-0.29 1.06 0S13.32 5.74 13.03 6.03z"/>\
13830                                    </svg>\
13831                                </label>\
13832                            </div>\
13833                            반품/교환요청 상품\
13834                        </div>';
13835                        var my_point = Number(data.r.my_point);
13836                        var gradeDeliveryBenefit = c_data.pay_info && c_data.pay_info.grade_delivery_benefit ? c_data.pay_info.grade_delivery_benefit : {};
13837                        var gradeDeliveryBenefitUsed = String(gradeDeliveryBenefit.used || '').toUpperCase() == 'Y';
13838                        var gradeDeliveryBenefitDiscount = gradeDeliveryBenefitUsed ? Number(gradeDeliveryBenefit.discount_price || 0) : 0;
13839                        var getPointCalcDeliveryPrice = function(deliveryPrice) {
13840                            deliveryPrice = Number(deliveryPrice || 0);
13841                            if(!gradeDeliveryBenefitUsed || gradeDeliveryBenefitDiscount <= 0) return deliveryPrice;
13842
13843                            return Math.max(deliveryPrice - gradeDeliveryBenefitDiscount, 0);
13844                        };
13845                        var weight_template_product = {};
13846
13847                        for (var i=0;i<data.r.odata.length;i++) {
13848                            if(c_data.odata[i].state != 'normal') return;
13849                            if (c_data.odata[i].exchange_check == 'Y') exchangeCheck = 'Y';
13850                            var dts = c_data.odata[i].state == 'normal' ? c_data.odata[i].delivery_template_seq : '';
13851                            if(c_data.odata[i].state == 'normal' && c_data.odata[i].mix_yn != 'Y') dts += '-' + c_data.odata[i].product_number;
13852                            var dt = c_data.odata[i].state == 'normal' ? c_data.odata[i].delivery_type : '';
13853
13854                            if(!weight_template_product.hasOwnProperty(dts)) weight_template_product[dts] = {};
13855                            if(!weight_template_product[dts].hasOwnProperty(dt)) weight_template_product[dts][dt] = {};
13856                            if(!weight_template_product[dts][dt].hasOwnProperty(c_data.odata[i].product_number)) weight_template_product[dts][dt][c_data.odata[i].product_number] = data.r.odata[i];
13857
13858                            var tooltip = '';
13859                            if(dtl[dts]['price_type'] == 'WEIGHT' || dtl[dts]['price_type'] == 'QUANTITY') {
13860                                if(dtl[dts]['price_type_detail']['method'] == 'DIFFERENTIAL') {
13861                                    if(dtl[dts]['price_type'] == 'QUANTITY') {
13862                                        tooltip += '<li class=\'title\'>수량별 배송비</li>';
13863                                        $(dtl[dts]['price_type_detail']['detail']).each(function(k, detail) {
13864                                            var d_v = Object.keys(detail)[0];
13865                                            var d_p = detail[d_v];
13866                                            tooltip += '<li class=\'item\'>' + d_v + '개 이상 ' + number_format(d_p) + '원</li>';
13867                                        });
13868                                    } else if(dtl[dts]['price_type'] == 'WEIGHT') {
13869                                        tooltip += '<li class=\'title\'>무게별 배송비</li>';
13870                                        $(dtl[dts]['price_type_detail']['detail']).each(function(k, detail) {
13871                                            var d_v = Object.keys(detail)[0];
13872                                            var d_p = detail[d_v];
13873                                            tooltip += '<li class=\'item\'>' + d_v + 'Kg 이상 ' + number_format(d_p) + '원</li>';
13874                                        });
13875                                    }
13876                                } else if(dtl[dts]['price_type_detail']['method'] == 'REPEAT') {
13877                                    if(dtl[dts]['price_type'] == 'QUANTITY') {
13878                                        tooltip += '<li class=\'title\'>수량별 배송비</li>';
13879                                        tooltip += '<li class=\'item\'>' + number_format(dtl[dts]['repeat_value']) + '개 구매시마다 ' + number_format(dtl[dts]['repeat_price']) + '원 반복 부과</li>';
13880                                    } else if(dtl[dts]['price_type'] == 'WEIGHT') {
13881                                        tooltip += '<li class=\'title\'>무게별 배송비</li>';
13882                                        tooltip += '<li class=\'item\'>' + number_format(dtl[dts]['repeat_value']) + 'Kg마다 ' + number_format(dtl[dts]['repeat_price']) + '원 반복 부과</li>';
13883                                    }
13884                                }
13885                                if(tooltip && (dt == 'DELIVERY' || dt == 'DIRECT'))  {
13886                                    if(!LUX) tooltip += '<li class=\'desc\'>추가 상품은 배송비 조건에 반영되지 않습니다.</li>';
13887
13888                                    if(dtl[dts]['price_type'] == 'WEIGHT' && weight_template_product[dts][dt]) {
13889                                        tooltip += '<li class=\'title product-weight\'>상품별 무게</li>';
13890                                        $.each(weight_template_product[dts][dt], function(k, v) {
13891                                            tooltip += '<li class=\'item\'>' + v.product_name + ' : ' + number_format(v.product_weight) + 'kg</li>';
13892                                        });
13893                                    }
13894
13895                                    tooltip = '<ul class=\'delivery-tooltip\'>' + tooltip + '</ul>';
13896                                    dtl[dts]['tooltip'] = tooltip;
13897                                }
13898                            }
13899                        }
13900                        
13901                        modal_str += '<table class="table product-table">';
13902                        for (var i=0;i<data.r.odata.length;i++) {
13903                            if (c_data.odata[i].d_status == '' || c_data.odata[i].d_status == 'CN') {
13904                                noneChecked = '';
13905                                if (!checkNoneAll) noneAll = '';
13906                            } else {
13907                                if (!checkNoneAll) noneAll = 'noneAll';
13908                                noneChecked = 'noneChecked';
13909                            }
13910
13911                            var curr_point = 0;
13912                            var usable_point = 0;
13913                            var refund_point = 0;
13914                            var expired_point = 0;
13915
13916                            if(c_data.odata[i].used_point) {
13917                                curr_point = Math.abs(c_data.odata[i].used_point.point);
13918                                usable_point = Math.abs(c_data.odata[i].used_point.usable_point);
13919                            }
13920
13921                            // if(c_data.odata[i].refund_point) {
13922                            //     refund_point = c_data.odata
13923                            // }
13924
13925                            if(c_data.odata[i].expired_point) {
13926                                expired_point = Math.abs(c_data.odata[i].expired_point.point);
13927                            }
13928
13929                            var dts = c_data.odata[i].state == 'normal' ? c_data.odata[i].delivery_template_seq : '';
13930                            if(c_data.odata[i].state == 'normal' && c_data.odata[i].mix_yn != 'Y') dts += '-' + c_data.odata[i].product_number;
13931                            var dt = c_data.odata[i].state == 'normal' ? c_data.odata[i].delivery_type : '';
13932
13933                            modal_str += '\
13934                            <tr class="cl-s-product-jumbotron clearfix">\
13935                                <td>\
13936                                <div class="newcheckbox hand">\
13937                                    <label>\
13938                                        <input type="checkbox" class="status-checkbox cancel-info-data '+noneAll+' '+noneChecked+'" data-curr_point="' + curr_point + '" data-usable_point="' + usable_point + '" data-expired_point="' + expired_point + '" data-type="'+c_data.pdata[i].state
13938+'" name="order_number_ary[]" value="'+c_data.odata[i].order_number+'" '+checkboxNone+' data-option_type="' + c_data.pdata[i].option_type + '" data-product_number="' + c_data.odata[i].product_number + '" data-product_weight="' + (c_data.odata[i].state == 'normal' ? c_data.odata[i].product_weight : 0) + '" data-mix_yn="' + (c_data.odata[i].state == 'normal' ? c_data.odata[i].mix_yn : '') + '" data-delivery_template_seq="' + (c_data.odata[i].state == 'normal' ? dts : '') + '" data-delivery_type="' + (c_data.odata[i].state == 'normal' ? c_data.odata[i].delivery_type : '') + '" data-quantity="' + c_data.odata[i].quantity + '" data-grade_discount_price="' + (parseInt(c_data.odata[i].grade_discount_price || 0)) + '" data-delivery_price="'+ (c_data.odata[i].state == 'normal' && dtl[dts]['pay_type'] == 'PREPAY' ? c_data.odata[i].delivery_price : 0) +'">\
13939                                        <svg viewBox="0 0 16 16" width="16" height="16">\
13940                                            <path d="M13 0H3C1.3 0 0 1.3 0 3v10c0 1.7 1.3 3 3 3h10c1.7 0 3-1.3 3-3V3C16 1.3 14.7 0 13 0zM15 13c0 1.1-0.9 2-2 2H3c-1.1 0-2-0.9-2-2V3c0-1.1 0.9-2 2-2h10c1.1 0 2 0.9 2 2V13z"/>\
13941                                        </svg>\
13942                                        <svg class="active" viewBox="0 0 16 16" width="16" height="16">\
13943                                            <path d="M13 0H3C1.34 0 0 1.34 0 3v10c0 1.66 1.34 3 3 3h10c1.66 0 3-1.34 3-3V3C16 1.34 14.66 0 13 0zM13.03 6.03l-5.5 5.5C7.38 11.68 7.19 11.75 7 11.75s-0.38-0.07-0.53-0.22l-3.5-3.5c-0.29-0.29-0.29-0.77 0-1.06s0.77-0.29 1.06 0L7 9.94l4.97-4.97c0.29-0.29 0.77-0.29 1.06 0S13.32 5.74 13.03 6.03z"/>\
13944                                        </svg>\
13945                                    </label>\
13946                                </div>\
13947                                <div class="cl-s-product-thumb">\
13948                                    <img src="' + c_data.pdata[i].img + '" alt="' + c_data.pdata[i].name + '" class="' + c_data.pdata[i].img_align + '" />\
13949                                </div>\
13950                                <div class="cl-s-product-info">\
13951                                    <h5 class="cl-s-product-title">' + c_data.pdata[i].name + '</h5>\
13952                            ';
13953
13954                            var price = c_data.odata[i].price,
13955                                quantity = Number(c_data.odata[i].quantity),
13956                                sum_price = quantity * price;
13957                                option_name = (typeof c_data.pdata[i].option != "undefined" && c_data.pdata[i].option) ? c_data.pdata[i].option : '',
13958                                option_str = '',
13959                                etc_str = (typeof c_data.pdata[i].etc_date != "undefined" && c_data.pdata[i].etc_date) ? '<span>선택일자: '+c_data.pdata[i].etc_date+'</span>' : '',
13960                                option_title = (c_data.pdata[i].option_type == 'A') ? '추가옵션: ' + (c_data.pdata[i].option_group ? c_data.pdata[i].option_group + ' : ' : '') : '옵션';
13961                            if(option_name) {
13962                                option_str = (c_data.pdata[i].option_text_str) ? '<span>' + option_title + ': '+option_name+' / '+c_data.pdata[i].option_text_str+'</span>' : '<span>' + option_title + ': '+option_name+'</span>';
13963                            } else {
13964                                option_str = (c_data.pdata[i].option_text_str) ? '<span>' + option_title + ': '+c_data.pdata[i].option_text_str+'</span>' : '';
13965                            }
13966
13967                            modal_str += '\
13968                                    <div class="option-str option-check" data-optionState="" data-optionPrice="'+sum_price+'" data-deliveryPrice="'+(dtl[dts]['sel_pay_type'] == 'DELIVERED' ? 0 : c_data.odata[i].delivery_price)+'"><span>' + number_format(sum_price) + '원</span>' + option_str + etc_str + '<span>' + quantity + '개</span></div>\
13969                                </div>\
13970                            </td>';
13971
13972                            if(c_data.odata[i].state == 'normal') {
13973                                var delivery_cnt = dtl[dts]['dtype'][dt].delivery_cnt;
13974                                if(!dtl[dts]['dtype'][dt].hasOwnProperty('counter')) {
13975                                    dtl[dts]['dtype'][dt]['counter'] = 0;
13976                                }
13977
13978                                dtl[dts]['dtype'][dt]['counter']++;
13979
13980                                if(dtl[dts]['dtype'][dt]['counter'] == 1) {
13981                                    modal_str +='\
13982                                        <td rowspan="' + delivery_cnt + '" class="delivery-price"><div>배송비</div><div class="price"><span>';
13983                                    if(dt == 'DELIVERY' || dt == 'DIRECT') {
13984                                        if(dtl[dts]['price_type'] == 'ETC') {
13985                                            modal_str += '별도안내</span>';
13986                                        } else {
13987                                            modal_str += number_format(dtl[dts]['dtype'][dt]['price']) + '</span> 원';    
13988                                        }
13989                                        if(dtl[dts]['pay_type'] == 'DELIVERED') modal_str += '(착불)';
13990
13991                                        if(dtl[dts]['price_type'] == 'FREE_CONDITION') {
13992                                            modal_str += '<div class="price-desc">' + number_format(dtl[dts]['free_condition']) + '원 이상<br>배송비 무료</div>';
13993                                        }
13994                                    } else {
13995                                        modal_str += $.lang[LANG]['shopping.delivery.template.delivery_type.' + dt.toLowerCase()] + '</span>';
13996                                        if(dt == 'QUICK') modal_str += '(착불)';
13997                                    }
13998                                    if(dtl[dts]['tooltip'] && (dt == 'DELIVERY' || dt == 'DIRECT')) {
13999                                        modal_str += '<svg class="cm-popover-info" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 13" width="13" height="13" tabindex="0" data-trigger="hover" data-toggle="popover" fill="#4789e7" data-html="true" data-placement="top" data-content="' + dtl[dts]['tooltip'] + '" data-original-title="" title=""><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"></path><path d="M6.66 3.01C5.61 3.01 4.58 3.5 4.5 4.8c0 0.06-0.01 0.12 0 0.2h1.02c0-0.07 0.01-0.15 0.02-0.23 0.08-0.62 0.52-0.76 1.08-0.76 0.63 0 1.02 0.37 1.02 0.95 -0.01 0.48-0.3 0.87-0.76 1.34C6.21 6.97 6.02 7.37 6 8h0.99C7 7.
1399966 7.04 7.37 7.67 6.75 8.17 6.27 8.7 5.68 8.7 4.87 8.7 3.85 7.89 3.01 6.66 3.01z"></path><rect x="6" y="9" width="1" height="1"></rect></svg>';
14000                                    }
14001                                    modal_str +='</div></td>\
14002                                    ';
14003                                }
14004
14005                                modal_str += '\
14006                                </tr>';
14007
14008                                if(dtl[dts]['dtype'][dt]['counter'] == dtl[dts]['dtype'][dt]['delivery_cnt']) {
14009                                    modal_str += '\
14010                                        <tr class="cl-s-product-jumbotron clearfix delivery-price delivery-price-mobile">\
14011                                            <td><div class="delivery-title">묶음 배송비</div><div class="delivey-price"><span>';
14012
14013                                    if(dtl[dts]['tooltip'] && (dt == 'DELIVERY' || dt == 'DIRECT')) {
14014                                        modal_str += '<svg class="cm-popover-info" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 13" width="13" height="13" tabindex="0" data-trigger="hover" data-toggle="popover" fill="#4789e7" data-html="true" data-placement="top" data-content="' + dtl[dts]['tooltip'] + '" data-original-title="" title=""><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"></path><path d="M6.66 3.01C5.61 3.01 4.58 3.5 4.5 4.8c0 0.06-0.01 0.12 0 0.2h1.02c0-0.07 0.01-0.15 0.02-0.23 0.08-0.62 0.52-0.76 1.08-0.76 0.63 0 1.02 0.37 1.02 0.95 -0.01 0.48-0.3 0.87-0.76 1.34C6.21 6.97 6.02 7.37 6 8h0.99C7 7.66 7.04 7.37 7.67 6.75 8.17 6.27 8.7 5.68 8.7 4.87 8.7 3.85 7.89 3.01 6.66 3.01z"></path><rect x="6" y="9" width="1" height="1"></rect></svg>';
14015                                    }
14016
14017                                    if(dt == 'DELIVERY' || dt == 'DIRECT') {
14018                                        modal_str += number_format(dtl[dts]['dtype'][dt]['price']) + '</span> 원';
14019                                        if(dtl[dts]['pay_type'] == 'DELIVERED') modal_str += '(착불)';
14020                                        if(dtl[dts]['price_type'] == 'FREE_CONDITION') {
14021                                            modal_str += '<div class="price-desc">' + number_format(dtl[dts]['free_condition']) + '원 이상 배송비 무료</div>';
14022                                        }
14023                                    } else {
14024                                        modal_str += $.lang[LANG]['shopping.delivery.template.delivery_type.' + dt.toLowerCase()] + '</span>';
14025                                        if(dt == 'QUICK') modal_str += '(착불)';
14026                                    }
14027
14028                                    modal_str += '</div></td>\
14029                                        </tr>\
14030                                    ';
14031                                }
14032                            }
14033                        }
14034
14035                        modal_str += '</table>';
14036
14037                        modal_str += '<div class="order-re-content">\
14038                            <div class="cl-s-form-selector">\
14039                                <select class="selectpicker dropdown" id="re-reason" name="reason">\
14040                                    <option value="구매의사 취소">구매의사 취소</option>\
14041                                    <option value="다른 상품 잘못 주문">다른 상품 잘못 주문</option>\
14042                                    <option value="상품파손">상품파손</option>\
14043                                    <option value="배송지연">배송지연</option>\
14044                                    <option value="상품정보 상이">상품정보 상이</option>\
14045                                    <option value="오배송">오배송</option>\
14046                                    <option value="기타">기타</option>\
14047                                </select>\
14048                                <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 8 4" width="8" height="4"><polygon points="0 0 4 4 8 0 "></polygon></svg>\
14049                            </div>\
14050                            <div class="cl-s-form-wrap">\
14051                                <div class="cl-s-form-group input-label-hide">\
14052                                    <textarea class="cl-s-form-control cl-s-form-textarea" id="re-requests" name="requests" maxlength="500" required="required"></textarea>\
14053                                    <label for="input" class="cl-s-control-label">자세한 내용을 적어주세요. (500자 이내)</label>\
14054                                </div>\
14055                            </div>\
14056                        </div>';
14057                        /*  반품/교환 사진 제거
14058                            <div class="cl-s-files re-files">\
14059                                <input id="re-file" type="file" name="files[]" multiple data-sid="' + sid + '" data-uid=\"' + c_data.writer.id + '\">\
14060                                <label class="cl-s-file-update re-file-update clearfix"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" width="20" height="20"><path d="M0 0v20h20V0H0zM19 1v11.3l-3-3 -4 4 -6-6 -5 5V1H19zM1 19v-5.3l5-5 6 6 4-4 3 3V19H1z"/><circle cx="14.5" cy="5.5" r="1.5"/></svg> <span>사진</span></label>\
14061                                <ul class="cl-s-files-list re-files-list clearfix">\
14062                                </ul>\
14063                            </div>\
14064                        */
14065
14066                        modal_str += checkEscrowExchangeFooter;
14067
14068                        modal_str += '<div class="order-cancel-content">\
14069                            <div class="cancel-info-box">\
14070                                <div class="cancel-info"><span class="cancel-info-title">반품상품 합계</span><span class="cancel-info-price" id="cancel-price">0원</span></div>\
14071                                <div class="cancel-info"><span class="cancel-info-title">반품 배송비 합계</span><span class="cancel-info-price" id="cancel-delivery-price">0원</span></div>\
14072                                <div class="cancel-info"><span class="cancel-info-title">적립금</span><span class="cancel-info-price" id="cancel-point-price">0원</span></div>\
14073                                <div class="cancel-info"><span class="cancel-info-title">쿠폰</span><span class="cancel-info-price" id="cancel-coupon-price">0원</span></div>\
14074                                <div class="cancel-info"><span class="cancel-info-title">
14074등급할인</span><span class="cancel-info-price" id="cancel-grade-discount-price">0원</span></div>\
14075                                <div class="cancel-info"><span class="cancel-info-title cancel-coupon-title"></span><span class="cancel-info-price" id="cancel-coupon-detail"></span></div>\
14076                                <div class="cancel-info-line"></div>\
14077                                <div class="return-total-info"><span class="cancel-info-title">환불 예정금액</span><span class="cancel-info-price"><span id="return-total-price">0</span>원</span></div>\
14078                            </div>'+checkEscrowFooter+'\
14079                        </div>';
14080                        modal_str += checkDepositCancel;
14081                    
14082                    if (pclass == '무통장 입금' || pclass == '가상계좌') {
14083                        var returnClass = '';
14084                        if (c_data.return_bank.length > 1 && c_data.return_bank.indexOf('')===-1) returnClass = 'returnDisabled';
14085
14086                        modal_str += '\
14087                            <div id="return-modal">\
14088                                <div class="modal-sub-title">환불 계좌</div>\
14089                                <ul class="qna-writer clearfix">\
14090                                    <li class="">\
14091                                        <div class="cl-s-form-wrap '+returnClass+'">\
14092                                            <div class="cl-s-form-group">';
14093                                            if (c_data.return_bank.length > 1 && c_data.return_bank.indexOf('')===-1) modal_str += '<input type="text" class="cl-s-form-control has-value" id="no-bank" name="no_bank" readonly required="required" value="'+c_data.return_bank[1]+'">';
14094                                            else modal_str += '<input type="text" class="cl-s-form-control" id="no-bank" name="no_bank" required="required" value="">';
14095                                            modal_str += '<label for="input" class="cl-s-control-label">은행명</label>\
14096                                            </div>\
14097                                        </div>\
14098                                    </li>\
14099                                    <li>\
14100                                        <div class="cl-s-form-wrap '+returnClass+'">\
14101                                            <div class="cl-s-form-group">';
14102                                            if (c_data.return_bank.length > 1 && c_data.return_bank.indexOf('')===-1) modal_str += '<input type="text" class="cl-s-form-control has-value" id="no-bank-name" readonly name="no_bank_name" required="required" value="'+c_data.return_bank[2]+'">';
14103                                            else modal_str += '<input type="text" class="cl-s-form-control" id="no-bank-name" name="no_bank_name" required="required">';
14104                                            modal_str += '<label for="input" class="cl-s-control-label">예금주</label>\
14105                                            </div>\
14106                                        </div>\
14107                                    </li>\
14108                                    <li>\
14109                                        <div class="cl-s-form-wrap '+returnClass+'">\
14110                                            <div class="cl-s-form-group">';
14111                                            if (c_data.return_bank.length > 1 && c_data.return_bank.indexOf('')===-1) modal_str += '<input type="text" class="cl-s-form-control has-value" id="no-bank-number" name="no_bank_number" readonly data-type="email" required="required" value="'+c_data.return_bank[3]+'">';
14112                                            else modal_str += '<input type="text" class="cl-s-form-control" id="no-bank-number" name="no_bank_number" data-type="email" required="required" value="">';
14113                                            modal_str += '<label for="input" class="cl-s-control-label">계좌번호</label>\
14114                                            </div>\
14115                                        </div>\
14116                                    </li>\
14117                                </ul>\
14118                                <div class="modal-comment">동일 주문 내 여러 상품을 환불 요청하시는 경우, ì
14118µœì´ˆ 입력한 환불계좌로 일괄 환불처리됩니다.</div>\
14119                                <div class="modal-comment point-used-desc hide">\
14120                                    <div class="desc-box">\
14121                                        <div class="desc-title">적립금 환불 안내</div>\
14122                                        <div class="section">상품(들)을 구매하여 적립된 적립금 <span id="disp_used_point_total" class="point-color"></span>원이 이미 사용되거나 유효기간이 만료되었습니다.</div>\
14123                                        <div class="section">현재 보유 적립금이 <span class="point-color">' + addCommas(my_point) + '</span>원 으로 구매 적립된 적립금 <span id="disp_cancel_after_point" class="point-color"></span>원을 취소 처리할 수 없습니다.</div>\
14124                                        <div class="section">미 취소된 적립금에 대한 처리는 판매자와 협의해주세요.</div>\
14125                                    </div>\
14126                                    <div class="newcheckbox hand">\
14127                                        <label style="margin-left: 25px;">\
14128                                            <input type="checkbox" class="cancel-agree" />\
14129                                            <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\
14130                                                <path d="M13 0H3C1.3 0 0 1.3 0 3v10c0 1.7 1.3 3 3 3h10c1.7 0 3-1.3 3-3V3C16 1.3 14.7 0 13 0zM15 13c0 1.1-0.9 2-2 2H3c-1.1 0-2-0.9-2-2V3c0-1.1 0.9-2 2-2h10c1.1 0 2 0.9 2 2V13z"></path>\
14131                                            </svg>\
14132                                            <svg class="active" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\
14133                                                <path d="M13 0H3C1.34 0 0 1.34 0 3v10c0 1.66 1.34 3 3 3h10c1.66 0 3-1.34 3-3V3C16 1.34 14.66 0 13 0zM13.03 6.03l-5.5 5.5C7.38 11.68 7.19 11.75 7 11.75s-0.38-0.07-0.53-0.22l-3.5-3.5c-0.29-0.29-0.29-0.77 0-1.06s0.77-0.29 1.06 0L7 9.94l4.97-4.97c0.29-0.29 0.77-0.29 1.06 0S13.32 5.74 13.03 6.03z"></path>\
14134                                            </svg>\
14135                                        위 내용을 확인하였습니다.</label>\
14136                                    </div>\
14137                                    <div class="point-used-cancel-agree-desc">\
14138                                        <svg viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>\
14139                                        적립금 환불 안내에 동의해주세요.\
14140                                    </div>\
14141                                </div>\
14142                            </div>\
14143                        ';
14144                    }
14145                    modal_str += '</form>\
14146                ';
14147                
14148                var oreModal = $(this).showModalFlat('반품/교환 요청', modal_str,true,true,function () {
14149
14150                    var f = document.re_form;
14151
14152                    if(oreModal.find('#re-reason').prop('value') == '') {
14153                        // $('#re-reason').selectpicker('toggle');
14154                        // return false;
14155                        $('#re-reason').closest('.cl-s-form-selector').addClass('empty');
14156                    }
14157
14158                    oreModal.find('.cl-s-form-wrap').each(function() {
14159                        var check_input = $(this).find('.cl-s-form-control'),
14160                            val = check_input.val().trim();
14161
14162                        if(val.length == 0) {
14163                            $(this).removeClass('error').addClass('empty');
14164                            $(this).find('.cl-s-control-label.error').remove();
14165                        } else {
14166                            if($(this).hasClass('error')) {
14167                                check_input.focus();
14168                            }
14169                        }
14170                    });
14171                    var checkCnt = 0;
14172
14173                    $(".status-checkbox").each(function (i, index) {
14174                        if ($(this).is(":checked") === true) {
14175                            checkCnt++;
14176                        }
14177                    });
14178
14179                    if (checkCnt < 1) {
14180                        alert('상품을 1개 이상 선택해 주세요');
14181                        return false;
14182                    }
14183
14184                    if(oreModal.find('.cl-s-form-wrap.empty, .cl-s-form-wrap.error').length > 0) {
14185                        // oreModal.find('.cl-s-form-wrap.empty, .cl-s-form-wrap.error').eq(0).find('.cl-s-form-control').focus();
14186                        return false;
14187                    }
14188
14189
14190                    if(oreModal.find("input[type='checkbox'].cancel-agree:visible").length && oreModal.find("input[type='checkbox'].cancel-agree:visible").length != oreModal.find("input[type='checkbox'].cancel-agree:visible:checked").length) {
14191                        $(".point-used-cancel-agree-desc").show();
14192                        return false;
14193                    } else {
14194                        $(".point-used-cancel-agree-desc").hide();
14195                    }
14196
14197                    var activeStatus = oreModal.find('.cl-s-btn-group-toggle .btn-secondary.active input[name="status"]').val();
14198                    if(activeStatus) {
14199                        oreModal.find('input[name="status"][value="' + activeStatus + '"]').prop('checked', true);
14200                        oreModal.find('input[name="status"]').not('[value="' + activeStatus + '"]').prop('checked', false);
14201                    }
14202
14203                    $.processON();
14204
14205                    f.submit();
14206
14207                },'close','등록하기','cl-s-order-returnexchange cl-s-order-cancel cl-modal cl-s-btn cover ' + checkEscrowClass, false, '', function() {
14208                    var totalCnt = 0, totalNomalCheck = 0, nomalCheck = 0;
14209                    var price = 0;
14210                    var deliveryPrice = 0;
14211                    var gradeDiscountPrice = 0;
14212                    
14213                    var mix_yn = $(this).data('mix_yn');
14214                    var delivery_price = 0;
14215                    var $form = $('form[name="re_form"]');
14216                    
14217                    $('.status-checkbox').each(function(i, index) {
14218                        if ($(this).is(":checked") === true) {
14219                            price += ($(this).closest('.cl-s-product-jumbotron').find('.option-check').attr('data-optionPrice') * 1);
14220                            gradeDiscountPrice += Number($(this).data('grade_discount_price') || 0);
14221                            totalCnt++;
14222                            if ($(this).attr('data-type') == 'normal') {
14223                                nomalCheck++;
14224                                var mix_yn = $(this).data('mix_yn');
14225                                var delivery_price = 0;
14226                                var delivery_template_seq = $(this).data('delivery_template_seq');
14227                                var delivery_type = $(this).data('delivery_type');
14228                                if(oreModal.find('input[name="order_number_ary[]"][data-delivery_type="' + delivery_type + '"][data-delivery_template_seq="' + delivery_template_seq + '"]').length == oreModal.find('input[name="order_number_ary[]"][data-delivery_type="' + delivery_type + '"][data-delivery_template_seq="' + delivery_template_seq + '"]:checked').length) {
14229                                    delivery_price = Number($(this).data('delivery_price'));
14230                                }
14231                                deliveryPrice += delivery_price;
14232                            }
14233                        }
14234
14235                        if ($(this).attr('data-type') == 'normal') {
14236                            totalNomalCheck++;
14237                        }
14238                    });
14239
14240                    var product_price = price + getPointCalcDeliveryPrice(deliveryPrice),
14241                        rePayment = parseInt(c_data.pay_info.request.payment.total) - parseInt(c_data.pay_info.request.payment.coupon) - parseInt(c_data.pay_info.request.cancel.total) - parseInt(c_data.pay_info.request.return.total);
14242
14243                    rePayment = (rePayment > 0) ? rePayment : 0;
14244
14245                    // coupon 처리
14246                    var coupon = c_data.pay_info.coupon_list,
14247                        cancel_coupon_price = 0;
14248                    if(coupon.length) {
14249                        var checked_order_number = $('.cancel-info-data:checked').map(function(){ return this.value; }).toArray();
14250                        $.each(coupon, function(i,v) {
14251                            if(checked_order_number.indexOf(v.order_number) > -1 || v.kind == 'C') {
14252                                cancel_coupon_price += parseInt(v.discount_price);
14253
14254                                // 환불금에서 쿠폰처리
14255                                if($('.coupon-detail-info[data-seq="' + v.seq + '"]').length == 0) {
14256                                    $('.cancel-coupon-title').append('<div class="coupon-name coupon-detail-info" data-seq="' + v.seq + '">' + v.coupon_name + '</div>');
14257                                    $('#cancel-coupon-detail').append('<div class="coupon-price coupon-detail-info" data-seq="' + v.seq + '">-' + number_format(parseInt(v.discount_price)) + '원</div>');
14258                                }
14259                            } else {
14260                                $('.coupon-detail-info[data-seq="' + v.seq + '"]').remove();
14261                            }
14262                        });
14263                        // 취소된 쿠폰 저장
14264                        
14265                    }
14266                    product_price = product_price - parseInt(cancel_coupon_price);
14267                    product_price = product_price - gradeDiscountPrice;
14268
14269                    var use_point = (rePayment - product_price > 0) ? 0 : rePayment - product_price;
14270                    product_price = product_price + use_point;
14271
14272                    $('#cancel-price').html(number_format(price)+'원');
14273                    $('#cancel-delivery-price').html(number_format(deliveryPrice)+'원');
14274                    $('#cancel-point-price').html(number_format(use_point)+'원');
14275                    $('#cancel-coupon-price').html(((cancel_coupon_price > 0) ? '-' + number_format(cancel_coupon_price) : '0')+'원');
14276                    $('#cancel-grade-discount-price').html(((gradeDiscountPrice > 0) ? '-' + number_format(gradeDiscountPrice) : '0')+'원');
14277                    $('#return-total-price').html(number_format(product_price));
14278
14279                    $('.cancel-info-data').on('change', function () {
14280                        if($(this).hasClass('noneAll')) return;    
14281                        var cancel_after_point = my_point;
14282                        var disp_used_point_total = 0;
14283                        var deliveryPrice = 0;
14284
14285                        var product_number = $(this).attr('data-product_number');
14286                        // console.log(product_number);
14287                        if($('input[name="status"]:checked').val() == 'R') { // 반품일때만 
14288                            if($(this).attr('data-option_type') != 'A' && !$('input[name="order_number_ary[]"][data-product_number="' + product_number + '"][data-option_type!="A"]:not(:checked)').length) {
14289                                $('input[name="order_number_ary[]"][data-product_number="' + product_number + '"][data-option_type="A"]').prop('checked',true);
14290                            } else if($(this).attr('data-option_type') == 'A' && !$('input[name="order_number_ary[]"][data-product_number="' + product_number + '"][data-option_type!="A"]:not(:checked)').length && !$(this).prop('checked')) {
14291                                $('input[name="order_number_ary[]"][data-product_number="' + product_number + '"][data-option_type!="A"]:last').prop('checked',fal
14291se);
14292                            }
14293                        }
14294
14295                        if($("input[name='order_number_ary[]']:checked").length) {
14296                            coupon.map(function(v,k) { coupon[k]['apply'] = '';  });
14297                            $("input[name='order_number_ary[]']:checked").each(function() {
14298                                cancel_after_point = Number(cancel_after_point) + ((Number($(this).data("expired_point"))) - Number($(this).data("curr_point")));
14299                                disp_used_point_total += ((Number($(this).data("expired_point"))) - Number($(this).data("curr_point")));
14300                                c_ord_num = $(this).val();
14301
14302                                if($(this).data('type') != 'normal' || $(this).data('option_type') == 'A') return;
14303                                var mix_yn = $(this).data('mix_yn');
14304                                var delivery_price = 0;
14305                                var delivery_template_seq = $(this).data('delivery_template_seq');
14306                                var delivery_type = $(this).data('delivery_type');
14307                                var product_weight = $(this).data('product_weight');
14308
14309                                
14310
14311                                if(delivery_type != 'DELIVERY' && delivery_type != 'DIRECT') return;
14312                                // if(dtl[delivery_template_seq]['price_type'] != 'WEIGHT' && dtl[delivery_template_seq]['price_type'] != 'QUANTITY') {
14313                                if(oreModal.find('input[name="order_number_ary[]"][data-delivery_type="' + delivery_type + '"][data-delivery_template_seq="' + delivery_template_seq + '"]').length == oreModal.find('input[name="order_number_ary[]"][data-delivery_type="' + delivery_type + '"][data-delivery_template_seq="' + delivery_template_seq + '"]:checked').length) {
14314                                    delivery_price = Number($(this).data('delivery_price'));
14315
14316                                    coupon.map(function(v,k) { if(v.order_number == c_ord_num && delivery_price > 0 && v.benefit == 'DELIVERY') coupon[k]['apply'] = '1';  });
14317                                } 
14318                                deliveryPrice += delivery_price;
14319                            });
14320                        }
14321
14322                        if(cancel_after_point < 0) {
14323                            $(".point-used-desc #disp_cancel_after_point").html(addCommas(Math.abs(cancel_after_point)));
14324                            $(".point-used-desc #disp_used_point_total").html(addCommas(Math.abs(disp_used_point_total)));
14325                            $(".point-used-desc").removeClass("hide");
14326                        } else {
14327                            $(".point-used-desc").addClass("hide");
14328                            $(".point-used-desc #disp_cancel_after_point").html("");
14329                            $(".point-used-desc #disp_used_point_total").html("");
14330                        }
14331
14332                        var price = 0;
14333                        var gradeDiscountPrice = 0;
14334                        var oLength = $('.option-check').length;
14335                        var totalCnt = 0, totalNomalCheck = 0, nomalCheck = 0;
14336                        var isReturn = $('input[name="status"]:checked').val();
14337
14338
14339                        $form.find('.order-cancel-content.extra-info').remove();
14340
14341                        if ($(this).hasClass('noneAll') === true) {
14342                            if ($(this).hasClass('noneChecked') === true) {
14343                                $(this).prop('checked', false);
14344                            } else {
14345                                $(this).prop('checked', true);
14346                                $('.status-checkbox').each(function () {
14347                                    if ($(this).prop('disabled') !== true) $(this).prop('checked', true);
14348                                });
14349                            }
14350                        }
14351
14352                        $('.status-checkbox').each(function (i, index) {
14353                            if ($(this).is(':checked') === true) {
14354                                price += ($(this).closest('.cl-s-product-jumbotron').find('.option-check').attr('data-optionPrice') * 1);
14355                                gradeDiscountPrice += Number($(this).data('grade_discount_price') || 0);
14356                                totalCnt++;
14357                                if ($(this).attr('data-type') == 'normal') {
14358                                    nomalCheck++;
14359                                }
14360                            }
14361
14362                            if ($(this).attr('data-type') == 'normal') {
14363                                totalNomalCheck++;
14364                            }
14365                        });
14366
14367                        var product_price = price + getPointCalcDeliveryPrice(deliveryPrice),
14368                            rePayment = parseInt(c_data.pay_info.request.payment.total) - parseInt(c_data.pay_info.request.payment.coupon) - parseInt(c_data.pay_info.request.cancel.total) - parseInt(c_data.pay_info.request.return.total);
14369
14370                        rePayment = (rePayment > 0) ? rePayment : 0;
14371
14372
14373                        // coupon 처리
14374                        var cancel_coupon_price = 0;
14375                        if(coupon.length) {
14376                            var checked_order_number = $('.cancel-info-data:checked').map(function(){ return this.value; }).toArray();
14377                            $.each(coupon, function(i,v) {
14378                                v.apply = (v.apply || v.benefit != 'DELIVERY') ? '1' : '';
14379                                if((checked_order_number.indexOf(v.order_number) > -1 && v.apply) || v.kind == 'C') {
14380                                    cancel_coupon_price += parseInt(v.discount_price);
14381
14382                                    // 환불금에서 쿠폰처리
14383                                    if($('.coupon-detail-info[data-seq="' + v.seq + '"]').length == 0) {
14384                                        $('.cancel-coupon-title').append('<div class="coupon-name coupon-detail-info" data-seq="' + v.seq + '">' + v.coupon_name + '</div>');
14385                                        $('#cancel-coupon-detail').append('<div class="coupon-price coupon-detail-info" data-seq="' + v.seq + '">-' + number_format(parseInt(v.discount_price)) + '원</div>');
14386                                    }
14387                                } else {
14388                                    $('.coupon-detail-info[data-seq="' + v.seq + '"]').remove();
14389                                }
14390                            });
14391                            // 취소된 쿠폰 저장
14392                        }
14393                        product_price = product_price - parseInt(cancel_coupon_price);
14394                        product_price = product_price - gradeDiscountPrice;
14395                        
14396                        var use_point = (rePayment - product_price > 0) ? 0 : rePayment - product_price;
14397                        product_price = product_price + use_point;
14398                        
14399                        $('#cancel-price').html(number_format(price)+'원');
14400                        $('#cancel-delivery-price').html(number_format(deliveryPrice)+'원');
14401                        $('#cancel-point-price').html(number_format(use_point)+'원');
14402                        $('#cancel-grade-discount-price').html(((gradeDiscountPrice > 0) ? '-' + number_format(gradeDiscountPrice) : '0')+'원');
14403                        $('#cancel-coupon-price').html(((cancel_coupon_price > 0) ? '-' + number_format(cancel_coupon_price) : '0')+'원');
14404                        $('#return-total-price').html(number_format((product_price>0) ? product_price : '0'));
14405
14406                        var priceSumArr = [];
14407                        var extra_charge_flag = {};
14408                        if(oreModal.find('.cancel-info-data:checked').length) {
14409                            oreModal.find('.cancel-info-data:checked').each(function() {
14410                                if($(this).data('type') != 'normal') 
14411                                    return;
14412
14413                                var dts = $(this).data('delivery_template_seq');
14414                                if(dtl[dts]['price_type'] != 'FREE_CONDITION') return;
14415                                var dt = $(this).data('delivery_type');
14416                                if(dt != 'DELIVERY' && dt != 'DIRECT') return;
14417
14418                                if(!priceSumArr.hasOwnProperty(dts)) {
14419                                    priceSumArr[dts] = [];
14420                                }
14421                                if(!priceSumArr[dts].hasOwnProperty(dt)) {
14422                                    priceSumArr[dts][dt] = 0;
14423                                }
14424                                // cancel_after_point = Number(cancel_after_point) + ((Number($(this).data("usable_point")) + Number($(this).data("expired_point"))) - Number($(this).data("curr_point")));
14425                                var selectedPrice = 0;
14426                                selectedPrice = Number($(this).closest('tr').find('[data-optionprice]').data('optionprice'));
14427                                priceSumArr[dts][dt] += selectedPrice;
14428
14429                                if(dtl[dts]['dtype'][dt]['product_price'] - priceSumArr[dts][dt] < dtl[dts]['free_condition'] && dtl[dts]['dtype'][dt]['product_price'] - priceSumArr[dts][dt] > 0 && dtl[dts]['dtype'][dt]['price'] == 0) {
14430                                    extra_charge_flag[dts + '|' + dt] = true;
14431                                } else {
14432                                    extra_charge_flag[dts + '|' + dt] = false;
14433                                }
14434                            });
14435                        }
14436
14437                        extra_charge_info($form, 'R', Object.values(extra_charge_flag).indexOf(true) > -1 ? true : false, false);
14438
14439                        if($('input[name="order_number_ary[]"]').length == $('input[name="order_number_ary[]"]:checked').length) $('#product-check').prop('checked', true);
14440                        else $('#product-check').prop('checked', false);
14441                    });
14442
14443                    $(document).on('click', '#product-check', function () {
14444                        var price = 0;
14445                        var deliveryPrice = 0;
14446                        var totalCnt = 0,
14447                            isReturn = $('input[name="status"]:checked').val();
14448                        $form.find('.order-cancel-content.extra-info').remove();   
14449                        if ($(this).hasClass('noneAll') === true) {
14450                            $(this).prop('checked', true);
14451                            $(".status-checkbox").each(function () {
14452                                if ($(this).prop('disabled') !== true) $(this).prop('checked', true).change();
14453                            });
14454                        }
14455                        if ($(this).is(':checked') === true) {
14456                            $('.status-checkbox').each(function (i) {
14457                                if ($(this).prop('disabled') !== true) {
14458                                    $(this).prop('checked', true).change();
14459                                }
14460                            });
14461                        } else {
14462                            $(".status-checkbox").each(function () {
14463                                if ($(this).prop('disabled') !== true) $(this).prop('checked', false).change();
14464                            });
14465
14466                            $('#cancel-price').html('0원');
14467                            $('#cancel-delivery-price').html('0원');
14468                            $('#cancel-point-price').html('0원');
14469                            $('#cancel-grade-discount-price').html('0원');
14470                            $('#return-total-price').html('0');
14471                        }
14472                    });
14473
14474                    /* first option setting */
14475                    $('.cl-s-order-returnexchange .cl-s-form-selector').each(function(e) {
14476                        var checkSelectOption = ($(this).find('select option').length > 0) ? true : false;
14477                        if(checkSelectOption) {
14478                            var selectId = $(this).find('select').attr('id'),
14479                                val = $(this).find('select').children().eq(0).val();
14480                            $(this).find('select').selectpicker({'val':val, dropupAuto:false});
14481                        }
14482                    });
14483
14484                    $('#re-reason').on({
14485                        'show.bs.select': function (e) {
14486                            $(this).closest('.cl-s-form-selector').addClass('active');
14487                        },
14488                        'hidden.bs.select': function(e) {
14489                            $(this).closest('.cl-s-form-selector').removeClass('active');
14490
14491                            if($('#re-reason').prop('value') == '') {
14492                                $(this).closest('.cl-s-form-selector').addClass('empty');
14493                            } else {
14494                                $(this).closest('.cl-s-form-selector').removeClass('empty');
14495                            }
14496                        },
14497                        'changed.bs.select': function (e, clickedIndex, newValue, oldValue) {
14498                            // console.log(this.value, clickedIndex, newValue, oldValue);
14499                        }
14500                    });
14501
14502
14503                    $('.cl-s-order-returnexchange .cl-s-form-group').on('click',function(e) {
14504                        if($(e.target).hasClass('cl-s-form-group')) {
14505                            $(e.target).find('.cl-s-form-control:not([type=hidden])').focus();
14506                        }
14507                    });
14508
14509
14510                    $('.cl-s-order-returnexchange .cl-s-form-textarea').on({
14511                        focus: function(e) {
14512                            $(this).closest('.cl-s-form-wrap').addClass('active');
14513                        },
14514                        blur: function(e) {
14515                            var error_str = '',
14516                                val = $(this).val().trim();
14517
14518                            $(this).closest('.cl-s-form-wrap').removeClass('active');
14519                            if(val.length == 0) {
14520                                $(this).closest('.cl-s-form-wrap').removeClass('error').addClass('empty');
14521                                $(this).closest('.cl-s-form-wrap').find('.cl-s-control-label.error').remove();
14522                                return false;
14523                            } else {
14524                                $(this).closest('.cl-s-form-wrap').removeClass('empty');
14525
14526                                if(checkEmojis(val)) error_str = $.lang[LANG]['config.unable.emoji'];
14527                                else if(val.length < 5) error_str = $.lang[LANG]['customsite.validate.message.minlengthto5'];
14528
14529                                if(error_str.length > 0) {
14530                                    $(this).closest('.cl-s-form-wrap').addClass('error');
14531                                    if($(this).parent().find('.cl-s-control-label.error').length > 0) {
14532                                        $(this).parent().find('.cl-s-control-label.error').html(error_str);
14533                                    } else {
14534                                        $(this).after('<label for="input" class="cl-s-control-label error">' + error_str + '</label>');
14535                                    }
14536                                    return false;
14537                                }
14538                            }
14539
14540                            $(this).closest('.cl-s-form-wrap').removeClass('error');
14541                            $(this).closest('.cl-s-form-wrap').find('.cl-s-control-label.error').remove();
14542                        }
14543                    });
14544
14545                    $('.cl-s-form-wrap .cl-s-form-control').on({
14546                        focus: function(e) {
14547                            $(this).closest('.cl-s-form-wrap').addClass('active');
14548                        },
14549                        blur: function(e) {
14550                            var val = $(this).val().trim();
14551
14552                            $(this).closest('.cl-s-form-wrap').removeClass('active');
14553                            if(val.length == 0) {
14554                                $(this).closest('.cl-s-form-wrap').removeClass('error').addClass('empty');
14555                                $(this).closest('.cl-s-form-wrap').find('.cl-s-control-label.error').remove();
14556                                return false;
14557                            } else {
14558                                $(this).closest('.cl-s-form-wrap').removeClass('empty');
14559
14560                                if(checkEmojis(val)) {
14561                                    $(this).closest('.cl-s-form-wrap').addClass('error');
14562                                    if($(this).parent().find('.cl-s-control-label.error').length > 0) {
14563                                        $(this).parent().find('.cl-s-control-label.error').html($.lang[LANG]['config.unable.emoji']);
14564                                    } else {
14565                                        $(this).after('<label for="input" class="cl-s-control-label error">' + $.lang[LANG]['config.unable.emoji'] + '</label>');
14566                                    }
14567                                    return false;
14568                                }
14569                            }
14570
14571                            $(this).closest('.cl-s-form-wrap').removeClass('error');
14572                            $(this).closest('.cl-s-form-wrap').find('.cl-s-control-label.error').remove();
14573                        }
14574                    });
14575
14576
14577
14578                    $(document).on('click', '.cl-s-order-returnexchange .re-img-close', function() {
14579                        $(this).closest('li').remove();
14580                    })
14581
14582                    $('.cl-s-order-returnexchange .re-file-update').on('click', function () {
14583                        $("#re-file").click();
14584                    });
14585
14586                    $('.cl-s-order-returnexchange #re-file').on({
14587                        click: function () {
14588
14589                            var reImageCnt = $('.re-files-list').children('li').length;
14590                            if (reImageCnt >= 5) {
14591                                alert('이미지는 최대 5개까지 등록이 가능합니다.');
14592                                return false;
14593                            }
14594
14595                            var sid = $('#re-file').attr('data-sid'),
14596                                uid = $('#re-file').attr('data-uid');
14597
14598                            $.uploadON();
14599                            $(this).fileupload({
14600                                url: '/_upload/type/re/sid/'+sid+'/uid/'+uid,
14601                                dataType: 'json',
14602                                pasteZone: null,
14603                                async: true,
14604                                sequentialUploads: true,
14605                                add: function(e, data) {
14606                                    var r = $.upload_add(e,data,'image');
14607
14608                                    if(r.submit) {
14609                                        var jqXHR = data.submit();
14610                                        UPLOAD++;
14611                                    } else {
14612                                        data.context.find('.loading').html('<i class="fa fa-times error"></i>');
14613                                        data.context.find('.ing').addClass('error').text(r.err);
14614                                    }
14615
14616                                    $('.uploadModal .upload-cancel .btn, .uploadModal .upload-close').off('click').on('click', function(e) {
14617                                        if(jqXHR != undefined) jqXHR.abort();
14618                                        data.context.fadeOut().remove();
14619                                        $('.uploadModal #file-upload-progress').css('width','0%');
14620                                        $.uploadOFF();
14621                                        UPLOAD = 0;
14622                                        UPLOADED = 0;
14623                                        PROGRESS = 0;
14624                                    });
14625                                },
14626                                progress: function(e, data) {
14627                                    $.upload_progress(e,data);
14628                                },                        
14629                                done: function(e, data) {
14630                                    $.upload_done(e,data);
14631                                    UPLOADED++;
14632                                    var src = (typeof data.result.magic != 'undefined') ? data.result.magic : data.result.src;
14633                                    var reImage = '\
14634                                        <li id="re-image-'+reImageCnt+'">\
14635                                            <img src="'+src+'" class="img-responsive" />\
14636                                            <input type="hidden" name="review_image[]" value="'+src+'" />\
14637                                            <div class="cl-s-files-img-close re-img-close"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 8 8" width="8" height="8"><path d="M4.71 4l3.15-3.15c0.2-0.2 0.2-0.51 0-0.71s-0.51-0.2-0.71 0L4 3.29 0.85 0.15c-0.2-0.2-0.51-0.2-0.71 0s-0.2 0.51 0 0.71L3.29 4 0.15 7.15c-0.2 0.2
14637-0.2 0.51 0 0.71C0.24 7.95 0.37 8 0.5 8s0.26-0.05 0.35-0.15L4 4.71l3.15 3.15C7.24 7.95 7.37 8 7.5 8s0.26-0.05 0.35-0.15c0.2-0.2 0.2-0.51 0-0.71L4.71 4z"/></svg></div>\
14638                                        </li>\
14639                                    ';
14640
14641                                    $(".cl-s-order-returnexchange .re-files-list").append(reImage);
14642                                    reImageCnt++;
14643
14644                                    if(UPLOADED) {
14645                                        if(UPLOAD==UPLOADED) {
14646                                            setTimeout(function() {
14647                                                $.uploadOFF();
14648                                                UPLOAD = 0;
14649                                                UPLOADED = 0;
14650                                                PROGRESS = 0;
14651                                            },1000);
14652                                        }
14653                                    }
14654                                },
14655                                progressall: function (e, data) {
14656                                    $.upload_progressall(e,data);
14657                                },
14658                                start : function(e, data) {
14659                                    $.upload_start(e,data);
14660                                    progress1 = 0; progress2 = 0; PROGRESS = 0;
14661                                },
14662                                dragover : function(e, data) {
14663                                    e.preventDefault();
14664                                },
14665                            }).prop('disabled', !$.support.fileInput)
14666                                .parent().addClass($.support.fileInput ? undefined : 'disabled');
14667                        }
14668                    });
14669                    if(status == 'Y') {
14670                        $('.status-checkbox').off('change');
14671                    }
14672                    if(status == 'Y' && data.r.exchange_check == true) {
14673                        $('.btn-group-toggle').off('click');
14674                        // console.log(oreModal.find('[btn-toggle="buttons"] .btn-secondary.disable'));
14675                        oreModal.find('[data-toggle="buttons"] .btn-secondary.disable').on('click', function(e) {
14676                            e.preventDefault();
14677                            e.stopPropagation();
14678                            alert('에스크로 결제 상품은 교환 요청/완료가 있는 경우 반품 요청이 불가능합니다.\n기타 요청이 있는 경우 관리자
14678에게 문의해 주세요.');
14679                            return false;
14680                        });
14681                    }
14682                    
14683                    oreModal.find('[data-toggle="popover"]').popover();
14684                });
14685
14686                var used_code_coupon = false;
14687                var coupon = c_data.pay_info.coupon_list;
14688                if(coupon.length) {
14689                    $.each(coupon, function(i,v) {
14690                        if(v.kind == 'C') used_code_coupon = true;
14691                    });
14692                }
14693
14694                $('.cl-s-order-returnexchange .cl-s-btn-group-toggle input:radio').on({
14695                    change: function() {
14696                        var order_status = $(this).val(),
14697                            re_reason_obj = {
14698                            'R' : '\
14699                                <option value="구매의사 취소">구매의사 취소</option>\
14700                                <option value="다른 상품 잘못 주문">다른 상품 잘못 주문</option>\
14701                                <option value="상품파손">상품파손</option>\
14702                                <option value="배송지연">배송지연</option>\
14703                                <option value="상품정보 상이">상품정보 상이</option>\
14704                                <option value="오배송">오배송</option>\
14705                                <option value="기타">기타</option>\
14706                            ',
14707                            'E' : '\
14708                                <option value="컬러 및 사이즈 변경">컬러 및 사이즈 변경</option>\
14709                                <option value="다른 상품 잘못 주문">다른 상품 잘못 주문</option>\
14710                                <option value="상품파손">상품파손</option>\
14711                                <option value="상품정보 상이">상품정보 상이</option>\
14712                                <option value="오배송">오배송</option>\
14713                                <option value="기타">기타</option>\
14714                            '
14715                        };
14716                        $('.order-candel-content.extra-info').remove();
14717                        $(this).closest('.btn-group-toggle').find('.btn-secondary').removeClass('active');
14718                        $(this).parent('.btn-secondary').addClass('active');
14719                        $(this).prop('checked', true);
14720                        $(this).closest('.btn-group-toggle').find('input:radio').not(this).prop('checked', false);
14721
14722                        if (order_status == 'R') {
14723                            if (status == 'Y' && data.r.exchange_check == true) {
14724                                alert('에스크로 결제 상품은 교환 요청/완료가 있는 경우 반품 요청이 불가능합니다.\n기타 요청이 있는 경우 관리자
14724에게 문의해 주세요.');
14725                                setTimeout(function () {
14726                                    $('#order-radio-exchange').click();
14727                                }, 500);
14728                                return false;
14729                            } else if(used_code_coupon && data.r.exchange_check == true) {
14730                                alert('코드 쿠폰이 적용된 주문건은 교환 접수 시 반품이 불가능합니다.\n자세한 사항은 판매자의 안내를 따라주세요.');
14731                                setTimeout(function() {
14732                                    $('#order-radio-exchange').click();
14733                                });
14734                                return false;
14735                            }
14736                            
14737                            $('#return-modal').css('display', 'block');
14738                            $('.order-cancel-content').css('display', 'block');
14739                            $('#no-bank').parent().parent().addClass('cl-s-form-wrap');
14740                            $('#no-bank-name').parent().parent().addClass('cl-s-form-wrap');
14741                            $('#no-bank-number').parent().parent().addClass('cl-s-form-wrap');
14742                            $('.code-coupon-exchange-warning').hide();
14743
14744                            if (status == 'Y') {
14745                                $('.status-checkbox').each(function () {
14746                                    $(this).prop('checked', true);
14747                                    $(this).addClass('noneAll');
14748                                });
14749                                $('#product-check').addClass('noneAll');
14750                                $('#product-check').prop('checked', true);
14751                                $('.escrow-warring').css({'display': 'block'});
14752                                $('.escrow-exchange-warning').hide();
14753                            } else if(used_code_coupon) {
14754                                $('.status-checkbox').each(function () {
14755                                    $(this).prop('checked', true);
14756                                    $(this).addClass('noneAll');
14757                                });
14758                                $('#product-check').addClass('noneAll');
14759                                $('#product-check').prop('checked', true);
14760                            }
14761                            var totalCnt = 0, totalNomalCheck = 0, nomalCheck = 0;
14762                            var price = 0;
14763                            var deliveryPrice = 0;
14764                            var gradeDiscountPrice = 0;
14765                            $(".status-checkbox").each(function (i, index) {
14766                                if ($(this).is(":checked") === true) {
14767                                    price += ($(this).closest('.cl-s-product-jumbotron').find('.option-check').attr('data-optionPrice') * 1);
14768                                    gradeDiscountPrice += Number($(this).data('grade_discount_price') || 0);
14769                                    totalCnt++;
14770                                    if ($(this).attr('data-type') == 'normal') {
14771                                        nomalCheck++;
14772                                        var mix_yn = $(this).data('mix_yn');
14773                                        var delivery_price = 0;
14774                                        var delivery_template_seq = $(this).data('delivery_template_seq');
14775                                        var delivery_type = $(this).data('delivery_type');
14776                                        if(oreModal.find('input[name="order_number_ary[]"][data-delivery_type="' + delivery_type + '"][data-delivery_template_seq="' + delivery_template_seq + '"]').length == oreModal.find('input[name="order_number_ary[]"][data-delivery_type="' + delivery_type + '"][data-delivery_template_seq="' + delivery_template_seq + '"]:checked').length) {
14777                                            delivery_price = Number($(this).data('delivery_price'));
14778                                        }
14779                                        deliveryPrice += delivery_price;
14780                                    }
14781
14782                                    var product_number = $(this).attr('data-product_number');
14783                                    if($(this).attr('data-option_type') != 'A' && !$('input[name="order_number_ary[]"][data-product_number="' + product_number + '"][data-option_type!="A"]:not(:checked)').length) {
14784                                        $('input[name="order_number_ary[]"][data-product_number="' + product_number + '"][data-option_type="A"]').prop('checked',true).change();
14785                                    } else if($(this).attr('data-option_type') == 'A' && !$('input[name="order_number_ary[]"][data-product_number="' + product_number + '"][data-option_type!="A"]:not(:checked)').length && !$(this).prop('checked')) {
14786                                        $('input[name="order_number_ary[]"][data-product_number="' + product_number + '"][data-option_type!="A"]:last').prop('checked',fal
14786se).change();
14787                                    }
14788                                }
14789
14790                                if ($(this).attr('data-type') == 'normal') {
14791                                    totalNomalCheck++;
14792                                }
14793                            });
14794
14795                            var product_price = price + getPointCalcDeliveryPrice(deliveryPrice),
14796                                rePayment = parseInt(c_data.pay_info.request.payment.total) - parseInt(c_data.pay_info.request.payment.coupon) - parseInt(c_data.pay_info.request.cancel.total) - parseInt(c_data.pay_info.request.return.total);
14797
14798                            rePayment = (rePayment > 0) ? rePayment : 0;
14799                            
14800                            // coupon 처리
14801                            
14802                            var cancel_coupon_price = 0;
14803                            if(coupon.length) {
14804                                var checked_order_number = $('.cancel-info-data:checked').map(function(){ return this.value; }).toArray();
14805                                $.each(coupon, function(i,v) {
14806                                    if(checked_order_number.indexOf(v.order_number) > -1 || v.kind == 'C') {
14807                                        cancel_coupon_price += parseInt(v.discount_price);
14808
14809                                        // 환불금에서 쿠폰처리
14810                                        if($('.coupon-detail-info[data-seq="' + v.seq + '"]').length == 0) {
14811                                            $('.cancel-coupon-title').append('<div class="coupon-name coupon-detail-info" data-seq="' + v.seq + '">' + v.coupon_name + '</div>');
14812                                            $('#cancel-coupon-detail').append('<div class="coupon-price coupon-detail-info" data-seq="' + v.seq + '">-' + number_format(parseInt(v.discount_price)) + '원</div>');
14813                                        }
14814                                    } else {
14815                                        $('.coupon-detail-info[data-seq="' + v.seq + '"]').remove();
14816                                    }
14817                                });
14818                                // 취소된 쿠폰 저장
14819                                
14820                            }
14821                            product_price = product_price - parseInt(cancel_coupon_price);
14822                            product_price = product_price - gradeDiscountPrice;
14823                            
14824                            var use_point = (rePayment - product_price > 0) ? 0 : rePayment - product_price;
14825                            product_price = product_price + use_point;
14826
14827                            $('#cancel-price').html(number_format(price)+'원');
14828                            $('#cancel-delivery-price').html(number_format(deliveryPrice)+'원');
14829                            $('#cancel-point-price').html(number_format(use_point)+'원');
14830                            $('#cancel-coupon-price').html(((cancel_coupon_price > 0) ? '-' + number_format(cancel_coupon_price) : '0')+'원');
14831                            $('#cancel-grade-discount-price').html(((gradeDiscountPrice > 0) ? '-' + number_format(gradeDiscountPrice) : '0')+'원');
14832                            $('#return-total-price').html(number_format(product_price));
14833                            $('.codecoupon-cancel-desc').show();
14834
14835                            var priceSumArr = [];
14836                            var extra_charge_flag = {};
14837                            if(oreModal.find('.cancel-info-data:checked').length) {
14838                                oreModal.find('.cancel-info-data:checked').each(function() {
14839                                    if($(this).data('type') != 'normal') 
14840                                        return;
14841
14842                                    var dts = $(this).data('delivery_template_seq');
14843                                    if(dtl[dts]['price_type'] != 'FREE_CONDITION') return;
14844                                    var dt = $(this).data('delivery_type');
14845                                    if(dt != 'DELIVERY' && dt != 'DIRECT') return;
14846
14847                                    if(!priceSumArr.hasOwnProperty(dts)) {
14848                                        priceSumArr[dts] = [];
14849                                    }
14850                                    if(!priceSumArr[dts].hasOwnProperty(dt)) {
14851                                        priceSumArr[dts][dt] = 0;
14852                                    }
14853                                    // cancel_after_point = Number(cancel_after_point) + ((Number($(this).data("usable_point")) + Number($(this).data("expired_point"))) - Number($(this).data("curr_point")));
14854                                    var selectedPrice = 0;
14855                                    selectedPrice = Number($(this).closest('tr').find('[data-optionprice]').data('optionprice'));
14856                                    priceSumArr[dts][dt] += selectedPrice;
14857
14858                                    if(dtl[dts]['dtype'][dt]['product_price'] - priceSumArr[dts][dt] < dtl[dts]['free_condition'] && dtl[dts]['dtype'][dt]['product_price'] - priceSumArr[dts][dt] > 0 && dtl[dts]['dtype'][dt]['price'] == 0) {
14859                                        extra_charge_flag[dts + '|' + dt] = true;
14860                                    } else {
14861                                        extra_charge_flag[dts + '|' + dt] = false;
14862                                    }
14863                                });
14864                            }
14865                            
14866                            extra_charge_info($form, 'R', Object.values(extra_charge_flag).indexOf(true) > -1 ? true : false, false);
14867                        } else {
14868
14869                            $('.order-candel-content.extra-info').remove();
14870                            $('#return-modal').css('display', 'none');
14871                            $('.order-cancel-content').css('display', 'none');
14872                            $('#no-bank').parent().parent().removeClass('cl-s-form-wrap');
14873                            $('#no-bank-name').parent().parent().removeClass('cl-s-form-wrap');
14874                            $('#no-bank-number').parent().parent().removeClass('cl-s-form-wrap');
14875                            if (status == 'Y') {
14876                                $('.status-checkbox').each(function () {
14877                                    $(this).prop('checked', false);
14878                                    $(this).removeClass('noneAll');
14879                                });
14880                                $('#product-check').removeClass('noneAll');
14881                                $('#product-check').prop('checked', false);
14882                                $('.escrow-warring').css({'display': 'none'});
14883                                $('.escrow-exchange-warning').show();
14884                            } else if(used_code_coupon) {
14885                                $('.status-checkbox').each(function () {
14886                                    $(this).prop('checked', false);
14887                                    $(this).removeClass('noneAll');
14888                                });
14889                                $('#product-check').removeClass('noneAll');
14890                                $('#product-check').prop('checked', false);
14891                                $('.code-coupon-exchange-warning').show();
14892                                $('.codecoupon-cancel-desc').hide();
14893                            }
14894                        }
14895
14896                        $('#re-reason').closest('.cl-s-form-selector').removeClass('empty');
14897                        $('#re-reason').html(re_reason_obj[order_status]).selectpicker('refresh');
14898                        $('#re-reason').selectpicker('val', $('#re-reason').val());
14899                    }
14900                });
14901                if((status == 'Y' || used_code_coupon) && data.r.exchange_check == true) { // 에스크로이고 교환건 존재
14902                    $('#order-radio-exchange[value="E"]').prop('checked', true).change();
14903                }
14904
14905            },'json');
14906
14907            $('.close-button-dialog').css({'display': 'block'});
14908        },
14909        writeReviewModal: function(sid, pnum, onum, type) {
14910            if(typeof sid == 'undefined' || typeof pnum == 'undefined' || typeof onum == 'undefined') {
14911                alert('정보가 올바르지 않습니다');
14912                return false;
14913            }
14914            $.post('/_check_order', { sid:sid, pnum:pnum, onum:onum, mode:'review' }, function(data) {
14915                if(typeof data.error != 'undefined' && data.error) {
14916                    $(this).showModalFlat('', data.error, true, false, '', 'close');
14917                    return false;
14918                }
14919
14920                var c_data = data.r,
14921                    modal_str = '',
14922                    order_group = data.order_group,
14923                    picturePointStr = '';
14924
14925                let use_review_img_upload = (typeof c_data.use_review_img_upload != 'undefined' && c_data.use_review_img_upload)? c_data.use_review_img_upload : 'true';
14926                
14927                if(c_data.writer.status == 'A') {
14928                    alert('관리자는 상품 후기 작성을 사용할 수 없습니다.');
14929                    return false;
14930                }
14931                    if (c_data.pay_info.settings.point_data != null && c_data.pay_info.settings.point_data['point_use'] == 'Y' && c_data.writer.status != 'T') {
14932                        if (c_data.pay_info.settings.point_data['review_point_status'] == 'Y') {
14933                            if(typeof c_data.pay_info.settings.point_data != "undefined" && c_data.pay_info.settings && c_data.odata.price > 0) {  
14934                                var photoPoint = (c_data.pay_info.settings.point_data['review_photo_point'] > 0) ? c_data.pay_info.settings.point_data['review_photo_point'] : 0,
14935                                    textPoint = (c_data.pay_info.settings.point_data['review_point'] > 0) ? c_data.pay_info.settings.point_data['review_point'] : 0;
14936                                    picturePointStr = '\
14937                                        <div class="cl-s-ps">\
14938                                            <svg viewBox="0 0 13 13" width="13" height="13">\
14939                                                <path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/>\
14940                                                <rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/>\
14941                                            </svg>사진 첨부 시 <span>'+number_format(photoPoint)+'원</span>이 적립됩니다.\
14942                                        </div>\
14943                                ';
14944                            }
14945
14946                            let maxPoint = textPoint;
14947                            let pointPopoverContent = `텍스트 후기 : &nbsp; ${number_format(textPoint)}원`;
14948                            if(use_review_img_upload != 'false') {
14949                                maxPoint = photoPoint;
14950                                pointPopoverContent = `텍스트 후기 : &nbsp; ${number_format(textPoint)}원 <br>포토 후기 : &nbsp; ${number_format(photoPoint)}원<br><p>텍스트 후기와 포토 후기 적립금은 중복지급되지 않으며, 최초 작성한 후기를 기준으로 지급됩니다.</p>`;
14951                            }
14952                           
14953                            if(c_data.odata.price > 0) {
14954                                modal_str += `
14955                                    <div class="review-point review-icon">후기 작성 시 적립금 <span>최대 ${maxPoint}원</span>
14956                                        <svg viewBox="0 0 13 13" width="13" height="13" class="cm-popover-info" tabindex="0" data-trigger="hover" data-toggle="popover" data-placement="bottom" data-html="true" data-content="${pointPopoverContent}">
14957                                            <path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/>\
14958                                            <rect x="6" y="9" width="1" height="1"/>
14959                                            <path d="M6.66 3.01C5.61 3.01 4.58 3.5 4.5 4.8c0 0.06-0.01 0.12 0 0.2h1.02c0-0.07 0.01-0.15 0.02-0.23 0.08-0.62 0.52-0.76 1.08-0.76 0.63 0 1.02 0.37 1.02 0.95 -0.01 0.48-0.3 0.87-0.76 1.34C6.21 6.97 6.02 7.37 6 8h0.99C7 7.
1495966 7.04 7.37 7.67 6.75 8.17 6.27 8.7 5.68 8.7 4.87 8.7 3.85 7.89 3.01 6.66 3.01z"/>
14960                                        </svg>
14961                                    </div>
14962                                `;
14963                            }
14964                        }
14965                    }
14966
14967                    modal_str += '\
14968                    <div class="review-body review-write-body">\
14969                        <div class="cl-s-product-jumbotron clearfix">\
14970                            <div class="cl-s-product-thumb">\
14971                                <img src="' + c_data.pdata.img + '" alt="' + c_data.pdata.name + '" class="' + c_data.pdata.img_align + '" />\
14972                            </div>\
14973                            <div class="cl-s-product-info">\
14974                                <h5 class="cl-s-product-title">' + c_data.pdata.name + '</h5>\
14975                    ';
14976                    var option_title = (c_data.pdata.option_type == 'A') ? '추가옵션: ' + (c_data.pdata.option_group ? c_data.pdata.option_group + ': ' : '') : '옵션: ';
14977                    if(typeof c_data.pdata.option != "undefined" && c_data.pdata.option) {
14978                        modal_str += (c_data.pdata.option_text_str)? '\
14979                                <div class="option-str">' + option_title + c_data.pdata.option + ' / ' + c_data.pdata.option_text_str + '</div>\
14980                        ' : '\
14981                                <div class="option-str">' + option_title + c_data.pdata.option + '</div>\
14982                        ';
14983                    } else {
14984                        modal_str += (c_data.pdata.option_text_str)? '\
14985                                <div class="option-str">' + c_data.pdata.option_text_str + '</div>\
14986                        ' : '';
14987                    }
14988                    if(typeof c_data.pdata.etc_date != "undefined" && c_data.pdata.etc_date) {
14989                        modal_str += '\
14990                                <div class="option-str">선택일자: ' + c_data.pdata.etc_date + '</div>\
14991                        ';
14992                    }
14993                    modal_str += '\
14994                            </div>\
14995                        </div>\
14996                        <div class="review-star">\
14997                            <h5>상품이 만족스러우셨나요?</h5>\
14998                            <div class="star text-center">\
14999                                <span data-idx="1" class="active"></span>\
15000                                <span data-idx="2" class="active"></span>\
15001                                <span data-idx="3" class="active"></span>\
15002                                <span data-idx="4" class="active"></span>\
15003                                <span data-idx="5" class="active"></span>\
15004                            </div>\
15005                        </div>\
15006                        <div class="review-content">\
15007                            <h5>어떤 점이 좋았나요?</h5>\
15008                            <div class="cl-s-form-wrap">\
15009                                <div class="cl-s-form-group input-label-hide">\
15010                                    <textarea class="cl-s-form-control" id="review-str" name="review" maxlength="1000" required="required"></textarea>\
15011                                    <label for="input" class="cl-s-control-label">자세한 내용을 적어주세요. (1000자 이내)</label>\
15012                                </div>\
15013                            </div>\
15014                        ';
15015                        if(use_review_img_upload != 'false') {
15016                        modal_str += '\
15017                            <div class="cl-s-files review-files file-center">\
15018                                <input id="review-file" type="file" name="files[]" accept="image/jpeg,image/gif,image/png" multiple data-sid="' + sid + '" data-uid=\"' + c_data.writer.id + '\">\
15019                                <label class="cl-s-file-update review-file-update display-flex align-items-center justify-center"><svg viewBox="0 0 42 36" width="18" height="16"><path d="M36 6h-5l-3-5c0 0-0.71-1-1.99-1 -0.72 0-2.54 0-3.99 0 0 0-0.91 0-2.04 0 -1.45 0-3.27 0-3.99 0C14.71 0 14 1 14 1l-3 5H6c-3.31 0-6 2.69-6 6v18c0 3.31 2.69 6 6 6h30c3.31 0 6-2.69 6-6V12C42 8.69 39.31 6 36 6zM21 31c-5.52 0-10-4.48-10-10 0-5.52 4.48-10 10-10 5.52 0 10 4.48 10 10C31 26.52 26.52 31 21 31z"/><circle cx="21" cy="21" r="6"/></svg><span>사진 첨부하기</span></label>';
15020                    if(c_data.pay_info.settings.point_data != null && c_data.pay_info.settings.point_data['point_use'] == 'Y' && c_data.pay_info.settings.point_data['review_point_status'] == 'Y') modal_str += picturePointStr;
15021                        modal_str += '\
15022                                <ul class="cl-s-files-list review-files-list clearfix files-list-wrap">\
15023                                </ul>\
15024                            </div>\
15025                            ';
15026                        }
15027                        modal_str += '\
15028                            </div>\
15029                        </div>\
15030                            ';
15031                
15032                // $('.flat-modal .modal').modal('hide');
15033                var wrModal = $(this).showModalFlat('후기 작성', modal_str, true, true,function () {
15034
15035                    var cl_s_f_body = $('.cl-s-product-review-write .review-content');
15036                    cl_s_f_body.find('.cl-s-form-wrap').each(function() {
15037                        var check_input = $(this).find('.cl-s-form-control'),
15038                            val = check_input.val().trim();
15039
15040                        if(val.length == 0) {
15041                            $(this).removeClass('error').addClass('empty');
15042                            $(this).find('.cl-s-control-label.error').remove();
15043                        } else {
15044                            if($(this).hasClass('error')) {
15045                                check_input.focus();
15046                            }
15047                        }
15048                    });
15049
15050                    if(cl_s_f_body.find('.cl-s-form-wrap.empty, .cl-s-form-wrap.error').length > 0) {
15051                        cl_s_f_body.find('.cl-s-form-wrap.empty, .cl-s-form-wrap.error').eq(0).find('.cl-s-form-control').focus();
15052                        return false;
15053                    }
15054
15055                    var page_mode = ($('.cl-s-mypage').length > 0) ? 'mypage' : 'no_member',
15056                        review = $('#review-str').val().trim(),
15057                        review_star = $('.cl-s-product-review-write .review-star .star .active').length,
15058                        review_image = new Array();
15059                        review_image_orig = new Array();
15060
15061                    $('input[name="review_image[]"]').each(function(i) {
15062                        review_image[i] = $(this).val();
15063                    });
15064
15065                    $('input[name="review_image_orig[]"]').each(function(i) {
15066                        review_image_orig[i] = $(this).val();
15067                    });
15068
15069                    var review_data = {
15070                        status : 'S',
15071                        page_mode : page_mode,
15072                        pnum : pnum,
15073                        onum : onum,
15074                        mb_status : c_data.writer.status,
15075                        review : review,
15076                        review_count : review_star,
15077                        review_image : review_image,
15078                        review_image_orig : review_image_orig
15079                    };
15080
15081                    if(c_data.writer.status == 'T') {
15082                        review_data['name'] = c_data.odata.name;
15083                        // review_data['order_group'] = c_data.order_data.group;
15084                    }
15085
15086                    $('.ok-button-dialog').prop('disabled', true);
15087
15088                    $.post('/_review_write', { sid:sid, order_group: order_group, data:JSON.stringify(review_data) }, function(rw_data) {
15089                        if(typeof rw_data.error != 'undefined' && rw_data.error) {
15090                            $(this).showModalFlat('ERROR', rw_data.error, true, false, '', 'close');
15091                            return false;
15092                        }
15093
15094                        location.reload();
15095                    }, 'json');
15096
15097                },'close','등록하기','cl-s-product-review-write cl-modal cl-s-btn cover', true, '', function() {
15098
15099                    $('.cl-s-product-review-write .cl-s-form-group').on('click',function(e) {
15100                        if($(e.target).hasClass('cl-s-form-group')) {
15101                            $(e.target).find('.cl-s-form-control:not([type=hidden])').focus();
15102                        }
15103                    });
15104                    $('[data-toggle="popover"]').popover();
15105                    $('.cl-s-product-review-write .cl-s-form-control').on({
15106                        focus: function(e) {
15107                            $(this).closest('.cl-s-form-wrap').addClass('active');
15108                        },
15109                        blur: function(e) {
15110                            var val = $(this).val().trim();
15111
15112                            $(this).closest('.cl-s-form-wrap').removeClass('active');
15113                            if(val.length == 0) {
15114                                $(this).closest('.cl-s-form-wrap').removeClass('error').addClass('empty');
15115                                $(this).closest('.cl-s-form-wrap').find('.cl-s-control-label.error').remove();
15116                                return false;
15117                            } else {
15118                                $(this).closest('.cl-s-form-wrap').removeClass('empty');
15119                                var passEmoji = ($.inArray($(this).attr('name'),['review']) > -1) ? true : false,
15120                                    error_str = '';
15121                                if(!passEmoji && checkEmojis(val)) error_str = $.lang[LANG]['config.unable.emoji'];
15122                                else if(val.length < 5) error_str = $.lang[LANG]['customsite.validate.message.minlengthto5'];
15123                                
15124                                if(error_str.length > 0) {
15125                                    $(this).closest('.cl-s-form-wrap').addClass('error');
15126                                    if($(this).parent().find('.cl-s-control-label.error').length > 0) {
15127                                        $(this).parent().find('.cl-s-control-label.error').html(error_str);
15128                                    } else {
15129                                        $(this).after('<label for="input" class="cl-s-control-label error">' + error_str + '</label>');
15130                                    }
15131                                    return false;
15132                                }
15133                            }
15134
15135                            $(this).closest('.cl-s-form-wrap').removeClass('error').removeClass('empty');
15136                            $(this).closest('.cl-s-form-wrap').find('.cl-s-control-label.error').remove();
15137                        }
15138                    });
15139
15140                    $(document).on('click', '.cl-s-product-review-write .review-img-close', {mode: 'review'}, deleteReviewQnaImg);
15141
15142                    $('.cl-s-product-review-write .review-file-update').on('click', function () {
15143                        $("#review-file").click();
15144                    });
15145
15146                    $('.cl-s-product-review-write #review-file').on('click', {mode: 'review'}, uploadReviewQnaImg);
15147
15148                    $('.cl-s-product-review-write .review-star .star span').on('click', function() {
15149                        var rCount = $(this).attr('data-idx');
15150                        $(this).parent().children('span').removeClass('active');
15151                        $(this).addClass('active').prevAll('span').addClass('active');
15152                    });
15153                }, function() {
15154                    if($('.cl-s-product-review-write .review-img-close').length > 0){
15155                        $.each($('.cl-s-product-review-write .review-img-close'), function(){
15156                            $(this).trigger('click');
15157                        });
15158                    }
15159                });
15160
15161
15162            },'json');
15163
15164        },
15165
15166        orderConfirmModal: function(sid, pnum, onum, ognum, status, dStatus, pclass) {
15167            if(typeof sid == "undefined" || typeof pnum == "undefined" || typeof onum == "undefined") {
15168                alert('정보가 올바르지 않습니다');
15169                return false;
15170            }
15171            $.post('/_check_order', { sid:sid, pnum:pnum, onum:onum, mode:'confirm', ognum: ognum }, function(data) {
15172
15173                if(typeof data.error != "undefined" && data.error) {
15174                    $(this).showModalFlat('ERROR', data.error, true, false, '', 'close');
15175                    return false;
15176                }
15177                var c_data = data.r, checkboxNone = '', noneAll = '', noneChecked = '', checkNoneAll = '', checkEscrowFooter = '', checkEscrowClass = '', checkOrderConfirm = '';
15178                var dtl = c_data.delivery_template_list;
15179                var used_code_coupon = false;
15180                
15181                if(c_data.pay_info.coupon_list && c_data.pay_info.coupon_list.length) {
15182                    $.each(c_data.pay_info.coupon_list, function(k, v) {
15183                        if(v.kind == 'C') {
15184                            used_code_coupon = true;
15185                        }
15186                    })
15187                }
15188
15189                if(used_code_coupon) {
15190                    checkboxNone = 'checked';
15191                    noneAll = ' noneAll';
15192                    checkNoneAll = 'fule';
15193                    checkOrderConfirm = '<div class="modal-comment deposit-cancel-desc codecoupon-cancel-desc order-cancel-content">\
15194                                <div class="desc-box">\
15195                                    <div class="desc-title">코드쿠폰 사용 구매확정 안내</div>\
15196                                    <div class="section">- 코드쿠폰 사용 주문 건은 <span class="cl-red">전체 구매확정</span>만 가능합니다.</div>\
15197                                </div>\
15198                            </div>\
15199                        ';
15200                }
15201
15202                var modal_str = '\
15203                    <form name="cancel_form" method="post" action="/_confirm">\
15204                        <input type="hidden" name="sid" value="' + sid + '">\
15205                        <input type="hidden" name="order_group" id="cancel-order-group" value="' + ognum + '">\
15206                        <input type="hidden" name="order_number" id="cancel-order-number" value="' + onum + '">\
15207                        <div class="cancel-product-title">\
15208                            <div class="newcheckbox hand">\
15209                                <label>\
15210                                    <input type="checkbox" class="'+noneAll+'" id="product-check" '+checkboxNone+'>\
15211                                    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\
15212                                        <path d="M13 0H3C1.3 0 0 1.3 0 3v10c0 1.7 1.3 3 3 3h10c1.7 0 3-1.3 3-3V3C16 1.3 14.7 0 13 0zM15 13c0 1.1-0.9 2-2 2H3c-1.1 0-2-0.9-2-2V3c0-1.1 0.9-2 2-2h10c1.1 0 2 0.9 2 2V13z"/>\
15213                                    </svg>\
15214                                    <svg class="active" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\
15215                                        <path d="M13 0H3C1.34 0 0 1.34 0 3v10c0 1.66 1.34 3 3 3h10c1.66 0 3-1.34 3-3V3C16 1.34 14.66 0 13 0zM13.03 6.03l-5.5 5.5C7.38 11.68 7.19 11.75 7 11.75s-0.38-0.07-0.53-0.22l-3.5-3.5c-0.29-0.29-0.29-0.77 0-1.06s0.77-0.29 1.06 0L7 9.94l4.97-4.97c0.29-0.29 0.77-0.29 1.06 0S13.32 5.74 13.03 6.03z"/>\
15216                                    </svg>\
15217                                </label>\
15218                            </div>\
15219                            구매확정 상품\
15220                        </div>';
15221
15222                        modal_str += '<table class="table product-table">';
15223                        for (var i=0;i<data.r.odata.length;i++) {
15224                            if (c_data.odata[i].d_status == '' || c_data.odata[i].d_status == 'CN' || c_data.odata[i].d_status == 'EY' || c_data.odata[i].d_status == 'ED' || c_data.odata[i].d_status == 'EN' || c_data.odata[i].d_status == 'RN' || c_data.odata[i].d_status == 'RD') {
15225                                noneChecked = '';
15226                                if (!checkNoneAll) noneAll = '';
15227                            } else {
15228                                if (!checkNoneAll) noneAll = 'noneAll';
15229                                noneChecked = 'noneChecked';
15230                            }
15231                            if (c_data.odata[i].p_status == 'W') {
15232                                if (!checkNoneAll) noneAll = 'noneAll';
15233                                noneChecked = 'noneChecked';
15234                                checkboxNone = 'checked';
15235                            }
15236
15237                            var dts = c_data.odata[i].state == 'normal' ? c_data.odata[i].delivery_template_seq : '';
15238                            if(c_data.odata[i].state == 'normal' && c_data.odata[i].mix_yn != 'Y') dts += '-' + c_data.odata[i].product_number;
15239                            var dt = c_data.odata[i].state == 'normal' ? c_data.odata[i].delivery_type : '';
15240
15241                            modal_str += '\
15242                            <tr class="cl-s-product-jumbotron clearfix">\
15243                                <td>\
15244                                <div class="newcheckbox hand">\
15245                                    <label>\
15246                                        <input type="checkbox" class="status-checkbox cancel-info-data '+noneAll+' '+noneChecked+'" data-type="'+c_data.pdata[i].state
15246+'" name="order_number_ary[]" value="'+c_data.odata[i].order_number+'" '+checkboxNone+' data-option_type="' + c_data.pdata[i].option_type + '" data-product_number="' + c_data.odata[i].product_number + '" data-mix_yn="' + (c_data.odata[i].state == 'normal' ? c_data.odata[i].mix_yn : '') + '" data-delivery_template_seq="' + (c_data.odata[i].state == 'normal' ? dts : '') + '" data-delivery_type="' + (c_data.odata[i].state == 'normal' ? c_data.odata[i].delivery_type : '') + '" data-quantity="' + c_data.odata[i].quantity + '" data-product_weight="' + (c_data.odata[i].state == 'normal' ? c_data.odata[i].product_weight : 0) + '" data-delivery_price="' +  (c_data.odata[i].state == 'normal' && dtl[dts]['pay_type'] == 'PREPAY' ? c_data.odata[i].delivery_price : 0) + '">\
15247                                        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\
15248                                        <path d="M13 0H3C1.3 0 0 1.3 0 3v10c0 1.7 1.3 3 3 3h10c1.7 0 3-1.3 3-3V3C16 1.3 14.7 0 13 0zM15 13c0 1.1-0.9 2-2 2H3c-1.1 0-2-0.9-2-2V3c0-1.1 0.9-2 2-2h10c1.1 0 2 0.9 2 2V13z"/>\
15249                                        </svg>\
15250                                        <svg class="active" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\
15251                                        <path d="M13 0H3C1.34 0 0 1.34 0 3v10c0 1.66 1.34 3 3 3h10c1.66 0 3-1.34 3-3V3C16 1.34 14.66 0 13 0zM13.03 6.03l-5.5 5.5C7.38 11.68 7.19 11.75 7 11.75s-0.38-0.07-0.53-0.22l-3.5-3.5c-0.29-0.29-0.29-0.77 0-1.06s0.77-0.29 1.06 0L7 9.94l4.97-4.97c0.29-0.29 0.77-0.29 1.06 0S13.32 5.74 13.03 6.03z"/>\
15252                                        </svg>\
15253                                    </label>\
15254                                </div>\
15255                                <div class="cl-s-product-thumb">\
15256                                    <img src="' + c_data.pdata[i].img + '" alt="' + c_data.pdata[i].name + '" class="' + c_data.pdata[i].img_align + '" />\
15257                                </div>\
15258                                <div class="cl-s-product-info">\
15259                                    <h5 class="cl-s-product-title">' + c_data.pdata[i].name + '</h5>\
15260                            ';
15261
15262                            // console.log(c_data.odata[i]);
15263
15264                            var price = (Number(c_data.odata[i].sale_price) > 0) ? c_data.odata[i].sale_price : c_data.odata[i].price,
15265                                quantity = Number(c_data.odata[i].quantity),
15266                                optionPrice = c_data.odata[i].price * quantity,
15267                                sum_price = quantity * price,
15268                                option_name = (typeof c_data.pdata[i].option != "undefined" && c_data.pdata[i].option) ? c_data.pdata[i].option : '',
15269                                option_str = '',
15270                                etc_str = (typeof c_data.pdata[i].etc_date != "undefined" && c_data.pdata[i].etc_date) ? '<span class="etc-date">선택일자: '+c_data.pdata[i].etc_date+'</span>' : '',
15271                                option_title = (c_data.pdata[i].option_type == 'A') ? '추가옵션: ' + (c_data.pdata[i].option_group ? c_data.pdata[i].option_group + ': ' : '') : '옵션: ';
15272                            if(option_name) {
15273                                option_str = (c_data.pdata[i].option_text_str) ? '<span class="' + (etc_str ? 'option-name' : '') + '">' + option_title + option_name+' / '+c_data.pdata[i].option_text_str+'</span>' : '<span class="' + (etc_str ? 'option-name' : '') + '">' + option_title + option_name+'</span>';
15274                            } else {
15275                                option_str = (c_data.pdata[i].option_text_str) ? '<span class="' + (etc_str ? 'option-name' : '') + '">' + option_title + c_data.pdata[i].option_text_str+'</span>' : '';
15276                            }
15277                            modal_str += '\
15278                                    <div class="option-str option-check" data-optionPrice="'+optionPrice+'">' + option_str + etc_str + '<span>' + quantity + '개</span><div class="price"><span>
15278' + number_format(optionPrice) + '</span> 원</div></div>\
15279                                </div>\
15280                                </td></tr>\
15281                            ';
15282
15283                        }
15284                        modal_str += '</table>';
15285
15286
15287                    var status = [];
15288                    for (var i=0;i<c_data.pdata.length;i++) {
15289                        status.push(c_data.pdata[i].p_status);
15290                    }
15291                    modal_str += checkOrderConfirm;
15292                    modal_str += '\
15293                        <div class="modal-sub-title order-cancel-content">구매확정을 진행하시겠습니까?</div>\
15294                        <div class="modal-comment order-cancel-content"></div>\
15295                    ';
15296
15297
15298                var ocModal = $(this).showModalFlat('구매 확정', modal_str,true,true,function () {
15299
15300                    var f = document.cancel_form;
15301
15302                    ocModal.find('.cl-s-form-wrap').each(function() {
15303                        var check_input = $(this).find('.cl-s-form-control'),
15304                            val = check_input.val().trim();
15305
15306                        if(val.length == 0) {
15307                            $(this).removeClass('error').addClass('empty');
15308                            $(this).find('.cl-s-control-label.error').remove();
15309                        } else {
15310                            if($(this).hasClass('error')) {
15311                                check_input.focus();
15312                            }
15313                        }
15314                    });
15315                    var checkCnt = 0;
15316
15317                    $(".status-checkbox").each(function (i, index) {
15318                        if ($(this).is(":checked") === true) {
15319                            checkCnt++;
15320                        }
15321                    });
15322
15323                    if (checkCnt < 1) {
15324                        alert('상품을 1개 이상 선택해 주세요');
15325                        return false;
15326                    }
15327
15328                    if(ocModal.find('.cl-s-form-wrap.empty, .cl-s-form-wrap.error').length > 0) {
15329                        // ocModal.find('.cl-s-form-wrap.empty, .cl-s-form-wrap.error').eq(0).find('.cl-s-form-control').focus();
15330                        return false;
15331                    }
15332
15333                    if(ocModal.find("input[type='checkbox'].cancel-agree:visible").length && ocModal.find("input[type='checkbox'].cancel-agree:visible").length != ocModal.find("input[type='checkbox'].cancel-agree:visible:checked").length) {
15334                        $(".point-used-cancel-agree-desc").show();
15335                        return false;
15336                    } else {
15337                        $(".point-used-cancel-agree-desc").hide();
15338                    }
15339
15340                    $.processON();
15341
15342                    f.submit();
15343                    ocModal.modal('hide');
15344
15345                },'취소','확인','cl-s-order-cancel cl-modal cl-s-btn cover ', false, '', function() {
15346                    var totalCnt = 0, totalNomalCheck = 0, nomalCheck = 0, price = 0, deliveryPrice = 0,
15347                        $form = $('form[name="cancel_form"]');
15348
15349                    $('.status-checkbox').each(function(i, index) {
15350                        if ($(this).is(":checked") === true) {
15351                            price += ($(this).closest('.cl-s-product-jumbotron').find('.option-check').attr('data-optionPrice') * 1);
15352                            totalCnt++;
15353                        }
15354
15355                        if ($(this).attr('data-type') == 'normal') {
15356                            totalNomalCheck++;
15357                        }
15358                    });
15359
15360                    $('.cancel-info-data').on('change', function (e) {
15361                        if($(this).hasClass('noneAll')) return;    
15362
15363                        var product_number = $(this).attr('data-product_number');
15364                        if($(this).attr('data-option_type') != 'A' && !$('input[name="order_number_ary[]"][data-product_number="' + product_number + '"][data-option_type!="A"]:not(:checked)').length) {
15365                            $('input[name="order_number_ary[]"][data-product_number="' + product_number + '"][data-option_type="A"]').prop('checked',true);
15366                        } else if($(this).attr('data-option_type') == 'A' && !$('input[name="order_number_ary[]"][data-product_number="' + product_number + '"][data-option_type!="A"]:not(:checked)').length && !$(this).prop('checked')) {
15367                            $('input[name="order_number_ary[]"][data-product_number="' + product_number + '"][data-option_type!="A"]:last').prop('checked',fal
15367se);
15368                        }
15369
15370                        var totalCnt = 0, totalNomalCheck = 0, nomalCheck = 0;
15371                        
15372                        $form.find('.order-cancel-content.extra-info').remove();
15373
15374                        if ($(this).hasClass('noneAll') === true) {
15375                            if ($(this).hasClass('noneChecked') === true) {
15376                                $(this).prop('checked', false);
15377                            } else {
15378                                $(this).prop('checked', true);
15379                                $(".status-checkbox").each(function () {
15380                                    if ($(this).prop('disabled') !== true) $(this).prop('checked', true);
15381                                });
15382                            }
15383                        }
15384
15385                        $(".status-checkbox").each(function (i, index) {
15386                            if ($(this).is(":checked") === true) {
15387                                price += ($(this).closest('.cl-s-product-jumbotron').find('.option-check').attr('data-optionPrice') * 1);
15388                                totalCnt++;
15389                                if ($(this).attr('data-type') == 'normal') nomalCheck++;
15390                            }
15391
15392                            if ($(this).attr('data-type') == 'normal') totalNomalCheck++;
15393                        });
15394
15395                        if($('input[name="order_number_ary[]"]').length == $('input[name="order_number_ary[]"]:checked').length) $('#product-check').prop('checked', true);
15396                        else $('#product-check').prop('checked', false);
15397                    });
15398
15399                    $(document).on('click', '#product-check', function () {
15400
15401                        $form.find('.order-cancel-content.extra-info').remove();
15402                        if ($(this).hasClass('noneAll') === true) {
15403                            $(this).prop('checked', true);
15404                            $(".status-checkbox").each(function () {
15405                                if ($(this).prop('disabled') !== true) $(this).prop('checked', true).change();
15406                            });
15407                        }
15408                        if ($(this).is(":checked") === true) {
15409                            $(".status-checkbox").each(function (i) {
15410                                if ($(this).prop('disabled') !== true) {
15411                                    $(this).prop('checked', true).change();
15412                                }
15413
15414                            });
15415                        } else {
15416                            $(".status-checkbox").each(function () {
15417                                if ($(this).prop('disabled') !== true) $(this).prop('checked', false).change();
15418                            });
15419                        }
15420                    });
15421
15422                    ocModal.find('[data-toggle="popover"]').popover();
15423                });
15424
15425            },'json');
15426            $('.close-button-dialog').css({'display': 'block'});
15427        },        
15428        editReviewModal: function(sid, pnum, onum, seq) {
15429            if(typeof sid == "undefined" || typeof pnum == "undefined" || typeof onum == "undefined") {
15430                alert('정보가 올바르지 않습니다');
15431                return false;
15432            }
15433            $.post('/_check_review', { sid:sid, seq: seq, mode:'review' }, function(data) {
15434
15435                if(typeof data.error != "undefined" && data.error) {
15436                    $(this).showModalFlat('', data.error, true, false, '', 'close');
15437                    return false;
15438                }
15439
15440                var c_data = data.r,
15441                    modal_str = '\
15442                    <div class="review-body review-write-body">\
15443                        <div class="cl-s-product-jumbotron clearfix">\
15444                            <div class="cl-s-product-thumb">\
15445                                <a href="' + c_data.pdata.product_url + '" target="_blank"><img src="' + c_data.pdata.img + '" alt="' + c_data.pdata.name + '" class="' + c_data.pdata.img_align + '" onerror="this.src=\'//storage.googleapis.com/i.addblock.net/img_broken_fill_500.png\'"/></a>\
15446                            </div>\
15447                            <div class="cl-s-product-info">\
15448                                <h5 class="cl-s-product-title"><a href="' + c_data.pdata.product_url + '" target="_blank">' + c_data.pdata.name + '</a></h5>\
15449                    ';
15450                    let use_review_img_upload = (typeof c_data.use_review_img_upload != 'undefined' && c_data.use_review_img_upload)? c_data.use_review_img_upload : 'true';
15451                    var option_title = (c_data.pdata.option_type == 'A') ? '추가옵션: ' + (c_data.pdata.option_group ? c_data.pdata.option_group + ': ' : '') : '옵션: ';
15452                    if(typeof c_data.pdata.option != "undefined" && c_data.pdata.option) {
15453                        modal_str += (c_data.pdata.option_text_str)? '\
15454                                <div class="option-str">' + option_title + c_data.pdata.option + ' / ' + c_data.pdata.option_text_str + '</div>\
15455                        ' : '\
15456                                <div class="option-str">' + option_title + c_data.pdata.option + '</div>\
15457                        ';
15458                    } else {
15459                        modal_str += (c_data.pdata.option_text_str)? '\
15460                                <div class="option-str">' + option_title + c_data.pdata.option_text_str + '</div>\
15461                        ' : '';
15462                    }
15463                    if(typeof c_data.pdata.etc_date != "undefined" && c_data.pdata.etc_date) {
15464                        modal_str += '\
15465                                <div class="option-str">선택일자: ' + c_data.pdata.etc_date + '</div>\
15466                        ';
15467                    }
15468                    var image = c_data.review.review_image.split("||").filter(function(v){return v!==''});
15469                    var image_orig = c_data.review.review_image_orig.split("||").filter(function(v){return v!==''});
15470                    var reviewImage = '';
15471                    if(image.length > 0) {
15472                        for (var i=0;i<image.length;i++) {
15473                            reviewImage += '\
15474                                <li id="review-image-'+i+'">\
15475                                    <img src="'+image[i]+'" class="img-responsive" />\
15476                                    <input type="hidden" name="review_image[]" value="'+image[i]+'" />\
15477                                    <input type="hidden" name="review_image_orig[]" value="'+image_orig[i]+'" />\
15478                                    <div class="cl-s-files-img-close review-img-close"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 8 8" width="8" height="8"><path d="M4.71 4l3.15-3.15c0.2-0.2 0.2-0.51 0-0.71s-0.51-0.2-0.71 0L4 3.29 0.85 0.15c-0.2-0.2-0.51-0.2-0.71 0s-0.2 0.51 0 0.71L3.29 4 0.15 7.15c-0.2 0.2-0.2 0.51 0 0.71C0.24 7.95 0.37 8 0.5 8s0.26-0.05 0.35-0.15L4 4.71l3.15 3.15C7.24 7.95 7.37 8 7.5 8s0.26-0.05 0.35-0.15c0.2-0.2 0.2-0.51 0-0.71L4.71 4z"/></svg></div>\
15479                                </li>\
15480                            ';
15481                        }
15482                    }
15483                    
15484                    modal_str += '\
15485                            </div>\
15486                        </div>\
15487                        <div class="review-star">\
15488                            <h5>상품이 만족스러우셨나요?</h5>\
15489                            <div class="star text-center">';
15490                            for(var i=0;i<5;i++) {
15491                                var rs_onof = (i < c_data.review.review_score) ? 'active' : '';
15492                                modal_str += '<span data-idx="'+(i+1)+'" class="'+rs_onof+'"></span>';
15493                            }
15494                            modal_str += '\
15495                            </div>\
15496                        </div>\
15497                        <div class="review-content">\
15498                            <h5>어떤 점이 좋았나요?</h5>\
15499                            <div class="cl-s-form-wrap">\
15500                                <div class="cl-s-form-group input-label-hide">\
15501                                    <textarea class="cl-s-form-control" id="review-str" name="review" maxlength="1000" required="required">'+c_data.review.review+'</textarea>\
15502                                    <label for="input" class="cl-s-control-label">자세한 내용을 적어주세요. (1000자 이내)</label>\
15503                                </div>\
15504                            </div>\
15505                        ';
15506                        if(use_review_img_upload != 'false') {
15507                        modal_str += '\
15508                            <div class="cl-s-files review-files">\
15509                                <input id="review-file" type="file" name="files[]" multiple data-sid="' + sid + '" data-uid=\"' + c_data.writer.id + '\" data-seq=\"'+seq+'\">\
15510                                <label class="cl-s-file-update review-file-update display-flex align-items-center justify-center"><svg viewBox="0 0 42 36" width="18" height="16"><path d="M36 6h-5l-3-5c0 0-0.71-1-1.99-1 -0.72 0-2.54 0-3.99 0 0 0-0.91 0-2.04 0 -1.45 0-3.27 0-3.99 0C14.71 0 14 1 14 1l-3 5H6c-3.31 0-6 2.69-6 6v18c0 3.31 2.69 6 6 6h30c3.31 0 6-2.69 6-6V12C42 8.69 39.31 6 36 6zM21 31c-5.52 0-10-4.48-10-10 0-5.52 4.48-10 10-10 5.52 0 10 4.48 10 10C31 26.52 26.52 31 21 31z"/><circle cx="21" cy="21" r="6"/></svg><span>사진 첨부하기</span></label>\
15511                                <ul class="cl-s-files-list review-files-list clearfix" >\
15512                                '+reviewImage+'\
15513                                </ul>\
15514                            </div>\
15515                        ';
15516                        }
15517                        modal_str += '\
15518                        </div>\
15519                    </div>\
15520                \
15521                ';
15522
15523                // $('.flat-modal .modal').modal('hide');
15524                var wrModal = $(this).showModalFlat('후기 작성', modal_str, true, true, function () {
15525
15526                    var cl_s_f_body = $('.cl-s-product-review-write .review-content');
15527                    cl_s_f_body.find('.cl-s-form-wrap').each(function() {
15528                        var check_input = $(this).find('.cl-s-form-control'),
15529                            val = check_input.val().trim();
15530
15531                        if(val.length == 0) {
15532                            $(this).removeClass('error').addClass('empty');
15533                            $(this).find('.cl-s-control-label.error').remove();
15534                        } else {
15535                            if($(this).hasClass('error')) {
15536                                check_input.focus();
15537                            }
15538                        }
15539                    });
15540
15541                    if(cl_s_f_body.find('.cl-s-form-wrap.empty, .cl-s-form-wrap.error').length > 0) {
15542                        cl_s_f_body.find('.cl-s-form-wrap.empty, .cl-s-form-wrap.error').eq(0).find('.cl-s-form-control').focus();
15543                        return false;
15544                    }
15545
15546                    var review = $('#review-str').val().trim(),
15547                        review_star = $('.cl-s-product-review-write .review-star .star .active').length,
15548                        review_image = new Array();
15549                        review_image_orig = new Array();
15550                    $('input[name="review_image[]"]').each(function(i) {
15551                        review_image[i] = $(this).val();
15552                    });
15553                    $('input[name="review_image_orig[]"]').each(function(i) {
15554                        review_image_orig[i] = $(this).val();
15555                    });
15556                    
15557                    var review_data = {
15558                        status : 'U',
15559                        page_mode : 'product',
15560                        pnum : pnum,
15561                        onum : onum,
15562                        seq : seq,
15563                        mb_status : c_data.writer.status,
15564                        review : review,
15565                        review_count : review_star,
15566                        review_image : review_image,
15567                        review_image_orig : review_image_orig
15568                    };
15569
15570                    if(c_data.writer.status == 'T') {
15571                        review_data['name'] = c_data.odata.name;
15572                        // review_data['order_group'] = c_data.order_data.group;
15573                    }
15574
15575                    $('.ok-button-dialog').prop('disabled', true);
15576                    
15577                    $.post('/_review_write', { sid:sid, data:JSON.stringify(review_data) }, function(rw_data) {
15578                        if(typeof rw_data.error != 'undefined' && rw_data.error) {
15579                            $(this).showModalFlat('ERROR', rw_data.error, true, false, '', 'close');
15580                            return false;
15581                        }
15582
15583                        wrModal.modal('hide');
15584                        setTimeout(function () {
15585                            location.reload();
15586                        }, 200); 
15587                    }, 'json');
15588
15589
15590
15591                },'close','수정하기','cl-s-product-review-write cl-modal cl-s-btn cover', true, '', function() {
15592                    $('.cl-s-product-review-write .cl-s-form-group').on('click',function(e) {
15593                        if($(e.target).hasClass('cl-s-form-group')) {
15594                            $(e.target).find('.cl-s-form-control:not([type=hidden])').focus();
15595                        }
15596                    });
15597
15598                    $('.cl-s-product-review-write .cl-s-form-control').on({
15599                        focus: function(e) {
15600                            $(this).closest('.cl-s-form-wrap').addClass('active');
15601                        },
15602                        blur: function(e) {
15603                            var val = $(this).val().trim();
15604
15605                            $(this).closest('.cl-s-form-wrap').removeClass('active');
15606                            if(val.length == 0) {
15607                                $(this).closest('.cl-s-form-wrap').removeClass('error').addClass('empty');
15608                                $(this).closest('.cl-s-form-wrap').find('.cl-s-control-label.error').remove();
15609                                return false;
15610                            } else {
15611                                $(this).closest('.cl-s-form-wrap').removeClass('empty');
15612
15613                                var passEmoji = ($.inArray($(this).attr('name'),['review']) > -1) ? true : false,
15614                                    error_str = '';
15615                                if(!passEmoji && checkEmojis(val)) error_str =  $.lang[LANG]['config.unable.emoji'];
15616                                else if(val.length < 5) error_str = $.lang[LANG]['customsite.validate.message.minlengthto5'];
15617
15618                                if(error_str.length > 0) {
15619                                    $(this).closest('.cl-s-form-wrap').addClass('error');
15620                                    if($(this).parent().find('.cl-s-control-label.error').length > 0) {
15621                                        $(this).parent().find('.cl-s-control-label.error').html(error_str);
15622                                    } else {
15623                                        $(this).after('<label for="input" class="cl-s-control-label error">' + error_str + '</label>');
15624                                    }
15625                                    return false;
15626                                }
15627                            }
15628
15629                            $(this).closest('.cl-s-form-wrap').removeClass('error').removeClass('empty');
15630                            $(this).closest('.cl-s-form-wrap').find('.cl-s-control-label.error').remove();
15631                        }
15632                    });
15633
15634
15635                    $(document).on('click', '.cl-s-product-review-write .review-img-close', {mode: 'review'}, deleteReviewQnaImg);
15636
15637
15638                    $('.cl-s-product-review-write .review-file-update').on('click', function () {
15639                        $("#review-file").click();
15640                    });
15641
15642                    $('.cl-s-product-review-write #review-file').on('click', {mode: 'review'}, uploadReviewQnaImg);
15643
15644                    $('.cl-s-product-review-write .review-star .star span').on('click', function() {
15645                        var rCount = $(this).attr('data-idx');
15646                        $(this).parent().children('span').removeClass('active');
15647                        $(this).addClass('active').prevAll('span').addClass('active');
15648                    });
15649
15650                });
15651
15652            },'json');
15653
15654        },
15655        viewReviewModal: function(sid, seq, page) {
15656            if(typeof sid == 'undefined' || typeof seq == 'undefined') {
15657                alert('정보가 올바르지 않습니다');
15658                return false;
15659            }
15660
15661            $.post('/_check_review', { sid:sid, seq:seq }, function(data) {
15662                if(typeof data.error != 'undefined' && data.error) {
15663                    $(this).showModalFlat('', data.error, true, false, '', 'close');
15664                    return false;
15665                }
15666
15667                var c_data = data.r;
15668                var um_id = c_data.review.um_id;
15669                var writer = c_data.writer.id;
15670                var writerName = (um_id == writer)? c_data.review.name : c_data.review.masked_name;
15671                    writerName = (c_data.writer.status == 'A')? c_data.review.name : writerName;
15672                var image = c_data.review.review_image.split("||").filter(function(v){return v!==''});
15673                var reviewImage = '';
15674                for (var i=0;i<image.length;i++) {
15675                    reviewImage += '<img src="'+getServeImage(image[i], '800', '')+'">';
15676                }
15677                
15678                var modal_str = '\
15679                    <div class="review-body">\
15680                        <div class="cl-s-product-jumbotron clearfix">\
15681                            <div class="cl-s-product-thumb">\
15682                                <a href="' + c_data.pdata.product_url + '" target="_blank"><img src="' + c_data.pdata.img + '" alt="' + c_data.pdata.name + '" class="' + c_data.pdata.img_align + '" onerror="this.src=\'//storage.googleapis.com/i.addblock.net/img_broken_fill_500.png\'"/></a>\
15683                            </div>\
15684                            <div class="cl-s-product-info">\
15685                                <h5 class="cl-s-product-title"><a href="' + c_data.pdata.product_url + '" target="_blank">' + c_data.pdata.name + '</a></h5>\
15686                            ';
15687                    var option_title = (c_data.pdata.option_type == 'A') ? '추가옵션: ' + (c_data.pdata.option_group ? c_data.pdata.option_group + ': ' : '') : '옵션: ';                            
15688                    if(typeof c_data.pdata.option != "undefined" && c_data.pdata.option) {
15689                        modal_str += '\
15690                                <div class="option-str">' + option_title + c_data.pdata.option + '</div>\
15691                        ';
15692                    }
15693                    if(typeof c_data.pdata.etc_date != "undefined" && c_data.pdata.etc_date) {
15694                        modal_str += '\
15695                                <div class="option-str">선택일자: ' + c_data.pdata.etc_date + '</div>\
15696                        ';
15697                    }
15698
15699                    c_data.review_status = (c_data.writer.status=='T' && page=='mypayment')? 'Y':c_data.review_status;
15700                    modal_str += '\
15701                            </div>\
15702                        </div>\
15703                        <div class="review-member-info">\
15704                            <span>' + (c_data.review.inflow=='NAVERPAY' ? '<svg class="ico-naverpay" viewBox="0 0 24 24" width="14" height="14"><polygon points="15.2 2.8 15.2 12.1 8.9 2.8 2 2.8 2 21.2 8.8 21.2 8.8 11.9 15.2 21.2 22 21.2 22 2.8 "></polygon></svg>' : '') + writerName + '<span class="view-review-date">' + c_data.review.reg_date + '</span></span>';
15705                            if (c_data.review_status == 'Y' || c_data.review_status == 'A' || c_data.writer.status == 'A') {
15706                                modal_str += '<div class="review-edit-box" data-pnum="'+c_data.review.product_number+'" data-onum="'+c_data.review.order_number+'" data-ogroup="'+c_data.odata.order_group+'" data-seq="'+c_data.review.seq+'">';
15707                                if (c_data.review_status == 'Y' && c_data.review.status == 'N' && c_data.review.seq.indexOf('mlux|') == -1) {
15708                                    modal_str += '<button type="button" class="review-edit">수정</button>';
15709                                    modal_str += '<button type="button" class="review-delete">삭제</button>';
15710                                }
15711                                if (c_data.writer.status == 'A' && c_data.review.seq.indexOf('mlux|') == -1) {
15712                                    modal_str += '<button type="button" class="review-delete">삭제</button>';
15713                                }
15714                                modal_str += '</div>\
15715                                ';
15716                            }
15717                        modal_str += '\
15718                        </div>\
15719                        <div class="view-review-box">\
15720                            <div class="review-score">';
15721                            for(var i=0;i<5;i++) {
15722                                var rs_onof = (i < c_data.review.review_score) ? 'on' : 'off';
15723                                modal_str += '<span class="re_starimg star_'+ rs_onof +'"><svg viewBox="0 0 15 15" width="15" height="15"><polygon points="15 5.8 9.78 4.77 7.5 0 5.22 4.77 0 5.8 3.59 9.55 2.93 15 7.5 12.61 12.07 15 11.41 9.55 "/></svg></span>';
15724                            }
15725
15726                            if(c_data.review.inflow=='NAVERPAY') {
15727                                if(c_data.review.review_image) {
15728                                    reviewImage = '<img src="' + c_data.review.review_image 
15728+ '" />';
15729                                } else {
15730                                    reviewImage = '';
15731                                }
15732                            }
15733
15734                            modal_str += '\
15735                            </div>\
15736                            <div class="review-box-content">'+nl2br(c_data.review.review)+'</div>\
15737                            <div class="review-box-image">'+reviewImage+'</div>\
15738                            ';
15739                            if(c_data.review.status == 'Y'){
15740                            modal_str += '\
15741                            <div class="review-box-content review-answer answer-content_'+seq+'">\
15742                                <div class="review-answer-info"><span>관리자<span class="view-review-date">'+c_data.review.answer_date+'</span></span></div>\
15743                                <div class="review-content">'+nl2br(c_data.review.answer)+'\
15744                            </div>'; //end review-answer-content
15745                            if(c_data.writer.status == 'A') {
15746                                modal_str += '\
15747                                    <div class="answer-editor-button" data-pnum="'+c_data.review.product_number+'" data-onum="'+c_data.review.order_number+'" data-seq="'+c_data.review.seq+'">\
15748                                        <button type="button" class="btn answer-modify-btn" data-seq="'+seq+'">수정</button>\
15749                                        <button type="button" class="btn answer-delete-btn" onclick="answerDelete('+seq+')">답글 삭제</button>\
15750                                    </div>\
15751                                ';
15752                            }
15753                            modal_str += '\
15754                            </div>'; //end review-answer
15755                            }          
15756                            
15757                            if(c_data.writer.status == 'A' && c_data.review.seq.indexOf('mlux|') == -1){
15758                            modal_str += '\
15759                            <div class="answer-editor answer-editor_'+seq+' answer_'+c_data.review.status+'">\
15760                                <div class="review-answer-info">답글</div>\
15761                                <textarea id="answer-'+seq+'" placeholder="답글을 작성해 주세요.">'+nl2br(c_data.review.answer)+'</textarea>\
15762                                <div class="answer-editor-button" data-pnum="'+c_data.review.product_number+'" data-onum="'+c_data.review.order_number+'" data-seq="'+c_data.review.seq+'">';
15763                            if(c_data.review.status == 'N'){
15764                            modal_str += '\
15765                                    <button type="button" class="btn answer-submit-btn">답글 등록</button>';
15766                            }
15767                            else{
15768                            modal_str += '\
15769                                    <button type="button" class="btn answer-cancel-btn">취소</button>\
15770                                    <button type="button" class="btn answer-submit-btn">답글 수정</button>';
15771                            }
15772                            modal_str += '\
15773                                </div>\
15774                            </div>';
15775                            }
15776                modal_str += '\
15777                        </div>\
15778                    </div>'; //end view-review-box
15779
15780                // $('.flat-modal .modal').modal('hide');
15781                var wrModal = $(this).showModalFlat('상품 후기', modal_str, true, false, '', '','','cl-s-product-review-write cl-s-product-review-view cl-modal cl-s-btn cover', false, '', function () {
15782                    $(document).off('click', '.review-edit');
15783                    $(document).on('click', '.review-edit', function (e) {
15784                        e.stopPropagation();
15785                        var $parent = $(this).parent(),
15786                            pnum = $parent.attr('data-pnum'),
15787                            onum = $parent.attr('data-onum'),
15788                            seq = $parent.attr('data-seq');
15789
15790                        $('.modal-backdrop').fadeOut(200);
15791                        $('.modal').fadeOut(200);
15792                        setTimeout(function () {
15793                            $('.modal-backdrop').remove();
15794                            $('.modal').remove();
15795                            $('button[data-dismiss="modal"]').trigger('click');
15796                            $.shoppingmall.editReviewModal(sid, pnum, onum, seq);
15797                        }, 200);
15798                    });
15799
15800                    $(document).off('click', '.review-delete');
15801                    $(document).off('click', '.answer-modify-btn');
15802                    $(document).off('click', '.answer-cancel-btn');
15803                    $(document).off('click', '.answer-submit-btn');
15804
15805                    $(document).on('click', '.review-delete', function () {
15806                    $this = $(this)
15807                        var $parent = $(this).parent(),                            
15808                            on = $parent.attr('data-onum'),
15809                            og = $parent.attr('data-ogroup');
15810                        $.ajax({
15811                            url: '/_review_delete_chk',
15812                            type: 'post',
15813                            data: {
15814                                review_og : og,
15815                                review_on : on 
15816                            },
15817                            success: function (data) {
15818                                var parsedData = JSON.parse(data);
15819                                if(parsedData.result == true ){
15820                                    if (confirm('정말로 삭제하시겠습니까?')) {
15821                                        var pnum = $parent.attr('data-pnum'),
15822                                            onum = $parent.attr('data-onum'),
15823                                            seq = $parent.attr('data-seq'),
15824                                            on = $parent.attr('data-onum'),                                            
15825                                            og = $parent.attr('data-ogroup');
15826                                        $.ajax({
15827                                            url: '/_review_delete',
15828                                            type: 'post',
15829                                            data: {
15830                                                sid: sid,
15831                                                seq: seq,
15832                                                review_og : og,
15833                                                review_on : on                                                 
15834                                            },
15835                                            success: function (data) {
15836                                                alert('삭제가 완료되었습니다.');
15837                                                location.reload();
15838                                            }
15839                                        });
15840                                    }
15841                                } else {
15842                                    console.log($(this),"2번")
15843                                    if($('.rv-cancel-paddingedit').length == 0) {
15844                                        $this.closest('.cl-s-product-review-view .modal-content').css('opacity','.5');
15845                                        var modal = $(this).showModalFlat('후기 삭제에 따른<br>적립금 회수 안내','후기를 삭제하시면 후기 작성 적립금이 회수됩니다.<br>후기를 삭제 하시겠습니까?',true,true,function(){                    
15846                                            var $parent = $this.parent(),
15847                                                pnum = $parent.attr('data-pnum'),
15848                                                onum = $parent.attr('data-onum'),
15849                                                seq = $parent.attr('data-seq'),
15850                                                on = $parent.attr('data-onum'),
15851                                                og = $parent.attr('data-ogroup');
15852
15853                                            $.ajax({
15854                                                url: '/_review_delete',
15855                                                type: 'post',
15856                                                data: {
15857                                                    sid: sid,
15858                                                    seq: seq,
15859                                                    review_og : og,
15860                                                    review_on : on 
15861                                                },
15862                                                success: function (data) {
15863                                                    alert('삭제가 완료되었습니다.');
15864                                                    location.reload();
15865                                                }
15866                                            });                            
15867                                        },'cancel','ok','cl-cmmodal cl-s-btn w560 cl-p130 cl-p0 review-opacity rv-cancel-paddingedit','',function(){
15868                                            $this.closest('.cl-s-product-review-view .modal-content').css('opacity','unset'); 
15869                                        }, function() {
15870                                            $(document).on('click', '.ok-button-dialog', function (e) {
15871                                                $(this).prop("disabled", true);
15872                                            });                                        
15873                                            $(document).on('keydown', function(e) {
15874                                                if(e.keyCode == 27) modal.modal('hide');
15875                                            });
15876                                        }, function() {
15877                                            $this.closest('.cl-s-product-review-view .modal-content').css('opacity','unset');
15878                                        });
15879                                    }
15880                                }
15881                            }
15882                        });   
15883
15884                    });
15885
15886                    $(document).on('click', '.answer-modify-btn', function(){
15887                        var $parent = $(this).parent(),
15888                            pnum = $parent.attr('data-pnum'),
15889                            onum = $parent.attr('data-onum'),
15890                            seq = $parent.attr('data-seq');
15891
15892                        $('.answer-content_'+seq).hide();
15893                        $('.answer-editor_'+seq).show();
15894                    });
15895
15896                    $(document).on('click', '.answer-cancel-btn', function(){
15897                        var $parent = $(this).parent(),
15898                            pnum = $parent.attr('data-pnum'),
15899                            onum = $parent.attr('data-onum'),
15900                            seq = $parent.attr('data-seq');
15901
15902                        $('.answer-content_'+seq).show();
15903                        $('.answer-editor_'+seq).hide();
15904                    });
15905
15906                    $(document).on('click', '.answer-submit-btn', function(){
15907                        var $parent = $(this).parent(),
15908                            pnum = $parent.attr('data-pnum'),
15909                            onum = $parent.attr('data-onum'),
15910                            seq = $parent.attr('data-seq');
15911
15912                        $.ajax({
15913                            url: '/_review_msg_write',
15914                            type: 'post',
15915                            data: {
15916                                sid: sid,
15917                                seq: seq,
15918                                review_admin_msg: $('#answer-'+seq).val()
15919                            },
15920                            success: function (data) {
15921                                alert('답글이 등록되었습니다.');
15922                                location.reload();
15923                            }
15924                        });
15925                    });
15926
15927                    $(document).on('click', '.answer-delete-btn', function(){
15928                        if (confirm('정말로 삭제하시겠습니까?')) {
15929                            var $parent = $(this).parent(),
15930                                pnum = $parent.attr('data-pnum'),
15931                                onum = $parent.attr('data-onum'),
15932                                seq = $parent.attr('data-seq');
15933
15934                            $.ajax({
15935                                url: '/_review_msg_write',
15936                                type: 'post',
15937                                data: {
15938                                    sid: sid,
15939                                    seq: seq,
15940                                },
15941                                success: function (data) {
15942                                    alert('답글이 삭제되었습니다.');
15943                                    location.reload();
15944                                }
15945                            });
15946                        }
15947                    });
15948                });
15949
15950
15951            },'json');
15952
15953        },
15954        editQnAModal: function(sid, pnum, seq, onum) {
15955            if(typeof property == 'undefined') {
15956                // alert('편집모드에서 지원하지 않습니다');
15957                var modal = $(this).showModalFlat('','편집모드에서 지원하지 않습니다',true,false,'','ok','','cl-cmmodal cl-s-btn w560 cl-p130 cl-t80 cl-modal cl-none-title cl-close-btn','','',function() {
15958                    $(document).on('keydown', function(e) {
15959                        if(e.keyCode == 27) modal.modal('hide');
15960                    });
15961                });
15962                return false;
15963            }
15964            if(typeof property.LOAD != 'undefined' && property.LOAD == 'RENDER') {
15965                alert('미리보기에서는 지원하지 않습니다');
15966                return false;
15967            }
15968            if(typeof seq == 'undefined' || seq == '') seq = -1;
15969            var mode = (seq == -1) ? 'new' : 'edit';
15970            var onum = (typeof onum == 'undefined' || onum == '')? '':onum;
15971            
15972            $.ajax({
15973                url: '/_qna_edit',
15974                type: 'POST',
15975                dataType: 'json',
15976                data: { sid:sid, pnum:pnum, seq:seq, mode:mode },
15977                async: false,
15978                cache: false,
15979                success: function(data) {
15980                    if (data.result == 'fail') {
15981                        location.href = '/_login';
15982                        return false;
15983                    }
15984
15985                    if (data.error) {
15986                        $(this).showModalFlat('', data.error, true, false, '', 'close');
15987                        return false;
15988                    }
15989
15990                    var status = data.um_status;
15991                    if(status == 'A') {
15992                        alert('관리자는 상품문의하기를 사용할 수 없습니다.');
15993                        return false;
15994                    }
15995
15996                    var qna_files_str = qna_secret_str = qna_answer_email_str = qna_answer_alimtalk_str = '';
15997
15998                    if(mode == 'edit') {
15999                        if(data['secret'] == 'Y') qna_secret_str = 'checked';
16000                        if(data['answer_email'] == 'Y') qna_answer_email_str = 'checked';
16001                        if(data['answer_alimtalk'] == 'Y') qna_answer_alimtalk_str = 'checked';
16002
16003                        if(data['qna_image']) {
16004                            var image = data['qna_image'].split('||').filter(function(v){return v!==''});
16005                            var image_orig = data['qna_image_orig'].split('||').filter(function(v){return v!==''});
16006                            $.each(image, function(i,v) {
16007                                qna_files_str += '\
16008                                    <li id="qna-image-' + i + '">\
16009                                        <img src="' + v + '" class="img-responsive" />\
16010                                        <input type="hidden" name="qna_image[]" value="' + v + '"/>\
16011                                        <input type="hidden" name="qna_image_orig[]" value="' + image_orig[i] + '"/>\
16012                                        <div class="cl-s-files-img-close qna-img-close"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 8 8" width="8" height="8"><path d="M4.71 4l3.15-3.15c0.2-0.2 0.2-0.51 0-0.71s-0.51-0.2-0.71 0L4 3.29 0.85 0.15c-0.2-0.2-0.51-0.2-0.71 0s-0.2 0.51 0 0.71L3.29 4 0.15 7.15c-0.2 0.2-0.2 0.51 0 0.71C0.24 7.95 0.37 8 0.5 8s0.26-0.05 0.35-0.15L4 4.71l3.15 3.15C7.24 7.95 7.37 8 7.5 8s0.26-0.05 0.35-0.15c0.2-0.2 0.2-0.51 0-0.71L4.71 4z"></path></svg></div>\
16013                                    </li>\
16014                                ';
16015                            });
16016                        }
16017                    }
16018                    data['email'] = (data['email'] !== null)? data['email']:'';
16019                    seq = (seq !== -1)? seq:'';
16020                    var qna_writer_str = (data['member']) ? '\
16021                        <input type="hidden" id="qna-name" class="cl-s-form-control" name="qna_name" value="' + data['name'] + '">\
16022                        <input type="hidden" id="qna-email" class="cl-s-form-control" name="qna_email" value="' + data['email'] + '">\
16023                        <input type="hidden" id="qna-tel" class="cl-s-form-control" name="qna_tel" value="' + data['tel'] + '">\
16024                        <input type="hidden" id="order-number" name="order_number" value="' + onum + '">\
16025                    ' : '\
16026                        <input type="hidden" id="order-number" name="order_number" value="' + onum + '">\
16027                            <ul class="qna-writer clearfix">\
16028                                <li>\
16029                                    <div class="cl-s-form-wrap">\
16030                                        <div class="cl-s-form-group">\
16031                                            <input type="text" class="cl-s-form-control" id="qna-name" name="qna_name" required="required" value="' + data['name'] + '">\
16032                                            <label for="input" class="cl-s-control-label">이름</label>\
16033                                        </div>\
16034                                    </div>\
16035                                </li>\
16036                                <li>\
16037                                    <div class="cl-s-form-wrap">\
16038                                        <div class="cl-s-form-group">\
16039                                            <input type="password" class="cl-s-form-control" id="qna-password" name="qna_password" required="required">\
16040                                            <label for="input" class="cl-s-control-label">비밀번호</label>\
16041                                        </div>\
16042                                    </div>\
16043                                </li>\
16044                            </ul>\
16045                        ';
16046
16047                    var qna_privacy_str = '\
16048                            <hr class="line"/>\
16049                            <div class="qna-privacy">\
16050                    ';
16051                    if(!data['member']) {
16052                        if(data['um_qna_fin'] == 'Y') {
16053                            qna_privacy_str += '\
16054                                <div class="cl-s-checkbox">\
16055                                    <label class="privacy-toggle" data-view="#qna-email-input">\
16056                                        <input type="checkbox" id="qna-btn-email" name="answer_email" value="Y" ' + qna_answer_email_str + '>\
16057                                        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path d="M13 0H3C1.3 0 0 1.3 0 3v10c0 1.7 1.3 3 3 3h10c1.7 0 3-1.3 3-3V3C16 1.3 14.7 0 13 0zM15 13c0 1.1-0.9 2-2 2H3c-1.1 0-2-0.9-2-2V3c0-1.1 0.9-2 2-2h10c1.1 0 2 0.9 2 2V13z"/></svg>\
16058                                        <svg class="active" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path d="M13 0H3C1.34 0 0 1.34 0 3v10c0 1.66 1.34 3 3 3h10c1.66 0 3-1.34 3-3V3C16 1.34 14.66 0 13 0zM13.03 6.03l-5.5 5.5C7.38 11.68 7.19 11.75 7 11.75s-0.38-0.07-0.53-0.22l-3.5-3.5c-0.29-0.29-0.29-0.77 0-1.06s0.77-0.29 1.06 0L7 9.94l4.97-4.97c0.29-0.29 0.77-0.29 1.06 0S13.32 5.74 13.03 6.03z"/></svg>\
16059                                        이메일로 답변완료 알림 받기\
16060                                    </label>\
16061                                </div>\
16062                                <div class="cl-s-form-wrap" id="qna-email-input" style="display:' + ((qna_answer_email_str == 'checked')? 'block':'none') + ';">\
16063                                    <div class="cl-s-form-group">\
16064                                        <input type="text" class="cl-s-form-control" id="qna-email" name="qna_email" data-type="email" required="required" value="' + data['email'] + '">\
16065                                        <label for="input" class="cl-s-control-label">이메일 주소</label>\
16066                                    </div>\
16067                                </div>\
16068                            ';
16069                            if(data['talk_cnt'] > 0) { //alimtalk
16070                                qna_privacy_str += '\
16071                                <div class="cl-s-checkbox">\
16072                                    <label class="privacy-toggle" data-view="#qna-tel-input">\
16073                                        <input type="checkbox" id="qna-btn-alimtalk" name="answer_alimtalk" value="Y" ' + qna_answer_alimtalk_str + '>\
16074                                        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path d="M13 0H3C1.3 0 0 1.3 0 3v10c0 1.7 1.3 3 3 3h10c1.7 0 3-1.3 3-3V3C16 1.3 14.7 0 13 0zM15 13c0 1.1-0.9 2-2 2H3c-1.1 0-2-0.9-2-2V3c0-1.1 0.9-2 2-2h10c1.1 0 2 0.9 2 2V13z"/></svg>\
16075                                        <svg class="active" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path d="M13 0H3C1.34 0 0 1.34 0 3v10c0 1.66 1.34 3 3 3h10c1.66 0 3-1.34 3-3V3C16 1.34 14.66 0 13 0zM13.03 6.03l-5.5 5.5C7.38 11.68 7.19 11.75 7 11.75s-0.38-0.07-0.53-0.22l-3.5-3.5c-0.29-0.29-0.29-0.77 0-1.06s0.77-0.29 1.06 0L7 9.94l4.97-4.97c0.29-0.29 0.77-0.29 1.06 0S13.32 5.74 13.03 6.03z"/></svg>\
16076                                        알림톡으로 답변완료 알림 받기\
16077                                    </label>\
16078                                </div>\
16079                                <div class="cl-s-form-wrap" id="qna-tel-input" style="display:' + ((qna_answer_alimtalk_str == 'checked')? 'block':'none') + ';">\
16080                                    <div class="cl-s-form-group">\
16081                                        <input type="text" class="cl-s-form-control" id="qna-tel" name="qna_tel" data-type="tel" required="required" value="' + data['tel'] + '">\
16082                                        <label for="input" class="cl-s-control-label">
16082전화번호</label>\
16083                                    </div>\
16084                                </div>\
16085                                ';
16086                            }
16087                        }
16088                        qna_privacy_str += '\
16089                                <div class="cl-s-checkbox">\
16090                                    <label>\
16091                                        <input type="checkbox" id="qna-btn-privacy" name="qna_btn_privacy">\
16092                                        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path d="M13 0H3C1.3 0 0 1.3 0 3v10c0 1.7 1.3 3 3 3h10c1.7 0 3-1.3 3-3V3C16 1.3 14.7 0 13 0zM15 13c0 1.1-0.9 2-2 2H3c-1.1 0-2-0.9-2-2V3c0-1.1 0.9-2 2-2h10c1.1 0 2 0.9 2 2V13z"/></svg>\
16093                                        <svg class="active" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path d="M13 0H3C1.34 0 0 1.34 0 3v10c0 1.66 1.34 3 3 3h10c1.66 0 3-1.34 3-3V3C16 1.34 14.66 0 13 0zM13.03 6.03l-5.5 5.5C7.38 11.68 7.19 11.75 7 11.75s-0.38-0.07-0.53-0.22l-3.5-3.5c-0.29-0.29-0.29-0.77 0-1.06s0.77-0.29 1.06 0L7 9.94l4.97-4.97c0.29-0.29 0.77-0.29 1.06 0S13.32 5.74 13.03 6.03z"/></svg>\
16094                                        <a href="javascript:;" class="qna-view-privacy privacy-toggle" data-view="#qna-privacy-textarea">개인정보 수집 및 이용</a>에 동의합니다.\
16095                                    </label>\
16096                                </div>\
16097                                <div class="qna-privacy-textarea hide" name="privacy_textarea" id="qna-privacy-textarea" style="display:none;">\
16098                                    ※ 비회원 서비스문의를 위한 개인정보 수집·이용 동의(필수)<br>\
16099                                    서비스 이용자의 개인정보를 수집하는 목적은 다음과 같습니다.\
16100                                    <table>\
16101                                        <colgroup>\
16102                                            <col width="25%">\
16103                                            <col width="45%">\
16104                                            <col width="30%">\
16105                                        </colgroup>\
16106                                        <thead>\
16107                                            <tr>\
16108                                                <th>수집목적</th>\
16109                                                <th>수집항목</th>\
16110                                                <th>이용기간</th>\
16111                                            </tr>\
16112                                        </thead>\
16113                                        <tbody>\
16114                                            <tr>\
16115                                                <td>문의 응대 및 서비스 개선</td>\
16116                                                <td>(필수) 이름, 이메일, 문의내용</td>\
16117                                                <td>문의 종료일로 5년</td>\
16118                                            </tr>\
16119                                        </tbody>\
16120                                    </table>\
16121                                    <br>\
16122                                    - 동의를 거부할 권리가 있으나, 동의거부에 따른 서비스 이용에 제한이 있을 수 있습니다.<br>\
16123                                    - 회사는 계약 및 서비스 이행을 위해 개인정보 처리업무를 위탁할 수 있으며, 개인정보처리방침에 그 내용을 고지합니다.<br>\
16124                                </div>\
16125                        ';
16126                    } else {
16127                        if(data['um_qna_fin'] == 'Y') {
16128                            qna_privacy_str += '\
16129                                <div class="cl-s-checkbox">\
16130                                    <label>\
16131                                        <input type="checkbox" id="qna-btn-email" name="answer_email" value="Y" ' + qna_answer_email_str + '>\
16132                                        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path d="M13 0H3C1.3 0 0 1.3 0 3v10c0 1.7 1.3 3 3 3h10c1.7 0 3-1.3 3-3V3C16 1.3 14.7 0 13 0zM15 13c0 1.1-0.9 2-2 2H3c-1.1 0-2-0.9-2-2V3c0-1.1 0.9-2 2-2h10c1.1 0 2 0.9 2 2V13z"/></svg>\
16133                                        <svg class="active" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path d="M13 0H3C1.34 0 0 1.34 0 3v10c0 1.66 1.34 3 3 3h10c1.66 0 3-1.34 3-3V3C16 1.34 14.66 0 13 0zM13.03 6.03l-5.5 5.5C7.38 11.68 7.19 11.75 7 11.75s-0.38-0.07-0.53-0.22l-3.5-3.5c-0.29-0.29-0.29-0.77 0-1.06s0.77-0.29 1.06 0L7 9.94l4.97-4.97c0.29-0.29 0.77-0.29 1.06 0S13.32 5.74 13.03 6.03z"/></svg>\
16134                                        이메일로 답변완료 알림 받기\
16135                                    </label>\
16136                                </div>\
16137                            ';
16138                            
16139                            if(data['talk_cnt'] > 0) { //alimtalk
16140                                qna_privacy_str += '\
16141                                <div class="cl-s-checkbox">\
16142                                    <label>\
16143                                        <input type="checkbox" id="qna-btn-alimtalk" name="answer_alimtalk" value="Y" ' + qna_answer_alimtalk_str + '>\
16144                                        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path d="M13 0H3C1.3 0 0 1.3 0 3v10c0 1.7 1.3 3 3 3h10c1.7 0 3-1.3 3-3V3C16 1.3 14.7 0 13 0zM15 13c0 1.1-0.9 2-2 2H3c-1.1 0-2-0.9-2-2V3c0-1.1 0.9-2 2-2h10c1.1 0 2 0.9 2 2V13z"/></svg>\
16145                                        <svg class="active" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path d="M13 0H3C1.34 0 0 1.34 0 3v10c0 1.66 1.34 3 3 3h10c1.66 0 3-1.34 3-3V3C16 1.34 14.66 0 13 0zM13.03 6.03l-5.5 5.5C7.38 11.68 7.19 11.75 7 11.75s-0.38-0.07-0.53-0.22l-3.5-3.5c-0.29-0.29-0.29-0.77 0-1.06s0.77-0.29 1.06 0L7 9.94l4.97-4.97c0.29-0.29 0.77-0.29 1.06 0S13.32 5.74 13.03 6.03z"/></svg>\
16146                                        알림톡으로 답변완료 알림 받기\
16147                                    </label>\
16148                                </div>\
16149                                ';
16150                            }
16151                        }
16152                    }
16153                    qna_privacy_str += '\
16154                        </div>\
16155                    '; //qna-privacy
16156
16157                    var modal_str = '\
16158                        <div class="qna-body">\
16159                            <h5 class="product-title">' + data['ptitle'] + '</h5>\
16160                            ' + qna_writer_str + '\
16161                            <ul class="qna-content">\
16162                                <li>\
16163                                    <div class="cl-s-form-wrap">\
16164                                        <div class="cl-s-form-group">\
16165                                            <input type="text" class="cl-s-form-control" id="qna-title" name="title" required="required" maxlength="100" value="' + data['title'] + '">\
16166                                            <label for="input" class="cl-s-control-label">제목</label>\
16167                                        </div>\
16168                                    </div>\
16169                                </li>\
16170                                <li>\
16171                                    <div class="cl-s-form-wrap">\
16172                                        <div class="cl-s-form-group input-label-hide">\
16173                                            <textarea type="text" class="cl-s-form-control" id="qna-str" name="qna" maxlength="500" required="required">' + data['qna'] + '</textarea>\
16174                                            <label for="input" class="cl-s-control-label">자세한 내용을 적어주세요. (500자 이내)</label>\
16175                                        </div>\
16176                                    </div>\
16177                                </li>\
16178                                <li class="last clearfix">\
16179                                    <div class="qna-secret">\
16180                                        <div class="secret cl-s-checkbox">\
16181                                            <label>\
16182                                                <input type="checkbox" id="secret-checkbox" name="secret" value="Y" ' + qna_secret_str + '>\
16183                                                <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path d="M13 0H3C1.3 0 0 1.3 0 3v10c0 1.7 1.3 3 3 3h10c1.7 0 3-1.3 3-3V3C16 1.3 14.7 0 13 0zM15 13c0 1.1-0.9 2-2 2H3c-1.1 0-2-0.9-2-2V3c0-1.1 0.9-2 2-2h10c1.1 0 2 0.9 2 2V13z"/></svg>\
16184                                                <svg class="active" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path d="M13 0H3C1.34 0 0 1.34 0 3v10c0 1.66 1.34 3 3 3h10c1.66 0 3-1.34 3-3V3C16 1.34 14.66 0 13 0zM13.03 6.03l-5.5 5.5C7.38 11.68 7.19 11.75 7 11.75s-0.38-0.07-0.53-0.22l-3.5-3.5c-0.29-0.29-0.29-0.77 0-1.06s0.77-0.29 1.06 0L7 9.94l4.97-4.97c0.29-0.29 0.77-0.29 1.06 0S13.32 5.74 13.03 6.03z"/></svg>\
16185                                                비밀글\
16186                                            </label>\
16187                                        </div>\
16188                                    </div>\
16189                                    <div class="cl-s-files qna-files f-left">\
16190                                        <input id="qna-file" type="file" name="files[]" accept="image/jpeg,image/gif,image/png" multiple data-sid="' + sid + '" data-uid=\"' + data['um_id'] + '\" data-seq=\"'+seq+'\">\
16191                                        <label class="cl-s-file-update qna-file-update clearfix"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" width="20" height="20"><path d="M0 0v20h20V0H0zM19 1v11.3l-3-3 -4 4 -6-6 -5 5V1H19zM1 19v-5.3l5-5 6 6 4-4 3 3V19H1z"/><circle cx="14.5" cy="5.5" r="1.5"/></svg> <span>사진</span></label>\
16192                                        <ul class="cl-s-files-list qna-files-list clearfix">\
16193                                            ' + qna_files_str + '\
16194                                        </ul>\
16195                                    </div>\
16196                                </li>\
16197                            </ul>\
16198                            ' + qna_privacy_str + '\
16199                        </div>\
16200                    ';
16201
16202
16203                    $('.flat-modal .modal').modal('hide');
16204                    var eqnaModal = $(this).showModalFlat('문의 작성', modal_str,true,true,function () {
16205
16206                        var error_cnt = 0;
16207                        var error_str = '';
16208                        var input_data = new Object();
16209
16210                        $('.cl-s-form-control').each(function(idx, v) {
16211                            error_str = '';
16212                            if($(v).val().trim().length == 0) {
16213                                if(!$('input[name="answer_email"]').is(':checked') && $(v).attr('name') == 'qna_email') return;
16214                                if(!$('input[name="answer_alimtalk"]').is(':checked') && $(v).attr('name') == 'qna_tel') return;
16215                                $(v).closest('.cl-s-form-wrap').addClass('empty');
16216                                error_str = '필수항목을 입력해주세요.';
16217                                error_cnt++;
16218                                if(error_cnt == 1) {
16219                                    alert(error_str);
16220                                    $(v).focus();
16221                                    return true;
16222                                }
16223                            } else {
16224                                $(v).closest('.cl-s-form-wrap').removeClass('empty');
16225                                var key = $(v).attr('name');
16226                                var val = $(v).val().trim();
16227                                var passEmoji = ($.inArray(key,['title','qna']) > -1) ? true : false;
16228
16229                                if(!passEmoji && checkEmojis(val)) error_str = $.lang[LANG]['config.unable.emoji'];
16230                                // else if(typeof regexp[key] != "undefined" && !regexp[key].test(val)) error_str = $.lang[LANG]['siteum.regexp.check.'+key];
16231
16232                                if(error_str && error_str.length > 0) {
16233                                    error_cnt ++;
16234                                    if(error_cnt == 1) $(v).focus();
16235
16236                                    $(v).closest('.cl-s-form-wrap').addClass('error');
16237                                    if($(v).closest('.cl-s-form-group').find('.cl-s-control-label.error').length > 0) {
16238                                        $(v).closest('.cl-s-form-group').find('.cl-s-control-label.error').html(error_str);
16239                                    } else {
16240                                        $(v).closest('.cl-s-form-group input').after('<label class="cl-s-control-label error">' + error_str + '</label>');
16241                                    }
16242                                } else {
16243                                    $(v).closest('.cl-s-form-wrap').removeClass('error');
16244                                    $(v).closest('.cl-s-form-group').find('.cl-s-control-label.error').remove();
16245                                    input_data[key] = $(v).val().trim();
16246                                }
16247                            }
16248
16249                        });
16250
16251
16252                        if(error_cnt > 0) {
16253                            // alert(error_str);
16254                            return false;
16255                        }
16256                        
16257                        if(status != 'U') {
16258                            if(!$('#qna-btn-privacy').prop('checked')) {
16259                                $("#qna-btn-privacy").addClass('error');
16260                                alert('개인정보 수집 및 이용 동의에 체크해 주세요.');
16261                                return false;
16262                            }
16263
16264                            if(!$('input[name="answer_email"]').is(':checked')) {
16265                                input_data['qna_email'] = '';
16266                            } else {
16267                                var regexp = {
16268                                    qna_email : /^[a-zA-Z0-9+-\_.]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$/i,
16269                                };
16270                                if(typeof regexp['qna_email'] != "undefined" && !regexp['qna_email'].test(input_data['qna_email'])) {
16271                                    alert($.lang[LANG]['siteum.regexp.check.email']);
16272                                    input_data['qna_email'] = '';
16273                                    $('#qna-email').closest('.cl-s-form-wrap').addClass('error');
16274                                    return false;
16275                                }
16276                            }
16277
16278                            if(!$('input[name="answer_alimtalk"]').is(':checked')) {
16279                                input_data['qna_tel'] = '';
16280                            } else {
16281                                if(input_data['qna_tel'].length > 0 && (input_data['qna_tel'].length < 10 || input_data['qna_tel'].length > 15)) {
16282                                    alert('올바르지 않은 번호 양식입니다.\n번호를 다시 확인해 주세요.');
16283                                    input_data['qna_tel'] = '';
16284                                    $('#qna-tel').closest('.cl-s-form-wrap').addClass('error');
16285                                    return false;
16286                                }
16287                            }
16288                        }
16289
16290                        if($('.qna-files-list').children('li').length > 0) {
16291                            var qna_files = '';
16292                            var qna_files_orig = '';
16293                            $('.qna-files-list').children('li').each(function() {
16294                                if(qna_files != '')  qna_files +='||';
16295                                qna_files += $(this).find('input[name="qna_image[]"]').val();
16296                                if(qna_files_orig != '')  qna_files_orig +='||';
16297                                qna_files_orig += $(this).find('input[name="qna_image_orig[]"]').val();
16298                            });
16299                        }
16300                        input_data['qna_image'] = (qna_files) ? qna_files : '';
16301                        input_data['qna_image_orig'] = (qna_files_orig) ? qna_files_orig : '';
16302                        input_data['secret'] = ($('#secret-checkbox').prop('checked')) ? 'Y' : '';
16303                        input_data['answer_email'] = ($('input[name="answer_email"]').prop('checked')) ? 'Y' : 'N';
16304                        input_data['answer_alimtalk'] = ($('input[name="answer_alimtalk"]').prop('checked')) ? 'Y' : 'N';
16305
16306                        var qna_status = { new:'S', edit:'E' },
16307                            page_type = (property.VIEW) ? 'product' : '';
16308                            
16309                        if($('.cl-s-mypage').length > 0) page_type = 'mypage';
16310                        else if($('.cl-s-nonmember-payment').length > 0) page_type = 'no_member';
16311
16312                        input_data['sid'] = sid;
16313                        input_data['page_mode'] = page_type;
16314                        input_data['qna_seq'] = (seq > 0) ? seq : '';
16315                        input_data['qna_type'] = 'P';
16316                        input_data['product_number'] = pnum;
16317                        input_data['order_number'] = onum;
16318                        input_data['status'] = qna_status[mode];
16319                        input_data['mb_status'] = status;
16320                        input_data['qna_page'] = (property.VIEW) ? property.PAGE : '';
16321                        
16322                        $('.ok-button-dialog').prop('disabled', true).addClass('spinner');
16323                        $.ajax({
16324                            url: '/_qna_update',
16325                            type: 'post',
16326                            data: input_data,
16327                            async: true,
16328                            cache: false,
16329                            success: function(data) {
16330                                if(typeof data.error != 'undefined') {
16331                                    alert(data.error);
16332                                    return false;
16333                                }
16334                                location.reload();
16335                            },
16336                            error: function(request,status,error) {
16337                                console.log('code:'+request.status+'\n'+'message:'+request.responseText+'\n'+'error:'+error);
16338                                return false;
16339                            }
16340
16341                        });
16342
16343                    },'close','등록하기','cl-s-product-qna-edit cl-modal cl-s-btn cover', true, '', function() {
16344                        $('.cl-s-product-qna-edit .cl-s-form-group').on('click',function(e) {
16345                            if($(e.target).hasClass('cl-s-form-group')) {
16346                                $(e.target).find('.cl-s-form-control:not([type=hidden])').focus();
16347                            }
16348                        });
16349
16350                        $('.cl-s-product-qna-edit .cl-s-form-control').on({
16351                            focus: function(e) {
16352                                $(this).closest('.cl-s-form-wrap').addClass('active');
16353                            },
16354                            blur: function(e) {
16355                                var type = $(this).attr('data-type'),
16356                                    // regexp = {
16357                                    //     email : /^[a-zA-Z0-9+-\_.]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$/i
16358                                    // },
16359                                    // checkRegexp = (typeof type != 'undefined' && typeof regexp[type] != 'undefined') ? true : false,
16360                                    passEmoji = ($.inArray($(this).attr('name'),['title','qna']) > -1) ? true : false,
16361                                    error_str = '',
16362                                    val = $(this).val().trim();
16363
16364                                $(this).closest('.cl-s-form-wrap').removeClass('active');
16365                                if(val.length == 0) {
16366                                    $(this).closest('.cl-s-form-wrap').removeClass('error').addClass('empty');
16367                                    $(this).closest('.cl-s-form-wrap').find('.cl-s-control-label.error').remove();
16368                                    return false;
16369                                } else if(!passEmoji && checkEmojis(val)) error_str = $.lang[LANG]['config.unable.emoji'];
16370                                // else if(checkRegexp && !regexp[type].test(val)) error_str = $.lang[LANG]['siteum.regexp.check.'+type];
16371
16372                                $(this).closest('.cl-s-form-wrap').removeClass('empty');
16373                                if(error_str.length > 0) {
16374                                    $(this).closest('.cl-s-form-wrap').addClass('error');
16375                                    if($(this).parent().find('.cl-s-control-label.error').length > 0) {
16376                                        $(this).parent().find('.cl-s-control-label.error').html(error_str);
16377                                    } else {
16378                                        $(this).after('<label for="input" class="cl-s-control-label error">'+error_str+'</label>');
16379                                    }
16380                                    return false;
16381                                } else {
16382                                    $(this).closest('.cl-s-form-wrap').removeClass('error');
16383                                    $(this).closest('.cl-s-form-wrap').find('.cl-s-control-label.error').remove();
16384                                }
16385
16386                            }
16387                        });
16388
16389                        $('.cl-s-product-qna-edit #qna-tel').on('keyup', function(e) {
16390                            var txt = $(this).val();
16391                            var match = txt.match(/[0-9]+/g);
16392                            $(this).val(match);
16393                        });
16394
16395                        $('.cl-s-product-qna-edit #qna-btn-privacy').on('change', function(e) {
16396                            if($(this).prop('checked')) $(this).removeClass('error');
16397                            else $(this).addClass('error');
16398                        });
16399
16400                        $(document).on('click', '.cl-s-product-qna-edit .qna-img-close', {mode: 'qna'}, deleteReviewQnaImg);
16401
16402                        $('.cl-s-product-qna-edit .qna-file-update').on('click', function () {
16403                            $("#qna-file").click();
16404                        });
16405
16406                        $('.cl-s-product-qna-edit #qna-file').on('click', {mode: 'qna'}, uploadReviewQnaImg);
16407
16408                        $('label.privacy-toggle').on('change', function(e) {
16409                            var $toggle = $($(this).attr('data-view'));
16410                            if ($(this).find('input[type="checkbox"]').is(':checked')) {
16411                                $toggle.removeClass('hide');
16412                                $toggle.slideDown(300);
16413                            } else {
16414                                $toggle.slideUp(300, function() {
16415                                    $toggle.addClass('hide');
16416                                });
16417                            }
16418                        });
16419
16420                        $('a.privacy-toggle').on('click', function(e) {
16421                            e.preventDefault();
16422                            var $toggle = $($(this).attr('data-view'));
16423                            if ($toggle.hasClass('hide')) {
16424                                $toggle.removeClass('hide');
16425                                $toggle.slideDown(300);
16426                            } else {
16427                                $toggle.slideUp(300, function() {
16428                                    $toggle.addClass('hide');
16429                                });
16430                            }
16431                        });
16432
16433                    }, function(){
16434                        if(qna_files_str.length === 0){
16435                            if($('.cl-s-product-qna-edit .qna-img-close').length > 0){
16436                                $.each($('.cl-s-product-qna-edit .qna-img-close'), function(){
16437                                    $(this).trigger('click');
16438                                });
16439                            }
16440                        }
16441                    });
16442
16443                },
16444                error: function(request,status,error) {
16445                    console.log('code:'+request.status+'\n'+'message:'+request.responseText+'\n'+'error:'+error);
16446                    return false;
16447                }
16448            });
16449
16450        },
16451        orderReceiptModal: function(sid, ogroup, refund) { 
16452
16453            $.post('/_check_receipt', { sid:sid, order_group:ogroup, mode:'default', refund : refund }, function(data) {
16454
16455                if(typeof data.error != 'undefined' && data.error) {
16456                    $(this).showModalFlat('ERROR', data.error, true, false, '', 'ok');
16457                    return false;
16458                }
16459
16460                var d_price = (typeof data.r.delivery_price != 'undefined' && data.r.delivery_price) ? data.r.delivery_price : 0,
16461                    d_price_str = number_format(d_price) + ' 원',
16462                    o_list_cnt = data.r.list.length,
16463                    o_org_total = 0,
16464                    o_total = 0;
16465
16466                var orm_html = '\
16467                    <div class="receipt-wrap">\
16468                        <table>\
16469                            <colgroup>\
16470                                <col width="*" />\
16471                                <col width="120px" />\
16472                                <col width="100px" />\
16473                            </colgroup>\
16474                            \
16475                            <thead>\
16476                                <tr>\
16477                                    <th>상품정보</th>\
16478                                    <th>상품가격</th>\
16479                                    <th>배송비<span class="visible-xs"> ' + d_price_str + '</span></th>\
16480                                </tr>\
16481                            </thead>\
16482                            <tbody>\
16483                ';
16484
16485                var refund_count = 0, list_count = 0;
16486                $.each(data.r.list, function(i, val) {
16487                    if(refund) {
16488                        if(val['d_status'] == 'CY' || val['d_status'] == 'RY') ;
16489                        else {
16490                            return true;
16491                        }
16492                    }
16493
16494                    var option_name    = (!$.isEmptyObject(val['option_list']) && val['option_list']['option_name']) ? val['option_list']['option_name'] : '',
16495                        option_type = (val['option_list']['option_type']=='A') ? '추가옵션' : '옵션',
16496                        option_str     = '';
16497                    if(val['option_list']['option_type']=='A' && val['option_list']['option_group']) {
16498                        option_type = option_type + ' : ' + val['option_list']['option_group'];
16499                    }
16500                    if(option_name && option_name!='noneOption') {
16501                        option_str     = (val['option_list']['option_text_str']) ? '<span>'+option_type+' : ' + option_name + '/' + val['option_list']['option_text_str'] + '</span>' : '<span>'+option_type+' : ' + option_name + '</span>';
16502                    } else {
16503                        option_str     = (val['option_list']['option_text_str']) ? '<span>'+option_type+' : ' + val['option_list']['option_text_str'] + '</span>' : '';
16504                    }
16505                    var checkSale = (typeof val['option_list']['sale_price'] != "undefined" && val['option_list']['sale_price']) ? true : false,
16506                        oi_org_price = (checkSale) ? val['option_list']['sale_price'] : val['option_list']['price'],
16507                        oi_price     = val['option_list']['price'],
16508                        oi_quantity  = val['option_list']['quantity'],
16509                        oi_sum       = oi_price * oi_quantity,
16510                        rowspan = 0;
16511
16512                    if(refund) {
16513                        rowspan = data.r.refund;
16514                    } else {
16515                        rowspan = o_list_cnt;
16516                    }
16517                    o_org_total += (oi_org_price * oi_quantity);
16518                    o_total += oi_sum;
16519
16520                    orm_html += '\
16521                                <tr class="or-grid">\
16522                                    <td class="mp-info">\
16523                                        <div class="cl-s-product-jumbotron clearfix">\
16524                                            <div class="cl-s-product-thumb">\
16525                                                <img src="' + val["pimg"] + '" alt="' + val["pname"] + '" class="img-responsive"/>\
16526                                            </div>\
16527                                            <div class="cl-s-product-info">\
16528                                                <h5 class="cl-s-product-title">' + val["pname"] + '</h5>\
16529                                                <div class="option-str">\
16530                                                    <div>\
16531                                                        <span class="visible-xs option-price">' + number_format(oi_sum) + ' 원</span>\
16532                                                        ' + option_str + '\
16533                                                        <span>' + oi_quantity + '개</span>\
16534                                                    </div>';
16535                                        if(val["etc_info"]) {
16536                                            orm_html += '\
16537                                                    <div>선택일자 : '+val["etc_info"]+'</div>';
16538                                        }
16539                                        orm_html += '\
16540                                                </div>\
16541                                            </div>\
16542                                        </div>\
16543                                    </td>\
16544                                    <td>' + number_format(oi_sum) + ' 원</td>\
16545                    ';
16546
16547                    if(list_count == 0) orm_html += '<td rowspan="' + ((rowspan) ? rowspan : '') + '">' + d_price_str + '</td>';
16548                    list_count++;
16549
16550                    orm_html += '\
16551                                </tr>\
16552                    ';
16553
16554                });
16555
16556                orm_html += '\
16557                            </tbody> \
16558                        </table>\
16559                        <p class="description">현금영수증은 발급 완료된 주문건에 한해 조회 및 출력이 가능하며, 구매확정일 기준으로 발급됩니다.<br>신용카드 매출 전표는 결제완료 시 자동 발급되며, 결제완료 후 확인 및 출력이 가능합니다.\
16560                ';
16561
16562                if(data.r.class_cd == 'PAKM') {
16563                    orm_html += '\
16564                    <br>카카오페이머니 결제 건은 카카오페이 APP에서 전표발행이 제공됩니다.\
16565                    ';
16566                }
16567
16568                orm_html += '</p>\
16569                ';
16570
16571
16572                orm_html += '\
16573                        <div class="receipt-btn-box">\
16574                ';
16575                if(data.r.pay_method != '무통장 입금' && data.r.class_cd != 'PAKM' && data.r.pay_method != '포인트 결제') {
16576                    orm_html += '<span class="cl-s-btn cl-s-btn-12 cl-s-btn-primary btn-card-slip" data-tno="' + data.r.tno + '">카드전표</span>';
16577                }
16578                orm_html += '\
16579                            <span class="cl-s-btn cl-s-btn-12 cl-s-btn-primary btn-receipt-details ' + ((refund == true) ? 'refund' : '') + '">' + ((refund == true) ? '환불영수증' : '구매영수증') + '</span>\
16580                        </div>\
16581                        <span class="cl-s-btn cl-s-btn-12 cl-s-btn-default btn-order-receipt-close">닫기</span>\
16582                    </div">\
16583                ';
16584                var title = (refund) ? '환불 영수증 발급내역' : '영수증 발급내역';
16585                var orModal = $(this).showModalFlat(title, orm_html, true, false, '', 'close', '', 'cl-s-receipt cl-modal cover', false, '', function() {
16586                    $('.btn-order-receipt-close').on('click', function() {
16587                        orModal.modal('hide');
16588                    });
16589
16590                    $('.btn-card-slip').on('click', function() {
16591                        var tno = $(this).data('tno');
16592                        if(data.r.class_cd == 'PANP') {
16593                            window.open('https://new-m.pay.naver.com');
16594                        } else if(isNaN(tno)) { // nicepay
16595                            window.open('https://npg.nicepay.co.kr/issue/IssueLoader.do?type=0&TID='+tno, '', 'width=800, height=700, toolbar=no, menubar=no, scrollbars=no, resizable=yes');
16596                        } else { // kcp
16597                            // window.open('https://www.kcp.co.kr/center.paysearch.do', '', 'width=1000,height=500,scrollbars=yes');
16598                            window.open('https://www.kcp.co.kr/viewPaymentParent/viewPayment', '', 'width=1200,height=860,scrollbars=yes');
16599                        }
16600                        
16601                    });
16602
16603                    $('.btn-receipt-details').on('click', function() {
16604                        var refund = ($(this).hasClass('refund')) ? true : false;
16605                        $.shoppingmall.orderReceiptDetailModal(sid, ogroup, refund);
16606                    });
16607
16608                });
16609
16610            }, 'json');
16611
16612        },
16613        orderReceiptDetailModal: function(sid, ogroup, refund) {
16614
16615            $.post('/_check_receipt', { sid:sid, order_group:ogroup, mode:'detail', refund : refund }, function(data) {
16616
16617                if(typeof data.error != 'undefined' && data.error) {
16618                    $(this).showModalFlat('ERROR', data.error, true, false, '', 'ok');
16619                    return false;
16620                }
16621                var ordm_html = '\
16622                    <div class="receipt-wrap">\
16623                        <table>\
16624                            <colgroup>\
16625                                <col width="25%" />\
16626                                <col width="75%" />\
16627                            </colgroup>\
16628                            \
16629                            <tbody id="receipt-list">\
16630                                <tr>\
16631                                    <td><span>주문번호</span><br>ORDER NO.</td>\
16632                                    <td>' + ogroup + '</td>\
16633                                </tr>';
16634                if(refund) {
16635                    ordm_html+= '\
16636                                <tr>\
16637                                    <td><span>환불일자</span><br>REFUND DATE</td>\
16638                                    <td>' + data.pay_info.reg_date + '</td>\
16639                                </tr>\
16640                    ';
16641                } else {
16642                    ordm_html+= '\
16643                                <tr>\
16644                                    <td><span>주문날짜</span><br>TRANS DATE</td>\
16645                                    <td>' + data.pay_info.reg_date + '</td>\
16646                                </tr>\
16647                    ';
16648                }
16649                ordm_html+= '\
16650                                <tr>\
16651                                    <td><span>상품명</span><br>DESCRIPTION</td>\
16652                                    <td>' + data.pay_info.product_name + '</td>\
16653                                </tr>\
16654                                <tr>\
16655                                    <td><span>합계</span><br>TOTAL</td>\
16656                                    <td><span>'+number_format(data.pay_info.payment)+'</span> 원</td>\
16657                                </tr>\
16658                                <tr>\
16659                                    <td><span>회사명</span><br>COMPANY NAME</td>\
16660                                    <td>' + data.setting.b_name + '</td>\
16661                                </tr>\
16662                                <tr>\
16663                                    <td><span>대표자</span><br>MASTER</td>\
16664                                    <td>' + data.setting.b_rep + '</td>\
16665                                </tr>\
16666                                <tr>\
16667                                    <td><span>사업자등록번호</span><br>BUSINESS NO.</td>\
16668                                    <td>' + data.setting.b_number + '</td>\
16669                                </tr>\
16670                                <tr>\
16671                                    <td><span>회사주소</span><br>ADDRESS</td>\
16672                                    <td>' + data.setting.b_addr + '</td>\
16673                                </tr>\
16674                                <tr>\
16675                                    <td><span>문의전화</span><br>TEL</td>\
16676                                    <td>' + data.setting.b_tel + '</td>\
16677                                </tr>\
16678                                <tr>\
16679                                    <td><span>서명</span><br>SIGNATURE</td>\
16680                                    <td>' + data.pay_info.buyr_name + '</td>\
16681                                </tr>\
16682                            </tbody>\
16683                        </table>\
16684                        <div class="additional-box">구매 영수증은 세금계산서 등 증빙서류로 활용할 수 없습니다.</div>\
16685                    </div>\
16686                ';
16687                var title = (refund) ? '환불영수증' : '구매영수증';
16688                var ordModal = $(this).showModalFlat(title, ordm_html, true, true, function() {
16689
16690                    $.shoppingmall.printModal(".cl-s-receipt-view");
16691
16692                }, 'close', '출력', 'cl-s-receipt-view cl-modal cover', false);
16693
16694
16695            }, 'json');
16696        },
16697        printModal: function(modalEL) {
16698            var popupWindow = window.open("", "printPopup", "_blank" );
16699
16700            var style = $('#cl_shopping').attr('href');
16701
16702            popupWindow.document.write('<head>');
16703            popupWindow.document.write($('head').html());
16704            popupWindow.document.write('<link rel="stylesheet" href="'+style+'">');
16705            popupWindow.document.write('<style>');
16706            popupWindow.document.write($('#el_0css').html());
16707            popupWindow.document.write('.close-button-dialog, .ok-button-dialog {display:none !important;}');
16708            popupWindow.document.write('.cl-mobile-btn, button.close {display:none !important;}');
16709            popupWindow.document.write('.modal-dialog {width:700px !important;max-width:700px !important;}');
16710            popupWindow.document.write('</style>');
16711            popupWindow.document.write('</head>');
16712
16713            var $table = $(modalEL);
16714     
16715            popupWindow.document.write('<body>');
16716            popupWindow.document.write('<div style="display:block;" class="flat-modal cl-flat-modal">');
16717            popupWindow.document.write($table.parent().parent().html());
16718            popupWindow.document.write('
16718</div></body>');
16719
16720            popupWindow.document.close();
16721
16722            setTimeout(function () {
16723                popupWindow.print();
16724            }, 1500);
16725        },
16726        orderDownloadModal: function(sid, pnum, onum) {
16727
16728            $.post('/_check_download', { sid:sid, pnum:pnum, onum:onum }, function(data) {
16729                
16730                if(typeof data.error != "undefined" && data.error) {
16731                    $(this).showModalFlat('ERROR', data.error, true, false, '', 'close');
16732                    return false;
16733                }
16734
16735                var cnacelBtn = $('.mp-table[data-onum='+ onum +']').find('button[data-fn="orderCancel"]');
16736                cnacelBtn.remove();
16737
16738                var download_href = data.r.url,
16739                    download_name = data.r.name,
16740                    download_real_name = data.r.real_name,
16741                    download_count = data.r.count;
16742
16743                var download_url = new getLocation(download_href),
16744                    file_name = encodeURIComponent(download_name),
16745                    file_real_name = encodeURIComponent(download_real_name),
16746                    go = '/down?n=' + file_real_name + '&s=' + (download_url.pathname).replace('/cr-resource/forum/','').replace('/','&f='),
16747                    temp_el = '<a href="'+go+'" target="_blank" download id="cl-download-a"></a>';
16748
16749                $('body').append(temp_el);
16750                document.querySelector('#cl-download-a').click();
16751                $('#cl-download-a').remove();
16752                
16753                if(download_count > 0) {
16754                    $('.mp-table[data-onum=' + onum + ']').find('.download-str span').text(download_count);
16755                } else {
16756                    $('.mp-table[data-onum=' + onum + ']').find('.download-str').html('<div class="cl-red">다운로드 기한이 지났거나<br>다운로드 횟수를 모두 사용하였습니다.</div>');
16757                    $('.mp-table[data-onum=' + onum + ']').find('button[data-fn="orderDownload"]').addClass('disabled');
16758                }
16759
16760            }, 'json');
16761        },        
16762        orderusedModal: function(sid, pnum, onum) {
16763
16764            $.post('/_check_used', { sid:sid, pnum:pnum, onum:onum }, function(data) {
16765                console.log(data);
16766                if(typeof data.error != "undefined" && data.error) {
16767                    $(this).showModalFlat('ERROR', data.error, true, false, '', 'close');
16768                    return false;
16769                }
16770
16771                var cnacelBtn = $('.mp-table[data-onum='+ onum +']').find('button[data-fn="orderCancel"]');
16772                cnacelBtn.remove();
16773
16774                var download_href = data.r.url,
16775                    download_name = data.r.name,
16776                    download_real_name = data.r.real_name,
16777                    download_count = data.r.count;
16778
16779                var download_url = new getLocation(download_href),
16780                    file_name = encodeURIComponent(download_name),
16781                    file_real_name = encodeURIComponent(download_real_name),
16782                    go = '/down?n=' + file_real_name + '&s=' + (download_url.pathname).replace('/cr-resource/forum/','').replace('/','&f='),
16783                    temp_el = '<a href="'+go+'" target="_blank" download id="cl-download-a"></a>';
16784
16785                $('body').append(temp_el);
16786                $('#cl-download-a').remove();
16787                
16788                if(download_count > 0) {
16789                    $('.mp-table[data-onum=' + onum + ']').find('.download-str span').text(download_count);
16790                } else {
16791                    $('.mp-table[data-onum=' + onum + ']').find('.download-str').html('<div class="cl-red">다운로드 기한이 지났거나<br>다운로드 횟수를 모두 사용하였습니다.</div>');
16792                    $('.mp-table[data-onum=' + onum + ']').find('button[data-fn="orderDownload"]').addClass('disabled');
16793                }
16794                
16795                window.location.reload();
16796            }, 'json');
16797        },
16798    }
16799
16800    // 파일이름 자르기
16801    function limitFilenameLength(filename, maxLength) {
16802        if (filename.length <= maxLength) return filename;
16803
16804        let ext = '';
16805        let name = filename;
16806        const dotIndex = filename.lastIndexOf('.');
16807        if (dotIndex !== -1) {
16808            ext = filename.substring(dotIndex);
16809            name = filename.substring(0, dotIndex);
16810        }
16811
16812        const trimmed = name.substring(0, maxLength - ext.length);
16813        return trimmed + '..' + ext;
16814    }
16815
16816    $.quickbasket = {
16817        data: {},
16818        dataReset: function(){
16819            $.quickbasket.data = {}
16820            $.quickbasket.productStates = {};
16821        },
16822        init: function (sid, pid, pnum) {
16823            $.ajax({
16824                url: '/_quickbasket',
16825                type: 'post',
16826                data: { 'sid':sid, 'pid':pid, 'pnum':pnum },
16827                async: false,
16828                cache: false,
16829                success: function (_data) {
16830                    var data = JSON.parse(_data);
16831
16832                    if(typeof data.error != 'undefined' & data.error) {
16833                        var error_str = (data.error == 'error-none-unique') ? '장바구니에 담기는 도중 오류가 발생했습니다.\n잠시후 다시시도 해주세요.\n같은 현상이 지속된다면 고객센터로 문의해주세요.' : data.error;
16834                        $(this).showModalFlat('INFORMATION', error_str, false, false, '', '', '', 'cl-cmmodal cl-s-btn w560 cl-p0');
16835                        return false;
16836                    }
16837
16838                    $.quickbasket.dataReset();
16839                    var quickbasket_str = '';
16840                    if(typeof data.option_data != 'undefined' && data.option_data) {
16841                        // product has options
16842                        // var check_options_merge = data.option_data.checkOptionsMerge,
16843                        var qbo_total_cnt = 0, 
16844                            qbo_total_price = 0,
16845                            qbo_select_box = '';
16846
16847                        $.quickbasket.data = data.option_data;
16848                        $.quickbasket.data.list.normal_md5 = {};
16849                        if(data.option_data.checkNomalOptionMixed) {
16850                            $.each(data.option_data.list.normal_org, function(a,b) {
16851                                var md5 = '';
16852                                switch(data.option_data.options_type) {
16853                                    case '1': md5 = clmd5.hex_md5(b.option_group + ' / ' + b.option_name); break;
16854                                    case '2': md5 = clmd5.hex_md5(b.option_mix2 + ' / ' + b.option_name); break;
16855                                    case '3': md5 = clmd5.hex_md5(b.option_mix2 + ' / ' + b.option_mix3 + ' / ' + b.option_name); break;
16856                                    default: break;
16857                                }
16858                                $.quickbasket.data.list.normal_md5[md5] = b;
16859                            });
16860                        }
16861
16862                        $.each(data.option_data.list, function(o_key, o_groups) {
16863                            if($.inArray(o_key, ['normal_org','normal_md5']) > -1) return true;
16864
16865                            var check_empty = (o_groups.length == 1 && o_groups[0]['arr'].length == 0) ? true : false;
16866                            if(!check_empty) {
16867                                 var printedTitles = [];
16868                                $.each(o_groups, function(og_idx, og_obj) {
16869                                    if (printedTitles.includes(og_obj['title'])) return true;
16870                                    printedTitles.push(og_obj['title']);                                    
16871                                    if(o_key == 'additional' && og_idx == 0) quickbasket_str += (data.option_data.checkFooterStatus[2] == 'false') ? '' : '<p class="option-title">추가옵션</p>';
16872                                    var qbo_wrap = '',
16873                                        qbo_box = '',
16874                                        qbo_noneoption_val = '';
16875                                    
16876                                    if(og_obj['arr'].length == 0 && (og_obj['value'].length == 0 || og_obj['title'] === null)) return true;
16877                                    let firstOptionNames = [];
16878                                    $.each(og_obj['arr'], function(og_idx2,og_obj2) {
16879                                        if (o_key == 'normal' && og_idx == 0) {
16880                                            // 첫 번째 옵션그룹에서 중복 이름 제거
16881                                            if (firstOptionNames.includes(og_obj2.option_name)) {
16882                                                return true; // continue (중복이면 skip)
16883                                            }
16884                                            firstOptionNames.push(og_obj2.option_name);
16885
16886                                            // download 파일명
16887                                            if (!$.quickbasket.productStates) $.quickbasket.productStates = {};
16888                                            if (og_obj2.product_state) {
16889                                                $.quickbasket.productStates[og_obj2.option_seq] = og_obj2.product_state;
16890                                            }                                            
16891                                        }                                        
16892                                        var div_property = '';
16893                                        if(o_key != 'text'  && !og_obj2.soldout) {
16894                                            div_property += 'onclick="$.quickbasket.pdOptionPick(this, \'' + data.option_data.product_price + '\')" ';
16895                                            // div_property += 'data-status="' + data.option_data.product_state + '" ';
16896                                            div_property += 'data-status="normal" ';
16897                                            div_property += (o_key == 'additional') ? 'data-option_type="' + og_obj2.option_type + '" ' : 'data-type="' + data.option_data.options_type + '" ';
16898                                            div_property += 'data-id
16898x="' + (og_idx2-1) + '" ';
16899                                            if(o_key == 'normal') div_property += 'data-option-index="' + og_idx + '" ';
16900                                            div_property += 'data-option-price="' + og_obj2.option_price + '" ';
16901                                        }
16902                                        var option_str = {
16903                                            'div_class': (og_obj2.soldout) ? 'sold-out' : '',
16904                                            'div_property': div_property,
16905                                            'span1': (og_obj2.soldout) ? '<span class="text-d-lt">' : '',
16906                                            'span2': (og_obj2.soldout) ? '</span>' : '',
16907                                            'seq': (og_obj2.soldout) ? '' : 'data-option-seq="'+og_obj2.option_seq+'"',
16908                                            'soldout': (og_obj2.soldout) ? '<label>품절</label>' : '',
16909                                        }
16910
16911                                        if(og_obj2.option_name == 'noneOption') {
16912
16913                                            if(o_key == 'text') {
16914                                                qbo_noneoption_val = (data.option_data.checkNoneTextOption) ? og_obj2.option_group + ' / ' + og_obj2.val : '';
16915                                            } else if(o_key == 'additional') {
16916                                                // var type = '';
16917                                                // qbo_selectbox = $.quickbasket.pdOptionBoxHtml(data.option_data.product_price, type, data.option_data.product_state, og_obj2.option_type == null ? '' : og_obj2.option_type, o_obj.val.split('||'), '');s
16918                                                var val_arr = og_obj2.val.split('||');
16919                                                if(data.option_data.checkOptionBox) {
16920                                                    if(data.option_data.checkFooterStatus[1] != 'true') {
16921                                                        qbo_select_box = '\
16922                                                            <div class="option-count-box">\
16923                                                                <input type="hidden" name="option_price[]" value="' + data.option_data.product_price + '">\
16924                                                                <input type="hidden" name="option_seq[]" class="option_seq" value="'+ val_arr[3] +'">\
16925                                                                <input type="hidden" class="total-quantity" value="'+ val_arr[2] +'">\
16926                                                                <input type="hidden" name="option_name[]" value="'+ val_arr[0] +'">\
16927                                                                <input type="hidden" name="option_type[]" value="' + ((og_obj2.option_type == null) ? '' : og_obj2.option_type) + '">\
16928                                                                <input type="hidden" name="option_text[]" value="">\
16929                                                                <div class="box-option-row">\
16930                                                                    <div class="box-option-name">' + data.option_data.product_title + '</div>\
16931                                                                </div>\
16932                                                                <div class="box-option-row">\
16933                                                                    <div class="box-option-price"><span class="option-price">' + addCommas(data.option_data.product_price) + '</span>원</div>\
16934                                                                    <div class="box-option-count"><div class="form-group"><span class="min"><svg viewBox="0 0 11 11" width="11" height="11"><rect y="5" width="11" height="1"></rect></svg></span><input type="text" class="option-normal-price" value="1" numberonly="true" name="option_count[]"><span class="plus"><svg viewBox="0 0 11 11" width="11" height="11"><polygon points="6 5 6 0 5 0 5 5 0 5 0 6 5 6 5 11 6 11 6 6 11 6 11 5 "></polygon></svg></span></div></div>\
16935                                                                </div>\
16936                                                            </div>\
16937                                                        ';
16938                                                        
16939                                                        qbo_total_cnt++;
16940                                                        qbo_total_price = data.option_data.product_price;
16941                                                    }
16942                                                } else {
16943                                                    qbo_select_box = '<input type="hidden" class="noneoption_seq" value="'+ og_obj2.option_seq +'">';
16944                                                }
16945                                            }
16946
16947                                        } else {
16948                                            if(o_key == 'text') {
16949                                                qbo_box += '\
16950                                                                <div class="cl-s-option-text" data-selected_option="' + ((data.option_data.options_type == 'TR') ? 'Y' : 'N') + '" data-status="' + data.option_data.product_state + '" >\
16951                                                                    <input type="text" placeholder="' + og_obj2.option_name + '" data-val="' + og_obj2.option_seq + '" data-status="' + data.option_data.product_state + '" data-option_type="T" maxlength="100" readonly>\
16952                                                                </div>\
16953                                                ';
16954                                            } else {
16955                                                qbo_box += '\
16956                                                    <div class="' + option_str.div_class + '" data-val="' + og_obj2.val + '" ' + option_str.div_property + '>\
16957                                                        ' + option_str.span1 + '\
16958                                                             <div class="quick-option-row">\
16959                                                                <div class="option-left">\
16960                                                                    <sp
16960an class="number">' + og_obj2.option_number + '.</span>\
16961                                                                    <span class="option-name" ' + option_str.seq + '>' + og_obj2.option_name + option_str.soldout + '</span>\
16962                                                                </div>\
16963                                                                <span class="price">' + og_obj2.option_price_str + ' 원</span>\
16964                                                            </div>';
16965                                                // download 일때 파일명 추가
16966                                                if (data.option_data.product_state === 'download' && og_obj2.product_state) {
16967                                                    var ps = JSON.parse(og_obj2.product_state);
16968                                                    if (ps.file_name && ps.file_url) {
16969                                                        var trimmedName = limitFilenameLength(ps.file_name, 14);
16970                                                        qbo_box += '\
16971                                                            <div class="quick-option-file">\
16972                                                                <span class="quick-option-file-name">' + trimmedName + '</span>\
16973                                                                <span class="quick-option-file-size">' + ps.file_size + '</span>\
16974                                                            </div>';
16975                                                    }
16976                                                }
16977
16978                                                if (og_obj2.product_state) {
16979                                                    og_obj2.val += '||' + encodeURIComponent(og_obj2.product_state);
16980                                                }
16981                                                qbo_box += '\
16982                                                        ' + option_str.span2 + '\
16983                                                    </div>\
16984                                                ';
16985                                            }
16986                                        }
16987                                    });
16988
16989                                    var qbo_key_str = (o_key == 'additional') ? 'addt' : o_key,
16990                                        qbo_required = (o_key == 'normal') ? 'option-required' : '',
16991                                        qbo_disabled = (o_key == 'normal' && og_idx > 0) ? 'option-disabled' : '',
16992                                        qbo_def_index = (o_key == 'normal') ? 'data-def-index="' + og_idx + '"' : '';
16993
16994                                    if(o_key == 'text') {
16995                                        if(data.option_data.checkFooterStatus[1] == 'true') {
16996                                            qbo_wrap = '\
16997                                                <div id="selected-product-option" data-val="' + qbo_noneoption_val + '" data-selected_option="" data-status=""></div>\
16998                                                <div class="text-option-box">\
16999                                                    ' + qbo_box + '\
17000                                                </div>\
17001                                            ';
17002                                            qbo_wrap += (qbo_box == '') ? '' : '\
17003                                                <div class="text-center text-option-btn-box">\
17004                                                    <div onclick="$.quickbasket.pdTextOptionPick(this, \'' + data.option_data.product_price + '\', \'' + ((data.option_data.checkOnlyTextOption) ? 'T' : '') + '\',' + data.option_data.options_type + ')" class="btn text-center hand text-option-btn disabled">입력한 옵션으로 선택</div>\
17005                                                </div>\
17006                                            ';
17007                                        }
17008                                    } else {
17009                                        qbo_wrap = (
17010                                            (o_key == 'normal' && data.option_data.checkFooterStatus[0] == 'false') ||
17011                                            (o_key == 'additional' && data.option_data.checkFooterStatus[2] == 'false')
17012                                        ) ? '' : '\
17013                                            <div class="select-box">\
17014                                                <div class="selected-option ' + ((o_key == 'normal' && og_idx > 0) ? 'ex' : '' ) + '" id="selected-product' + ((o_key == 'normal') ? '' : qbo_key_str) + '-
17014option"  data-val="" data-selected_option="" data-status="">\
17015                                                    <span class="selected-option-text">' + og_obj['title'] + '</span>\
17016                                                    <span class="selected-option-title hide">' + og_obj['title'] + '</span>\
17017                                                    ' + clSVG('caret',8,4,false) + '\
17018                                                </div>\
17019                                            </div>\
17020                                            <div class="option-box product-option-box" style="display: none;">\
17021                                                ' + qbo_box + '\
17022                                            </div>\
17023                                        ';
17024                                    }
17025
17026                                    quickbasket_str += (qbo_wrap == '') ? '' : '\
17027                                        <div class="cl-s-option-selector cl-s-' + qbo_key_str + '-option-selector ' + qbo_required + ' ' + qbo_disabled + '" ' + qbo_def_index + '>\
17028                                            ' + qbo_wrap + '\
17029                                        </div>\
17030                                    ';
17031                                });
17032
17033                            }
17034                        });
17035
17036                        quickbasket_str += '\
17037                            <div class="option-select-box">\
17038                                ' + qbo_select_box + '\
17039                            </div>\
17040                            <div class="total-price-box">\
17041                                <span class="panel-total-title">총 상품 금액</span>\
17042                                <span class="panel-total-cnt">총 수량 <span class="total-cnt">' + qbo_total_cnt + '</span>개 </span>\
17043                                <span class="panel-total-price"><span class="total-price">' + addCommas(qbo_total_price) + '</span>원</span>\
17044                            </div>\
17045                        ';
17046
17047                        var quickBasketOptionModal = $(this).showModalFlat($.lang[LANG]['gallery.sh.quickbasket.option'], quickbasket_str, true, true, function() {
17048
17049                            if($('.cl-modal-check-quantity').length > 0) return false;
17050
17051                            var checkEmpty = false;
17052                            quickBasketOptionModal.find('.option-normal-price').each(function() {
17053                                if($(this).val() == '' || $(this).val() < 1) {
17054                                    checkEmpty = true;
17055                                    $(this).val(1);
17056                                }
17057                            });
17058                            if(checkEmpty) {
17059                                if($('.cl-modal-check-quantity').length == 0) $.quickbasket.alertModal('ERROR','최소 구매 수량은 1개 입니다.','cl-modal-check-quantity');
17060                                return false;
17061                            }
17062
17063                            $.quickbasket.setKeepShopping(sid,RENDER.b.PAGE,pid,pnum);
17064                            var optionName = quickBasketOptionModal.find('input[name="option_name[]"]'),
17065                                optionPrice = quickBasketOptionModal.find('input[name="option_price[]"]'),
17066                                optionCount = quickBasketOptionModal.find('input[name="option_count[]"]'),
17067                                optionSeq = quickBasketOptionModal.find('.option_seq'),
17068                                optionText = quickBasketOptionModal.find('input[name="option_text[]"]'),
17069                                optionType = quickBasketOptionModal.find('input[name="option_type[]"]'),
17070                                etcStartDate = quickBasketOptionModal.find('input[name="etc_start_date[]"]'),
17071                                etcEndDate = quickBasketOptionModal.find('input[name="etc_end_date[]"]'),
17072                                oCnt = quickBasketOptionModal.find('input[name="option_name[]"]').length,
17073                                state = data.option_data.state,
17074                                deliveryType = data.option_data.delivery_type,
17075                                deliveryPayType = data.option_data.delivery_pay_type;
17076
17077                            if (oCnt < 1) {
17078                                $.quickbasket.alertModal('ERROR','옵션을 선택해주세요.','cl-modal-check-select');
17079                                
17080                                // var modal = $(this).showModalFlat('','옵션을 선택해주세요.',true,false,'','ok','','cl-cmmodal cl-s-btn w560 cl-p130 cl-t80 cl-modal cl-none-title cl-close-btn','','',function() {
17081                                //     modal.closest('.cl-flat-modal').next('.modal-backdrop.in').attr('style', 'z-index: 1050!important');
17082                                //     modal.closest('.modal').css('z-index', 1051);
17083                                //     $(document).on('keydown', function(e) {
17084                                //         if(e.keyCode == 27) modal.modal('hide');
17085                                //     });
17086                                // });
17087                                return false;
17088                            }
17089
17090                            if(quickBasketOptionModal.find('.cl-s-addt-option-selector').length > 0) { //추가옵션 존재
17091                                var optionLength = quickBasketOptionModal.find('.option-count-box:not(.additional) input[name="option_name[]"]').length;
17092                                if(optionLength < 1) {
17093                                    $.quickbasket.alertModal('ERROR','옵션을 선택해주세요.','cl-modal-check-select');
17094                                    return false;
17095                                }
17096                            }
17097
17098                            if(quickBasketOptionModal.find('.cl-s-option-text').length > 0) { //입력형옵션 존재
17099                                var optionTextArr = quickBasketOptionModal.find('input[name="option_text[]"]').map(function(){
17100                                    if($(this).val().trim() != '') {
17101                                        return $(this).val().trim();
17102                                    }
17103                                }).get();
17104                                if(optionTextArr.length < 1) {
17105                                    $.quickbasket.alertModal('ERROR','옵션을 선택해주세요.','cl-modal-check-select');
17106                                    return false;
17107                                }
17108                            }
17109
17110                            if(!quickBasketOptionModal.find('.ok-button-dialog').hasClass('active')) return false;
17111
17112                            var optionNameAry = [],
17113                                optionPriceAry = [],
17114                                optionCountAry = [],
17115                                optionSeqAry = [],
17116                                optionTextAry = [],
17117                                optionTypeAry = [],
17118                                etcStartDateAry = [],
17119                                etcEndDateAry = [];
17120                            
17121                            for (var i=0;i<oCnt;i++) {
17122                                if (optionName[i].value == 'noneOption') {
17123                                    optionName[i].value = '';
17124                                }
17125
17126                                if (optionName[i].value.length == 0) {
17127                                    if(optionText[i].value.length > 0) {
17128                                        optionSeqAry[i] = optionSeq[i].value;
17129                                    } else {
17130                                        optionSeqAry[i] = '';
17131                                    }
17132                                } else if (optionName[i].value.length > 0) {
17133                                    optionSeqAry[i] = optionSeq[i].value;
17134                                }
17135
17136                                if($("#product_state").val() == 'download') {
17137                                    optionSeqAry[i] = optionSeq[i].value;   
17138                                }
17139
17140                                optionTextAry[i] = optionText[i].value; //입력형 옵션
17141                                optionTypeAry[i] = optionType[i].value; //옵션 타입
17142                                optionNameAry[i] = optionName[i].value;
17143                                
17144                                optionPriceAry[i] = optionPrice[i].value;
17145                                optionCountAry[i] = optionCount[i].value;
17146                                
17147                                etcStartDateAry[i] = etcStartDate[i] ? etcStartDate[i].value : '';
17148                                etcEndDateAry[i] = etcEndDate[i] ? etcEndDate[i].value : '';
17149                            }
17150
17151                            var productBasketData = {
17152                                'product_number': data.option_data.product_number, // 상품 번호
17153                                'option_name': optionNameAry,                   // 옵션명
17154                                'option_text': optionTextAry,
17155                                'option_type': optionTypeAry,                   
17156                                'option_price': optionPriceAry,                 // 옵션 가격
17157                                'option_count': optionCountAry,                 // 옵션 개수
17158                                'option_seq': optionSeqAry,                     // 옵션 시퀀스
17159                                'etc_start_date': etcStartDateAry,              // 기타무형 상품 시작 날짜
17160                                'etc_end_date': etcEndDateAry,                  // 기타무형 상품 종료 날짜
17161                                'state': state,                                 // 상품 타입 (normal: 일반상품, download: 다운로드 상품, etc: 기타무형 상품)
17162                                'sid': data.option_data.sid,                    // site id,
17163                                'delivery_type' : deliveryType,                 // 배송타입
17164                                'delivery_pay_type' : deliveryPayType,          // 배송비 지불 (선착불)
17165                            }
17166
17167                            $.quickbasket.initOptions(quickBasketOptionModal, productBasketData);
17168
17169
17170                        }, 'cancel', 'gallery.sh.quickbasket.add', 'cl-cmmodal cl-s-btn w560 in-w360 cl-p0 cl-quickbasket-modal ', false, '', function() {
17171
17172                            if(quickBasketOptionModal.find('.option-count-box:not(.additional)').length >
17172 0) quickBasketOptionModal.find('.modal-footer .ok-button-dialog').addClass('active');
17173                            else quickBasketOptionModal.find('.modal-footer .ok-button-dialog').removeClass('active');
17174                            
17175                            if(quickBasketOptionModal.find('.option-select-box > .option-count-box').length > 0) quickBasketOptionModal.find('.total-price-box .total-cnt').text('1');
17176                            else quickBasketOptionModal.find('.total-price-box .total-cnt').text('0');
17177
17178                            if( quickBasketOptionModal.find('.cl-s-normal-option-selector').length == 0 &&
17179                                quickBasketOptionModal.find('.cl-s-option-date-selector').length == 0 
17180                            ) {
17181                                quickBasketOptionModal.find('.cl-s-option-text input').prop('readonly', false);
17182                            }
17183                            $.quickbasket.pdTotalPriceUpdate(quickBasketOptionModal);
17184                            $.quickbasket.bindOptionCountEvents(quickBasketOptionModal);
17185                            quickBasketOptionModal.find('.cl-s-option-text input').on('keyup blur', function(e) {
17186                                var textOptionTarr = [];
17187                                textOptionTarr = quickBasketOptionModal.find('.cl-s-option-text input').map(function(){
17188                                    var input_str = ($(this).val().trim() != '') ? $(this).val().trim() : '';
17189                                    if(input_str != '' && checkEmojis(input_str)) {
17190                                        input_str = removeEmojis(input_str);
17191                                        $(this).val(input_str);
17192                                    }
17193
17194                                    if(input_str != '') return input_str;
17195                                }).get();
17196
17197                                if(quickBasketOptionModal.find('.cl-s-option-text input').length == textOptionTarr.length && quickBasketOptionModal.find('.cl-s-option-selector.option-required .selected-option[data-val=""]').length == 0) {
17198                                    quickBasketOptionModal.find('.text-option-btn').removeClass('disabled');
17199                                } else {
17200                                    quickBasketOptionModal.find('.text-option-btn').addClass('disabled');
17201                                }
17202                            });
17203
17204                            quickBasketOptionModal.find('.cl-s-option-selector').each(function(idx, item){
17205                                var cnt = quickBasketOptionModal.find('.cl-s-option-selector').length;
17206                                $(this).css('z-index', cnt - idx + 1);
17207                            });
17208                            quickBasketOptionModal.find('.cl-s-option-selector .selected-option').on('click', function (e) {
17209                                if($(this).parents('.cl-s-option-selector').hasClass('option-disabled')) return false;
17210                                var option_parent = $(this).closest('.cl-s-option-selector');
17211
17212                                if(quickBasketOptionModal.find('.product-option-box div').length == 0) return false;
17213                                if ($(this).hasClass('active') === true) {
17214                                    option_parent.find('.product-option-box').slideUp(300);
17215                                    $(this).removeClass('active');
17216                                    $(this).parents('.cl-s-option-selector').removeClass('active');
17217                                } else {
17218                                    option_parent.find('.product-option-box').slideDown(300);
17219                                    $(this).addClass('active');
17220                                    $(this).parents('.cl-s-option-selector').addClass('active');
17221                                }
17222                            });
17223
17224                            quickBasketOptionModal.on('click', function(e) {
17225                                var container = quickBasketOptionModal.find('.cl-s-normal-option-selector #selected-product-option');
17226                                if(container.has(e.target).length == 0) {
17227                                    quickBasketOptionModal.find('.cl-s-normal-option-selector .product-option-box').slide
17227Up(200);
17228                                    container.removeClass('active');
17229                                    container.parents('.cl-s-option-selector').removeClass('active');
17230                                } else {
17231                                    if($(e.target).closest('.cl-s-option-selector').length > 0) {
17232                                        $(e.target).closest('.cl-s-option-selector').siblings('.cl-s-option-selector').find('.product-option-box').slideUp(200);
17233                                    }
17234                                }
17235
17236                                if($(e.target).is('.btn')) {
17237                                    if(quickBasketOptionModal.find('.cl-modal-check-quantity').length > 0) {
17238                                        e.preventDefault(); 
17239                                        return false; 
17240                                    }
17241                                    var input_v = quickBasketOptionModal.find('.box-option-count input').val();
17242                                    if(!$(e.target).hasClass('.box-option-count') && (input_v == '' || Number(input_v) < 1)) {
17243                                        $.quickbasket.alertModal('ERROR','최소 구매 수량은 1개 입니다.','cl-modal-check-quantity');
17244                                        if(input_v) quickBasketOptionModal.find('.box-option-count input').val(1);
17245                                        $.quickbasket.pdTotalPriceUpdate(quickBasketOptionModal);
17246                                        return false;
17247                                    }
17248                                }
17249                            });
17250
17251                        });
17252
17253                        return false;
17254
17255                    } else {
17256                        // product none option
17257                        $.quickbasket.setKeepShopping(sid,RENDER.b.PAGE,pid,pnum);
17258                        $.quickbasket.close(true);
17259                        return false;
17260                    }
17261
17262                    // var dataObj = JSON.parse(data.r);
17263                }
17264            });
17265        },
17266        initOptions: function (qbModal, pdBasketObj) {
17267            $.ajax({
17268                url: '/_basket',
17269                type: 'post',
17270                data: pdBasketObj,
17271                async: false,
17272                cache: false,
17273                success: function (data) {
17274                    if (data == 'error-none-unique') {
17275                        alert('장바구니에 담기는 도중 오류가 발생했습니다.\n잠시후 다시시도 해주세요.\n같은 현상이 지속된다면 고객센터로 문의해주세요.');
17276                        return false;
17277                    }
17278
17279                    var checkClnav =  $.clnav.check();
17280                    var dataObj = JSON.parse(data);
17281                    var basketConfirm = dataObj.r.basket_confirm;
17282                    var state = dataObj.r.state;
17283                    var remainQuantity = dataObj.r.remain_quantity;
17284                    var totalQuantity = $('.total-quantity').val();
17285
17286                    if(basketConfirm.indexOf(false)>-1 && basketConfirm.indexOf(true)==-1){
17287                        if(state=='download'){
17288                            alert('장바구니에 이미 담겨있는 상품입니다.');
17289                        } else if(state == 'normal' && (deliveryType != dataObj.r.delivery_type || deliveryPayType != dataObj.r.delivery_pay_type)) {
17290                            alert('해당 상품을 장바구니에서 비우거나 배송방법을 ' + $.lang[LANG]['shopping.delivery.template.delivery_type.' + dataObj.r.delivery_type.toLowerCase()] + ', 배송비결제를 ' + $.lang[LANG]['shopping.delivery.template.pay_type.' + dataObj.r.delivery_pay_type.toLowerCase()] + '로 수정해 주세요.');
17291                        }
17292                        else{
17293                            $(this).blur();
17294                            var modal = $(this).showModalFlat('ERROR','재고 수량('+remainQuantity+'개) 이상 구매하실 수 없습니다.',true,false,'','ok','','cl-cmmodal cl-s-btn w560 cl-p130 cl-t80 cl-modal cl-none-title cl-close-btn','','',function() {
17295                                modal.closest('.cl-flat-modal').next('.modal-backdrop.in').attr('style', 'z-index: 1050!important');
17296                                modal.closest('.modal').css('z-index', 1051);
17297                                $(document).on('keydown', function(e) {
17298                                    if(e.keyCode == 27) modal.modal('hide');
17299                                });
17300                            });
17301                        }
17302                        return false;
17303                    }
17304
17305                    var optionName = qbModal.find('input[name="option_name[]"]'),
17306                        optionPrice = qbModal.find('input[name="option_price[]"]'),
17307                        optionCount = qbModal.find('input[name="option_count[]"]'),
17308                        optionSeq = qbModal.find('.option_seq'),
17309                        optionQuantity = qbModal.find('.option-normal-price'),
17310                        etcStartDate = qbModal.find('input[name="etc_start_date[]"]'),
17311                        etcEndDate = qbModal.find('input[name="etc_end_date[]"]'),
17312                        oCnt = qbModal.find('input[name="option_name[]"]').length,
17313                        state = qbModal.find('#product_state').val();
17314
17315                    var optionNameAry = [],
17316                        optionSeqAry = [],
17317                        optionQuantityAry = [],
17318                        optionPriceAry = [],
17319                        optionCountAry =   
17320                        etcStartDateAry = [],
17321                        etcEndDateAry = [],
17322                        prod, prodAry = [],
17323                        totalPrice = qbModal.find('.total-price').text().replace(/[\{\}\[\]\/?.,;:|\)*~`!^\-+<>@\#$%&\\\=\(\'\"]/gi, ""),
17324                        fdq_arr = [];
17325
17326                    for (var i=0;i<oCnt;i++) {
17327                        if (optionName[i].value == 'noneOption') optionName[i].value = '';
17328                        optionNameAry[i] = optionName[i].value;
17329                        optionSeqAry[i] = optionSeq[i].value;
17330                        optionQuantityAry[i] = optionQuantity[i].value;
17331                        optionPriceAry[i] = (optionPrice[i].value * 1) * (optionQuantity[i].value * 1);
17332                        optionCountAry[i] = optionCount[i].value;
17333                        etcStartDateAry[i] = etcStartDate[i] ? etcStartDate[i].value : '';
17334                        etcEndDateAry[i] = etcEndDate[i] ? etcEndDate[i].value : '';
17335                        prod = {
17336                            'option_seq': optionSeq[i].value,
17337                            'option_name': optionName[i].value,
17338                            'option_quantity': optionQuantity[i].value,
17339                            'option_price': optionPriceAry[i],
17340                            'etc_option_start': etcStartDate[i] ? etcStartDate[i].value : '',
17341                            'etc_option_end': etcEndDate[i] ? etcEndDate[i].value : '',
17342                        }
17343                        prodAry[i] = prod;
17344
17345                        var fdq_pn = qbModal.find('.product-title [data-project-title]').text(),
17346                            fdq_nm = (optionName[i].value) ? optionName[i].value : qbModal.find('.option-select-box .option-count-box:eq('+i+') .box-option-name').text();
17347                        fdq_arr.push({
17348                            'id': optionSeq[i].value, 
17349                            'name': (fdq_pn != fdq_nm) ? fdq_pn + ' ' + fdq_nm : fdq_nm,
17350                            'quantity': optionQuantity[i].value, 
17351                            'price': optionPriceAry[i], 
17352                        });
17353                    }
17354
17355                    var productCart = {
17356                        'product_number': pdBasketObj.value,   // 상품 번호
17357                        'option': prodAry,                     // 옵션
17358                        'state': state,                        // 상품 타입 (normal: 일반상품, download: 다운로드 상품, etc: 기타무형 상품)
17359                        'total_price': totalPrice,             // 상품 총 가격
17360                        'sid': pdBasketObj.sid,                // site id
17361                    }
17362                    if(typeof productCartCallback == 'function') productCartCallback(productCart);
17363                    if(typeof callbackEvtAddToCart == 'function') callbackEvtAddToCart(fdq_pn,fdq_arr,totalPrice);
17364
17365                    if(basketConfirm.indexOf(true) > -1) {
17366                        var checkFixTypeMenu = (typeof $('.el-menu header.navbar').attr('data-fixtype') != 'undefined' && $('.el-menu header.navbar').attr('data-fixtype')) ? true : false;     
17367                        property.CART = (checkFixTypeMenu || checkClnav) ? dataObj.r.cart_cnt : 'true';
17368                        if(checkClnav) $.clnav.setFixnavShopping($('.cl-nav'));
17369                        else $.shopping.makeSiteFixedCART();
17370
17371                        qbModal.modal('hide');
17372                        $.quickbasket.close(false);
17373                        return false;
17374                    } else {
17375                        if(checkClnav) $.clnav.setFixnavShopping($('.cl-nav'));
17376                        else $.shopping.makeSiteFixedCART();
17377                    }
17378                }
17379            });
17380        },
17381        close: function (checkPlusCart) {
17382            quickbasket_str = '\
17383                <div class="modal-footer mt-20\">\
17384                    <button type="button" class="btn btn-sm btn-line">' + $.lang[LANG]['gallery.sh.quickbasket.goto'] + '</button>\
17385                    <button type="button" class="btn btn-sm btn-active close-button-dialog" data-dismiss="modal">' + $.lang[LANG]['gallery.sh.quickbasket.keep'] + '</button>\
17386                </div>\
17387            ';
17388
17389            var checkClnav = $.clnav.check();
17390
17391            var quickBasketModal = $(this).showModalFlat($.lang[LANG]['gallery.sh.quickbasket.success'], quickbasket_str, false, false, '', '', '', 'cl-cmmodal cl-s-btn w560 cl-p0 cl-quickbasket-modal', false, '', function() {
17392                // quickBasketModal.closest('.cl-flat-modal').next('.modal-backdrop.in').attr('style', 'z-index: 1050!important');
17393                // quickBasketModal.closest('.modal').css('z-index', 1051);
17394
17395                if(checkPlusCart) {
17396                    var checkFixTypeMenu = (typeof $('.el-menu header.navbar').attr('data-fixtype') != 'undefined' && $('.el-menu header.navbar').attr('data-fixtype')) ? true : false;     
17397                    property.CART = (checkFixTypeMenu || checkClnav) ? Number(property.CART) + 1 : 'true';
17398                    if(checkClnav) $.clnav.setFixnavShopping($('.cl-nav'));
17399                    else $.shopping.makeSiteFixedCART();
17400                }
17401
17402                quickBasketModal.find('.btn-line').on('click', function(e) {
17403                    location.href = '/_cart';
17404                    quickBasketModal.modal('hide');
17405                });
17406
17407                $(document).on('keydown', function(e) {
17408                    if(e.keyCode == 13) {
17409                        e.preventDefault();
17410                        return false;
17411                    }
17412                    if(e.keyCode == 27) quickBasketModal.modal('hide');
17413                });
17414            });
17415        },
17416        alertModal: function (am_header, am_content, am_modalclass) {
17417            var am_selector = (am_modalclass) ? '.'+am_modalclass.replace(' ',',.') : '';
17418            if(am_selector != '' && $(am_selector).length > 0) return false;
17419
17420            var am_zindex = ($('body').width() < 768) ? 9998 : 1050;
17421            var am_modal = $(this).showModalFlat(am_header, am_content, true, false, '', 'ok', '', 'cl-cmmodal cl-s-btn w560 cl-p130 cl-t80 cl-modal cl-none-title cl-close-btn ' + am_modalclass, '', '', function() {
17422                am_modal.closest('.cl-flat-modal').next('.modal-backdrop.in').attr('style', 'z-index: '+am_zindex+'!important');
17423                am_modal.closest('.modal').css('z-index', am_zindex+1);
17424
17425                $(document).on('keydown', function(e) {
17426                    if(e.keyCode == 27) am_modal.modal('hide');
17427                });
17428            });
17429        },
17430        bindOptionCountEvents: function (quickbasketModal) {
17431            quickbasketModal = (quickbasketModal && $(quickbasketModal).length) ? $(quickbasketModal).closest('.cl-quickbasket-modal') : $('.cl-quickbasket-modal:visible').last();
17432            if(!quickbasketModal.length) quickbasketModal = $('.cl-quickbasket-modal').last();
17433
17434            quickbasketModal.find('.option-select-box .box-option-count .plus').off('click').on('click', function(e) {
17435                if($('.cl-modal-check-quantity').length > 0) {
17436                    e.preventDefault();
17437                    return false;
17438                }
17439
17440                var totalQuantity = $(this).closest('.option-count-box').find('.total-quantity').val();
17441                var count = $(this).parent().children('input').val();
17442                var optionSeq = $(this).closest('.option-count-box').find('input[name="option_seq[]"]').val();
17443                var optionName = $(this).closest('.option-count-box').find('input[name="option_name[]"]').val();
17444                var optionStartDate = $(this).closest('.option-count-box').find('input[name="etc_start_date[]"]').val();
17445                var etcTotalCount = 0;
17446
17447                var target = this;
17448                var sameCount = 0;
17449                quickbasketModal.find('input[name="option_seq[]"][value="' + optionSeq + '"]').each(function() {
17450                    if($(this).closest('.option-count-box').has(target).length === 0) {
17451                        sameCount += Number($(this).parent().find('input[name="option_count[]"]').val());
17452                    }
17453                });
17454
17455                if (count > 1000) {
17456                    $(this).blur();
17457                    $.quickbasket.alertModal('ERROR','최대 구매 수량은 1000개 입니다.','cl-modal-check-quantity');
17458                    return false;
17459                }
17460
17461                count = (count * 1) + 1;
17462
17463                if(optionStartDate!==undefined && optionStartDate.length > 0){
17464                    var sameOptions = (optionName!='noneOption') ? quickbasketModal.find('input[value="'+optionSeq+'"]').closest('.option-count-box').find('input[name="option_count[]"]') : quickbasketModal.find('input[value="'+optionName+'"]').closest('.option-count-box').find('input[name="option_count[]"]');
17465                    sameOptions.each(function(){
17466                        etcTotalCount += Number($(this).val());
17467                    });
17468
17469                    if(etcTotalCount >= totalQuantity) {
17470                        $(this).blur();
17471                        $.quickbasket.alertModal('ERROR','재고 수량('+totalQuantity+'개) 이상 구매하실 수 없습니다.','cl-modal-check-quantity');
17472                        return false;
17473                    }
17474                } else {
17475                    if(count + sameCount > totalQuantity) {
17476                        $(this).blur();
17477                        $.quickbasket.alertModal('ERROR','재고 수량('+totalQuantity+'개) 이상 구매하실 수 없습니다.','cl-modal-check-quantity');
17478                        count = totalQuantity - sameCount;
17479                    }
17480                }
17481
17482                $(this).parent().children('input').val(count);
17483                $.quickbasket.pdTotalPriceUpdate(quickbasketModal);
17484            });
17485
17486            quickbasketModal.find('.option-select-box .box-option-count .min').off('click').on('click', function(e) {
17487                if($('.cl-modal-check-quantity').length > 0) {
17488                    e.preventDefault();
17489                    return false;
17490                }
17491
17492                var count = $(this).parent().children('input').val();
17493                count = (count * 1) - 1;
17494
17495                if (count < 1) {
17496                    $(this).blur();
17497                    $.quickbasket.alertModal('ERROR','최소 구매 수량은 1개 입니다.','cl-modal-check-quantity');
17498                    e.preventDefault();
17499                    return false;
17500                }
17501
17502                $(this).parent().children('input').val(count);
17503                $.quickbasket.pdTotalPriceUpdate(quickbasketModal);
17504            });
17505
17506            quickbasketModal.find('.option-normal-price').off('keyup.quickbasketQty blur.quickbasketQty').on('keyup.quickbasketQty blur.quickbasketQty', function(e) {
17507                if (e.keyCode == 13 || $('.cl-modal-check-quantity').length > 0) {
17508                    e.preventDefault();
17509                    return false;
17510                }
17511
17512                var totalQuantity = $(this).closest('.option-count-box').find('.total-quantity').val();
17513                var cnt = $(this).val();
17514                var optionSeq = $(this).closest('.option-count-box').find('input[name="option_seq[]"]').val();
17515                var optionName = $(this).closest('.option-count-box').find('input[name="option_name[]"]').val();
17516                var optionStartDate = $(this).closest('.option-count-box').find('input[name="etc_start_date[]"]').val();
17517                var etcTotalCount = 0;
17518
17519                cnt = (cnt) ? Number(cnt.replace(/[^0-9\.]/g,'')) : '';
17520                if (!cnt) {
17521                    e.preventDefault();
17522                    return false;
17523                }
17524                $(this).val(cnt);
17525
17526                if(cnt < 1) {
17527                    $.quickbasket.alertModal('ERROR','최소 구매 수량은 1개 입니다.','cl-modal-check-quantity');
17528                    $(this).val(1);
17529                    return false;
17530                }
17531                if(totalQuantity==99999 && cnt > 1000) {
17532                    $.quickbasket.alertModal('ERROR','최대 구매 수량은 1000개 입니다.','cl-modal-check-quantity');
17533                    cnt = 1000;
17534                    $(this).val(cnt);
17535                    return false;
17536                }
17537
17538                var target = this;
17539                var sameCount = 0;
17540                quickbasketModal.find('input[name="option_seq[]"][value="' + optionSeq + '"]').each(function() {
17541                    if($(this).closest('.option-count-box').has(target).length === 0) {
17542                        sameCount += Number($(this).parent().find('input[name="option_count[]"]').val());
17543                    }
17544                });
17545
17546                cnt += sameCount;
17547
17548                if(optionStartDate!==undefined && optionStartDate.length > 0){
17549                    var sameOptions = (optionName!='noneOption') ? quickbasketModal.find('input[value="'+optionSeq+'"]').closest('.option-count-box').find('input[name="option_count[]"]') : quickbasketModal.find('input[value="'+optionName+'"]').closest('.option-count-box').find('input[name="option_count[]"]');
17550                    sameOptions.each(function(){
17551                        etcTotalCount += Number($(this).val());
17552                    });
17553
17554                    if(etcTotalCount > totalQuantity) {
17555                        var inputValue = $(this).val();
17556                        $(this).blur();
17557                        $.quickbasket.alertModal('ERROR','재고 수량('+totalQuantity+'개) 이상 구매하실 수 없습니다.','cl-modal-check-quantity');
17558                        $(this).val(inputValue-(etcTotalCount-totalQuantity));
17559                        return false;
17560                    }
17561                } else {
17562                    if(cnt > totalQuantity) {
17563                        $(this).blur();
17564                        $.quickbasket.alertModal('ERROR','재고 수량('+totalQuantity+'개) 이상 구매하실 수 없습니다.','cl-modal-check-quantity');
17565                        $(this).val(totalQuantity - sameCount);
17566                        return false;
17567                    }
17568                }
17569
17570                $.quickbasket.pdTotalPriceUpdate(quickbasketModal);
17571            });
17572
17573            quickbasketModal.find('.option-select-box .box-delete').off('click').on('click', function(e) {
17574                var optionCountBox = $(this).closest('.option-count-box'),
17575                    optionName = optionCountBox.find('input[name="option_name[]"]').val();
17576
17577                if(optionName == 'noneOption') {
17578                    if(quickbasketModal.find('.cl-s-option-text').length > 0) {
17579                        quickbasketModal.find('.cl-s-option-text > input').prop('readonly', false);
17580                        optionCountBox.find('input[name="option_text[]"]').val('');
17581                    }
17582                }
17583                optionCountBox.remove();
17584                if(quickbasketModal.find('.option-count-box:not(.additional)').length > 0) quickbasketModal.find('.modal-footer .ok-button-dialog').addClass('active');
17585                else quickbasketModal.find('.modal-footer .ok-button-dialog').removeClass('active');
17586
17587                $.quickbasket.pdTotalPriceUpdate(quickbasketModal);
17588            });
17589        },
17590        checkQty: function (optionAry) {
17591            var currentOptCnt = 0;
17592            var selectedSeq = optionAry[3]; // option_seq
17593            var quickbasketModal = $('.cl-quickbasket-modal:visible').last();
17594            if(!quickbasketModal.length) quickbasketModal = $('.cl-quickbasket-modal').last();
17595
17596            quickbasketModal.find('.box-option-name').each(function () {
17597                var box = $(this).closest('.option-count-box');
17598                var boxOptionSeq = box.find('.option_seq').val();
17599                var boxQty = parseInt(box.find('.option-normal-price').val() || "0", 10);
17600
17601                if (boxOptionSeq === selectedSeq) {
17602                    currentOptCnt += boxQty;
17603                }
17604            });
17605
17606            if (currentOptCnt >= Number(optionAry[2])) {
17607                var modal = $(this).showModalFlat('ERROR', '재고 수량(' + optionAry[2] + '개) 이상 구매하실 수 없습니다.', true, false, '', 'ok', '', 'cl-cmmodal cl-s-btn w560 cl-p130 cl-t80 cl-modal cl-none-title cl-close-btn', '', '', function () {
17608                    modal.closest('.cl-cmmodal').next('.modal-backdrop.in').attr('style', 'z-index: 1050!important');
17609                    modal.closest('.modal').css('z-index', 1051);
17610                    $(document).on('keydown', function (e) {
17611                        if (e.keyCode === 27) modal.modal('hide');
17612                    });
17613                });
17614                return false;
17615            }
17616
17617            return true;
17618        },
17619        pdOptionBoxHtml: function (productPrice, type, optionStatus, optionType, optionAry, textOption, textOptionObj) {
17620            // 옵션에 파일명 추가
17621            var trimmedName = '', fileSize = '';
17622            var psRaw = ($.quickbasket.productStates && optionAry[3]) ? $.quickbasket.productStates[optionAry[3]] : ''; // option_seq
17623            if (psRaw) {
17624                var ps = JSON.parse(psRaw);
17625                if (ps.file_name && ps.file_size) {
17626                    trimmedName = limitFilenameLength(ps.file_name, 14);
17627                    fileSize = ps.file_size;
17628                }
17629            }            
17630            var quickbasketModal = $('.cl-quickbasket-modal:visible').last(),
17631                total = 0,
17632                dateCheckCnt = 1,
17633                etcStartDate = '', etcEndDate = '', etcDate = '';
17634            if(!quickbasketModal.length) quickbasketModal = $('.cl-quickbasket-modal').last();
17635
17636            if (quickbasketModal.find('.cl-s-option-date-selector').length > 0) { //기간
17637                var optionStatus = 'etc';
17638                etcStartDate = quickbasketModal.find('#etc-start-date-option').val();
17639                etcEndDate = quickbasketModal.find('#etc-end-date-option').val();
17640                etcTime = quickbasketModal.find('#etc-time').val();
17641                if (etcEndDate) etcDate = etcStartDate + ' - ' + etcEndDate;
17642                else etcDate = etcStartDate;
17643                if(etcTime) {
17644                    var etcTimeTmp = etcTime.split(' ');
17645                    etcTimeTmp[0] = (etcTimeTmp[0] == 'am')? '오전 ' : '오후 ';
17646                    var etcTimeStr = etcTimeTmp[0] + etcTimeTmp[1];
17647                    etcDate += ' '+etcTimeStr;
17648                    etcStartDate += '|'+etcTime;
17649                    if(etcEndDate) etcEndDate += '|'+etcTime;
17650                }
17651
17652                var etcStartDateAry = quickbasketModal.find('#etc-start-date-option').val().split(".");
17653                var etcEndDateAry = quickbasketModal.find('#etc-end-date-option').val().split(".");
17654                var disabledDateArr = quickbasketModal.find('#etc-exclude-date').val().split(',');
17655                var startDateObj = new Date(etcStartDateAry[0], (etcStartDateAry[1] * 1) - 1, etcStartDateAry[2]);
17656                var endDateObj = new Date(etcEndDateAry[0], (etcEndDateAry[1] * 1) - 1, etcEndDateAry[2]);
17657                var betweenDate = (endDateObj.getTime() - startDateObj.getTime()) / 1000 / 60 / 60 / 24;
17658
17659                var dayArr = (quickbasketModal.find('#etc-term-setting').val() && JSON.parse(quickbasketModal.find('#etc-term-setting').val()).days !== undefined)? JSON.parse(quickbasketModal.find('#etc-term-setting').val()).days.split('|'):[];
17660                var disabledDayArr = [];
17661                if(dayArr.length > 0) {
17662                    disabledDayArr = [0, 1, 2, 3, 4, 5, 6];
17663                    $.each(dayArr, function(i, v){
17664                        enableIdx = disabledDayArr.indexOf(daysObj[v]);
17665                        if(enableIdx > -1) {
17666                            disabledDayArr.splice(enableIdx, 1);
17667                        }
17668                    });
17669                }
17670
17671                for (var i=0;i<betweenDate;i++) {
17672                    var dayCheck = 0;
17673                    var dateCheck;
17674                    var dt;
17675 
17676                    dayCheck = new Date(etcStartDateAry[0], (etcStartDateAry[1] * 1) - 1, (etcStartDateAry[2] * 1) + i).getDay();
17677                    dt = new Date(etcStartDateAry[0], (etcStartDateAry[1] * 1) - 1, (etcStartDateAry[2] * 1) + i);
17678                    dateCheck = dt.getFullYear()+'.'+ String(dt.getMonth()+1).padStart(2, '0') +'.'+dt.getDate();
17679                    if (disabledDateArr.indexOf(dateCheck)===-1 && disabledDayArr.indexOf(dayCheck)===-1) dateCheckCnt++;
17680                }
17681            }
17682            var boxOptionTextStr = (textOptionObj)? textOptionObj.map(function(element, index, array){return Object.values(element);}).join(' / ') : ''; //입력옵션 텍스트값
17683            if (dateCheckCnt == 0) dateCheckCnt = 1;
17684
17685            optionAry[0] = (optionAry[0] === undefined) ? '' : strReplace(optionAry[0], '\\quot;', "&quot;");
17686            optionAry[3] = (optionAry[3] === undefined) ? quickbasketModal.find('.noneoption_seq').val() : optionAry[3];
17687            textOption = (textOption === undefined)? '' : textOption;
17688            var optionPrice = (optionAry[1] === undefined)? 0 : Number(optionAry[1]);
17689            var boxOptionPrice = 0;
17690            var boxOptionName = '';
17691            var boxOptionNameArr = new Array();
17692            if(optionType == 'A') {
17693                boxOptionNameArr.push(optionAry[0]);
17694                productPrice = 0;
17695            } else {
17696                if(optionAry[0] != '' && optionAry[0] != 'undefined') { //일반옵션
17697                    boxOptionNameArr.push(optionAry[0]);
17698                }
17699                if(etcDate != '') { //무형-날짜
17700                    if(boxOptionNameArr.indexOf(etcDate) === -1) boxOptionNameArr.push(etcDate);
17701                }
17702                if(textOption!='') { //입력옵션
17703                    boxOptionNameArr.push(boxOptionTextStr);
17704                }
17705            }
17706            boxOptionName = boxOptionNameArr.join(' / '); //옵션명
17707            var cnt = 0;
17708            quickbasketModal.find('.box-option-name').each(function () {
17709                var boxOptionSeq = $(this).closest('.option-count-box').find('.option_seq').val();
17710                var boxOptionText = $(this).closest('.option-count-box').find('input[name="option_text[]"]').val();
17711                if (quickbasketModal.find('.cl-s-option-date-selector').length > 0) { //날짜선택옵션
17712                    if ($(this).text() == boxOptionName || $(this).text() == etcDate) {
17713                        cnt++;
17714                        $(this).blur();
17715                        $.quickbasket.alertModal('ERROR','이 옵션은 이미 선택되어 있습니다.','cl-modal-check-select');
17716                    }
17717                } else {
17718                    if(textOption !== undefined && textOption != '') { //입력옵션 있음
17719                        if(optionAry[3] !== undefined) { //일반옵션 있음
17720                            if (boxOptionSeq == optionAry[3] && boxOptionText == strReplace(textOption, '&quot;', '"')) {
17721                                cnt++;
17722                                $(this).blur();
17723                                $.quickbasket.alertModal('ERROR','이 옵션은 이미 선택되어 있습니다.','cl-modal-check-select');
17724                            }
17725                        } else { //일반옵션 없음
17726                            if (boxOptionText == strReplace(textOption, '&quot;', '"')) {
17727                                cnt++;
17728                                $(this).blur();
17729                                $.quickbasket.alertModal('ERROR','이 옵션은 이미 선택되어 있습니다.','cl-modal-check-select');
17730                            }
17731                        }
17732                        
17733                    } else { //일반옵션만
17734                        if (boxOptionSeq == optionAry[3]) {
17735                            cnt++;
17736                            $(this).blur();
17737                            $.quickbasket.alertModal('ERROR','이 옵션은 이미 선택되어 있습니다.','cl-modal-check-select');
17738                        }
17739                    }   
17740                }
17741            });
17742
17743            if (cnt > 0) return false;
17744
17745            var plusOptionPrice = (optionType == 'A')? optionPrice : ((productPrice * 1) + optionPrice) * dateCheckCnt;
17746            if(plusOptionPrice < 0) {
17747                alert('구매금액이 0원보다 적을 수 없습니다.\r\n판매자에게 문의하세요.');
17748                return false;
17749            }
17750            if(optionType == 'A' && (optionAry[0]).indexOf(' / ') > -1) {
17751                var tmp = (optionAry[0]).split(' / ');
17752                optionAry[0] = tmp[1];
17753            }
17754            var totalPriceOption = (plusOptionPrice + total);
17755            var html = '';
17756                if(optionType == 'A') html += '<div class="option-count-box additional">';
17757                else html += '<div class="option-count-box">';
17758                html += '<input type="hidden" name="option_price[]" value="'+plusOptionPrice+'">';
17759                html += '<input type="hidden" name="option_seq[]" class="option_seq" value="'+optionAry[3]+'">';
17760                html += '<input type="hidden" class="total-quantity" value="'+optionAry[2]+'">';
17761                if (type) html += '<input type="hidden" name="option_name[]" value="noneOption">';
17762                else html += '<input type="hidden" name="option_name[]" value="'+optionAry[0]+'">';
17763                if(optionType != '') html += '<input type="hidden" name="option_type[]" value="'+optionType+'">';
17764                else html += '<input type="hidden" name="option_type[]" value="">';
17765                html += '<input type="hidden" name="option_text[]" value="'+textOption+'">';
17766                html += '<div class="box-option-row">';
17767                if (quickbasketModal.find('.cl-s-option-date-selector').length > 0) { //기간 있음
17768                    if(optionType != 'A') {
17769                        html += '<input type="hidden" name="etc_start_date[]" value="'+etcStartDate+'">';
17770                        html += '<input type="hidden" name="etc_end_date[]" value="'+etcEndDate+'">';
17771                    } else {
17772                        html += '<input type="hidden" name="etc_start_date[]" value="">';
17773                        html += '<input type="hidden" name="etc_end_date[]" value="">';
17774                    }
17775                    if (type) html += '<div class="box-option-name">' + etcDate + '</div>';
17776                    else html += '<div class="box-option-name">' + boxOptionName + '</div>';
17777                } else { //기간 없음
17778                    html += '<div class="box-option-name">'+boxOptionName+'</div>';
17779                }
17780                    html += '<div class="box-option-del"><span class="box-delete"><svg viewBox="0 0 12 12" width="12" height="12"><polygon points="12 0.71 11.29 0 6 5.29 0.71 0 0 0.71 5.29 6 0 11.29 0.71 12 6 6.71 11.29 12 12 11.29 6.71 6 "/></svg></span></div>';
17781                html += '</div>'; //end row
17782
17783                // 파일명 추가
17784                if (trimmedName && fileSize) {
17785                    html += '<div class="quick-option-file2">';  // 새로운 줄
17786                    html += '<span class="quick-option-file-name">' + trimmedName + '</span><br>';
17787                    html += '<span class="quick-option-file-size">' + fileSize + '</span>';
17788                    html += '</div>';
17789                }
17790
17791                html += '<div class="box-option-row">';
17792                    html += '<div class="box-option-price">
17792<span class="option-price">'+number_format(plusOptionPrice)+'</span>원</div>';
17793                    html += '<div class="box-option-count">';
17794                    html += '<div class="form-group">';
17795                    html += '<span class="min"><svg viewBox="0 0 11 11" width="11" height="11"><rect y="5" width="11" height="1"/></svg></span>';
17796                    html += '<input type="text" class="option-normal-price" value="1" numberOnly="true" name="option_count[]">';
17797                    html += '<span class="plus"><svg viewBox="0 0 11 11" width="11" height="11"><polygon points="6 5 6 0 5 0 5 5 0 5 0 6 5 6 5 11 6 11 6 6 11 6 11 5 "/></svg></span>';
17798                    html += '</div>';
17799                    html += '</div>';
17800                html += '</div>'; //end row
17801                html += '</div>';
17802
17803            return html;
17804        },
17805        pdOptionPick: function (obj, productPrice) {
17806            // console.log('pdOptionPick() ----------------------------------------------');
17807            // console.log($.quickbasket.data);
17808
17809            var quickbasketModal = $(obj).closest('.cl-quickbasket-modal'),
17810                type = '',
17811                option = obj.getAttribute('data-val'),
17812                optionAry = option.split('||'),
17813                optionStatus =  obj.getAttribute('data-status'),
17814                optionType = obj.getAttribute('data-option_type'),
17815                _idx = obj.getAttribute('data-idx'),
17816                total = 0,
17817                totalCnt = 1,
17818                dateCheckCnt = 1,
17819                submit = false,
17820                reSelected = false,
17821                parent = $(obj).closest('.cl-s-option-selector'),
17822                textParent = $(obj).closest('.cl-s-option-text'),
17823                selectedBoxTitle = parent.find('.selected-option-title').text(),
17824                selectedPrice = $(obj).attr('data-option-price'),
17825                onlySelectedText = $(obj).find('.option-name').text();
17826
17827            if(quickbasketModal.find('.cl-s-normal-option-selector').length > 1 && !$.quickbasket.checkQty(optionAry)) return false; //옵션재고수량 검사
17828
17829            selectedBoxTitle += (selectedBoxTitle.length > 0) ? ' / ' : '';
17830            if(selectedPrice != undefined) {
17831                selectedPrice = (selectedPrice.indexOf('-') > -1) ? '-' + number_format(selectedPrice.substring(1)) : '+' + number_format(selectedPrice);
17832                selectedPrice = ' (' + selectedPrice + '원)';
17833            } else selectedPrice = '';
17834
17835            if(parent.hasClass('cl-s-normal-option-selector')) {
17836                var selected_option = $(obj).parents('.cl-s-normal-option-selector'),
17837                    selected_index = selected_option.attr('data-def-index'),
17838                    last_index = quickbasketModal.find('.cl-s-normal-option-selector').last().attr('data-def-index');
17839                if (selected_index != last_index) reSelected = true;
17840            }
17841
17842            // 하위메뉴 리셋
17843            if(selected_index != undefined) {
17844                $.each(quickbasketModal.find('.cl-s-normal-option-selector'), function(i,v) {
17845                    if(i > Number(selected_index)) {
17846                        var otitle = $(this).find('.selected-option-title').text();
17847                        $(this).addClass('option-disabled');
17848                        $(this).find('.selected-option')
17849                                .attr('data-selected_option','')
17850                                .attr('data-val','')
17851                                .attr('data-status','');
17852                        $(this).find('.selected-option-text').text(otitle);
17853                    }
17854                });
17855            }
17856
17857            setTimeout(function() {
17858                var checkSelectEmpty = (quickbasketModal.find('.cl-s-option-selector.option-required .selected-option[data-val=""]').length > 0) ? true : false,
17859                    checkInputEmpty = false;
17860                quickbasketModal.find('.text-option-box input').each(function() {
17861                    if($(this).val() == '' || $(this).val().trim() == '') checkInputEmpty = true;
17862                });
17863
17864                if(!checkSelectEmpty && !checkInputEmpty) quickbasketModal.find('.text-option-btn').removeClass('disabled');
17865                else quickbasketModal.find('.text-option-btn').addClass('disabled');
17866            }, 100);
17867
17868            // 추가옵션 존재
17869            if(quickbasketModal.find('.cl-s-option-text input').length > 0 || quickbasketModal.find('.cl-s-normal-option-selector.option-disabled').length > 0 || reSelected) {
17870                //셀렉트박스 선택
17871                var optionSelectedVal = (quickbasketModal.find('.cl-s-option-text input').length > 0) ? quickbasketModal.find('#selected-product-option').attr('data-val') : '';
17872                var selectedOptionName = selectedBoxTitle + onlySelectedText + selectedPrice;
17873                if (optionType == null) {
17874                    parent.find('.selected-option-text').text(selectedOptionName);
17875                    parent.find('.selected-option').attr('data-selected_option', onlySelectedText);
17876                    parent.find('.selected-option').attr('data-val', option);
17877                    parent.find('.selected-option').attr('data-status', optionStatus);
17878                }
17879
17880                // console.log(obj.getAttribute('data-type'));
17881                if(quickbasketModal.find('.cl-s-normal-option-selector.option-disabled').length == 0) {
17882                    quickbasketModal.find('.cl-s-option-text input').prop('readonly', false);
17883                }
17884
17885                if(obj.getAttribute('data-type') == '1') {
17886                    quickbasketModal.find('.cl-s-normal-option-selector.option-disabled').eq(0).removeClass('option-disabled');
17887                } else if(obj.getAttribute('data-type') == '2') {
17888                    var $required = quickbasketModal.find('.cl-s-normal-option-selector').eq(1),
17889                        $op = $required.find('.product-option-box'),
17890                        idx = 0;
17891
17892                    $required.find('.selected-option-text').text('선택');
17893                    $op.empty();
17894                    var selectedMix2 = onlySelectedText;
17894 // 첫 번째 옵션에서 선택한 값
17895                    $.each($.quickbasket.data.list.normal[_idx]['value'], function(a,b) {
17896                        if (b.option_mix2 !== selectedMix2) return true;
17897                        if(b.option_status == 'H') return true;
17898                        var custom_option_number = (a + 1).toString().padStart(2, '0');
17899                        b.option_number = custom_option_number;
17900                        var div_property = '';
17901                        if(!b.soldout) {
17902                            div_property += 'onclick="$.quickbasket.pdOptionPick(this, \'' + productPrice + '\')" ';
17903                            div_property += 'data-status="normal" ';
17904                            div_property += 'data-idx="' + a + '" ';
17905                            // if(o_key == 'normal') div_property += 'data-option-index="' + og_idx + '" ';
17906                            div_property += 'data-option-price="' + b.option_price + '" ';
17907                        }
17908                        var option_str = {
17909                            'div_class': (b.soldout) ? 'sold-out' : '',
17910                            'div_property': div_property,
17911                            'span1': (b.soldout) ? '<span class="text-d-lt">' : '',
17912                            'span2': (b.soldout) ? '</span>' : '',
17913                            'seq': 'data-option-seq="'+b.option_seq+'"',
17914                            'soldout': (b.soldout) ? '<label>품절</label>' : '',
17915                        }
17916
17917                        var s = '\
17918                            <div class="' + option_str.div_class + '" data-val="' + b.val + '" ' + option_str.div_property + '>\
17919                                ' + option_str.span1 + '\
17920                                    <span class="number">' + b.option_number + '.</span>\
17921                                    <div class="option-name" ' + option_str.seq + '>' + b.option_name + option_str.soldout + '</div>\
17922                                    <span class="price">' + b.option_price_str + ' 원</span>\
17923                                ' + option_str.span2 + '\
17924                            </div>\
17925                        ';
17926
17927
17928                        /*
17929                        if(soldout == true) {
17930                            var s = '\
17931                            <div class="sold-out" data-val="' + b.option_name + '||' + b.option_price + '||0">\
17932                                <span class="text-d-lt">\
17933                                    <span class="number">' + b.option_number + '.</span>\
17934                                    <div class="option-name" data-option-seq="' + b.option_seq + '">' + b.option_name + '<label>품절</label></div>\
17935                                    <span class="price">' + b.option_price_str + ' 원</span>\
17936                                </span>\
17937                            </div>\
17938                            ';
17939                        } else {
17940                            var s = '\
17941                            <div data-val="' + b.option_name + '||' + b.option_price + '||' + quantity + '||' + b.option_seq + '" onclick="$.quickbasket.pdOptionPick(this, \'' + productPrice + '\')" data-status="normal" data-idx=' + a + ' data-option-price="' + b.option_price + '">\
17942                                <span class="number">' + b.option_number + '.</span>\
17943                                <div class="option-name" data-option-seq="' + b.option_seq + '">' + b.option_name + '</div>\
17944                                <span class="price">' + b.option_price_str + ' 원</span>\
17945                            </div>\
17946                            ';
17947                        }
17948                        */
17949                        $op.append(s);
17950                        idx++;
17951                    });
17952                    $required.removeClass('option-disabled');
17953                } else if(obj.getAttribute('data-type') == '3') {
17954
17955                    var option_index = obj.getAttribute('data-option-index'),
17956                        selected_index = Number(option_index) + 1,
17957                        $required = quickbasketModal.find('.cl-s-normal-option-selector').eq(selected_index),
17958                        $op = $required.find('.product-option-box'),
17959                        idx = 0;
17960                        $data = (option_index == '0') ? $.quickbasket.data.list.normal[_idx]['value'] : $.quickbasket.data.list.normal[_idx]['value2'];
17961
17962                    if(option_index == '1') {
17963                        var s1 = quickbasketModal.find('.cl-s-normal-option-selector').eq(0).find('.selected-option').attr('data-selected_option'),
17964                            s2 = onlySelectedText,
17965                            result = [];
17966                        $.each($.quickbasket.data.list.normal_org, function(a,b) {
17967                            if(b['option_mix2'] == s1 && b['option_mix3'] == s2) {
17968                                var tmp = b;
17969                                tmp['option_number'] = String(result.length + 1).padStart(2, '0');
17970                                result.push(tmp);
17971                            }
17972                        });
17973
17974                        $data = result;
17975                    }
17976                    // $required.find('.selected-option-text').text('선택');
17977
17978                    $op.empty();
17979                    $.each($data, function(a,b) {
17980                        var div_property = '';
17981                        if(selected_index == '2' && b.soldout) {
17982                        } else {
17983                            div_property += 'onclick="$.quickbasket.pdOptionPick(this, \'' + productPrice + '\')" ';
17984                            // div_property += 'data-status="' + data.option_data.product_state + '" ';
17985                            div_property += 'data-status="normal" data-type="3" ';
17986                            div_property += 'data-idx="' + a + '" ';
17987                            div_property += 'data-option-index="' + selected_index + '" ';
17988                            div_property += 'data-option-price="' + b.option_price + '" ';
17989                        }
17990                        var option_val_arr = b.val.split('||');
17991                        option_val_arr[0] = (selected_index == '2') ? b.option_name : b.option_mix3;
17992                        var option_str = {
17993                            'div_class': (b.soldout) ? 'sold-out' : '',
17994                            'div_property': div_property,
17995                            'span1': (b.soldout) ? '<span class="text-d-lt">' : '',
17996                            'span2': (b.soldout) ? '</span>' : '',
17997                            'seq': 'data-option-seq="'+b.option_seq+'"',
17998                            'soldout': (selected_index == '2' && b.soldout) ? '<label>품절</label>' : '',
17999                            'val' : option_val_arr.join('||'),
18000                        }
18001
18002                        var s = '\
18003                            <div class="' + option_str.div_class + '" data-val="' + option_str.val + '" ' + option_str.div_property + '>\
18004                                ' + option_str.span1 + '\
18005                                    <span class="number">' + b.option_number + '.</span>\
18006                                    <div class="option-name" ' + option_str.seq + '>' + option_val_arr[0] + option_str.soldout + '</div>\
18007                                    <span class="price">' + b.option_price_str + ' 원</span>\
18008                                ' + option_str.span2 + '\
18009                            </div>\
18010                        ';
18011
18012
18013
18014                        // var quantity = ($.quickbasket.data.product_quantity_on == 'on') ? b.option_quantity : 99999,
18015                        //     soldout = (quantity == 0 || b.option_status == 'O') ? true : false,
18016                        //     col = (selected_index == '2') ? b.option_name : b.option_mix3;
18017                        // if(selected_index == '2' && soldout == true) {
18018                        //     var s = '\
18019                        //     <div class="sold-out" data-val="' + b.option_name + '||' + b.option_price + '||0">\
18020                        //         <span class="text-d-lt">\
18021                        //             <span class="number">' + b.option_number + '.</span>\
18022                        //             <div class="option-name" data-option-seq="' + b.option_seq + '">' + col + '<label>품절</label></div>\
18023                        //             <span class="price">' + b.option_price_str + ' 원</span>\
18024                        //         </span>\
18025                        //     </div>\
18026                        //     ';
18027                        // } else {
18028                        //     var s = '\
18029                        //     <div data-val="' + col + '||' + b.option_price + '||' + quantity + '||' + b.option_seq + '" onclick="$.quickbasket.pdOptionPick(this, \'' + productPrice + '\')" data-status="normal" data-idx=' + _idx + ' data-type="3" data-option-index="' + selected_index + '" data-option-price="' + b.option_price + '">\
18030                        //         <span class="number">' + b.option_number + '.</span>\
18031                        //         <div class="option-name" data-option-seq="' + b.option_seq + '">' + col + '</div>\
18032                        //         <span class="price">' + b.option_price_str + ' 원</span>\
18033                        //     </div>\
18034                        //     ';
18035                        // }
18036                        $op.append(s);
18037                        idx++;
18038                    });
18039                    $required.removeClass('option-disabled');
18040                }
18041                
18042                optionAry = (typeof optionSelectedVal !== 'undefined' && optionSelectedVal) ? optionSelectedVal.split('||') : optionAry;
18043                
18044                if (optionType == 'A') {
18045                    optionAry = option.split('||');
18046                }
18047                // var boxOptionName = optionAry[0] ;
18048                if (optionType != 'A') {
18049                    parent.find(".product-option-box").slideToggle(300);
18050
18051                    if (parent.find(".selected-option").hasClass('active') === true) {
18052                        parent.find(".selected-option").removeClass('active');
18053                    } else {
18054                        parent.find(".selected-option").addClass('active');
18055                    }
18056
18057                    return false;
18058                }
18059            } else {
18060                //셀렉트박스 선택
18061                var selectedOptionName = selectedBoxTitle + onlySelectedText + selectedPrice;
18062                if (optionType == null) {
18063                    parent.find('.selected-option-text').text(selectedOptionName);
18064                    parent.find('.selected-option').attr('data-selected_option', onlySelectedText);
18065                    parent.find('.selected-option').attr('data-val', option);
18066                    parent.find('.selected-option').attr('data-status', optionStatus);
18067                }
18068                
18069                option = quickbasketModal.find('.selected-option:not(#selected-delivery-type)').eq(0).attr('data-val'); 
18070                
18071                if(option == undefined || option == '') {
18072                    submit = false;
18073                } else {
18074                    optionAry = option.split('||'); 
18075                    optionStatus =  quickbasketModal.find('#selected-product-option').attr('data-status');
18076                    optionType = quickbasketModal.find('#selected-product-option').attr('data-option_type');
18077                    submit = true;
18078                }
18079            }
18080
18081            if($(obj).parents('.cl-s-option-selector').hasClass('cl-s-normal-option-selector')) {
18082                // 추가된 기본 옵션
18083                $.each(quickbasketModal.find('.selected-option.ex'), function(i,v) {
18084                    var selectedOption = $(this).attr('data-val');
18085                    if(selectedOption == undefined) selectedOption = '';
18086                    var ex_option_arry = selectedOption.split('||');
18087                    if(ex_option_arry[0] !== undefined) {
18088                        if(optionAry[0] !== undefined) optionAry[0]+=' / ' + ex_option_arry[0];
18089                    }
18090                    if(ex_option_arry[1] !== undefined) {
18091                        if(optionAry[1] !== undefined) optionAry[1] = Number(optionAry[1]) + Number(ex_option_arry[1]);
18092                    }
18093                    if(ex_option_arry[2] !== undefined) {
18094                        if(optionAry[2] !== undefined) optionAry[2] = Number(ex_option_arry[2]);
18095                    }
18096                    if(ex_option_arry[3] !== undefined) {
18097                        if($.quickbasket.data.options_type == '1') {
18098                            if(optionAry[3] !== undefined) optionAry[3]+=',' + ex_option_arry[3];
18099                        } else optionAry[3] = ex_option_arry[3];
18100                    }
18101                });
18102            }
18103            
18104            if($(obj).parents('.cl-s-option-selector').hasClass('cl-s-addt-option-selector')) {
18105                var option_title = selectedBoxTitle;
18106                option = $(obj).attr('data-val');
18107                optionType = $(obj).attr('data-option_type');
18108                optionAry = option.split('||');
18109                if(optionAry[0] !== undefined) optionAry[0] = option_title + optionAry[0];
18110                $(obj).parents('.cl-s-option-selector').removeClass('active');
18111            }
18112
18113            //html 생성
18114            var html = $.quickbasket.pdOptionBoxHtml(productPrice, type, optionStatus, optionType == null ? '' : optionType, optionAry, '');
18115            parent.find('.product-option-box').slideToggle(300);
18116
18117            if (parent.find('.selected-option').hasClass('active') === true) parent.find('.selected-option').removeClass('active');
18118            else parent.find('.selected-option').addClass('active');
18119
18120            if(quickbasketModal.find('.cl-s-option-text').length > 0 && optionType != 'A') {
18121                return false;
18122            } else {
18123                quickbasketModal.find('.option-select-box').append(html);
18124                if(quickbasketModal.find('.option-count-box:not(.additional)').length > 0) quickbasketModal.find('.modal-footer .ok-button-dialog').addClass('active');
18125                else quickbasketModal.find('.modal-footer .ok-button-dialog').removeClass('active');
18126            }
18127            
18128            //합계
18129            $.quickbasket.pdTotalPriceUpdate(quickbasketModal);
18130
18131            if (optionStatus === null || optionStatus=='etc') {
18132                var lastBox = quickbasketModal.find('.option-count-box').last();
18133                var totalQuantity = lastBox.find('.total-quantity').val();
18134                var state = quickbasketModal.find('#product_state').val();
18135                var optionSeq = lastBox.find('input[name="option_seq[]"]').val();
18136                var optionName = lastBox.find('input[name="option_name[]"]').val();
18137                var optionStartDate = lastBox.find('input[name="etc_start_date[]"]').val();
18138                var optionCount = quickbasketModal.find('input[name="option_count[]"]');
18139                var optionCountAry = [];
18140                var etcTotalCount = 0;
18141                
18142                if(optionStartDate!==undefined && optionStartDate.length > 0) { 
18143                    var sameOptions = (optionName!='noneOption') ? quickbasketModal.find('input[value="'+optionSeq+'"]').closest('.option-count-box').find('input[name="option_count[]"]') : quickbasketModal.find('input[value="'+optionName+'"]').closest('.option-count-box').find('input[name="option_count[]"]');
18144                    var sameOptionsTotal = sameOptions.find('.total-quantity').val();
18145                    
18146                    sameOptions.each(function(){
18147                        etcTotalCount += Number($(this).val());
18148                    });
18149                    
18150                    if(etcTotalCount > totalQuantity) {
18151                        // alert('재고 수량('+totalQuantity+'개) 이상 구매하실 수 없습니다.');
18152                        $(this).blur();
18153                        $.quickbasket.alertModal('ERROR','재고 수량('+totalQuantity+'개) 이상 구매하실 수 없습니다.','cl-modal-check-quantity');
18154                        lastBox.remove();
18155                    }
18156                    $.quickbasket.pdTotalPriceUpdate(quickbasketModal);
18157                    submit = true;
18158                }
18159            }
18160
18161            if(submit) {
18162                // 옵션 초기화
18163                quickbasketModal.find('.selected-option')
18164                                .attr('data-selected_option','')
18165                                .attr('data-val','')
18166                                .attr('data-status','');
18167                    // .find('.selected-option-text').text('선택');
18168                $.each(quickbasketModal.find('.cl-s-option-selector'), function(i,v) {
18169                    var title = $(this).find('.selected-option-title').text();
18170                    if(title == '') title = '선택';
18171                    $(this).find('.selected-option-text').text(title);
18172                });
18173                $.each(quickbasketModal.find('.cl-s-normal-option-selector'), function(i,v) {
18174                    if(i > 0) $(this).addClass('option-disabled');
18175                });
18176                quickbasketModal.find('#etc-start-date-option, #etc-end-date-option, #etc-time, #etc-start-date-txt, #etc-end-date-txt').val('');
18177                quickbasketModal.find('.selected-option > span').each(function(idx, v){
18178                    if($(v).attr('data-default') !== undefined) {
18179                        $(v).text($(v).attr('data-default'));
18180                    }
18181                });
18182            }
18183
18184
18185            quickbasketModal.find('.option-select-box .box-option-count .plus').off('click').on('click', function(e) {
18186                if($('.cl-modal-check-quantity').length > 0) {
18187                    e.preventDefault(); 
18188                    return false; 
18189                }
18190
18191                var totalQuantity = $(this).closest('.option-count-box').find('.total-quantity').val();
18192                var count = $(this).parent().children('input').val();
18193                var state = quickbasketModal.find('#product_state').val();
18194                var optionSeq = $(this).closest('.option-count-box').find('input[name="option_seq[]"]').val();
18195                var optionName = $(this).closest('.option-count-box').find('input[name="option_name[]"]').val();
18196                var optionStartDate = $(this).closest('.option-count-box').find('input[name="etc_start_date[]"]').val();
18197                var etcTotalCount = 0;
18198
18199                var target = this;
18200                var sameCount = 0;
18201                quickbasketModal.find('input[name="option_seq[]"][value="' + optionSeq + '"]').each(function() {
18202                    if($(this).closest('.option-count-box').has(target).length === 0) {
18203                        sameCount += Number($(this).parent().find('input[name="option_count[]"]').val());
18204                    }
18205                });
18206
18207
18208                if (count > 1000) {
18209                    $(this).blur();
18210                    $.quickbasket.alertModal('ERROR','최대 구매 수량은 1000개 입니다.','cl-modal-check-quantity');
18211                    return false;
18212                }
18213                
18214                count = (count * 1) + 1;
18215
18216                if(optionStartDate!==undefined && optionStartDate.length > 0){
18217                    etcTotalCount = 0;
18218
18219                    var sameOptions = (optionName!='noneOption') ? quickbasketModal.find('input[value="'+optionSeq+'"]').closest('.option-count-box').find('input[name="option_count[]"]') : quickbasketModal.find('input[value="'+optionName+'"]').closest('.option-count-box').find('input[name="option_count[]"]');
18220
18221                    var sameOptionsTotal = sameOptions.find('.total-quantity').val();
18222                    sameOptions.each(function(){
18223                        etcTotalCount += Number($(this).val());
18224                    });
18225
18226                    if(etcTotalCount >= totalQuantity) {
18227                        $(this).blur();
18228                        $.quickbasket.alertModal('ERROR','재고 수량('+totalQuantity+'개) 이상 구매하실 수 없습니다.','cl-modal-check-quantity');
18229                        return false;
18230                    }
18231                }
18232                else {
18233                    if(count + sameCount > totalQuantity) {
18234                        $(this).blur();
18235                        $.quickbasket.alertModal('ERROR','재고 수량('+totalQuantity+'개) 이상 구매하실 수 없습니다.','cl-modal-check-quantity');
18236                        count = totalQuantity - sameCount;
18237                    }
18238                }
18239
18240
18241                $(this).parent().children('input').val(count);
18242                $.quickbasket.pdTotalPriceUpdate(quickbasketModal);
18243            });
18244            quickbasketModal.find('.option-select-box .box-option-count .min').off('click').on('click', function(e) {
18245                if($('.cl-modal-check-quantity').length > 0) {
18246                    e.preventDefault(); 
18247                    return false; 
18248                }
18249
18250                var count = $(this).parent().children('input').val();
18251                count = (count * 1) - 1;
18252
18253                if (count < 1) {
18254                    $(this).blur();
18255                    $.quickbasket.alertModal('ERROR','최소 구매 수량은 1개 입니다.','cl-modal-check-quantity');
18256                    e.preventDefault(); 
18257                    return false;
18258                }
18259
18260                $(this).parent().children('input').val(count);
18261                $.quickbasket.pdTotalPriceUpdate(quickbasketModal);
18262            });
18263
18264            quickbasketModal.find('.option-normal-price').off('keyup.quickbasketQty blur.quickbasketQty').on('keyup.quickbasketQty blur.quickbasketQty', function(e) {
18265                if (e.keyCode == 13 || $('.cl-modal-check-quantity').length > 0) { 
18266                    e.preventDefault(); 
18267                    return false; 
18268                }
18269
18270                var totalQuantity = $(this).closest('.option-count-box').find('.total-quantity').val(),
18271                    cnt = $(this).val();
18272                var state = quickbasketModal.find('#product_state').val();
18273                var optionSeq = $(this).closest('.option-count-box').find('input[name="option_seq[]"]').val();
18274                var optionName = $(this).closest('.option-count-box').find('input[name="option_name[]"]').val();
18275                var optionStartDate = $(this).closest('.option-count-box').find('input[name="etc_start_date[]"]').val();
18276                var etcTotalCount = 0;
18277                
18278                cnt = (cnt) ? Number(cnt.replace(/[^0-9\.]/g,'')) : '';
18279                if (!cnt) {
18280                    // if(e.type == 'blur') {
18281                    //     $.quickbasket.alertModal('ERROR','최소 구매 수량은 1개 입니다.','cl-modal-check-quantity');
18282                    //     return false;
18283                    // } else {
18284                    //     return false;
18285                    // }
18286                    e.preventDefault(); 
18287                    return false;
18288                }
18289                $(this).val(cnt);
18290                
18291                if(cnt < 1) {
18292                    $.quickbasket.alertModal('ERROR','최소 구매 수량은 1개 입니다.','cl-modal-check-quantity');
18293                    $(this).val(1);
18294                    return false;
18295                }
18296                if(totalQuantity==99999 && cnt > 1000) {
18297                    $.quickbasket.alertModal('ERROR','최대 구매 수량은 1000개 입니다.','cl-modal-check-quantity');
18298                    cnt = 1000;
18299                    $(this).val(cnt);
18300                    return false;
18301                }
18302
18303                var target = this;
18304                var sameCount = 0;
18305                quickbasketModal.find('input[name="option_seq[]"][value="' + optionSeq + '"]').each(function() {
18306                    if($(this).closest('.option-count-box').has(target).length === 0) {
18307                        sameCount += Number($(this).parent().find('input[name="option_count[]"]').val());
18308                    }
18309                });
18310
18311                cnt += sameCount;
18312
18313                if(optionStartDate!==undefined && optionStartDate.length > 0){
18314                    etcTotalCount = 0;
18315
18316                    var sameOptions = (optionName!='noneOption')? quickbasketModal.find('input[value="'+optionSeq+'"]').closest('.option-count-box').find('input[name="option_count[]"]') : quickbasketModal.find('input[value="'+optionName+'"]').closest('.option-count-box').find('input[name="option_count[]"]');
18317
18318                    var sameOptionsTotal = sameOptions.find('.total-quantity').val();
18319                    sameOptions.each(function(){
18320                        etcTotalCount += Number($(this).val());
18321                    });
18322
18323                    if(etcTotalCount > totalQuantity) {
18324                        var $this = $(this).val();
18325                        $(this).blur();
18326                        $.quickbasket.alertModal('ERROR','재고 수량('+totalQuantity+'개) 이상 구매하실 수 없습니다.','cl-modal-check-quantity');
18327                        $(this).val($this-(etcTotalCount-totalQuantity));
18328                        return false;
18329                    }
18330                    
18331                }
18332                else {
18333                    if(cnt > totalQuantity) {
18334                        $(this).blur();
18335                        $.quickbasket.alertModal('ERROR','재고 수량('+totalQuantity+'개) 이상 구매하실 수 없습니다.','cl-modal-check-quantity');
18336                        $(this).val(totalQuantity - sameCount);
18337                        return false;
18338                    }
18339                }
18340
18341                $.quickbasket.pdTotalPriceUpdate(quickbasketModal);
18342            });
18343
18344            quickbasketModal.find('.option-select-box .box-delete').off('click').on('click', function(e) {
18345                var optionCountBox = $(this).closest('.option-count-box'),
18346                    optionName = optionCountBox.find('input[name="option_name[]"]').val();
18347
18348                if(optionName == 'noneOption') {
18349                    if(quickbasketModal.find('.cl-s-option-text').length > 0) {
18350                        quickbasketModal.find('.cl-s-option-text > input').prop('readonly', false);
18351                        optionCountBox.find('input[name="option_text[]"]').val('');
18352                    }
18353                }
18354                optionCountBox.remove();
18355                if(quickbasketModal.find('.option-count-box:not(.additional)').length > 0) quickbasketModal.find('.modal-footer .ok-button-dialog').addClass('active');
18356                else quickbasketModal.find('.modal-footer .ok-button-dialog').removeClass('active');
18357                
18358                $.quickbasket.pdTotalPriceUpdate(quickbasketModal);
18359            });
18360        },
18361        pdTextOptionPick: function (pickBtn, productPrice, type, options_type) {
18362            // console.log('pdTextOptionPick() ----------------------------------------------');
18363
18364            var type = (typeof type == 'undefined') ? '' : type,
18365                pickOption = document.querySelector('#selected-product-option'),
18366                option = (pickOption !== null) ? pickOption.getAttribute('data-val') : '',
18367                optionAry = (pickOption !== null) ? option.split('||') : [],
18368                optionStatus = (pickOption !== null) ? pickOption.getAttribute('data-status') : $(pickBtn).closest('.cl-s-option-text').attr('data-status'),
18369                optionType = (pickOption !== null) ? pickOption.getAttribute('data-option_type') : type;
18370
18371            if(optionType == null) optionType = '';
18372                // _idx = obj.getAttribute('data-idx'),
18373            var stock = optionAry[2],
18374                cnt = 0,
18375                total = 0,
18376                totalCnt = 1,
18377                // dateCheckCnt = 1,
18378                // submit = false,
18379                // reSelected = false,
18380                quickbasketModal = $(pickBtn).closest('.cl-quickbasket-modal'),
18381                parent = $(pickBtn).closest('.cl-s-text-option-selector'),
18382                textParent = parent.find('.text-option-box'),
18383                textOptionT = quickbasketModal.find('.cl-s-option-text input[data-option_type="T"], .cl-s-option-text input[data-option_type="TR"]'),
18384                textOptionTarr = [];
18385                // selectedBoxTitle = parent.find('.selected-option-title').text(),
18386                // selectedPrice = $(obj).attr('data-option-price'),
18387                // onlySelectedText = $(obj).find('.option-name').text();
18388
18389            // if(selectedOption !== null && typeof obj.getAttribute('data-option_type') != 'undefined') optionType = obj.getAttribute('data-option_type');
18390            quickbasketModal.find('input[name="option_seq[]"][value="' + optionAry[3] + '"]').each(function() {
18391                if(textParent.find('input[name="product_state"]').val() == 'download') cnt += 1;
18392                else cnt += Number($(this).parent().find('input[name="option_count[]"]').val());
18393            });
18394
18395            if(cnt + 1 > stock) {
18396                $(this).blur();
18397                $.quickbasket.alertModal('ERROR','재고 수량('+stock+'개) 이상 구매하실 수 없습니다.','cl-modal-check-quantity');
18398                return false;
18399            }
18400
18401            // 추가된 기본 옵션
18402            $.each(quickbasketModal.find('.selected-option.ex'), function(i,v) {
18403                var ex_option_arry = $(this).attr('data-val').split('||');
18404                if(ex_option_arry[0] !== undefined) {
18405                    if(optionAry[0] !== undefined) optionAry[0]+=' / ' + ex_option_arry[0];
18406                }
18407                if(ex_option_arry[1] !== undefined) {
18408                    if(optionAry[1] !== undefined) optionAry[1] = Number(optionAry[1]) + Number(ex_option_arry[1]);
18409                }
18410                if(ex_option_arry[3] !== undefined) {
18411                    if($.quickbasket.data.options_type == '1') {
18412                        if(optionAry[3] !== undefined) optionAry[3]+=',' + ex_option_arry[3];
18413                    } else optionAry[3] = ex_option_arry[3];
18414                }
18415            });
18416
18417            if(options_type == 2 || options_type == 3) {
18418                var md5 = clmd5.hex_md5(optionAry[0]);
18419                if($.quickbasket.data.list.normal_md5.hasOwnProperty(md5)) {
18420                    var selected = $.quickbasket.data.list.normal_md5[md5];
18421                    optionAry[1] = selected['option_price'];
18422                    optionAry[2] = (optionAry[2] == '99999') ? '99999' : selected['option_quantity'];
18423                    optionAry[3] = selected['option_seq'];
18424                } else {
18425                    alert('옵션 선택에 오류입니다.\n 관리자에게 문의하세요');
18426                }
18427            }
18428
18429            var flag;
18430            textOptionT.each(function(){
18431                if(checkEmojis($(this).val())) {
18432                    alert('이모지를 사용할 수 없습니다.');
18433                    flag = false;
18434                    return false;
18435                }
18436            });
18437
18438            if(flag == false) {
18439                return false;
18440            }
18441
18442            textOptionT.each(function(){
18443                if($(this).val() != "") {
18444                    var objKey = $(this).attr('data-val');
18445                    var textTempObj = {};
18446                    textTempObj[$(this).attr('data-val')] = $(this).val().trim();
18447                    textOptionTarr.push(textTempObj);
18448                }
18449            });
18450
18451            var textOption = '';
18452            if(textOptionT.length == textOptionTarr.length) {
18453                textOption = strReplace(JSON.stringify(textOptionTarr), '"', '&quot;'); //JSON
18454            } else {
18455                alert('필수 입력옵션을 모두 입력해주세요.');
18456                return false;
18457            }
18458
18459            // 일반옵션 없을때 처리
18460            if(optionAry[0] == ' / noneOption') {
18461                optionAry[0] = optionAry[0].replace(' / noneOption','');
18462            }
18463
18464            var html = $.quickbasket.pdOptionBoxHtml(productPrice, type, optionStatus, optionType, optionAry, textOption, textOptionTarr);
18465            quickbasketModal.find('.option-select-box').append(html);
18466            
18467            if(quickbasketModal.find('.option-count-box:not(.additional)').length > 0) quickbasketModal.find('.modal-footer .ok-button-dialog').addClass('active');
18468            else quickbasketModal.find('.modal-footer .ok-button-dialog').removeClass('active');
18469            $.quickbasket.pdTotalPriceUpdate(quickbasketModal);
18470
18471            if(quickbasketModal.find('.cl-s-normal-option-selector').length > 0 || quickbasketModal.find('.cl-s-option-date-selector').length > 0) textParent.find('input').val('').prop('readonly', true);
18472            else textParent.find('input').val('');
18473
18474            quickbasketModal.find('#selected-product-option .selected-option-text').text('선택');
18475            quickbasketModal.find('#selected-product-option').attr('data-selected_option', '');
18476            quickbasketModal.find('#selected-product-option').attr('data-val', '');
18477            quickbasketModal.find('#selected-product-option').attr('data-status', '');
18478            $(pickBtn).addClass('disabled');
18479
18480            // 추가된 기본 옵션 처리
18481            quickbasketModal.find('.selected-option.ex').attr('data-selected_option', '');
18482            quickbasketModal.find('.selected-option.ex').attr('data-val', '');
18483            quickbasketModal.find('.selected-option.ex').attr('data-status', '');
18484            quickbasketModal.find('.selected-option.ex').parents('.cl-s-option-selector').addClass('option-disabled');
18485
18486            quickbasketModal.find('#etc-start-date-option, #etc-end-date-option, #etc-time, #etc-start-date-txt, #etc-end-date-txt').val('');
18487            quickbasketModal.find('.selected-option > span').each(function(idx, v){
18488                if($(v).attr('data-default') !== undefined) {
18489                    $(v).text($(v).attr('data-default'));
18490                }
18491            });
18492
18493            // $.quickbasket.pdOptionPick(this, \'' + data.option_data.product_price + '\')
18494
18495
18496            quickbasketModal.find('.option-select-box .box-option-count .plus').off('click').on('click', function(e) {
18497                if($('.cl-modal-check-quantity').length > 0) {
18498                    e.preventDefault(); 
18499                    return false; 
18500                }
18501
18502                var totalQuantity = $(this).closest('.option-count-box').find('.total-quantity').val();
18503                var count = $(this).parent().children('input').val();
18504                var state = quickbasketModal.find('#product_state').val();
18505                var optionSeq = $(this).closest('.option-count-box').find('input[name="option_seq[]"]').val();
18506                var optionName = $(this).closest('.option-count-box').find('input[name="option_name[]"]').val();
18507                var optionStartDate = $(this).closest('.option-count-box').find('input[name="etc_start_date[]"]').val();
18508                var etcTotalCount = 0;
18509
18510                var target = this;
18511                var sameCount = 0;
18512                quickbasketModal.find('input[name="option_seq[]"][value="' + optionSeq + '"]').each(function() {
18513                    if($(this).closest('.option-count-box').has(target).length === 0) {
18514                        sameCount += Number($(this).parent().find('input[name="option_count[]"]').val());
18515                    }
18516                });
18517
18518
18519                if (count > 1000) {
18520                    // alert('최대 구매 수량은 1000개 입니다.');
18521                    $(this).blur();
18522                    $.quickbasket.alertModal('ERROR','최대 구매 수량은 1000개 입니다.','cl-modal-check-quantity');
18523                    return false;
18524                }
18525                
18526                count = (count * 1) + 1;
18527
18528                if(optionStartDate!==undefined && optionStartDate.length > 0){
18529                    etcTotalCount = 0;
18530
18531                    var sameOptions = (optionName!='noneOption') ? quickbasketModal.find('input[value="'+optionSeq+'"]').closest('.option-count-box').find('input[name="option_count[]"]') : quickbasketModal.find('input[value="'+optionName+'"]').closest('.option-count-box').find('input[name="option_count[]"]');
18532
18533                    var sameOptionsTotal = sameOptions.find('.total-quantity').val();
18534                    sameOptions.each(function(){
18535                        etcTotalCount += Number($(this).val());
18536                    });
18537
18538                    if(etcTotalCount >= totalQuantity) {
18539                        // alert('재고 수량('+totalQuantity+'개) 이상 구매하실 수 없습니다.');
18540                        $(this).blur();
18541                        $.quickbasket.alertModal('ERROR','재고 수량('+totalQuantity+'개) 이상 구매하실 수 없습니다.','cl-modal-check-quantity');
18542                        return false;
18543                    }
18544                }
18545                else {
18546                    if(count + sameCount > totalQuantity) {
18547                        // alert('재고 수량('+totalQuantity+'개) 이상 구매하실 수 없습니다.');
18548                        $(this).blur();
18549                        $.quickbasket.alertModal('ERROR','재고 수량('+totalQuantity+'개) 이상 구매하실 수 없습니다.','cl-modal-check-quantity');
18550                        count = totalQuantity - sameCount;
18551                    }
18552                }
18553
18554
18555                $(this).parent().children('input').val(count);
18556                $.quickbasket.pdTotalPriceUpdate(quickbasketModal);
18557            });
18558            quickbasketModal.find('.option-select-box .box-option-count .min').off('click').on('click', function(e) {
18559                if($('.cl-modal-check-quantity').length > 0) {
18560                    e.preventDefault(); 
18561                    return false; 
18562                }
18563
18564                var count = $(this).parent().children('input').val();
18565                count = (count * 1) - 1;
18566
18567                if (count < 1) {
18568                    $(this).blur();
18569                    $.quickbasket.alertModal('ERROR','최소 구매 수량은 1개 입니다.','cl-modal-check-quantity');
18570                    return false;
18571                }
18572
18573                $(this).parent().children('input').val(count);
18574                $.quickbasket.pdTotalPriceUpdate(quickbasketModal);
18575            });
18576            quickbasketModal.find('.option-normal-price').off('keyup.quickbasketQty blur.quickbasketQty').on('keyup.quickbasketQty blur.quickbasketQty', function(e) {
18577                if (e.keyCode == 13 || $('.cl-modal-check-quantity').length > 0) { 
18578                    e.preventDefault(); 
18579                    return false; 
18580                }
18581
18582                var totalQuantity = $(this).closest('.option-count-box').find('.total-quantity').val(),
18583                    cnt = $(this).val();
18584                var state = quickbasketModal.find('#product_state').val();
18585                var optionSeq = $(this).closest('.option-count-box').find('input[name="option_seq[]"]').val();
18586                var optionName = $(this).closest('.option-count-box').find('input[name="option_name[]"]').val();
18587                var optionStartDate = $(this).closest('.option-count-box').find('input[name="etc_start_date[]"]').val();
18588                var etcTotalCount = 0;
18589
18590                cnt = (cnt) ? Number(cnt.replace(/[^0-9\.]/g,'')) : '';
18591                if (!cnt) {
18592                    // if(e.type == 'blur') {
18593                    //     $.quickbasket.alertModal('ERROR','최소 구매 수량은 1개 입니다.','cl-modal-check-quantity');
18594                    //     return false;
18595                    // } else {
18596                    //     return false;
18597                    // }
18598                    e.preventDefault(); 
18599                    return false;
18600                }
18601                $(this).val(cnt);
18602                
18603                if(cnt < 1) {
18604                    $.quickbasket.alertModal('ERROR','최소 구매 수량은 1개 입니다.','cl-modal-check-quantity');
18605                    $(this).val(1);
18606                    return false;
18607                }
18608                if(totalQuantity==99999 && cnt > 1000) {
18609                    $.quickbasket.alertModal('ERROR','최대 구매 수량은 1000개 입니다.','cl-modal-check-quantity');
18610                    cnt = 1000;
18611                    $(this).val(cnt);
18612                    return false;
18613                }
18614
18615                var target = this;
18616                var sameCount = 0;
18617                quickbasketModal.find('input[name="option_seq[]"][value="' + optionSeq + '"]').each(function() {
18618                    if($(this).closest('.option-count-box').has(target).length === 0) {
18619                        sameCount += Number($(this).parent().find('input[name="option_count[]"]').val());
18620                    }
18621                });
18622
18623                cnt += sameCount;
18624
18625                if(optionStartDate!==undefined && optionStartDate.length > 0){
18626                    etcTotalCount = 0;
18627
18628                    var sameOptions = (optionName!='noneOption')? quickbasketModal.find('input[value="'+optionSeq+'"]').closest('.option-count-box').find('input[name="option_count[]"]') : quickbasketModal.find('input[value="'+optionName+'"]').closest('.option-count-box').find('input[name="option_count[]"]');
18629
18630                    var sameOptionsTotal = sameOptions.find('.total-quantity').val();
18631                    sameOptions.each(function(){
18632                        etcTotalCount += Number($(this).val());
18633                    });
18634
18635                    if(etcTotalCount > totalQuantity) {
18636                        var $this = $(this).val();
18637                        $(this).blur();
18638                        $.quickbasket.alertModal('ERROR','재고 수량('+totalQuantity+'개) 이상 구매하실 수 없습니다.','cl-modal-check-quantity');
18639                        $(this).val($this-(etcTotalCount-totalQuantity));
18640                        return false;
18641                    }
18642                    
18643                }
18644                else {
18645                    if(cnt > totalQuantity) {
18646                        $(this).blur();
18647                        $.quickbasket.alertModal('ERROR','재고 수량('+totalQuantity+'개) 이상 구매하실 수 없습니다.','cl-modal-check-quantity');
18648                        $(this).val(totalQuantity - sameCount);
18649                        return false;
18650                    }
18651                }
18652
18653                $.quickbasket.pdTotalPriceUpdate(quickbasketModal);
18654            });
18655            quickbasketModal.find('.option-select-box .box-delete').off('click').on('click', function(e) {
18656                var optionCountBox = $(this).closest('.option-count-box');
18657                var optionName = optionCountBox.find('input[name="option_name[]"]').val();
18658                if(optionName == 'noneOption') {
18659                    if(quickbasketModal.find('.cl-s-option-text').length > 0) {
18660                        quickbasketModal.find('.cl-s-option-text > input').prop('readonly', false);
18661                        optionCountBox.find('input[name="option_text[]"]').val('');
18662                    }
18663                }
18664                $(this).closest('.option-count-box').remove();
18665                if(quickbasketModal.find('.option-count-box:not(.additional)').length > 0) quickbasketModal.find('.modal-footer .ok-button-dialog').addClass('active');
18666                else quickbasketModal.find('.modal-footer .ok-button-dialog').removeClass('active');
18667                $.quickbasket.pdTotalPriceUpdate(quickbasketModal);
18668            });
18669        },
18670        pdTotalPriceUpdate: function (modal) {
18671            var $modal = (modal && $(modal).length) ? $(modal).closest('.cl-quickbasket-modal') : $('.cl-quickbasket-modal:visible').last();
18672            if(!$modal.length) {
18673                $modal = $('.cl-quickbasket-modal').last();
18674            }
18675            var total_price = 0,
18676                total_cnt = 0,
18677                total_grade_discount = 0,
18678                normal_rows = [],
18679                additional_rows = [],
18680                umgrade = (typeof property != 'undefined' && property.UMGRADE) ? property.UMGRADE : null,
18681                discount_use = umgrade ? String(umgrade.discount_use || '0') : '0',
18682                discount_amount = umgrade ? Number(umgrade.discount_amount || 0) : 0,
18683                discount_type = umgrade ? String(umgrade.discount_type || '0') : '0',
18684                discount_value = umgrade ? Number(umgrade.discount_value || 0) : 0,
18685                discount_max = umgrade ? Number(umgrade.discount_max || 0) : 0,
18686                grade_onoff = ($.quickbasket.data && $.quickbasket.data.grade_onoff) ? $.quickbasket.data.grade_onoff : '';
18687            $modal.find('.option-select-box').find('.option-count-box:not(.additional)').each(function() {
18688                var unti_price = $(this).find('input[name="option_price[]"]').val(),
18689                    cnt = $(this).find('.option-normal-price').val(),
18690                    price = (Number(unti_price) * Number(cnt)),
18691                    display_price = price,
18692                    option_type = $(this).find('input[name="option_type[]"]').val(),
18693                    discount_amt = 0;
18694
18695                normal_rows.push({
18696                    $el: $(this),
18697                    price: price,
18698                    option_type: option_type
18699                });
18700
18701                total_price += price;
18702                total_cnt += Number(cnt);
18703                if (discount_amt > 0) {
18704                    $(this).find('.box-option-price').html(
18705                        '<div class="option-price-original-row" style="font-size:12px; color:#999; text-decoration:line-through; line-height:1.2; margin-bottom:4px;">' +
18706                            '<span class="option-price-original">' + number_format(price) + '</span>원' +
18707                        '</div>' +
18708                        '<div class="option-price-current-row" style="line-height:1.2;">' +
18709                            '<span class="option-price">' + number_format(display_price) + '</span>원' +
18710                        '</div>'
18711                    );
18712                } else {
18713                    $(this).find('.box-option-price').html(
18714                        '<div class="option-price-current-row" style="line-height:1.2;">' +
18715                            '<span class="option-price">' + number_format(display_price) + '</span>원' +
18716                        '</div>'
18717                    );
18718                }
18719            });
18720
18721            
18722            $modal.find('.option-select-box').find('.option-count-box.additional').each(function() {
18723                var unti_price = $(this).find('input[name="option_price[]"]').val(),
18724                    cnt = $(this).find('.option-normal-price').val(),
18725                    price = (Number(unti_price) * Number(cnt));
18726
18727                additional_rows.push({
18728                    $el: $(this),
18729                    price: price
18730                });
18731
18732                total_price += price;
18733                total_cnt += Number(cnt);
18734
18735                $(this).find('.box-option-price').html(
18736                    '<div class="option-price-current-row" style="line-height:1.2;">' +
18737                        '<span class="option-price">' + number_format(price) + '</span>원' +
18738                    '</div>'
18739                );
18740            });
18741
18742            if (
18743                discount_use === '1' &&
18744                grade_onoff === 'ON' &&
18745                discount_value > 0
18746            ) {
18747                var additional_total_price = 0;
18748                $.each(additional_rows, function(_, row) {
18749                    additional_total_price += row.price;
18750                });
18751                $.each(normal_rows, function(index, row) {
18752                    var grade_discount_base_price = row.price + (index === 0 ? additional_total_price : 0),
18753                        row_discount = 0;
18754
18755                    if(grade_discount_base_price < discount_amount) return;
18756
18757                    if (discount_type === '0') {
18758                        row_discount = Math.floor(grade_discount_base_price * (discount_value / 100.0));
18759                        if (discount_max > 0 && row_discount > discount_max) {
18760                            row_discount = discount_max;
18761                        }
18762                    } else {
18763                        row_discount = discount_value;
18764                    }
18765                    if (row_discount > grade_discount_base_price) row_discount = grade_discount_base_price;
18766                    if (row_discount < 0) row_discount = 0;
18767                    total_grade_discount += row_discount;
18768                });
18769            }
18770            total_price -= total_grade_discount;
18771
18772            var $totalBox = $modal.find('.total-price-box').first();
18773            $totalBox.find('.panel-grade-price-row').remove();
18774            if (total_grade_discount > 0) {
18775                $totalBox.prepend(
18776                    '<div class="panel-grade-price-row" style="display:flex; justify-content:space-between; align-items:center; width:100%; margin-bottom:8px;">' +
18777                        '<span class="panel-total-title">등급할인 금액</span>' +
18778                        '<span class="panel-grade-price" style="font-size:16px; font-weight:bold; color:#ee445f;">-<span class="grade-price-total">0</span>원</span>' +
18779                    '</div>'
18780                );
18781                $totalBox.find('.grade-price-total').text(number_format(total_grade_discount));
18782            }
18783            $totalBox.find('.total-price').text(number_format(total_price));
18784            $totalBox.find('.total-cnt').text(total_cnt);
18785        },
18786        setKeepShopping : function(sid,page,pid,pnum) {
18787            if(typeof sid == 'undefined') sid = RENDER.b.SID;
18788            if(typeof page == 'undefined') page = (RENDER.b.VIEW) ? RENDER.b.PARENT.ppage : RENDER.b.PAGE;
18789            if(typeof pid == 'undefined') pid = (RENDER.b.VIEW) ? RENDER.b.PARENT.pid : '';
18790            if(typeof pnum == 'undefined') pnum = (RENDER.b.VIEW) ? RENDER.b.PARENT.seq : '';
18791
18792            var cookie_g = $.cookie('gallery'),
18793                cookie_keepsh = [];
18794            if(typeof cookie_g != 'undefined' && cookie_g) {
18795                cookie_keepsh = [page,cookie_g,$.cookie('loadmore-'+cookie_g),$.cookie('gallery-category-'+cookie_g),$.cookie('gallery-orderby-'+cookie_g),$.cookie('gallery-item')];
18796            } else {
18797                if(pid && pnum) cookie_keepsh = [page,pid,'1','','recent',pnum];
18798            }
18799
18800            if(cookie_keepsh.length > 0) $.cookie('keep-shopping-'+sid, cookie_keepsh.toString(), { path : '/', expires: new Date(Date.now() + 1000*60*60*3) });
18801        },
18802    }
18803
18804    $.products = {
18805        init : function() {
18806            $.category.init();
18807            var isMainImageClick = false, idx = -1, replace = false;
18808            $(document)
18809            .off('click', '.cl-p-modal')
18810            .on('click', '.cl-p-modal', function(e) {
18811                if($('#prod-category-lists').css('display') == 'block') {
18812                    $('.category-lists').slideUp(200, function() {
18813                        $('.category-wrap').removeClass('open');    
18814                    });
18815                }
18816                $('.option-price-status-select').slideUp(200, function() {
18817                    $('.option-price-status-str').removeClass('open');    
18818                });
18819                if($('.gallery-menus-wrap').css('display') == 'block') {
18820                    $('.choose-gallery').removeClass('open');
18821                    $('.gallery-menus-wrap').hide();
18822                }
18823            });
18824
18825            $(document)
18826            .off('click','.form-label.textarea')
18827            .on('click','.form-label.textarea', function() { $('#prod-desc').focus(); });
18828            $(document)
18829            .off('click','.prod-modal .modal-close')
18830            .on('click','.prod-modal .modal-close', function() { $.products.close(); });
18831
18832            $(document)
18833            .off('keydown, keyup', '#prod-desc')
18834            .on('keydown, keyup', '#prod-desc', function(){
18835                $('#prod-desc')[0].style.height = 'auto';
18836                var descHeight = $('#prod-desc').prop('scrollHeight');
18837                if(descHeight > 55) {
18838                    $('#prod-desc').css('height', descHeight+'px');
18839                }
18840
18841                //size check
18842                var value = $(this).val();        
18843                if(value.length > 255){
18844                    $(this).val(value.substr(0,255).trim());
18845                }
18846            });
18847
18848            $(document)
18849            .off('change','.switch-product')
18850            .on('change','.switch-product', function() {
18851                $('.switch-product + label').removeClass('active');
18852                if($(this).val() == 'off') {
18853                    $('#status-append').fadeOut(0);
18854                    $('#sale-calendar').hide();
18855                } else {
18856                    var check = $('input[name="product_state"]:checked').val();
18857                    var a = 0;
18858
18859                    if ($('#none-option-file').length > 0) {
18860                        var fileBoxCnt = $('.file-box-list').length;
18861                        $('.file-box-list').each(function (idx, v) {
18862                            var downloadCnt = $(v).find('.file-name').length;
18863                            if (fileBoxCnt > 1) {
18864                                if (a == 0) a++;
18865                                else {
18866                                    if (check == 'D' && downloadCnt == 0) {
18867                                        alert('다운로드 상품일 경우 파일이 1개 이상 등록되어 있어야 합니다.');
18868                                        $('.switch-product[value="off"]').prop('checked', true);
18869                                        $('#status-append').fadeOut(0);
18870                                        $('#sale-calendar').hide();
18871                                        a++;
18872                                        return false;
18873                                    }
18874                                }
18875                            } else {
18876                                if (check == 'D' && downloadCnt == 0) {
18877                                    alert('다운로드 상품일 경우 파일이 1개 이상 등록되어 있어야 합니다.');
18878                                    $('.switch-product[value="off"]').prop('checked', true);
18879                                    $('#status-append').fadeOut(0);
18880                                    $('#sale-calendar').hide();
18881                                    a += 2;
18882                                    return false;
18883                                }
18884                            }
18885                        });
18886                        if (a <= 1) {
18887                            $(this).prop('checked', true);
18888                        }
18889                    } else {
18890                        $(this).prop('checked', true);
18891                    }
18892
18893                    if(a <= 1) {
18894                        if($(this).val() == 'lim') {
18895                            $('#status-append').fadeIn(0);
18896                            $('#sale-calendar').show();
18897                        } else {
18898                            $('#status-append').fadeOut(0);
18899                            $('#sale-calendar').hide();
18900                        }
18901                    }
18902                }
18903            });
18904            $(document)
18905            .off('change','.switch-quantity')
18906            .on('change','.switch-quantity', function() { //재고관리 on
18907                switchQuantity();
18908            });
18909            $(document)
18910            .off('input.productQuantityLimit', '#prod-quantity')
18911            .on('input.productQuantityLimit', '#prod-quantity', function() {
18912                var quantity = Number(removeCommas($(this).val()));
18913                if(quantity > 9999) {
18914                    alert('최대 입력 수량은 9,999 입니다.');
18915                    $(this).val(addCommas('9999'));
18916                }
18917            })
18918            .off('keydown.productQuantityLimit', '#prod-quantity')
18919            .on('keydown.productQuantityLimit', '#prod-quantity', function(e) {
18920                var is_number_key = (e.keyCode >= 48 && e.keyCode <= 57) || (e.keyCode >= 96 && e.keyCode <= 105);
18921                var value = String(removeCommas($(this).val()));
18922                var has_selection = this.selectionStart !== this.selectionEnd;
18923
18924                if(is_number_key && !e.ctrlKey && !e.metaKey && !e.altKey && !e.shiftKey && value.length >= 4 && !has_selection) {
18925                    e.preventDefault();
18926                    alert('최대 입력 수량은 9,999 입니다.');
18927                    $(this).val(addCommas('9999'));
18928                }
18929            })
18930            .off('paste.productQuantityLimit', '#prod-quantity')
18931            .on('paste.productQuantityLimit', '#prod-quantity', function(e) {
18932                var clipboard = e.originalEvent && e.originalEvent.clipboardData;
18933                var value = clipboard ? clipboard.getData('text').replace(/[^0-9]/g, '') 
18933: '';
18934                var current_value = String(removeCommas($(this).val()));
18935                var selected_value = $(this).val().substring(this.selectionStart, this.selectionEnd).replace(/[^0-9]/g, '');
18936                var result_length = current_value.length - selected_value.length + value.length;
18937
18938                if(value !== '' && result_length > 4) {
18939                    e.preventDefault();
18940                    alert('최대 입력 수량은 9,999 입니다.');
18941                    $(this).val(addCommas('9999'));
18942                }
18943            });
18944            $(document)
18945            .off('click','.switch-category')
18946            .on('click','.switch-category', function() {
18947                if($(this).is(':checked')) {
18948                    $(this).parents('.form-wrap').removeClass('disabled');
18949                    $(this).parents('.form-wrap').find('.category-text').removeClass('hide');
18950                } else {
18951                    $(this).parents('.form-wrap').addClass('disabled');
18952                    $(this).parents('.form-wrap').find('.category-text').addClass('hide');
18953                    $('.category-lists').slideUp(200, function() {
18954                        $('.category-wrap').removeClass('open');    
18955                    });                    
18956                }
18957            });
18958            $(document)
18959            .off('change','.switch-text-option')
18960            .on('change','.switch-text-option', function() {
18961                if($(this).is(':checked')) {
18962                    $(this).parents('.form-wrap').removeClass('disabled');
18963                    $(this).parents('.form-wrap').find('#text-option-name').removeClass('hide');
18964                } else {
18965                    $(this).parents('.form-wrap').addClass('disabled');
18966                    $(this).parents('.form-wrap').find('#text-option-name').addClass('hide');
18967                }
18968            });
18969
18970            $(document)
18971            .off('click','.switch-prod-info')
18972            .on('click','.switch-prod-info', function() {
18973                if($(this).is(':checked')) {
18974                    $(this).parents('.form-wrap').removeClass('disabled');
18975                    $(this).parents('.form-wrap').find('.info-selected').removeClass('hide');
18976                } else {
18977                    $(this).parents('.form-wrap').addClass('disabled');
18978                    $(this).parents('.form-wrap').find('.info-selected').addClass('hide');
18979
18980                }
18981            });
18982
18983            $(document)
18984            .off('click','.switch-mngprd')
18985            .on('click','.switch-mngprd', function() {
18986                if($(this).is(':checked')) {
18987                    $('#mng-prd-info').removeClass('disabled');
18988                    $(this).parents('.mng-prd-wrap').find('.mng-prd-info-toggle').removeClass('hide');
18989                } else {
18990                    $('#mng-prd-info').addClass('disabled');
18991                    $(this).parents('.mng-prd-wrap').find('.mng-prd-info-toggle').addClass('hide');
18992                }
18993            });
18994
18995            $(document)
18996            .off('click', '.prod-discount-unit-select:not(.disabled)')
18997            .on('click', '.prod-discount-unit-select:not(.disabled)', function(e) {
18998                $(this).find('.discount-unit-select').toggle();
18999            });
19000
19001            $(document)
19002            .off('click', '.discount-unit-select > div')
19003            .on('click','.discount-unit-select > div', function(e) {
19004                var val = $(this).attr('data-value');
19005                var unitStr = $(this).text();
19006
19007                $('#prod-discount-unit').attr('data-value', val).text(unitStr);
19008
19009                if(val == 'P') {
19010                    var discountRate = Number($('#prod-discount-rate').val().replace(/,/g, ''));
19011                    if(discountRate > 100) discountRate = 100;
19012                    $('#prod-discount-rate').val(discountRate);
19013                    // $('#price-cut-btn').removeClass('hide');
19014                } else {
19015                    var discountRate = removeCommas($('#prod-discount-rate').val());
19016                    $('#prod-discount-rate').val(number_format(discountRate));
19017                    // $('#price-cut-btn').addClass('hide');
19018                }
19019
19020                calDiscount($('#prod-discount-rate'));
19021            });
19022
19023            $(document)
19024            .off('click','.switch-pccc, .switch-require-navershop')
19025            .on('click','.switch-pccc, .switch-require-navershop', function(e) {
19026                if($(this).closest('.input-switch').hasClass('editor-upgrade-popup')) {
19027                    e.preventDefault();
19028                    return false;
19029                }
19030
19031                // 네이버쇼핑 off 시 안내팝업
19032                if($(this).hasClass('switch-require-navershop') && $(this).closest('.form-wrap').hasClass('use-nshop-setting')) {
19033                    var modal_description = 'DBURL 기능을 사용하고 있지 않습니다.<br>DBURL 기능을 사용으로 설정 후 이용할 수 있습니다.';
19034                    var link = (uadmin == 'um' ? '/_admin' : '') + '/shopping/setting/T';
19035                    var btnstr = '<div class="btn-box">\
19036                        <a href="' + link + '" target="_blank" style="line-height:2;">DBURL 설정하러 가기</a>\
19037                        <button type="button" class="btn btn-default btn-sm close-button-dialog" data-dismiss="modal">' + $.lang[LANG]['config.close'] + '</button>\
19038                    </div>\
19039                    ';
19040                    
19041                    var str = '\
19042                        <div class="site-upgrade-notice">\
19043                            <p><span class="text-centermodal">' + modal_description + '</span></p>\
19044                            ' + btnstr +
19045                        '</div>\
19046                    ';
19047                    $(this).showModalFlat('안내', str, false, false, '', '', '', 'cl-cmmodal cl-s-btn w560 cl-p0');
19048                    e.preventDefault();
19049                    return false;
19050                }
19051
19052                if($(this).is(':checked')) {
19053                    $(this).parents('.form-wrap').removeClass('disabled');
19054                } else {
19055                    $(this).parents('.form-wrap').addClass('disabled');
19056                }
19057            });
19058            
19059            $(document)
19060            .off('click','.check-sale > .checkbox > label')
19061            .on('click','.check-sale > .checkbox > label', function() {
19062                if($(this).prev('input').is(':disabled')) {
19063                    alert('0원인 상품은 할인을 할 수 없습니다.');
19064                    return false;
19065                }
19066            });
19067
19068            $(document)
19069            .off('click','.grade-sale > .checkbox > label')
19070            .on('click','.grade-sale > .checkbox > label', function() {
19071                if($(this).prev('input').is(':disabled')) {
19072                    alert('0원인 상품은 등급가를 사용 할 수 없습니다.');
19073                    return false;
19074                }
19075            });
19076
19077            $(document)
19078            .off('click','#prod-sale-check')
19079            .on('click','#prod-sale-check', function() {
19080                if($(this).parents('.check-sale').hasClass('disabled')) {
19081                    alert('가격이 연동이 활성화 되어있습니다.\n가격연동을 먼저 해제하세요');
19082                    return false;
19083                }
19084                
19085                $('.form-group.discount-append + .error-msg').remove();
19086                if($(this).is(':checked')) {
19087                    var prod_price = ($('#prod-price').val()) ? $('#prod-price').val() : 0;
19088                    $('#prod-sale').addClass('strike');
19089                    $('#prod-sale').text(prod_price);
19090                    $('#prod-sale').show();
19091                    $('.discount-append').removeClass('hide');
19092                    // $('#prod-price').val('').attr('placeholder','할인 가격을 입력하세요').focus();
19093                    $('#prod-price').prop('readonly', true);
19094                    $('#prod-price').addClass('sale-on');
19095                    $('#check-sale').html('<path d="M13 0H3C1.34 0 0 1.34 0 3v10c0 1.66 1.34 3 3 3h10c1.66 0 3-1.34 3-3V3C16 1.34 14.66 0 13 0zM13.03 6.03l-5.5 5.5C7.38 11.68 7.19 11.75 7 11.75s-0.38-0.07-0.53-0.22l-3.5-3.5c-0.29-0.29-0.29-0.77 0-1.06s0.77-0.29 1.06 0L7 9.94l4.97-4.97c0.29-0.29 0.77-0.29 1.06 0S13.32 5.74 13.03 6.03z"/>');
19096                    $('.check-sale').removeClass('unchecked').addClass('checked');
19097                    calDiscount($('#prod-discount-rate'));
19098                } else {
19099                    var prod_price = ($('#prod-sale').text()) ? $('#prod-sale').text() : '';
19100                    $('#prod-price').val(prod_price);
19101                    $('#prod-price').prop('readonly', false);
19102                    $('#prod-price').removeClass('sale-on').focus();
19103                    // $('#prod-price').removeClass('sale-on').attr('placeholder','가격을 입력하세요').focus();
19104                    $('#prod-sale').removeClass('strike');
19105                    $('#prod-sale').hide();
19106                    $('.discount-append').addClass('hide');
19107                    $('#check-sale').html('<path d="M13 0H3C1.3 0 0 1.3 0 3v10c0 1.7 1.3 3 3 3h10c1.7 0 3-1.3 3-3V3C16 1.3 14.7 0 13 0zM15 13c0 1.1-0.9 2-2 2H3c-1.1 0-2-0.9-2-2V3c0-1.1 0.9-2 2-2h10c1.1 0 2 0.9 2 2V13z"/>');
19108                    $('.check-sale').removeClass('checked').addClass('unchecked');
19109                    calInputWidth($('#prod-price'));
19110                }
19111            });
19112
19113            $(document)
19114            .off('click','#grade-sale-check')
19115            .on('click','#grade-sale-check', function() {
19116                $('.form-group.discount-append + .error-msg').remove();
19117                if($(this).is(':checked')) {
19118                    $('#grade-sale').html('<path d="M13 0H3C1.34 0 0 1.34 0 3v10c0 1.66 1.34 3 3 3h10c1.66 0 3-1.34 3-3V3C16 1.34 14.66 0 13 0zM13.03 6.03l-5.5 5.5C7.38 11.68 7.19 11.75 7 11.75s-0.38-0.07-0.53-0.22l-3.5-3.5c-0.29-0.29-0.29-0.77 0-1.06s0.77-0.29 1.06 0L7 9.94l4.97-4.97c0.29-0.29 0.77-0.29 1.06 0S13.32 5.74 13.03 6.03z"/>');
19119                    $('.grade-sale').removeClass('unchecked').addClass('checked');
19120                    $('#shopping-grade').val('ON');
19121                    // calDiscount($('#prod-discount-rate'));
19122                } else {
19123                    $('#grade-sale').html('<path d="M13 0H3C1.3 0 0 1.3 0 3v10c0 1.7 1.3 3 3 3h10c1.7 0 3-1.3 3-3V3C16 1.3 14.7 0 13 0zM15 13c0 1.1-0.9 2-2 2H3c-1.1 0-2-0.9-2-2V3c0-1.1 0.9-2 2-2h10c1.1 0 2 0.9 2 2V13z"/>');
19124                    $('.grade-sale').removeClass('checked').addClass('unchecked');
19125                    $('#shopping-grade').val('OFF');
19126                    // calInputWidth($('#prod-price'));
19127                }
19128            });
19129
19130            $(document)
19131            .off('click','#price-cut-btn')
19132            .on('click','#price-cut-btn', function() {
19133                if($(this).hasClass('disabled')) {
19134                    $(this).showModalFlat('','원단위 절사 버튼은 판매가 원단위가 1이상인 경우에만 사용할 수 있습니다.',true,false,'','ok','','cl-cmmodal cl-s-btn w560 cl-p130 cl-t80 cl-modal cl-none-title cl-close-btn','','',function() {
19135                        $(document).on('keydown', function(e) {
19136                            if(e.keyCode == 27) modal.modal('hide');
19137                        });
19138                    });
19139                    return false;
19140                }
19141                if($('#prod-discount-unit').attr('data-value') == 'P') {
19142                    var orgPrice = Number(removeCommas($('#prod-sale').text()));
19143                    var discountRate = Number($('#prod-discount-rate').val());
19144                    var discountPrice = orgPrice * (discountRate / 100);
19145                    var price = ($('#prod-price').val()) ? Number(removeCommas($('#prod-price').val())) : 0;
19146
19147                    price = Math.floor(price / 10) * 10;
19148                    discountRate = Math.round(((orgPrice - price) / orgPrice) * 100);
19149
19150                    $('#prod-price').val(number_format(price));
19151                    $('#prod-discount-rate').val(discountRate);
19152
19153                    $(this).addClass('disabled');
19154                }
19155            });
19156
19157            $(document)
19158            .off('input', '#prod-price')
19159            .on('input', '#prod-price', function () {
19160                var price = $(this).val().replace(/[\u3131-\u318E\uAC00-\uD7A3]/g, '');
19161                price = removeCommas(price);
19162                price = price * 1;
19163                var nPrice = Number(price);
19164
19165                if(!nPrice || nPrice == 0) {
19166                    $('#prod-sale-check').prop('disabled', true);
19167                    $('#prod-grade-check').prop('disabled', true);
19168                } else {
19169                    $('#prod-sale-check').prop('disabled', false);
19170                    $('#grade-sale-check').prop('disabled', false);
19171                }
19172
19173                if(nPrice > 1000000000) {
19174                    $(this).val('1,000,000,000');
19175                }
19176
19177                calInputWidth($(this));
19178            });
19179
19180            $(document)
19181            .off('focusout', '#prod-price')
19182            .on('focusout', '#prod-price', function () {
19183                if($(this).prop('readonly') == true) return false;
19184                
19185                var price = $(this).val().replace(/[\u3131-\u318E\uAC00-\uD7A3]/g, '');
19186                price = removeCommas(price);
19187                price = price * 1;
19188
19189                var nPrice = Number(price),
19190                    submit = true;
19191
19192                if(nPrice > 1000000000) price = 1000000000;
19193
19194                // 옵션 가격 검색
19195                $.each($('.prod-option-price'), function(i,v) {
19196                    var oPrice = $(this).attr('data-option-price');
19197                    if(i > 0) {
19198                        if(nPrice + Number(oPrice) < 0) {
19199                            $(this).click();
19200                            $(this).parents('li').addClass('err');
19201                            submit = false;
19202                        }
19203                    }
19204                });
19205
19206                if(submit) {                   
19207                    price = addCommas(price);
19208                    $(this).val(price);
19209                } else {
19210                    alert('판매가가 0원 아래로 적용될 수 있는 옵션 가격이 존재하여 변경할 수 없습니다.');
19211                    $(this).val(price);
19212                }
19213
19214                if(!nPrice || nPrice == 0) {
19215                    $('#prod-sale-check').prop('disabled', true);
19216                    $('#grade-sale-check').prop('disabled', true);
19217                } else {
19218                    $('#prod-sale-check').prop('disabled', false);
19219                    $('#grade-sale-check').prop('disabled', false);
19220                }
19221
19222                calInputWidth($(this));
19223            });
19224
19225            $(document)
19226            .off('input', '#prod-discount-rate')
19227            .on('input', '#prod-discount-rate', function(){
19228                calDiscount($(this));
19229            });
19230
19231            $(document)
19232            .off('focusout', '#prod-discount-rate')
19233            .on('focusout', '#prod-discount-rate', function(){
19234                var discountUnit = $('#prod-discount-unit').attr('data-value');
19235                var discountRate = $(this).val();
19236                $(this).removeClass('empty');
19237                $('.form-group.discount-append + .error-msg').remove();
19238                
19239                if(discountRate) {
19240                    if(discountUnit == 'P') {
19241                        var percentVal = Number((Math.floor(discountRate * 100) / 100).toFixed(2));
19242                        $(this).val(percentVal);
19243                    }
19244                } else {
19245                    $(this).val(0);
19246                }
19247
19248                if($(this).val() == 0) {
19249                    var error_str = '<svg viewBox="0 0 13 13" width="13" height="13">
19249<path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12.13c-3.11 0-5.63-2.53-5.63-5.63S3.39 0.87 6.5 0.87s5.63 2.53 5.63 5.63S9.61 12.13 6.5 12.13z"></path><path d="M7.44 9.58c-0.1-0.02-0.18-0.05-0.25-0.1C7.12 9.44 7.07 9.37 7.03 9.28 6.98 9.19 6.96 9.07 6.96 8.92V5h-1.7v0.4h0.03c0.11 0 0.21 0.01 0.3 0.02 0.09 0.02 0.18 0.05 0.25 0.09 0.07 0.05 0.13 0.11 0.17 0.2 0.04 0.09 0.06 0.2 0.06 0.34v2.91c0 0.14-0.02 0.25-0.06 0.34C5.97 9.39 5.91 9.45 5.84 9.5 5.77 9.54 5.68 9.57 5.59 9.58 5.49 9.6 5.39 9.6 5.29 9.6H5.16v0.4h2.71V9.6H7.75C7.64 9.6 7.54 9.6 7.44 9.58z"></path><rect x="6" y="3" width="1" height="1"></rect></svg>\
19250                    1 이상 입력해 주세요.';
19251                    $('.form-group.discount-append').after('<div class="error-msg c-red">'+error_str+'</div>');
19252                    $(this).addClass('empty');
19253                }
19254            });
19255
19256            $(document)
19257            .off('click','.prod-item-image-add,.prod-item-image')
19258            .on('click','.prod-item-image-add,.prod-item-image',function(e) {
19259                idx = -1;
19260                isMainImageClick = ($(this).hasClass('prod-item-image')) ? true : false;
19261                replace = (isMainImageClick && $('.prod-item-image .preview-img').length) ? true : false;
19262                if($(this).hasClass('.prod-item-image-add')) {
19263                    $('img').removeClass('replace');
19264                }
19265                if($(this).hasClass('.prod-item-image')) $(this).find('.preview-img').addClass('replace');
19266                $.resource.open();
19267            });
19268
19269            $(document)
19270            .off('click','.prod-item-thumb img:not(.guide-img)')
19271            .on('click','.prod-item-thumb img:not(.guide-img)',function(e) {
19272                isMainImageClick = false;
19273                idx = $(this).parent().index();
19274                replace = true;
19275                $(this).addClass('replace');
19276                $(this).attr('data-idx',idx);
19277                $.resource.open();
19278            });
19279
19280            $(document)
19281            .off('hover', '.prod-item-thumb li')
19282            .on('hover', '.prod-item-thumb li',function(e) {
19283                e.stopPropagation();
19284                $('.img-delete').hide();
19285                $(this).find('.img-delete').show();
19286            });
19287
19288            $(document)
19289            .off('click','.img-delete')
19290            .on('click','.img-delete',function(e) {
19291                $(this).parent().remove();
19292                if($('.prod-item-thumb li').length < 11) $('.prod-item-image-add').removeClass('hide');
19293                if($(this).index() == 1) {
19294                    var src = $('.prod-item-thumb li:not(.prod-item-image-add):eq(0)').find('img:not(.guide-img)').attr('src');
19295                    if(typeof src != 'undefined') {
19296                        src = src.replace('/250/','/800/');
19297                        $('.prod-item-image .preview-img').css('background-image', 'url("'+ src +'")');
19298                    } else {
19299                        $('.prod-item-image').removeClass('active').find('.preview-img').remove();
19300                    }
19301                }
19302            });
19303
19304            $(document)
19305            .off('click','.resource-useit')
19306            .on('click','.resource-useit',function(e) {
19307                if($('.prod-modal').length == 0) return;
19308
19309                var isLink = $(this).attr('data-property');
19310                if(typeof flinkChange !== 'function' && isLink == 'flink-change') {
19311                    setFileLink();
19312                    return false;
19313                }
19314
19315                var useitResourceTab = $(this).closest('.tab-pane.active');
19316                var useitResourceSelected = useitResourceTab.find('.resource-selected-ul');
19317                var useitResourceBtn = $(this);
19318                var rmode = useitResourceTab.attr('id').replace(/storage$/gi,'');
19319
19320                if(useitResourceSelected.children('li').length == 0) {
19321                    var z_idx = ($('.flink-fileupload').length) ? 'z-1044' : 'z-1042';
19322                    var error_modal = $(this).showModalFlat($.lang[LANG]['config.information'], $.lang[LANG]['editor.resource.useit'], true, false, '', 'ok', '', 'cl-p130 cl-cmmodal cl-s-btn w560 cl-p0 cl-okbtn-pbt70', '', '', '', function() {
19323                        useitResourceBtn.removeClass('clicked');
19324                    });
19325                    error_modal.closest('.flat-modal').addClass(z_idx);
19326                    return;
19327                }
19328
19329                var imgs = $.resource.selected(),
19330                    empty = ($('.prod-item-image').find('.preview-img').length) ? false : true;
19331
19332                var url = (typeof RESOURCE == 'undefined') ? property.RESOURCE : RESOURCE,
19333                    site = (typeof SID == 'undefined') ? property.SID : SID,
19334                    folder = '', f = '';
19335
19336                var thumbs = $('.prod-item-thumb li:not(.prod-item-image-add)').length,
19337                    remain = 10-thumbs;
19338
19339                replace = ($('.replace').length) ? true : false;
19340                if(imgs.length > remain && !replace) imgs.length = remain;
19341                if(replace) imgs.length = 1;
19342                if(replace && imgs.length > 1) {
19343                    $(this).showModalFlat('INFORMATION', $.lang[LANG]['editor.resource.choose.count.1'], true, false, '', 'ok');
19344                    useitResourceBtn.removeClass('clicked');
19345                    return false;
19346                }
19347                if(rmode == 'free' && useitResourceSelected.children('li').length > 0) {
19348                    $.processON('Image upload to storage...');
19349                    var frUpload = frStorageUpload(imgs.join('|'),800);
19350
19351                    frUpload.then(function(data) {
19352                        $.each(data.u, function(i,v) {
19353                            if(empty && i == 0) {
19354                                folder = 800;
19355                                f = v.path + folder + '/' + v.file;
19356                                var thumb = v.path + '250/' + v.file,
19357                                    img_src = (v.magic) ? v.magic : v.file,
19358                                    src_s800 = getServeImage(img_src,'800',v.path),
19359                                    src_s250 = getServeImage(img_src,'250',v.path);
19360
19361                                $('.prod-item-image').append('<div class="preview-img" style="background-image: url(' + src_s800 + ')">').addClass('active');
19362                                $('.prod-item-thumb .prod-item-image-add').before('<li><img src="' + src_s250 + '"><span class="img-delete"><i class="fa fa-times-circle" aria-hidden="true"></i></span></li>');
19363                            } else {
19364                                if(isMainImageClick && i == 0) {
19365                                    folder = 800;
19366                                    f = v.path + folder + '/' + v.file;
19367                                    var thumb = v.path + '250/' + v.file,
19368                                        img_src = (v.magic) ? v.magic : v.file,
19369                                        src_s800 = getServeImage(img_src,'800',v.path),
19370                                        src_s250 = getServeImage(img_src,'250',v.path);
19371
19372                                    $('.prod-item-image').addClass('active').find('.preview-img').css('background-image','url("'+ src_s800 +'")');
19373                                    if($('.prod-item-thumb .prod-item-image-add').before().hasClass('.prod-item-image-add')) {
19374                                        $('.prod-item-thumb .prod-item-image-add').before('<li><img src="' + src_s250 + '"><span class="img-delete"><i class="fa fa-times-circle" aria-hidden="true"></i></span></li>');
19375                                    } else {
19376                                        $('.prod-item-thumb li:eq(0) img').replaceWith('<img src="' + src_s250 + '">');   
19377                                    }
19378                                } else {
19379                                    folder = 250;
19380                                    f = v.path + folder + '/' + v.file;
19381                                    var thumb = v.path + '250/' + v.file,
19382                                        img_src = (v.magic) ? v.magic : v.file,
19383                                        src_s800 = getServeImage(img_src,'800',v.path),
19384                                        src_s250 = getServeImage(img_src,'250',v.path);
19385
19386                                    if(idx > -1) {
19387                                        if(idx == 0) $('.prod-item-image .preview-img').css('background-image', 'url("' + src_s800 + '")');
19388                                        $('.prod-item-thumb li:eq(' + idx +') img').replaceWith('<img src="' + src_s250 + '">');
19389                                    } else {
19390                                        $('.prod-item-thumb .prod-item-image-add').before('<li><img src="' + src_s250 + '"><span class="img-delete"><i class="fa fa-times-circle" aria-hidden="true"></i></span></li>');
19391                                    }
19392                                }
19393                            }
19394                            if(imgs.length) $('.prod-item-image').removeClass('empty');
19395                            if($('.prod-item-thumb li').length > 10) $('.prod-item-image-add').addClass('hide');
19396                        });
19397                        $('#el-fileupload').modal('hide');
19398                    });
19399                } else {
19400                    $.each(imgs, function(i,v) {
19401                        if(empty && i == 0) {
19402                            p = url + '/' + site + '/';
19403                            var thumb = p + '250/' + v,
19404                                src_s800 = getServeImage(v,"800",p),
19405                                src_s250 = getServeImage(v,"250",p);
19406                            $('.prod-item-image').append('<div class="preview-img" style="background-image: url(' + src_s800 + ');">').addClass('active');
19407                            $('.prod-item-thumb .prod-item-image-add').before('<li><img src="' +  src_s250 + '"><span class="img-delete"><i class="fa fa-times-circle" aria-hidden="true"></i></span></li>');
19408                        } else {
19409                            if(isMainImageClick && i == 0) {
19410                                p = url + '/' + site + '/';
19411                                var thumb = p + '250/' + v,
19412                                    src_s800 = getServeImage(v,"800",p),
19413                                    src_s250 = getServeImage(v,"250",p);
19414                                $('.prod-item-image').addClass('active').find('.preview-img').css('background-image','url("'+ src_s800 +'")');
19415                                $('.prod-item-thumb li:eq(0) img').replaceWith('<img src="' + src_s250 + '">');
19416                            } else {
19417                                p = url + '/' + site + '/';
19418                                var thumb = p + '250/' + v,
19419                                    src_s800 = getServeImage(v,"800",p),
19420                                    src_s250 = getServeImage(v,"250",p);
19421                                if(idx > -1) {
19422                                    if(idx == 0) $('.prod-item-image .preview-img').css('background-image', 'url("' + src_s800 + '")');
19423                                    $('.prod-item-thumb li:eq(' + idx +') img').replaceWith('<img src="' + src_s250 + '">');
19424                                } else {
19425                                    $('.prod-item-thumb .prod-item-image-add').before('<li><img src="' + src_s250 + '"><span class="img-delete"><i class="fa fa-times-circle" aria-hidden="true"></i></span></li>');
19426                                }
19427                            }
19428                        }
19429                    });
19430                }
19431                if(imgs.length) $('.prod-item-image').removeClass('empty');
19432                if($('.prod-item-thumb li').length > 10) $('.prod-item-image-add').addClass('hide');
19433                $('#el-fileupload').modal('hide');
19434                useitResourceBtn.removeClass('clicked');
19435            });
19436            
19437            $(document)
19438            .off('keyup', '.option-price-number')
19439            .on('keyup', '.option-price-number', function(e) {
19440                var key = e.keyCode || e.which;
19441                    txt = $(this).val();
19442                var match;
19443
19444                if($(this).closest('.prod-option').attr('data-option_mode') == 'additional') {
19445                    match = txt.match(/[0-9]+/g);
19446                } else {
19447                    match = txt.match(/[0-9,\-\+]+/g);
19448                }
19449                
19450                $(this).val(match);
19451                var price = removeCommas($('#prod-price').val()),
19452                    input = (match == null) ? 0 : removeCommas(match[0]);
19453
19454                if(parseInt(price) + parseInt(input) < 0) {
19455                    alert('판매가가 0원 아래로 적용될 수 있는 옵션 가격입니다.');
19456                    $(this).val('0').focus();
19457                }
19458            });
19459
19460            $(document)
19461            .off('keyup', '#brand')
19462            .on('keyup', '#brand', function (e) {
19463                var key = e.keyCode || e.which;
19464                    txt = $(this).val();
19465                var match = txt.match(/[a-zA-Zㄱ-ㅎㅏ-ㅣ가-힣0-9-_/:&+() ]/g);
19466                if (match != null) {
19467                    $(this).val(match.join(''));
19468                } else {
19469                    $(this).val('');
19470                }
19471            });
19472
19473            $(document)
19474            .off('click','.choose-gallery')
19475            .on('click','.choose-gallery', function(e) {
19476                e.stopPropagation();
19477                var pid = $('#prod-pid').val();
19478                $(this).toggleClass('open');
19479                $('.gallery-menus-wrap').toggle();
19480                $('.gallery-menus-wrap .gallery-menus li').removeClass('active');
19481                $('.gallery-menus-wrap .gallery-menus li.gallery-name[data-gallery-id="' + pid + '"]').addClass('active');
19482            });
19483
19484            $(document)
19485            .off('click','.gallery-menus-wrap .gallery-menus li')
19486            .on('click','.gallery-menus-wrap .gallery-menus li', function(e) {
19487                e.stopPropagation();
19488                if($(this).hasClass('gallery-name')) {
19489                    var pid = $(this).attr('data-gallery-id'),
19490                        name = $(this).html();
19491                    if(typeof pid == 'undefined' || pid == '') {
19492                        alert('블럭 오류 입니다. 관리자
19492에게 문의하세요');
19493                        $('.gallery-menus-wrap').hide();
19494                        return false;
19495                    }
19496                    $('#prod-pid').val(pid);
19497                    $('.product-gallery-name').html(name);
19498                    $(this).parents('.form-wrap').removeClass('empty');
19499                    $('.choose-gallery').removeClass('open');
19500                    $('.gallery-menus-wrap').hide();
19501                }
19502            });
19503        },
19504        add : function(id,gpos,gcate) {
19505            if($('.prod-modal.cl-p-modal').length > 0) return false;
19506
19507            var site = (typeof SID == 'undefined') ? property.SID : SID,
19508                page = ($.gallery.item_of_page) ? $.gallery.item_of_page : '',
19509                pid = (typeof selectID == 'undefined') ? null : selectID;
19510
19511            if(typeof $.gallery.block_id != 'undefined' && $.gallery.block_id) pid = $.gallery.block_id;
19512            if((typeof pid == 'undefined' || pid == null || pid == '') && $('.gallery-add-items').length) {
19513                pid = $('.gallery-add-items').attr('data-pid') || pid;
19514            }
19515
19516            if(typeof page == 'undefined' || page == '') page = $('.gallery-modal').attr('data-page');
19517            if(typeof page == 'undefined' || page == '') page = $('.gallery-add-items').attr('data-page');
19518            if((typeof page == 'undefined' || page == '') && typeof getGalleryItemPage == 'function') page = getGalleryItemPage(pid);
19519            if(typeof page == 'undefined' || page == '')
19520                page = (typeof PAGE == 'undefined') ? ((typeof property == 'undefined') ? '' : property.PAGE) : PAGE;
19521
19522            if(typeof page == 'undefined' || page == '') {
19523                alert('Undefined page!!!');
19524                return false;
19525            }
19526            // 상품 옵션
19527            product_options = {};
19528            fileUpdateCnt = 0;
19529            //     pid = $('.gallery-add-items').attr('data-pid');
19530            // if(typeof pid == 'undefined' || pid == null) pid = $('.config-image-edit').attr('data-pid');
19531            // if(typeof pid == 'undefined' || pid == null) { pid = (typeof PARENT == 'undefined') ? property.PARENT.pid : PARENT.pid }
19532            // if(typeof pid == 'undefined' || pid == null) pid = (typeof selectID == 'string') ? selectID : null;
19533            // console.log(site,page,pid);
19534            // return false;
19535
19536            if(!site || !pid || typeof pid == 'undefined' || pid == null) {
19537                alert('Undefined gallery');
19538                return false;
19539            }
19540
19541            if(pid.toString().toLowerCase().match(/^cl-s-product-detail,/g) !== null) {
19542                pid = PARENT.pid;
19543            }
19544
19545            page = (page.indexOf(',') > -1) ? page_split(page) : page;
19546
19547            if($('.table-item[data-seq="' + id + '"]').length) pid = $('.table-item[data-seq="' + id + '"]').attr('data-pid');
19548
19549            var parentDocument = $(window.parent.document),
19550                $detail_modal = parentDocument.find('.product-detail-modal');
19551            if($detail_modal.length) $detail_modal.addClass('overlap');
19552            
19553            var params = ($('.gallery-modal').length) ? getProductParams() : getSearchURL();
19554            $.processON();
19555            $.ajax({
19556                url: '/template/products',
19557                data: { type:'get', sid:site, id:id, pid:pid, params:params },
19558                dataType: 'json',
19559                type: 'POST',
19560                async: true,
19561                cache: false,
19562                success: function (data) {
19563                    $.processOFF();
19564                    if(data.error != 'undefined' && data.error) {
19565                        alert(data.error);
19566                        return false;
19567                    }
19568                    var i = data.item,
19569                        plan = i.valid_plan;
19570
19571                    closeProductNumber = i.no;
19572                    product_options = i.prod_options_settings;
19573                    var prod_quantity = parseInt(i.quantity),
19574                        category = '';
19575                    if(id == -1 && $.gallery.category) {
19576                        category = $.gallery.category;
19577                    }
19578                    if(typeof gcate != 'undefined' && gcate) category = gcate;
19579                    if(!category) category = i.category;
19580
19581                    if(prod_quantity < 0 || isNaN(prod_quantity)) i.quantity = 0;
19582                    if(!i.price) i.price = 0;
19583
19584                    $m = $(data.r).hide();
19585                    $('body').append($m);
19586                    $('#sid').val(i.sid);
19587                    $('#prod-page').val(page);
19588                    $('#prod-pid').val(i.pid);
19589                    $('#prod-no').val(i.no);
19590                    $('#prod-title').val(i.title);
19591                    $('#prod-desc').val(i.desc);
19592                    $('#prod-price').val(i.price);
19593                    $('#prod-sale').text(i.sale);
19594                    $('#lux-product').val(i.lux_product);
19595                    
19596                    if(!LUX) {
19597                        if(i.discount_unit == 'P') {
19598                            $('#prod-discount-rate').val(i.discount_rate);
19599                            // $('#price-cut-btn').removeClass('hide');
19600                        } else {
19601                            $('#prod-discount-rate').val(number_format(i.discount_rate));
19602                        }
19603                    }
19604
19605                    if(typeof i.discount_rate == 'undefined' || i.discount_rate == 0) i.discount_unit = 'W';
19606                    $('#prod-discount-unit').attr('data-value', i.discount_unit);
19607                    $('#prod-discount-unit').text($('.discount-unit-select > div[data-value="'+i.discount_unit+'"]').text());
19608                    
19609                    // 상품 세일가 hidden
19610                    $('#retail-price').val(i.retail_price);
19611                    $('#prod-quantity').val(i.quantity);
19612                    if(typeof gpos != 'undefined' && gpos) $('#prod-gpos').val(gpos);
19613                    else $('#prod-gpos').val('');
19614                    $('#prod-category-text').text(category);
19615                    $('#prod-category-lists ul').empty();
19616                    $('#prod-category').attr('data-category',i.category_lists.toString());
19617
19618
19619                    if(plan.type == 'SM' && plan.valid_plan == true) {
19620                        $('.form-wrap.culture-benefit').removeClass('plan-upgrade');
19621                        if(i.use_naverpay == true) {
19622                            $('.form-wrap.culture-benefit').removeClass('not-support');
19623                            if(i.culture_benefit_yn == 'Y') {
19624                                $('.form-wrap.culture-benefit').removeClass('disabled');
19625                            }
19626                        }
19627
19628                        $('.form-wrap#pccc-yn, .form-wrap#require-navershop, .form-wrap#mng-prd-info').removeClass('plan-upgrade');
19629                        $('.form-wrap#pccc-yn,.form-wrap#require-navershop, .form-wrap#mng-prd-info').find('input-switch').removeClass('editor-upgrade-popup').removeAttr('data-mode');
19630                        
19631                        if(i.product_pccc_yn == 'Y') {
19632                            $('.form-wrap#pccc-yn').removeClass('disabled');
19633                        }
19634
19635                        if(i.nshop_setting == 'Y') {
19636                            if(LUX && i.require_navershop == 'T') {
19637                                $('.form-wrap#require-navershop').removeClass('disabled');
19638                                $('.form-wrap#require-navershop').find('input').prop('checked', true);
19639                            }
19640                        } else {
19641                            $('.form-wrap#require-navershop').addClass('use-nshop-setting not-support');
19642                        }
19643                        if(i.mng_product_info_use == 'on') {
19644                            $('.form-wrap#mng-prd-info').removeClass('disabled');
19645                        }
19646                    }
19647
19648                    if(i.culture_benefit_yn == 'Y') {
19649                        $('.form-wrap.culture-benefit').find('input').prop('checked', true);
19650                    }
19651                    if(i.product_pccc_yn == 'Y') {
19652                        $('.form-wrap#pccc-yn').find('input').prop('checked', true);
19653                    }
19654
19655                    if(parseFloat(i.total_unit_value)) {
19656                        $('.form-wrap.unit-pricing').find('input').prop('checked', true).change();
19657                        $('input[name="total_unit_value"]').val(number_format(parseFloat(i.total_unit_value)));
19658                        $('select[name="total_unit"]').val(i.total_unit).selectpicker('render');
19659                        $('input[name="total_unit_bundle"]').val(number_format(i.total_unit_bundle));
19660                        $('select[name="total_unit"]').change();
19661                        $('select[name="basic_unit"]').val(i.basic_unit).selectpicker('render');
19662                        $('input[name="basic_unit_value"]').val(number_format(parseFloat(i.basic_unit_value))).change();
19663                    } else {
19664                        $('select[name="total_unit"]').change();
19665                    }
19666
19667
19668                    var delivery_template_str = '';
19669                    if(i.delivery_template) {
19670                        $.each(i.delivery_template, function(k, v) {
19671                            var template_desc = '';
19672                            template_desc += '(';
19673                            template_desc += $.lang[LANG]['shopping.delivery.template.mix_yn.' + v.mix_yn.toLowerCase()];
19674                            var delivery_type_arr = v.delivery_type.split(',');
19675                            var delivery_type_str = '';
19676                            $.each(delivery_type_arr, function(idx, delivery_type) {
19677                                if(delivery_type_str) delivery_type_str += ', ';
19678                                delivery_type_str += $.lang[LANG]['shopping.delivery.template.delivery_type.' + delivery_type.toLowerCase()];
19679                            });
19680                            if(delivery_type_str) 
19681                                template_desc += ' / ' + delivery_type_str;
19682                            
19683                            if(delivery_type_arr.indexOf('DELIVERY') > -1) {
19684                                template_desc += ' / ' + $.lang[LANG]['shopping.delivery.' + v.delivery_company.toLowerCase()];
19685                            }
19686
19687                            template_desc += ' / ' + $.lang[LANG]['shopping.delivery.template.price_type.' + v.price_type.toLowerCase()];
19688
19689                            if(v.price_type == 'FIX') {
19690                                template_desc += '(' + number_format(v.delivery_fee) + '원)';
19691                            } else if(v.price_type == 'QUANTITY' || v.price_type == 'WEIGHT') {
19692                                var price_type_detail = v.price_type_detail ? JSON.parse(v.price_type_detail) : {};
19693                                
19694                                if(price_type_detail.method == 'DIFFERENTIAL') {
19695                                    var detail = '';
19696                                    if(price_type_detail.detail) {
19697                                        $.each(price_type_detail.detail, function(i, j) {
19698                                            var value = Object.keys(j);
19699                                            var price = Object.values(j);
19700
19701                                            if(v.price_type == 'QUANTITY') {
19702                                                // if(i < 2) {
19703                                                    if(detail) detail += ', ';
19704                                                    detail += value + '개 이상(' + number_format(price) + '원)';
19705                                                // }
19706                                            } else if(v.price_type == 'WEIGHT') {
19707                                                // if(i < 2) {
19708                                                    if(detail) detail += ', ';
19709                                                    detail += value + 'Kg 이상(' + number_format(price) + '원)';
19710                                                // }
19711                                            }
19712                                        });
19713                                    }
19714                                    if(template_desc) {
19715                                        detail = '(차등 / ' + detail + ')';
19716                                        template_desc += detail;
19717                                    }
19718                                } else if(price_type_detail.method == 'REPEAT') {
19719                                    var detail = '';
19720                                    var value = Object.keys(price_type_detail.detail);
19721                                    var price = Object.values(price_type_detail.detail);
19722
19723                                    if(v.price_type == 'QUANTITY') {
19724                                        detail += value + '개 구매시마다 ' + number_format(price) + '원 반복 부과';
19725                                    } else if(v.price_type == 'WEIGHT') {
19726                                        detail += value + 'Kg마다 ' + number_format(price) + '원 반복 부과';
19727                                    }
19728
19729                                    if(detail) {
19730                                        detail = '(반복 / ' + detail + ')';
19731                                        template_desc += detail;
19732                                    }
19733                                }
19734                            }
19735
19736                            if(v.additional_yn == 'Y') {
19737                                template_desc += ' / 도서산간 지역 추가 배송비 (제주 ' + number_format(v.additional_jeju_price) + '원, 제주 외 도서산간 ' + number_format(v.additional_land_price) + '원)';
19738                            }
19739
19740                            template_desc += ' / ' + $.lang[LANG]['shopping.delivery.template.pay_type.' + v.pay_type.toLowerCase()];
19741
19742                            if(v.free_condition_yn == 'Y') {
19743                                template_desc += ' / ' + number_format(v.free_condition) + '원 이상 무료 배송';
19744                            }
19745
19746                            if(v.make_to_order_yn == 'Y') {
19747                                template_desc += ' / 주문 확인 후 ' + v.due_date + '일 후 배송 예정';
19748                            }
19749                            if(v.install_fee_yn == 'Y') {
19750                                template_desc += ' / 별도 설치비 있음';
19751                            }
19752                            template_desc += ')';
19753
19754                            delivery_template_str += '\
19755                            <li data-val="' + v.seq + '" data-weight="' + (v.price_type == 'WEIGHT' ? 'true' : 'false') + '">\
19756                                <input type="radio" id="delivery_template_seq_' + v.seq + '" name="delivery_template_seq" value="' + v.seq + '" />\
19757                                <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 18 18" width="18" height="18"><path d="M9 0a9 9 0 1 0 .001 18.001A9 9 0 0 0 9 0zm0 17c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"></path></svg><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 18 18" width="18" height="18"><path d="M9 0a9 9 0 1 0 .001 18.001A9 9 0 0 0 9 0zm0 17c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"></path><circle cx="9" cy="9" r="6"></circle></svg>\
19758                                <label for="delivery_template_seq_' + v.seq + '">\
19759                                    <span class="template-name">' + v.name + '</span>\
19760                                    <span class="template-desc">' + template_desc + '</span>\
19761                                </label>\
19762                            </li>';
19763                        });
19764                    }
19765
19766                    $('.option-delivery-template-select').html(delivery_template_str);
19767
19768                    if(typeof i.delivery_template_seq != 'undefined' && i.delivery_template_seq) {
19769                        $('.option-delivery-template-select input[name="delivery_template_seq"][value="' + i.delivery_template_seq + '"]').prop('checked', true);
19770
19771                        $('.option-delivery-template-str').html($('.option-delivery-template-select li[data-val="' + i.delivery_template_seq + '"] label').html());
19772
19773                        if($('.option-delivery-template-select li[data-val="' + i.delivery_template_seq + '"]').data('weight') == false) {
19774                            $('.product-weight').hide();
19775                            $('#product_weight').val('');
19776                        } else {
19777                            $('#product_weight').val(number_format(i.p.product_weight) + 'kg');
19778                        }
19779                    } else {
19780                        $('.option-delivery-template-select input[name="delivery_template_seq"]:first').prop('checked', true).change();
19781                    }
19782                    uadmin = i.uadmin;
19783                    var etcAry = [];
19784                    if (i.etc_info) etcAry = i.etc_info.split('||');
19785                    $('.cl_etc_state_check').removeClass('active');
19786                    switch(etcAry[0]) {
19787                        case 'Y':
19788                        case 'T':
19789                            $('#cl_etc_state_'+etcAry[0].toLowerCase()).addClass('active');
19790                            
19791                            if(etcAry[0] == 'Y') {
19792                                $('.etc-setting').not('.time-setting').removeClass('hide');
19793                            } else {
19794                                $('.etc-setting').removeClass('hide');
19795                            }
19796
19797                            if (etcAry[1] == 'S') {
19798                                $('#cl_etc_status_s').addClass('active');
19799                                $('#cl_etc_status_p').removeClass('active');
19800                            } else {
19801                                $('#cl_etc_status_s').removeClass('active');
19802                                $('#cl_etc_status_p').addClass('active');
19803                            }
19804                            $('#etc-date-state').val(etcAry[0]);
19805                            $('#etc-date-status').val(etcAry[1]);
19806                            $('#etc-week').val(etcAry[2]);
19807                            $('#etc-start-date').val(etcAry[3]);
19808                            $('#etc-end-date').val(etcAry[4]);
19809                            $('#etc-date-time').val(etcAry[5]);
19810                            $('#etc-exclude-date').val(etcAry[6]);
19811                            $('#etc-term').val(etcAry[7]);
19812                            $('#etc-time').val(etcAry[8]);
19813                            break;
19814                        default:
19815                            $('#etc-term').val(etcAry[7]);
19816                            $('#etc-time').val(etcAry[8]);
19817                            $('#cl_etc_state_n').addClass('active');
19818                            break;
19819                    }
19820
19821                    
19822                    if(LUX) {
19823                        if(!id || id < 1 || id == '0' || id >= 1000000000) {
19824                            $('.prod-price-sync').removeClass('active').hide();
19825                            $('.margin-config').addClass('disabled');
19826                            $('#prod-price').removeAttr('readonly');
19827                            $('.check-sale').removeClass('disabled');
19828                        } else if(i.price_sync == 'F') {
19829                            $('.prod-price-sync').removeClass('active');
19830                            $('.margin-config').addClass('disabled');
19831                            $('#prod-price').removeAttr('readonly');
19832                            $('.check-sale').removeClass('disabled');
19833                        }
19834
19835                        if(i.prod_status) {
19836                            $('.prod-status').removeClass('active');
19837                            $('.prod-status[data-val="' + i.prod_status + '"]').addClass('active');
19838                        }
19839                    }
19840
19841                    var cate = (category) ? category.split(', ') : [];
19842                    $.each(i.category_lists, function(i,v) {
19843                        $li = $('<li>' + v + '</li>');
19844                        if($.inArray(v.trim(),cate) > -1) $li.addClass('active');
19845                        $('#prod-category-lists ul').append($li);
19846                    });
19847
19848                    $('input#product_weight').on('focus', function() {
19849                        $(this).val($.trim($(this).val()).replace('kg', ''));
19850                    }).on('blur', function() {
19851                        $(this).val($.trim($(this).val()).replace('kg', '') + ($.trim($(this).val()).replace('kg', '') ? 'kg' : ''));
19852                    });
19853                    
19854                    if(LUX) {
19855                        $.each(i.footer, function(idx,v) {
19856                            if (idx == 1) return true;
19857                            if(idx <= 3 && v == 'true') {
19858                                if (idx == 2) {
19859                                    $('.page-options input:eq(1)').prop('checked',true);
19860                                } else if (idx == 3) { //photo
19861                                    if (v == 'true') {
19862                                        $('.photo-review-tab #photo-review').prop('checked',true);
19863                                    } else {
19864                                        $('.photo-review-tab #photo-review').prop('checked',fal
19864se);
19865                                    }
19866                                } else {
19867                                    $('.page-options input:eq(' + idx + ')').prop('checked',true);
19868                                }
19869                            }
19870                        });
19871                    } else {
19872                        // $.each(i.footer, function(idx,v) {
19873                        //     if(idx <= 3 && v == 'true') {
19874                        //         if (idx == 3) { //photo
19875                        //             if (v == 'true') {
19876                        //                 $('.photo-review-tab #photo-review').prop('checked',true);
19877                        //             } else {
19878                        //                 $('.photo-review-tab #photo-review').prop('checked',false);
19879                        //             }
19880                        //         } else {
19881                        //             $('.page-options input:eq(' + idx + ')').prop('checked',true);
19882                        //         }
19883                        //     }
19884                        //     if (idx == 1) { //review
19885                        //         if (v == 'true') {
19886                        //             $('.photo-review-tab').removeClass('hide');
19887                        //         } else {
19888                        //             $('.photo-review-tab').addClass('hide');
19889                        //         }
19890                        //     }
19891                        // });
19892
19893                        if(i.footer[1] == 'true') { //review
19894                            $('#review-checkbox').closest('.form-wrap').removeClass('disabled');
19895                            $('#review-checkbox').prop('checked',true);
19896                            $('.photo-review-tab').removeClass('hide');
19897                        } else {
19898                            $('#review-checkbox').closest('.form-wrap').addClass('disabled');
19899                            $('#review-checkbox').prop('checked',false);
19900                            $('.photo-review-tab').addClass('hide');
19901                        }
19902
19903                        if(i.footer[2] == 'true') { //qna
19904                            $('#qna-checkbox').closest('.form-wrap').removeClass('disabled');
19905                            $('#qna-checkbox').prop('checked',true);
19906                        } else {
19907                            $('#qna-checkbox').closest('.form-wrap').addClass('disabled');
19908                            $('#qna-checkbox').prop('checked',false);
19909                        }
19910
19911                        if(i.footer[3] == 'true') { //top photo review
19912                            $('.photo-review-tab #photo-review').prop('checked',true);
19913                        } else {
19914                            $('.photo-review-tab #photo-review').prop('checked',false);
19915                        }
19916                        // if(i.footer.length > 0 && i.footer[1] == 'true' && typeof i.footer[7] == 'undefined') {
19917                        //     $('.photo-review-top-view').removeClass('hide');
19918                        //     $('.photo-review-tab #use-review-img-upload').prop('checked',true);
19919                        // }
19920                        if (i.use_review_img_upload != 'false') {
19921                            $('.photo-review-top-view').removeClass('hide');
19922                            $('.photo-review-tab #use-review-img-upload').prop('checked',true);
19923                        } else {
19924                            $('.photo-review-top-view').addClass('hide');
19925                            $('.photo-review-tab #use-review-img-upload').prop('checked',false);
19926                            $('.photo-review-tab #photo-review').prop('checked',false);
19927                        }
19928                    }
19929
19930                    if(i.imgs.length > 10) $('.prod-item-image-add').addClass('hide');
19931                    $.each(i.imgs, function(idx,img) {
19932                        if(idx > 10) return true;
19933                        if(img) {
19934                            (idx == 0) ? $('.prod-item-image').addClass('active').append('<div class="preview-img" style="background-image: url(' + img + ');">') :
19935                                         $('.prod-item-thumb .prod-item-image-add').before('<li><img src="' + img + '"><span class="img-delete"><i class="fa fa-times-circle" aria-hidden="true"></i></li>');
19936                        }
19937                    });
19938
19939                    $('.prod-option').each(function(){
19940                        if($(this).data('option_mode') == 'normal' && i.options.length == 0) {
19941                            i.options[0] = { 
19942                                'seq' : '',
19943                                'option_name' : 'noneOption',
19944                                'option_price' : 0
19945                            } 
19946                        }
19947                    });
19948
19949                    if(i.quantity_on == 'on') {
19950                        $('.switch-quantity').prop('checked','checked').parents('.form-wrap').removeClass('disabled');
19951                    }
19952
19953                    setOptionlist(i.options);
19954                    i.footer[4] = (i.footer[4] == '' || i.footer[4] == undefined)? 'true':i.footer[4];
19955                    $('#normal-option').prop('checked', true);
19956
19957                    $('.prod-option-tab').addClass('hide');
19958                    $('#normal-option').prop('checked', false);
19959                    $('#text-option').prop('checked', false);
19960                    $('#additional-option').prop('checked', false);
19961                    $('.prod-option-tab .prod-option').addClass('hide');
19962                    if(i.footer[4]=='true' && $('.prod-option[data-option_mode="normal"] .prod-option-list>li').length > 1) {
19963                        $('#normal-option').prop('checked', true);
19964                        $('.prod-option-tab').removeClass('hide');
19965                        $('.prod-option[data-option_mode="normal"]').removeClass('hide');
19966                        $('.prod-option[data-option_mode="normal"] .plus-price').removeClass('hide');
19967                        $('.prod-option[data-option_mode="normal"] .plus-status').removeClass('hide');
19968                        if(i.quantity_on == 'on') {
19969                            $('.prod-option[data-option_mode="normal"] .plus-quantity').removeClass('hide');
19970                        }
19971                    }
19972                    if(i.footer[5]=='true' && $('.prod-option[data-option_mode="text"] .prod-option-list>li').length > 0) {   
19973                        $('#text-option').prop('checked', true);
19974                        $('.prod-option-tab').removeClass('hide');
19975                        $('.prod-option[data-option_mode="text"]').removeClass('hide');
19976                        $('.prod-option[data-option_mode="text"] .plus-price').removeClass('hide');
19977                        $('.prod-option[data-option_mode="text"] .plus-status').removeClass('hide');
19978                        if(i.quantity_on == 'on') {
19979                            $('.prod-option[data-option_mode="text"] .plus-quantity').removeClass('hide');
19980                        }
19981                        if($('.prod-option[data-option_mode="text"] .prod-option-list>li').length >= 7) { //입력옵션 7개이상 추가X
19982                            $('.prod-option[data-option_mode="text"] > .prod-option-add').addClass('disabled');
19983                        }
19984                    }
19985                    if(i.footer[6]=='true' && $('.prod-option[data-option_mode="additional"] .prod-option-list>li').length > 0) {
19986                        $('#additional-option').prop('checked', true);
19987                        $('.prod-option-tab').removeClass('hide');
19988                        $('.prod-option[data-option_mode="additional"]').removeClass('hide');
19989                        $('.prod-option[data-option_mode="additional"] .plus-price').removeClass('hide');
19990                        $('.prod-option[data-option_mode="additional"] .plus-status').removeClass('hide');
19991                        if(i.quantity_on == 'on') {
19992                            $('.prod-option[data-option_mode="additional"] .plus-quantity').removeClass('hide');
19993                        }
19994                    }
19995
19996                    if(i.prod_info_on == 'on') {
19997                        $('.switch-prod-info').prop('checked','checked').parents('.form-wrap').removeClass('disabled');
19998                        $('.prod-info-toggle').addClass('open');
19999                        $('.info-selected').removeClass('hide');
20000                    } else {
20001                        $('.switch-prod-info').prop('checked', '').parents('.form-wrap').addClass('disabled');
20002                        $('.prod-info-toggle').removeClass('open');
20003                        $('.info-selected').addClass('hide');
20004                    }
20005
20006                    if(i.product_on) {
20007                        $('.switch-product[value="'+i.product_on+'"]').prop('checked', true);
20008                        $('.switch-product[value="'+i.product_on+'"] + label').addClass('active');
20009
20010                        if(i.product_on == 'lim') {
20011                            $('#status-append').fadeIn(0);
20012                            $('#sale-calendar').show();
20013                        } else {
20014                            $('#status-append').hide();
20015                            $('#sale-calendar').hide();
20016                        }
20017                    } else {
20018                        $('.switch-product[value="on"]').prop('checked', true);
20019                        $('.switch-product[value="on"] + label').addClass('active');
20020                    }
20021
20022                    if(i.sales_start && i.sales_end) {
20023                        $('#sale-start-datetime').val(i.sales_start);
20024                        $('#sale-end-datetime').val(i.sales_end);
20025                        var startDateTimeArr = i.sales_start.split(' ');
20026                        var endDateTimeArr = i.sales_end.split(' ');
20027                        var startTime = convertTime12(startDateTimeArr[1]);
20028                        var endTime = convertTime12(endDateTimeArr[1]);
20029                        $('.sale-setting .setting-text .content-start').text(startDateTimeArr[0].replace(/-/g, '.') + '. ' + startTime);
20030                        $('.sale-setting .setting-text .content-end').text(endDateTimeArr[0].replace(/-/g, '.') + '. ' + endTime);
20031                    }
20032                    
20033                    if(i.quantity_on == 'on') {
20034                        $('.switch-quantity').prop('checked','checked').parents('.form-wrap').removeClass('disabled');
20035                        if($('#normal-option').is(':checked') === true) {
20036                        // $('#prod-quantity').attr('readonly','true').removeClass('hide').attr('placeholder','옵션에서 재고 관리');
20037                            $('.quantity-label').addClass('on');
20038                            $('.plus-quantity').removeClass('hide');
20039                        } else if($('#normal-option').is(':checked') === false && $('#additional-option').is(':checked') === true) {
20040                            $('.quantity-label').removeClass('on');
20041                            $('#prod-quantity').removeAttr('readonly').removeClass('hide');
20042                            $('.plus-quantity').removeClass('hide');
20043                        } else {
20044                            $('.quantity-label').removeClass('on');
20045                            $('#prod-quantity').removeAttr('readonly').removeClass('hide');
20046                            $('.plus-quantity').addClass('hide');
20047                        }
20048                    } else {
20049                        $('.prod-option-quantity, .edit-option-quantity').hide();
20050                        $('.plus-quantity').addClass('hide');
20051                    }
20052
20053                    if(!i.sale && i.price == 0) {
20054                        $('#prod-sale-check').prop('disabled', true);
20055                        $('#grade-sale-check').prop('disabled', true);
20056                    } else {
20057                        $('#prod-sale-check').prop('disabled', false);
20058                        $('#grade-sale-check').prop('disabled', false);
20059                    }
20060
20061                    if(i.sale) {
20062                        $('#prod-price').addClass('sale-on');
20063                        $('#prod-price').prop('readonly', true);
20064                        $('#prod-sale').show().addClass('strike');
20065                        $('.discount-append').removeClass('hide');
20066                        $('#prod-sale-check').prop('checked',true);
20067                        $('#grade-sale-check').prop('checked',true);
20068                        $('#check-sale').html('<path d="M13 0H3C1.34 0 0 1.34 0 3v10c0 1.66 1.34 3 3 3h10c1.66 0 3-1.34 3-3V3C16 1.34 14.66 0 13 0zM13.03 6.03l-5.5 5.5C7.38 11.68 7.19 11.75 7 11.75s-0.38-0.07-0.53-0.22l-3.5-3.5c-0.29-0.29-0.29-0.77 0-1.06s0.77-0.29 1.06 0L7 9.94l4.97-4.97c0.29-0.29 0.77-0.29 1.06 0S13.32 5.74 13.03 6.03z"/>');
20069                        $('.check-sale').addClass('checked');
20070
20071                        // if (Number(removeCommas(i.price)) % 10 == 0 || Number(removeCommas(i.price)) == 0) $('#price-cut-btn').addClass('disabled');
20072                        // else $('#price-cut-btn').removeClass('disabled');
20073                    }
20074
20075                    if(i.grade_onoff == 'ON') {
20076                        $('#grade-sale-check').prop('checked', true);
20077                        $('#shopping-grade').val('ON');
20078                        $('#grade-sale').html('<path d="M13 0H3C1.34 0 0 1.34 0 3v10c0 1.66 1.34 3 3 3h10c1.66 0 3-1.34 3-3V3C16 1.34 14.66 0 13 0zM13.03 6.03l-5.5 5.5C7.38 11.68 7.19 11.75 7 11.75s-0.38-0.07-0.53-0.22l-3.5-3.5c-0.29-0.29-0.29-0.77 0-1.06s0.77-0.29 1.06 0L7 9.94l4.97-4.97c0.29-0.29 0.77-0.29 1.06 0S13.32 5.74 13.03 6.03z"/>');
20079                        $('.grade-sale').addClass('checked');
20080                    } else {
20081                        $('#grade-sale-check').prop('checked', false);
20082                        $('#shopping-grade').val('OFF');
20083                    }
20084
20085                    calInputWidth($('#prod-price'));                    
20086
20087                    $('.prod-option').each(function(){
20088                        if($(this).data('option_mode') == 'normal' && i.options.length == 0) {
20089                            i.options[0] = { 
20090                                'seq' : '',
20091                                'option_name' : 'noneOption',
20092                                'option_price' : 0
20093                            } 
20094                        }
20095                    });
20096                              
20097                    $m.fadeIn(300);
20098                    $('.prod-option-list').sortable({
20099                       handle : ".prod-option-move",
20100                       refreshPositions: true
20101                    });
20102
20103                    if (i.product_state == 'download') {
20104                        $('#download-product').attr('checked', true);
20105                        $('.cl_product_state_check').each(function () {
20106                            if ($(this).attr('for') == 'download-product') {
20107                                $(this).find('.cl-icon').removeClass('cl_icon_check02_off').removeClass('cl_icon_check02_on').addClass('cl_icon_check02_on');
20108                                $(this).click();
20109                                $('#download-date').val(i.download_date);
20110                                $('#download-count').val(i.download_count);
20111                            } else {
20112                                $(this).find('.cl-icon').removeClass('cl_icon_check02_off').removeClass('cl_icon_check02_on').addClass('cl_icon_check02_off');
20113                            }
20114                        });
20115                        $('.delivery-template, .product-weight, .brand, .culture-benefit').hide();
20116                    }
20117
20118                    if (i.product_state == 'normal') {
20119                        $('#normal-product').attr('checked', true);
20120                        $('.cl_product_state_check').each(function () {
20121                            if ($(this).attr('for') == 'normal-product') {
20122                                $(this).find('.cl-icon').removeClass('cl_icon_check02_off').removeClass('cl_icon_check02_on').addClass('cl_icon_check02_on');
20123                                $(this).click();
20124                            } else {
20125                                $(this).find('.cl-icon').removeClass('cl_icon_check02_off').removeClass('cl_icon_check02_on').addClass('cl_icon_check02_off');
20126                            }
20127                        });
20128
20129                        if(!$('.delivery-template-list').find('[data-val]').find('input[name="delivery_template_seq"]:checked').length) {
20130                            $('.delivery-template-list').find('[data-val]:first').find('input[name="delivery_template_seq"]').prop('checked', true).change();
20131                        }
20132
20133                        $('.delivery-template').show();
20134                    }
20135
20136                    if (i.product_state == 'etc') {
20137                        $('#etc-product').attr('checked', true);
20138                        $('.cl_product_state_check').each(function () {
20139                            if ($(this).attr('for') == 'etc-product') {
20140                                $(this).find('.cl-icon').removeClass('cl_icon_check02_off').removeClass('cl_icon_check02_on').addClass('cl_icon_check02_on');
20141                                $(this).click();
20142                            } else {
20143                                $(this).find('.cl-icon').removeClass('cl_icon_check02_off').removeClass('cl_icon_check02_on').addClass('cl_icon_check02_off');
20144                            }
20145                        });
20146                        $('.delivery-template, .product-weight, .brand, .culture-benefit').hide();
20147                    }
20148
20149                    if(typeof updateNpayButtonSettingState == 'function') {
20150                        var npayProductState = i.product_state == 'normal' ? 'normal-product' : (i.product_state == 'download' ? 'download-product' : 'etc-product');
20151                        updateNpayButtonSettingState(npayProductState);
20152                    }
20153
20154                    taxUse = i.tax_use;
20155                    if (i.tax_use == 'TG03') {
20156                        $('#state-append').fadeIn(0);
20157                        $('#normal-product-state').fadeIn(0);
20158                        if (i.tax == 'TG01') {
20159                            $('#tax').attr('data-val', 'TG01');
20160                            $('#tax').html('과세');
20161                        }
20162
20163                        if (i.tax == 'TG02') {
20164                            $('#tax').attr('data-val', 'TG02');
20165                            $('#tax').html('비과세');
20166                        }
20167                        $('#tax').attr('data-total-tax', 'TG03');
20168                    } else {
20169                        if (i.product_state == 'normal') $('#state-append').fadeOut(0);
20170                        $('#normal-product-state').fadeOut(0);
20171                        $('#tax').attr('data-val', 'TG01');
20172                        $('#tax').html('과세');
20173                    }
20174                    setAdvancedMode(product_options.advanced);
20175
20176                    var descHeight = $('#prod-desc').prop('scrollHeight');
20177                    if(descHeight > 55) {
20178                        $('#prod-desc').css('height', descHeight+'px');
20179                    } else {
20180                        $('#prod-desc').removeAttr('style');
20181                    }
20182                },
20183                error : function(xhr, status, error) {
20184                    var parentDocument = $(window.parent.document),
20185                        $detail_modal = parentDocument.find('.product-detail-modal');
20186                    if($detail_modal.length) $detail_modal.removeClass('overlap');
20187
20188                    $.processOFF();
20189                    alert("Error " + xhr.status);
20190                }            
20191            });
20192        },
20193        review : function(id,page) {
20194            var site = (typeof SID == 'undefined') ? property.SID : SID;
20195
20196            $.ajax({
20197                url: '/template/products/',
20198                data: { type:'review', sid:site, id:id, page:page },
20199                dataType: 'json',
20200                type: 'POST',
20201                async: false,
20202                cache: false,
20203                success: function (data) {
20204                    if(data.error != 'undefined' && data.error) {
20205                        alert(data.error);
20206                        return false;
20207                    }
20208                    var $review = $(data.r).hide();
20209                    if(typeof property == "undefined") {
20210                        $lastEl = ($('.el-footer_ctrl').length) ? $('.el-footer_ctrl') : $('.add-footer-information');
20211                        if($('.page-bottomlist').length) $lastEl = $('.page-bottomlist');
20212                        if($('.fnav').length) $lastEl = $('.fnav');
20213                        $lastEl.before($review);
20214                        $review.show();
20215                    } else {
20216                        if(typeof property.ISLOCK != 'undefined' && property.ISLOCK == 'true') {
20217                            $review.addClass('hide');
20218                        }
20219                        if($('.el-footer').length) {
20220                            $lastEl = ($('.page-bottomlist').length) ? $('.page-bottomlist') : $('.el-footer');
20221                            if($('.fnav').length) $lastEl = $('.fnav');
20222                            $lastEl.before($review);
20223                            $review.show();
20224
20225                            var reviewArr = new Array();
20226
20227                            $('.s-table-review .review-content>div').each(function(idx, item){
20228                                reviewArr[idx] = $(this).html();
20229                            });
20230
20231                            truncateReviewTitle(reviewArr);
20232
20233                            $(window).on('resize', function(){
20234                                truncateReviewTitle(reviewArr)
20235                            });
20236                        } else {
20237                            $('.dsgn-body').append($review);
20238                            $review.show();
20239                        }
20240                    }
20241                    var cnt = ($('.review-wrap h4 > span').text()=="") ? 0 : $('.review-wrap h4 > span').text();
20242                    $('.review-count').text(' ' + cnt);
20243                }
20244            });
20245        },
20246        qna : function(id,page) {
20247            var site = (typeof SID == 'undefined') ? property.SID : SID;
20248
20249            $.ajax({
20250                url: '/template/products/',
20251                data: { type:'qna', sid:site, id:id, page:page },
20252                dataType: 'json',
20253                type: 'POST',
20254                async: false,
20255                cache: false,
20256                success: function (data) {
20257                    if(data.error != 'undefined' && data.error) {
20258                        alert(data.error);
20259                        return false;
20260                    }
20261                    var $qna = $(data.r).hide();
20262                    if(typeof property == "undefined") {
20263                        $lastEl = ($('.el-footer_ctrl').length) ? $('.el-footer_ctrl') : $('.add-footer-information');
20264                        if($('.page-bottomlist').length) $lastEl = $('.page-bottomlist');
20265                        if($('.fnav').length) $lastEl = $('.fnav');
20266                        $lastEl.before($qna);
20267                        $qna.show();
20268                    } else {
20269                        if(typeof property.ISLOCK != 'undefined' && property.ISLOCK == 'true') {
20270                            $qna.addClass('hide');
20271                        }
20272                        if($('.el-footer').length) {
20273                            $lastEl = ($('.page-bottomlist').length) ? $('.page-bottomlist') : $('.el-footer');
20274                            if($('.fnav').length) $lastEl = $('.fnav');
20275                            $lastEl.before($qna);
20276                            $qna.show();
20277                        } else {
20278                            $('.dsgn-body').append($qna);
20279                            $qna.show();
20280                        }
20281                    }
20282                    var cnt = ($('.qna-wrap h4 > span').text()=="") ? 0 : $('.qna-wrap h4 > span').text();
20283                    $('.qna-count').text(' ' + cnt);
20284                }
20285            });
20286        },
20287        list : function(id, page, view, page_num, sfl, stx, scate) {
20288        },
20289        save : function(go) {
20290            var before_prod = {};
20291            $('.product-wrap form input[name="before_prod[]"]').each(function() {
20292                var bd_key = $(this).attr('data-key'),
20293                    bd_val = $(this).val();
20294                
20295                before_prod[bd_key] = bd_val;
20296            });
20297
20298            var seq = $('#prod-no').val(),
20299                page = $('#prod-page').val(),
20300                pid = $('#prod-pid').val(),
20301                gpos = $('#prod-gpos').val(),
20302                s_grade = $('#shopping-grade').val(),
20303                $title = $('#prod-title'),
20304                $price = $('#prod-price'),
20305                $sale = $('#prod-sale'),
20306                $quantity = $('#prod-quantity'),
20307                $img = $('.prod-item-image'),
20308                $desc = $('#prod-desc'),
20309                $category = $('#prod-category-text'),
20310                $brand = $('#brand'),
20311                discountRate = ($('#prod-sale-check').is(':checked'))? $('#prod-discount-rate').val().trim().replace(/,/gi, '') : 0,
20312                discountUnit = ($('#prod-sale-check').is(':checked'))? $('#prod-discount-unit').attr('data-value') : 'W',
20313                // checkSaleCut = ($('#price-cut-btn').is(':checked'))? 'Y':'N',
20314                quantity_on = ($('.switch-quantity').is(":checked") == true) ? 'on' : 'off',
20315                product_on =  $('input[name="product_status"]:checked').val(),
20316                category_on = ($('.switch-category').is(":checked") == true) ? 'ON' : 'OFF',
20317                product_info_on = ($('.switch-prod-info').is(":checked") == true) ? 'on' : 'off',
20318                mng_product_info_use = ($('.switch-mngprd').is(":checked") == true) ? 'on' : 'off',
20319                mng_product_name = $('#mng-prd-name').val(),
20320                mng_product_code = $('#mng-prd-code').val(),
20321                submit = true,
20322                downloadDate = $('#download-date').val(),
20323                downloadCount = $('#download-count').val(),
20324                submit = true,
20325                productState = '',
20326                taxState = $('#tax').attr('data-val'),
20327                etcDateState = '',
20328                etcDateStatus = '', etcDateWeek = '',
20329                salesStart = '', salesEnd = '', open_out_datetime_yn = 'N',
20330                delete_options = $('#options-delete-list').val(),
20331                deliveryTemplateSeq = $('input[name="delivery_template_seq"]:checked').val(),
20332                productWeight = $('#product_weight').val().replace(/kg|,/gi, ''),
20333                culture_benefit_yn = $('.switch-culture-benefit').is(':checked') ? 'Y' : 'N',
20334                npay_button = $('.switch-npay-button').is(':checked') ? 'Y' : 'N',
20335                product_pccc_yn = $('.switch-pccc').is(':checked') ? 'Y' : 'N',
20336                require_navershop = $('.switch-require-navershop').is(':checked') ? 'T' : 'F',
20337                startDate = '', endDate = '', etcDate = '', exceptDate = '', termData = '', timeData = '',
20338                dayCheck = false, dayCheckLan = $('#etc-date-time').val();
20339                prod_info = getProductInfoList(),
20340                lux_product = ($('#lux-product').val() == "true") ? true : false,
20341                unit_use_yn = $('.switch-unit-pricing').prop('checked') ? 'Y' : 'N',
20342                total_unit_value = $('input[name="total_unit_value"]').val().replace(/,/g, ''),
20343                total_unit = $('select[name="total_unit"]').val(),
20344                total_unit_bundle = $('input[name="total_unit_bundle"]').val().replace(/,/g, ''),
20345                basic_unit_value = $('input[name="basic_unit_value"]').val().replace(/,/g, ''),
20346                basic_unit = $('select[name="basic_unit"]').val();
20347
20348            var price = $price.val();
20349            price = removeCommas(price);
20350            price = price * 1;
20351
20352            var nPrice = Number(price),
20353                submit = true;
20354
20355            // 옵션 가격 검색
20356            $.each($('.prod-option-price'), function(i,v) {
20357                var oPrice = $(v).attr('data-option-price');
20358                if(i > 0) {
20359                    if(nPrice + Number(oPrice) < 0) {
20360                        $(v).parents('li').addClass('err');
20361                        submit = false;
20362                    }
20363                }
20364            });
20365            if(submit == false) {
20366                // alert('옵션 가격이 올바르지 않습니다.');
20367                var modal = $(this).showModalFlat('','판매가가 0원 아래로 적용될 수 있는 옵션 가격이 존재하여 저장할 수 없습니다.',true,false,'','ok','','cl-cmmodal cl-s-btn w560 cl-p130 cl-t80 cl-modal cl-none-title cl-close-btn','','',function() {
20368                    $(document).on('keydown', function(e) {
20369                        if(e.keyCode == 27) modal.modal('hide');
20370                    });
20371                });
20372                return false;
20373            }
20374
20375            if(product_on == 'lim') {
20376                if($('#sale-start-datetime').val() && $('#sale-end-datetime').val()) {
20377                    salesStart = $('#sale-start-datetime').val();
20378                    salesEnd = $('#sale-end-datetime').val();
20379                    open_out_datetime_yn = $('input[name="open_out_datetime_yn"]:checked').val();
20380                } else {
20381                    submit = false;
20382                    var modal = $(this).showModalFlat('','판매 시작, 판매 종료 날짜/시간을 모두 입력해주세요.',true,false,'','ok','','cl-cmmodal cl-s-btn w560 cl-p130 cl-t80 cl-modal cl-none-title cl-close-btn','','',function() {
20383                        $(document).on('keydown', function(e) {
20384                            if(e.keyCode == 27) modal.modal('hide');
20385                        });
20386                    });
20387                    return false;
20388                }
20389
20390            }
20391
20392            if ($('#download-product').is(":checked") == true) productState = 'download';
20393            if ($('#normal-product').is(":checked") == true) productState = 'normal';
20394            if ($('#etc-product').is(":checked") == true) {
20395                productState = 'etc';
20396                etcDateState = $('#etc-date-state').val();
20397                if (etcDateState == 'Y' || etcDateState == 'T') {
20398                    etcDateStatus = $('#etc-date-status').val();
20399                    etcDateWeek = $('#etc-week').val();
20400                    startDate = $('#etc-start-date').val();
20401                    endDate = $('#etc-end-date').val();
20402                    exceptDate = $('#etc-exclude-date').val();
20403                    termData = $('#etc-term').val();
20404                    timeData = $('#etc-time').val();
20405                    
20406                    // var checkStartDate = startDate.split('.');
20407                    // var checkEndDate = endDate.split('.');
20408                    // var checkStart = new Date(checkStartDate[0], (checkStartDate[1] * 1) - 1, checkStartDate[2]);
20409                    // var checkEnd = new Date(checkEndDate[0], (checkEndDate[1] * 1) - 1, checkEndDate[2]);
20410                    // if (checkStart.getTime() > checkEnd.getTime()) {
20411                    //     alert('시작일이 종료일보다 큽니다.');
20412                    //     return false;
20413                    // }
20414                    if($('input.select-terms:checked').val() == 'Y' && (!startDate || !endDate)) {
20415                        alert('날짜 기간을 선택해주세요.');
20416                        return false;
20417                    }
20418                }
20419
20420                etcDate = etcDateState+'||'+etcDateStatus+'||'+etcDateWeek+'||'+startDate+'||'+endDate;
20421                etcDate += (dayCheckLan)? '||' + dayCheckLan : '||';
20422                etcDate += (exceptDate)? '||' + exceptDate : '||';
20423                etcDate += (termData)? '||' + termData : '||';
20424                etcDate += (timeData)? '||' + timeData : '||';
20425            }
20426            // 빈 갤러리 처리
20427            if(pid == '-1') {
20428                $('.choose-gallery').parent().addClass('empty');
20429                submit = false;                
20430            } else $('.choose-gallery').parent().removeClass('empty');
20431
20432            if($img.find('.preview-img').length == 0) {
20433                $img.addClass('empty');
20434                submit = false;
20435            } else $img.removeClass('.empty');
20436
20437            if(!$title.val().trim()) {
20438                $title.focus().parents('.form-wrap').addClass('empty');
20439                submit = false;
20440            } else $title.parents('.form-wrap').removeClass('empty');
20441            if(!$price.val().trim()) {
20442                $price.focus().parents('.form-wrap').addClass('empty');
20443                submit = false;
20444            } else $price.parents('.form-wrap').removeClass('empty');
20445
20446            var item_quantity = (typeof $quantity.val() == 'undefined') ? 0 : parseInt($quantity.val().trim().replace(/\,/g, ''), 10),
20447                item_price = ($price.val().trim()) ? parseInt($price.val().trim().replace(/\,/g, ''), 10) : 0;
20448            if(item_quantity > 9999) {
20449                alert('최대 입력 수량은 9,999 입니다.');
20450                item_quantity = 9999;
20451                $quantity.val(addCommas('9999')).parents('.form-wrap').removeClass('empty');
20452            }
20453            if(item_price > 1000000000) {
20454                $price.focus().parents('.form-wrap').addClass('empty');
20455                alert('최대상품가격은 10억입니다');
20456                return false;
20457            }
20458
20459            if($('#prod-sale-check').is(':checked') && discountRate == 0) {
20460                var error_str = '<svg viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12.13c-3.11 0-5.63-2.53-5.63-5.63S3.39 0.87 6.5 0.87s5.63 2.53 5.63 5.63S9.61 12.13 6.5 12.13z"></path><path d="M7.44 9.58c-0.1-0.02-0.18-0.05-0.25-0.1C7.12 9.44 7.07 9.37 7.03 9.28 6.98 9.19 6.96 9.07 6.96 8.92V5h-1.7v0.4h0.03c0.11 0 0.21 0.01 0.3 0.02 0.09 0.02 0.18 0.05 0.25 0.09 0.07 0.05 0.13 0.11 0.17 0.2 0.04 0.09 0.06 0.2 0.06 0.34v2.91c0 0.14-0.02 0.25-0.06 0.34C5.97 9.39 5.91 9.45 5.84 9.5 5.77 9.54 5.68 9.57 5.59 9.58 5.49 9.6 5.39 9.6 5.29 9.6H5.16v0.4h2.71V9.6H7.75C7.64 9.6 7.54 9.6 7.44 9.58z"></path><rect x="6" y="3" width="1" height="1"></rect></svg>\
20461                1 이상 입력해 주세요.';
20462                $('.form-group.discount-append + .error-msg').remove();
20463                $('.form-group.discount-append').after('<div class="error-msg c-red">'+error_str+'</div>');
20464                $('#prod-discount-rate').addClass('empty');
20465                submit = false;
20466            } else {
20467                $('.form-group.discount-append + .error-msg').remove();
20468                $('#prod-discount-rate').removeClass('empty');
20469            }
20470
20471            // if(!empty(seq)) {
20472            //     if($('#grade-sale-check').is(':checked')) {
20473            //         $.post('/template/gallery/grade', { s: seq, view: visible, mode: 'ON' }, function (data) {
20474            //             checkError(data);
20475            //         },'json');
20476            //     } else {
20477            //         $.post('/template/gallery/grade', { s: seq, view: visible, mode: 'OFF' }, function (data) {
20478            //             checkError(data);
20479            //         },'json');
20480            //     }
20481            // }
20482
20483            $('.unit-pricing').removeClass('empty');
20484            if($('#normal-product').is(":checked") == true && $('.switch-unit-pricing').prop('checked') && $('.unit-pricing').find('input').filter(function() { return $.trim(this.value) == '' || $.trim(this.value) == '0'}).length) {
20485                $('.unit-pricing').addClass('empty');
20486                $('.unit-pricing').find('input').filter(function() { return $.trim(this.value) == '' || $.trim(this.value) == '0'})[0].focus();
20487                return false;
20488            }
20489
20490            var delivery_template_weight = $('input[name="delivery_template_seq"]:checked').parent().data('weight');
20491            var product_weight = $.trim($('#product_weight').val()).replace(/kg/gi, '');
20492            if((lux_product || $('#normal-product').is(":checked") == true) && delivery_template_weight == true && (product_weight == '' || product_weight == 0)) {
20493                $('#product_weight').closest('.form-wrap.product-weight').addClass('empty');
20494                alert('상품 무게를 입력해 주세요.');
20495                return false;
20496            } else {
20497                $('#product_weight').closest('.form-wrap.product-weight').removeClass('empty');
20498            }
20499
20500            var emptyval ='\
20501                <div class="value-empty">\
20502                    <svg viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>필수 입력 항목 입니다.\
20503                </div>\
20504            ';
20505
20506            if(product_info_on=='on') {
20507                if(prod_info.cate_null) {
20508                    $('.prod-info-notice').addClass('empty');
20509                    return false;
20510                }
20511                if(prod_info.input_empty) {
20512                    $('.value-empty').remove();
20513                    $('.prod-info-notice').css('border','3px solid #ee445f');
20514                    var offset_idx = 0;                    
20515
20516                    $.each(prod_null, function(i,v) {
20517                        $('.prod-input-value:eq(' + v + ')').parent('div').append(emptyval);
20518                        if(i==0) offset_idx = v;
20519                    });
20520                    prod_null.offset_idx = offset_idx;
20521                    var input_height = $('.prod-input-value:eq(' + prod_null.offset_idx + ')').offset().top;
20522                    if($('.prod.empty').length==0) $('.prod-modal').animate({ scrollTop: input_height*0.8 }, 500, 'easeInOutQuart');
20523                    return false;
20524                }
20525            }
20526
20527            if(productState != 'normal') npay_button = 'N';
20528
20529            if(mng_product_info_use=='on') {
20530                $('.value-empty').remove();
20531                $('.mng-prd-info-toggle').removeClass('err');
20532                if(mng_product_code.trim()=='') {
20533                    var mng_prd_empty_val = (mng_product_name.trim()=='') ? 'name' : 'code';
20534                    if (mng_product_code.trim()=='') $('.form-mng-prd-code').after(emptyval);
20535                    $('.mng-prd-info-toggle').addClass('err');
20536                    
20537                    return false;
20538                }
20539            }
20540            
20541            if(lux_product) {
20542                if(!$('.prod-type.active').length) {
20543                    alert('상품유형을 선택해주세요.');
20544                    return false;
20545                }
20546
20547                if(!$('#lux-category-text').find('ul').length) {
20548                    alert('카테고리를 하나 이상 추가해주세요.');
20549                    return false;
20550                }
20551
20552                var selected_brand = $('.prod-input.prod-brand').val();
20553                if(selected_brand == '') {
20554                    alert('브랜드를 검색 후 항목에서 선택해주세요.');
20555                    $('#brand').focus();
20556                    return false;
20557                }
20558
20559                var brand_check = brand_list.indexOf(selected_brand) > -1 ? true : false;
20560
20561                if(!brand_check) {
20562                    alert('브랜드 목록에 없는 브랜드명입니다.\n브랜드를 검색 후 목록에서 선택해주세요.');
20563                    $('#brand').focus();
20564                    return false;
20565                }
20566            }
20567
20568            if($('.prod-option-list > li').hasClass('err') == true) {
20569                alert('옵션 항목을 모두 작성해주세요.')
20570                return false;
20571            }
20572
20573            var options = $('.prod-option-list > li').map(function(i,v) {
20574                if($(this).find('.prod-option-title').text().trim()) {
20575                    var quantity = $(this).find('.prod-option-quantity').text().trim(),
20576                        status = $(this).find('.option-price-status-str').attr('data-val'),
20577                        type = '';
20578                    if ($(this).closest('.prod-option').data('option_mode') == 'additional') type = 'A';
20579                    else if ($(this).closest('.prod-option').data('option_mode') == 'text') type = 'T';
20580                    
20581                    if(quantity == '') quantity = '0';
20582                    if(quantity == '0' && quantity_on == 'on') status = 'O'; 
20583
20584                    var fileUrl = [],
20585                        fileSize = [],
20586                        fileStrName = [],
20587                        fileName = [];
20588
20589                    var fileUrlCheck = $(this).find('.file-url'),
20590                        fileSizeCheck = $(this).find('.file-size'),
20591                        fileStrNameCheck = $(this).find('.file-name-detail'),
20592                        fileNameCheck = $(this).find('.real-file-name');
20593
20594                    if (fileUrlCheck.length > 0) $(this).find('.file-url').each(function () { fileUrl.push($(this).text()); });
20595                    else fileUrl.push('');
20596                    if (fileUrlCheck.length > 0) $(this).find('.file-size').each(function () { fileSize.push($(this).text()); });
20597                    else fileUrl.push('');
20598                    if (fileUrlCheck.length > 0) $(this).find('.file-name-detail').each(function () { fileStrName.push($(this).text()); });
20599                    else fileUrl.push('');
20600                    if (fileUrlCheck.length > 0) $(this).find('.real-file-name').each(function () { fileName.push($(this).text()); });
20601                    else fileUrl.push('');
20602
20603                    var strFileUrl = fileUrl.join('||'),
20604                        strFileSize = fileSize.join('||'),
20605                        strFileStrName = fileStrName.join('||'),
20606                        strFileName = fileName.join('||');
20607
20608                    if(type == 'T' || type == 'A') {
20609                        strFileStrName = "";
20610                        strFileSize = "";
20611                        strFileName = "";
20612                        strFileUrl="";
20613                    }
20614
20615                    var optionTitle = '';
20616                    if(product_options.advanced == 'true') {
20617                        if(i == 0 || type == 'T') {
20618                            optionTitle = $(this).find('.prod-option-title').text().trim();
20619                        } else {
20620                            var $val = $(this).find('.prod-option-title > label.owidth');
20621                            optionTitle = $val.map(function() {
20622                                return $(this).text();
20623                            }).get().join(' / ');
20624
20625                        }
20626                    } else {
20627                        optionTitle = $(this).find('.prod-option-title').text().trim();
20628                    }
20629
20630                    var optionPrice = (type != 'T')? $(this).find('.prod-option-price').attr('data-option-price').trim() : 0;
20631                    var optionGroup = '', m2 = '', m3 = '';
20632                    var arrTitle = optionTitle.split(" / ");
20633                    switch(arrTitle.length) {
20634                        case 1: optionTitle = arrTitle[0]; break;
20635                        case 2: optionTitle = arrTitle[1]; m2 = arrTitle[0]; break;
20636                        case 3: optionTitle = arrTitle[2]; m2 = arrTitle[0]; m3 = arrTitle[1]; break;
20637                    }
20638
20639                    if(type == 'T') {
20640                        status = 'S';
20641                        type = 'T';
20642                        optionPrice = "0";
20643                    } else if(type == 'A') {
20644                        optionGroup = m2;
20645                        m2 = '';
20646                    } else if(type == '') {
20647                        if(product_options.type == "1") {
20648                            optionGroup = m2;
20649                            m2 = "";
20650                        }
20651                    }
20652                    // if(product_options.advanced == false && optionTitle != 'noneOption') {
20653                    //     switch(type) {
20654                    //         case ""  : product_options.config1[0].title = '옵션선택'; break;
20655                    //         case "A" : product_options.config3[0].title = '추가옵션'; break;
20656                    //     }                        
20657                    // }
20658                    return { 
20659                        s : $(this).find('.prod-option-title').attr('data-seq'),
20660                        m2 : m2,
20661                        m3 : m3,
20662                        o : optionTitle, 
20663                        v : optionPrice,
20664                        fn : strFileName,
20665                        fdn : strFileStrName,
20666                        fs : strFileSize,
20667                        fu : strFileUrl,
20668                        q : quantity,
20669                        t : status,
20670                        g : optionGroup,
20671                        a : i,
20672                        ty: type
20673                    }
20674                 }
20675            }).get();
20676
20677            var options_changed = true;
20678            if(seq && !lux_product && productState == 'normal' && before_prod.option_list && !delete_options) {
20679                try {
20680                    var before_options = JSON.parse(before_prod.option_list);
20681                    options_changed = (Object.keys(before_options).length != options.length);
20682
20683                    if(!options_changed) {
20684                        $.each(options, function(i, option) {
20685                            var before_option = before_options[option.s];
20686                            if(
20687                                !before_option
20688                                || option.fn || option.fdn || option.fs || String(option.fu || '').replace(/\|/g, '')
20689                                || String(before_option.option_mix2 || '') != String(option.m2 || '')
20690                                || String(before_option.option_mix3 || '') != String(option.m3 || '')
20691                                || String(before_option.option_group || '') != String(option.g || '')
20692                                || String(before_option.option_name || '') != String(option.o || '')
20693                                || Number(before_option.option_price || 0) != Number(option.v || 0
20693)
20694                                || Number(before_option.option_quantity || 0) != Number(removeCommas(option.q || 0))
20695                                || String(before_option.option_status || '') != String(option.t || '')
20696                                || String(before_option.option_type || '') != String(option.ty || '')
20697                                || Number(before_option.idx || 0) != Number(option.a || 0)
20698                            ) {
20699                                options_changed = true;
20700                                return false;
20701                            }
20702                        });
20703                    }
20704
20705                    if(!options_changed) {
20706                        var before_options_config = JSON.parse(before_prod.option_settings || '{}');
20707                        options_changed = (
20708                            JSON.stringify(before_options_config) != JSON.stringify(product_options)
20709                            || String(before_prod.option_normal) != String($('#normal-option').is(':checked'))
20710                            || String(before_prod.option_text) != String($('#text-option').is(':checked'))
20711                            || String(before_prod.option_additional) != String($('#additional-option').is(':checked'))
20712                        );
20713                    }
20714                } catch(e) {
20715                    options_changed = true;
20716                }
20717            }
20718
20719            if(options.length==0 && $('.prod-option-tab .prod-option.hide').length < 3) {
20720                $('.prod-option-add').addClass('empty');
20721                submit = false;
20722            }
20723
20724            var optionsAry = options_changed ? division(options, 300) : [[]];
20725            // console.log(optionsAry);
20726            var price1 = removeCommas($price.val().trim()), //할인가
20727                price2 = removeCommas($sale.text().trim()); //정가
20728
20729            if($sale.css('display') == 'none') {
20730                $sale.text('');
20731                price2 = 0;
20732            }
20733            
20734            if(lux_product == false) {
20735                if($('#prod-sale-check').is(':checked') && (parseInt(price1) - parseInt(price2) >= 0)) {
20736                // alert('할인 가격은 정가보다 높거나 동일할 수 없습니다');
20737                    var modal = $(this).showModalFlat('','할인 가격은 정가보다 높거나 동일할 수 없습니다',true,false,'','ok','','cl-cmmodal cl-s-btn w560 cl-p130 cl-t80 cl-modal cl-none-title cl-close-btn','','',function() {
20738                        $(document).on('keydown', function(e) {
20739                            if(e.keyCode == 27) modal.modal('hide');
20740                        });
20741                    });
20742                    if(price2 == 0) $price.val('');
20743                    submit = false;
20744                    return;
20745                }
20746            } else {
20747                if($('#prod-sale-check').is(':checked') && (parseInt(price1) - parseInt(price2) > 0)) {
20748                    var modal = $(this).showModalFlat('','할인 가격은 정가보다 높을 수 없습니다',true,false,'','ok','','cl-cmmodal cl-s-btn w560 cl-p130 cl-t80 cl-modal cl-none-title cl-close-btn','','',function() {
20749                        $(document).on('keydown', function(e) {
20750                            if(e.keyCode == 27) modal.modal('hide');
20751                        });
20752                    });
20753                    if(price2 == 0) $price.val('');
20754                    submit = false;
20755                    return;
20756                }
20757            }
20758/*
20759            if(nPrice > 0 && nPrice < 10) {
20760                $('#prod-price').focus();
20761                $('.prod-item-price1').addClass('err')
20762                // alert('상품 가격을 10원 이상 입력해주세요.');
20763                var modal = $(this).showModalFlat('','상품 가격을 10원 이상 입력해주세요.',true,false,'','ok','','cl-cmmodal cl-s-btn w560 cl-p130 cl-t80 cl-modal cl-none-title cl-close-btn','','',function() {
20764                    $(document).on('keydown', function(e) {
20765                        if(e.keyCode == 27) modal.modal('hide');
20766                    });
20767                });
20768                submit = false;
20769            } else {
20770                $('.prod-item-price1').removeClass('err');
20771            }
20772*/
20773            var imgs = [];
20774            if(submit) {
20775                $('.prod-item-thumb li').each(function(i,v) {
20776                    var s = $(this).find('img:not(.guide-img)').attr('src');
20777                    if($(this).hasClass('prod-item-image-add')) return true;
20778                    imgs.push(s);
20779                });
20780
20781                
20782                $.processON('상품을 등록중입니다...');
20783                
20784                var func = new Array();
20785                func[0] = true;
20786                func[1] = $('#review-checkbox').is(":checked"); // 리뷰사용
20787                func[2] = $('#qna-checkbox').is(":checked"); // QNA 사용
20788                func[3] = $('#photo-review').is(":checked"); // 상단 포토리뷰 표시
20789                 
20790                func[4] = ($('#normal-option').is(':checked'))? true : false; //일반옵션 활성화
20791                func[5] = ($('#text-option').is(':checked'))? true : false; //입력옵션 활성화
20792                func[6] = ($('#additional-option').is(':checked'))? true : false; //추가옵션 활성화
20793
20794                var useReviewImgUpload = $('#use-review-img-upload').is(":checked"); // 후기 사진업로드 사용여부
20795                
20796                var cate = ($category.text().trim()) ? $category.text().trim().split(',') : '',
20797                    brand = ($brand.val().trim())? $brand.val().trim():'',
20798                    //재고수량
20799                    quantity_val = (func[4] == 'true' || func[6] == 'true')? 0 : item_quantity,
20800                    options_config = $.extend(true, {}, product_options);
20801
20802                delete options_config.options1;
20803                delete options_config.options2;
20804                delete options_config.options3;
20805
20806                var prod_user_margin = (typeof $('.prod-user-margin').val() == 'undefined') ? 0 : $('.prod-user-margin').val().trim(),
20807                    prod_user_price = (typeof $('.prod-user-price').val() == 'undefined') ? 0 : $('.prod-user-price').val().trim(),
20808                    prod_price_sync = ($('.prod-price-sync').hasClass('active')) ? 'T' : 'F',
20809                    prod_status = $('.prod-status.active').attr('data-val'),
20810                    prod_type = $('.prod-type.active').attr('data-val'),
20811                    prod_brand = $('.prod-brand').val(),
20812                    prod_category = [];
20813                
20814                if(lux_product) {
20815                    if(seq < 1 || seq >= 1000000000) {
20816                        if(prod_status == 'T' && $('.prod-option-quantity').not(':first').length == $('.prod-option-quantity').not(':first').map(function(k, v) { if($(v).text() == 0 ) return v;}).length) {
20817                            prod_status = 'F';
20818                        } else if(prod_status == 'T' && $('.prod-option-status').not(':first').length == $('.prod-option-status').not(':first').map(function(k, v) { if($(v).attr('data-val') == 'O') return v;}).length) {
20819                            prod_status = 'F';
20820                        }
20821                        var invenCheck = false;
20822                        
20823                        $.each(optionsAry[0], function(idx, v) {
20824                            if(prod_status != 'T' || (idx > 0 && v.t != 'O')) {
20825                                invenCheck = true;
20826                            }
20827                        });
20828
20829                        if(!invenCheck) prod_status = 'F';
20830                    }
20831                }
20832
20833                if($('#lux-category-text').length) {
20834                    $.each($('#lux-category-text ul'),function(i,v) { 
20835                        prod_category[i] = {
20836                          'sid' : $(this).attr('data-sid'),
20837                          'no' : $(this).attr('data-no'),
20838                          'category' : [],
20839                          'category_name' : [],
20840                          'update' : []
20841                        }
20842                        $.each($(this).find('li'),function(a,b) {
20843                            prod_category[i]['category'].push($(this).attr('data-category-no'));
20844                            var seq = (typeof $(this).attr('data-seq') != 'undefined' && $(this).attr('data-seq') != '') ? $(this).attr('data-seq') : '';
20845                            prod_category[i]['update'].push(seq);
20846                            prod_category[i]['category_name'].push($(this).text().trim());
20847                        });
20848                    });
20849                }
20850
20851                setTimeout(function() {
20852                    var optionRequestCompleteCount = 0;
20853                    for (var optionCnt=0;optionCnt<optionsAry.length;
20853optionCnt++) {
20854                        var prod = {
20855                            'seq' : seq,
20856                            'page' : page,
20857                            'pid' : pid,
20858                            'gpos'  : gpos,
20859                            's_grade' : s_grade,
20860                            'title' : $title.val().trim(),
20861                            'price' : $price.val().trim(),
20862                            'sale' : $sale.text().trim(),
20863                            'discount_rate' : discountRate,
20864                            'discount_unit' : discountUnit,
20865                            // 'check_sale_cut' : checkSaleCut,
20866                            'product_on' : product_on,
20867                            'product_info_on' : product_info_on,
20868                            'mng_product_info_use' : mng_product_info_use,
20869                            'mng_product_name' : mng_product_name,
20870                            'mng_product_code' : mng_product_code,
20871                            'quantity' : quantity_val,
20872                            'quantity_on' : quantity_on,
20873                            'desc' : $desc.val().trim(),
20874                            'category' : cate,
20875                            'category_on' : category_on,
20876                            'brand' : brand,
20877                            'imgs' : imgs,
20878                            'func' : func,
20879                            'product_state' : productState,
20880                            'tax' : taxState,
20881                            'download_date' : downloadDate,
20882                            'download_count' : downloadCount,
20883                            'etc_data' : etcDate,
20884                            'options' : JSON.stringify(optionsAry[optionCnt]),
20885                            'options_changed' : options_changed ? 'Y' : 'N',
20886                            'prod_info' : prod_info,
20887                            'options_config' : options_changed ? options_config : {},
20888                            'delete_options' : delete_options,
20889                            'before_prod' : JSON.stringify(before_prod),
20890                            'delivery_template_seq' : deliveryTemplateSeq,
20891                            'product_weight' : productWeight,
20892                            'culture_benefit_yn' : culture_benefit_yn,
20893                            'npay_button' : npay_button,
20894                            'lux' : lux_product,
20895                            'prod_user_margin' : prod_user_margin,
20896                            'prod_user_price' : prod_user_price,
20897                            'prod_price_sync' : prod_price_sync,
20898                            'prod_status' : prod_status,
20899                            'prod_type' : prod_type,
20900                            'prod_category' : prod_category,
20901                            'prod_brand' : prod_brand,
20902                            'category_deleted' : ($('#category-deleted').length) ? $('#category-deleted').val() : '',
20903                            'product_pccc_yn' : product_pccc_yn,
20904                            'require_navershop' : require_navershop,
20905                            'sales_start': salesStart,
20906                            'sales_end': salesEnd,
20907                            'open_out_datetime_yn': open_out_datetime_yn,
20908                            'unit_use_yn': unit_use_yn,
20909                            'total_unit_value' : total_unit_value,
20910                            'total_unit' : total_unit,
20911                            'total_unit_bundle' : total_unit_bundle,
20912                            'basic_unit_value' : basic_unit_value,
20913                            'basic_unit' : basic_unit,
20914                            'use_review_img_upload' : useReviewImgUpload
20915                        }
20916
20917                        $.post('/template/products', { sid: SID, type : 'add', s: prod, lux : lux_product }, function (data) {
20918                            // checkError(data);
20919                            if(data.error) {
20920                                $.processOFF();
20921                                if(data.price) $('#prod-price').val('');
20922                                var modal = $(this).showModalFlat('',data.error,true,false,'','ok','','cl-cmmodal cl-s-btn w560 cl-p130 cl-t80 cl-modal cl-none-title cl-close-btn','','',function() {
20923                                    $(document).on('keydown', function(e) {
20924                                        if(e.keyCode == 27) modal.modal('hide');
20925                                    });
20926                                });
20927                                return false;
20928                            }
20929
20930                            optionRequestCompleteCount++;
20931                            // control panel
20932                            if (optionsAry.length == optionRequestCompleteCount) {
20933                                $('img.galleryItemEdit[data-seq="' + data.r.id + '"]').attr('src',data.r.imgs[0].path+'/60/'+data.r.imgs[0].file);
20934                                $('.image-title.galleryItemEdit[data-seq="' + data.r.id + '"]').text(data.r.title);
20935
20936                                PRODINFO = (product_info_on=='on') ? prod_info : '';
20937                                PRODSETTING = 'on';
20938
20939                                    // dashboard
20940                                    if(typeof MODE == 'undefined') {
20941                                        $.processOFF();
20942                                        $.products.close();
20943                                        if($('.gallery-modal').length) {
20944                                            var now_page = getStorageItem('gallery-product-page');
20945                                            $.gallery.show($.gallery.block_id,now_page,$.gallery.category);
20946                                        }
20947
20948                                    } else {
20949                                        if(go) {
20950                                            var block = ($('.el_1').length) ? '.el_1' : '.default_project_contents',
20951                                                menuPage = PAGE.split(',');
20952                                            if(LUX) menuPage[0] = '_product';
20953                                            $.cookie('product-detail', true, { expires: 60*60, path : '/' });
20954                                            location.href = '/'+CONFIG_URL+'config/page/'+menuPage[0]+'/view/'+data.r.id;
20955
20956                                        } else {
20957                                            var $emptyShoppingGallery = $('.element[data-id="' + pid + '"][data-type="gallery"][data-mode="shopping"].emptyGallery');
20958                                            if(seq < 1 && $emptyShoppingGallery.length > 0) {
20959                                                $.cookie('block-add', '.element[data-id="' + pid + '"]', { path: '/' });
20960                                            }
20961                                            showPageCallback(showPage);
20962                                            $.processOFF();
20963                                            $.products.close();
20964                                            if($('.gallery-modal').length) {
20965                                                var now_page = getStorageItem('gallery-product-page');
20966                                                $.gallery.show($.gallery.block_id,now_page,$.gallery.category);
20967                                            }
20968                                        }
20969                                    }
20970                            }
20971                        }, 'json').fail(function() {
20972                            $.processOFF();
20973                            var modal = $(this).showModalFlat('','상품 저장 중 오류가 발생했습니다. 잠시 후 다시 시도해 주세요.',true,false,'','ok','','cl-cmmodal cl-s-btn w560 cl-p130 cl-t80 cl-modal cl-none-title cl-close-btn','','',function() {
20974                                $(document).on('keydown', function(e) {
20975                                    if(e.keyCode == 27) modal.modal('hide');
20976                                });
20977                            });
20978                        });
20979                    }
20980                });
20981            }
20982        },
20983        display_info : function() {
20984            var prodObj = (typeof property == "undefined") ? PRODINFO : property.PRODINFO;
20985            var s = '\
20986            <div class="cl-s-product-info-notice element el_000">\
20987                <div class="container">\
20988                <span class="prod-info-notice">상품정보 제공고시</span>\
20989                <table>\
20990                    <colgroup>\
20991                        <col width="">\
20992                        <col width="*">\
20993                    </colgroup>\
20994                    <tbody>\
20995            ';
20996
20997            $.each(prodObj.content, function(i,v) {
20998                s = s + '\
20999                    <tr>\
21000                        <td class="prod-info-title">' + v.title + '</td>\
21001                        <td>' + v.content + '</td>\
21002                    </tr>\
21003                    ';
21004            });
21005            s = s + '\
21006                    </tbody>\
21007                </table>\
21008                </div>\
21009            </div>\
21010            ';
21011
21012            if(typeof property == "undefined") {
21013                $lastEl = ($('.el-footer_ctrl').length) ? $('.el-footer_ctrl') : $('.add-footer-information');
21014                if($('.page-bottomlist').length) $lastEl = $('.page-bottomlist');
21015                if($('.fnav').length) $lastEl = $('.fnav');
21016                $lastEl.before(s);
21017            } else {
21018                if($('.el-footer').length) {
21019                    $lastEl = ($('.page-bottomlist').length) ? $('.page-bottomlist') : $('.el-footer');
21020                    if($('.fnav').length) $lastEl = $('.fnav');
21021                    $lastEl.before(s);
21022                } else {
21023                    $('.dsgn-body').append($s);
21024                }
21025            }
21026        },
21027        close : function() {
21028            var parentDocument = $(window.parent.document),
21029                $detail_modal = parentDocument.find('.product-detail-modal');
21030            if($detail_modal.length) $detail_modal.removeClass('overlap');
21031
21032            if($('.prod-modal').length) {
21033                $('.prod-modal').fadeOut(300, function() {
21034                    $(this).remove();
21035                });
21036            }
21037        }
21038    }
21039
21040    var clicking = false;
21041    $.gallery = {
21042        mode : '',
21043        SMENU : '',
21044        SFOLDER : '',
21045        valid_plan : '',
21046        valid_type : '',
21047        service : '',
21048        one : '',
21049        block_id : '',
21050        block_name : '',
21051        block_el : '',
21052        blocks : [],
21053        pages : [],
21054        seqs : [],
21055        copy : [],
21056        move : [],
21057        delete : [],
21058        ex_id : [],
21059        view_item : 30,
21060        update : false,
21061        unlink : false,
21062        category : '',
21063        cates : '',
21064        drag : '',
21065        last : '',
21066        site_settings : '',
21067        item_of_page : '',
21068        sort_icon_checked : '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-check2-square" viewBox="0 0 16 16"><path d="M3 14.5A1.5 1.5 0 0 1 1.5 13V3A1.5 1.5 0 0 1 3 1.5h8a.5.5 0 0 1 0 1H3a.5.5 0 0 0-.5.5v10a.5.5 0 0 0 .5.5h10a.5.5 0 0 0 .5-.5V8a.5.5 0 0 1 1 0v5a1.5 1.5 0 0 1-1.5 1.5z"/><path d="m8.354 10.354 7-7a.5.5 0 0 0-.708-.708L8 9.293 5.354 6.646a.5.5 0 1 0-.708.708l3 3a.5.5 0 0 0 .708 0"/></svg>',
21069        sort_icon_desc : '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="down" viewBox="0 0 16 16"><path d="M3.5 2.5a.5.5 0 0 0-1 0v8.793l-1.146-1.147a.5.5 0 0 0-.708.708l2 1.999.007.007a.497.497 0 0 0 .7-.006l2-2a.5.5 0 0 0-.707-.708L3.5 11.293zm3.5 1a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7a.5.5 0 0 1-.5-.5M7.5 6a.5.5 0 0 0 0 1h5a.5.5 0 0 0 0-1zm0 3a.5.5 0 0 0 0 1h3a.5.5 0 0 0 0-1zm0 3a.5.5 0 0 0 0 1h1a.5.5 0 0 0 0-1z"/></svg>',
21070        sort_icon_asc : '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="up" viewBox="0 0 16 16"><path d="M3.5 3.5a.5.5 0 0 0-1 0v8.793l-1.146-1.147a.5.5 0 0 0-.708.708l2 1.999.007.007a.497.497 0 0 0 .7-.006l2-2a.5.5 0 0 0-.707-.708L3.5 12.293zm4 .5a.5.5 0 0 1 0-1h1a.5.5 0 0 1 0 1zm0 3a.5.5 0 0 1 0-1h3a.5.5 0 0 1 0 1zm0 3a.5.5 0 0 1 0-1h5a.5.5 0 0 1 0 1zM7 12.5a.5.5 0 0 0 .5.5h7a.5.5 0 0 0 0-1h-7a.5.5 0 0 0-.5.5"/></svg>',
21071        edit_icon : '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 16 16"><path d="M15.41 0.76l-0.17-0.17C14.85 0.2 14.34 0 13.83 0s-1.02 0.2-1.41 0.59L1 12l-1 4 4-1L15.41 3.59C16.2 2.8 16.2 1.54 15.41 0.76zM3.49 14.1l-2.11 0.53 0.53-2.11 8.95-8.95 1.59 1.59L3.49 14.1zM14.71 2.88l-1.56 1.56 -1.59-1.59 1.56-1.56C13.31 1.1 13.56 1 13.83 1s0.52 0.1 0.71 0.29l0.17 0.17C15.1 1.85 15.1 2.49 14.71 2.88z"></path></svg>',
21072        close_icon : '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-x-lg" viewBox="0 0 16 16"><path d="M2.146 2.854a.5.5 0 1 1 .708-.708L8 7.293l5.146-5.147a.5.5 0 0 1 .708.708L8.707 8l5.147 5.146a.5.5 0 0 1-.708.708L8 8.707l-5.146 5.147a.5.5 0 0 1-.708-.708L7.293 8z"/></svg>',
21073        conf_icon : '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-gear-fill" viewBox="0 0 16 16"><path d="M9.405 1.05c-.413-1.4-2.397-1.4-2.81 0l-.1.34a1.464 1.464 0 0 1-2.105.872l-.31-.17c-1.283-.698-2.686.705-1.987 1.987l.169.311c.446.82.023 1.841-.872 2.105l-.34.1c-1.4.413-1.4 2.397 0 2.81l.34.1a1.464 1.464 0 0 1 .872 2.105l-.17.31c-.698 1.283.705 2.686 1.987 1.987l.311-.169a1.464 1.464 0 0 1 2.105.872l.1.34c.413 1.4 2.397 1.4 2.81 0l.1-.34a1.464 1.464 0 0 1 2.105-.872l.31.17c1.283.698 2.686-.705 1.987-1.987l-.169-.311a1.464 1.464 0 0 1 .872-2.105l.34-.1c1.4-.413 1.4-2.397 0-2.81l-.34-.1a1.464 1.464 0 0 1-.872-2.105l.17-.31c.698-1.283-.705-2.686-1.987-1.987l-.311.169a1.464 1.464 0 0 1-2.105-.872zM8 10.93a2.929 2.929 0 1 1 0-5.86 2.929 2.929 0 0 1 0 5.858z"/></svg>',
21074        info_icon_option_true : '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-info-circle" viewBox="0 0 16 16" data-toggle="tooltip" data-placement="top" title="전체 또는 일부 상품들 재고가 5개 이하입니다"><path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14m0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16"/><path d="m8.93 6.588-2.29.287-.082.38.45.083c.294.07.352.176.288.469l-.738 3.468c-.194.897.105 1.319.808 1.319.545 0 1.178-.252 1.465-.598l.088-.416c-.2.176-.492.246-.686.246-.275 0-.375-.193-.304-.533zM9 4.5a1 1 0 1 1-2 0 1 1 0 0 1 2 0"/></svg>',
21075        info_icon_option_false : '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-info-circle" viewBox="0 0 16 16" data-toggle="tooltip" data-placement="top" title="현재 재고가 5개 이하
21075입니다"><path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14m0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16"/><path d="m8.93 6.588-2.29.287-.082.38.45.083c.294.07.352.176.288.469l-.738 3.468c-.194.897.105 1.319.808 1.319.545 0 1.178-.252 1.465-.598l.088-.416c-.2.176-.492.246-.686.246-.275 0-.375-.193-.304-.533zM9 4.5a1 1 0 1 1-2 0 1 1 0 0 1 2 0"/></svg>',
21076        reset : function() { $.gallery.move = []; $.gallery.copy = []; $.gallery.seqs = []; },
21077        init : function() {
21078            var clearLocalStorage = function() {
21079                window.localStorage.removeItem('gallery-product-page');
21080                window.localStorage.removeItem('gallery-product-name');
21081                window.localStorage.removeItem('gallery-product-filter');
21082                window.localStorage.removeItem('gallery-product-sort');
21083                window.localStorage.removeItem('gallery-product-by');
21084            }
21085            clearLocalStorage();
21086            var galleryMoveItem = function(block_id,seq,page,callback) {
21087                if(CANCEL) return true;
21088                var seqs = [];
21089                seqs.push(seq);
21090                $.ajax({
21091                    url: '/template/gallery/move',
21092                    data: { s: seqs, sid : SID, page : page, block_id : block_id },
21093                    dataType: 'json',
21094                    type: 'POST',
21095                    async: true,
21096                    cache: false,
21097                    success: function(data) {
21098                        checkError(data);
21099                        if(typeof callback == 'function') {
21100                            callback();
21101                        }
21102                    }
21103                });
21104            }
21105            var reloadItems = function(items) {
21106
21107            }
21108            var updateItem = function(item) {
21109            
21110            }
21111            var getSearchProduct = function(product_name) {
21112                if(typeof product_name == 'undefined' || (product_name.length > 0 && product_name.length < 2)) {
21113                    alert('최소 2자이상 검색어를 입력하세요');
21114                    $('.gallery-list-search-text').focus();
21115                    return false;
21116                }
21117                window.localStorage.setItem('gallery-product-name',product_name);
21118                $.gallery.show($.gallery.block_id,1,$.gallery.category);
21119            }
21120            var setQuantity = function(seqs) {
21121                if(typeof seqs == 'undefined') {
21122                    var product_number_arr = $('[name="item_check[]"]:checked').map(function() { return $(this).closest('.table-item').attr('data-seq'); }).toArray();    
21123                } else {
21124                    var product_number_arr = seqs;
21125                }
21126                var route = (CONFIG_URL) ? '/_admin' : '';
21127                $.ajax({
21128                    url: route + '/shopping/stock_use_check',
21129                    type:'post',
21130                    dataType:'json',
21131                    async: true,
21132                    data:{
21133                        'sid' : SID,
21134                        'product_number' : product_number_arr
21135                    },
21136                    success:function(data) {
21137                        var valid_data = data.filter(function(v){ if(v.product_quantity_on == 'on') return v; });
21138                        var invalid_data = data.filter(function(v){ if(v.product_quantity_on != 'on') return v; });
21139                        if(valid_data.length > 0 && valid_data.length <= product_number_arr.length) {
21140                            var invalid_products = invalid_data.map(function(v) { return v.title; }).join('<br>');
21141                            var showProductList = function() {
21142                                $.ajax({
21143                                    url: route + '/shopping/batch_stock_list',
21144                                    type:'post',
21145                                    dataType:'html',
21146                                    data: {
21147                                        'sid' : SID,
21148                                        'product_number' : valid_data.map(function(v) { return v.product_number; })
21149                                    },
21150                                    success:function(data) {
21151                                        var modal = $(this).showModalFlat($.lang[LANG]['editor.block.gallery.product.stock'] + $.lang[LANG]['editor.block.gallery.product.price'], data, false, true, function() { //confirm
21152
21153                                            var dataSet = [];
21154
21155                                            modal.find('.setting_product_list [data-product_number]').each(function() {
21156                                                var product_number = $(this).attr('data-product_number');
21157                                                var option_seq = $(this).attr('data-option_seq');
21158                                                var pre_quantity = Number(removeC
21158ommas($(this).find('.input-stock[data-quantity]').attr('data-pre_quantity')));
21159                                                var quantity = Number(removeCommas($(this).find('.input-stock[data-quantity]').attr('data-quantity')));
21160                                                var option_status = $(this).find('.input-stock[data-quantity]').attr('data-option_status');
21161                                                var product_name = $(this).find('.product_title').text();
21162                                                var option_name = $(this).find('.option_name').text();
21163                                                var option_value = $(this).find('.option_value').text();
21164                                                var option_type = $(this).find('.input-stock[data-quantity]').attr('data-option_type');
21165
21166                                                var arr = {'product_number': product_number, 'option_seq': option_seq, 'pre_quantity': pre_quantity, 'quantity': quantity, 'option_status' : option_status, 'product_name' : product_name, 'option_name' : option_name, 'option_value' : option_value, 'option_type' : option_type };
21167                                                dataSet.push(arr);
21168                                            });
21169
21170                                            $.ajax({
21171                                                url : route + '/shopping/batch_stock_set',
21172                                                type:'post',
21173                                                dataType:'json',
21174                                                data: {
21175                                                    'sid' : SID,
21176                                                    'datalist' : dataSet
21177                                                },
21178                                                success: function(data) {
21179                                                    // if(data.result == true) $.gallery.show($.gallery.block_id);
21180                                                }, error: function() {
21181
21182                                                }, complete: function() {
21183                                                    // showPageCallback(showPage)
21184                                                    var page = getStorageItem('gallery-product-page');
21185                                                    $.gallery.show($.gallery.block_id,page,$.gallery.category);
21186                                                }
21187                                            });
21188
21189                                            modal.modal('hide');
21190                                        } ,'cancel', 'config.change', 'cl-cmmodal cl-s-btn cl-p0 w900 cl-edit-discount modal-product-discount site-popup-discount cl-product-setting cover fullcover-modal fixed', '', '', function() { //show
21191                                        }, function(){ //hide
21192                                        },true);
21193                                    }
21194                                });
21195
21196                            };
21197                            if(!invalid_products) {
21198                                showProductList();
21199                                return false;
21200                            }
21201
21202                            $(this).showModalFlat('안내', '<div>재고 일괄 관리는 상품정보 <span style="color:#4789e7;">설정페이지 &gt; 재고관리 옵션</span>이<br><span style="color:#4789e7;">사용</span>으로 설정된 상품만 가능합니다.<br><br>아래 상품들은 재고 관리 옵션이 <span style="color:#4789e7;">사용안함</span>으로 설정 되어 있습니다.<br>이 상품들을 제외하고 재고 설정 페이지로 이동합니다.<br>(재고관리 옵션은 각 상품들의 상품정보 설정 페이지에서 설정할 수 있습니다.)</div><div class="title">상품명</div><div class="scroll">' + invalid_products + '</div>', true, false, function() {
21203                                // ok callback
21204                                // showProductList();
21205                            }, 'ok', '', 'cl-cmmodal cl-s-btn w700 cl-p70 cl-t80 cl-close-btn cover cover-inner-scroll', false, function() {
21206                                // close callback
21207                                // showProductList();
21208                            }, function() {
21209                                // show callback
21210                            }, function() {
21211                                // hide callback
21212                                showProductList();
21213                            });
21214                        } else if(valid_data.length == 0) {
21215                            var modal = $(this).showModalFlat('안내', '<div>재고 일괄 관리는 상품정보 <span style="color:#4789e7;">설정페이지 &gt; 재고관리 옵션</span>이<br><span style="color:#4789e7;">사용</span>으로 설정된 상품만 가능합니다.</div>', true, false, function() {
21216                                // ok callback
21217                                modal.modal('hide');
21218                            }, 'ok', '', 'cl-cmmodal cl-s-btn w700 cl-p70 cl-t80 cl-close-btn', false, function() {
21219                                // close callback
21220                            }, function() {
21221                                // show callback
21222                            }, function() {
21223                                // hide callback
21224                            });
21225                        }
21226                    }
21227                });
21228            }
21229            var checkUserEdit = function(v,type) {
21230                console.log(v,type);
21231                switch(type) {
21232                    case 'sale':
21233                        if(!isNaN(parseFloat(v)) && isFinite(v) && parseFloat(v) >= 0 && parseFloat(v) <= 1000000000) return true;
21234                        break;
21235                    case 'org':
21236                        if(!isNaN(parseFloat(v)) && isFinite(v) && parseFloat(v) >= 0 && parseFloat(v) <= 1000000000) return true;
21237                        break;
21238                    case 'disc':
21239                        if(!isNaN(parseFloat(v)) && isFinite(v) && parseFloat(v) <= 100) return true;
21240                        break;
21241                    case 'quantity':
21242                        if(!isNaN(parseFloat(v)) && isFinite(v) && parseFloat(v) < 10000) return true;
21243                        break;
21244                    default: return false;
21245                }
21246
21247                return false;
21248            }
21249            var getEditType = function($o) {
21250                var type = '';
21251                if($o.parent().hasClass('td-orig-price')) type = 'org';
21252                if($o.parent().hasClass('td-price')) type = 'sale';
21253                if($o.parent().hasClass('td-discount')) type = 'disc';
21254                if($o.parent().hasClass('td-quantity')) type = 'quantity';
21255                if(type == '') {
21256                    alert('Invalid type');
21257                    return false;
21258                }
21259                return type;
21260            }
21261            $(document).on('click','.gallery-modal .gallery-block-select', function(e) {
21262                $('.gallery-modal .gallery-blocks.mobile').toggle();
21263            })
21264            $(document).on('click','.item-header .product-sort, .table-toolbar li .product-sort',function(e) {
21265                var sort = $(this).attr('data-sort'),
21266                    by = $(this).attr('data-by');
21267
21268                if(by == '') by = 'desc';
21269                else {
21270                    by = (by == 'desc') ? 'asc' : 'desc';
21271                }
21272                window.localStorage.setItem('gallery-product-sort',sort);
21273                window.localStorage.setItem('gallery-product-by',by);
21274                $.gallery.show($.gallery.block_id,1,$.gallery.category);
21275            });
21276            $(document).on('click','.item-header .product-sort-checked, .table-toolbar li .product-sort-checked',function(e) {
21277                window.localStorage.removeItem('gallery-product-sort');
21278                window.localStorage.removeItem('gallery-product-by');
21279                $.gallery.show($.gallery.block_id,1,$.gallery.category);
21280            });
21281            $(document).on('click','.gallery-blocks .all-items', function(e) {
21282                clearLocalStorage();
21283                $.gallery.show('',1);
21284            });
21285            $(document).on('click','.table-item .td-status', function(e) {
21286                var is_product = $(this).parent().attr('data-product');
21287                if(typeof is_product == 'undefined' || is_product == 'false') {
21288                    $(this).showModalFlat($.lang[LANG]["config.information"], '상품 정보를 입력한 후에 이용 가능합니다.<br>상품 설정을 완료해주세요', true, false, '', 'ok','','cl-p130 cl-cmmodal cl-s-btn w560 cl-p0 cl-okbtn-pbt70');
21289                    return false;
21290                }
21291                e.stopPropagation();
21292                if($(this).hasClass('open')) {
21293                    $(this).removeClass('open').find('.table-item-status').hide();
21294                    return false;
21295                }
21296                $(this).toggleClass('open');
21297                $('.table-item-status').hide();
21298                var $status = $(this).find('.table-item-status');
21299                ($(this).hasClass('open')) ? $status.show() : $status.hide().removeClass('open');
21300            });
21301            $(document).on('click','.table-item .table-item-status li', function(e) {
21302                e.preventDefault();
21303                var product_number = $(this).parent().attr('data-seq'),
21304                    status = $(this).attr('data-val');
21305                $(this).parent().find('li').removeClass('active');
21306                $(this).addClass('active');
21307
21308                $.processON();
21309                var route = (CONFIG_URL) ? '/_admin' : '';
21310                $.ajax({
21311                    url: route + '/shopping/setProductStatus',
21312                    type: 'post',
21313                    data: { sid : SID, product_number : product_number, status : status },
21314                    async: true,
21315                    cache: false,
21316                    dataType: 'json',
21317                    success: function(data) {
21318                        $.processOFF();
21319                        if(typeof data.error != 'undefined' && data.error) {
21320                            $p.find('.prev-value').text(t);
21321                            alert(data.error);
21322                            return false;
21323                        }
21324                        var page = getStorageItem('gallery-product-page');
21325                        $.gallery.show($.gallery.block_id,page,$.gallery.category);
21326                        $.gallery.update = true;
21327                        $.gallery.reset();
21328                    },
21329                    error: function(request,status,error) {
21330                        $.processOFF();
21331                        alert('code:'+request.status+'\n'+'message:'+request.responseText+'\n'+'error:'+error);
21332                        return false;
21333                    }
21334                });
21335            });
21336            $(document).on('keyup','.gallery-list-search-text', function(e) {
21337                var product_name = $(this).val().trim();
21338                // if(product_name.length == 0) return false;
21339                if(e.key === 'Enter') {
21340                    getSearchProduct(product_name);
21341                }
21342            });
21343            $(document).on('click','.gallery-list-search-submit', function(e) {
21344                var product_name = $('.gallery-list-search-text').val().trim();
21345                // if(product_name.length == 0) return false;
21346                getSearchProduct(product_name);
21347            });
21348            $(document).on('click','.gallery-list-search-cancel',function(e) {
21349                // $(this).hide();
21350                $('.gallery-list-search-submit').show();
21351                $('.gallery-list-search-text').val('');
21352                window.localStorage.removeItem('gallery-product-name');
21353                $.gallery.show($.gallery.block_id,1,$.gallery.category);
21354            });
21355            $(document).on('click','.gallery-list-filter ul li', function(e) {
21356                $('.gallery-list-filter ul li').removeClass('active');
21357                $(this).addClass('active');
21358                var filter = $(this).attr('data-val');
21359                window.localStorage.setItem('gallery-product-filter',filter);
21360                $.gallery.show($.gallery.block_id,1,$.gallery.category);
21361            });
21362            var isClose = false;
21363            $(document).on('click','.table-item .edit-button',function(e) {
21364                isClose = false;
21365                if($(this).hasClass('conf')) {
21366                    var $parent = $(this).parents('.table-item'),
21367                        seq = $parent.attr('data-seq'),
21368                        seqs = [seq];
21369                    setQuantity(seqs);
21370                    return false;
21371                }
21372                var s = $(this).parent().find('.prev-value').text(),
21373                    type = getEditType($(this));
21374                $('#user-edit').remove();
21375                $('.close-button').hide();
21376                $(this).parents('.table-item').find('.edit-button').show();
21377                $(this).hide();
21378                if($(this).parent().find('input').length == 0) {
21379                    $(this).parent().append('<input type="text" class="' + type + '" id="user-edit" value="' + s + '" numberOnly>');
21380                    $('#user-edit').focus();
21381                    $(this).parent().find('.close-button').show();
21382                    $('.edit-button').hide();
21383                }
21384            });
21385            $(document).on('mousedown','.close-button',function(e) {
21386                e.preventDefault();
21387            });
21388            $(document).on('click','.close-button', function(e) { 
21389                var s = $(this).attr('data-val'),
21390                    $this = $(this);
21391                isClose = true;
21392                $(this).removeClass('err not').hide();
21393                $(this).parent().find('.prev-value').text(s);
21394                $(this).parent().find('input').remove();
21395                $(this).parents('.table-item').find('.edit-button').show();
21396            });
21397            $(document).on('blur','#user-edit',function(e) {
21398                if(isClose) return false;
21399                var s = $(this).val().trim(),
21400                    $p = $(this).parent(),
21401                    $this = $(this),
21402                    type = getEditType($(this)),
21403                    $parent = $this.parents('.table-item'),
21404                    pid = $parent.attr('data-pid'),
21405                    seq = $parent.attr('data-seq'),
21406                    t = $this.parent().find('.prev-value').text(),
21407                    p_orig = $parent.find('.td-orig-price').find('.prev-value').text(),
21408                    p_price = $parent.find('.td-price').find('.prev-value').text(),
21409                    p_discount = $parent.find('.td-discount').find('.prev-value').text(),
21410                    p_quantity = $parent.find('.td-quantity').find('.prev-value').text();
21411
21412                if(type == 'quantity' && Number(uncomma(s)) > 9999) {
21413                    alert('최대 입력 수량은 9,999 입니다.');
21414                    s = addCommas('9999');
21415                    $this.val(s);
21416                }
21417
21418                $this.parents('.table-item').find('.close-button').removeClass('err not');
21419                if(!checkUserEdit(uncomma(s),type) || s.length == 0) {
21420                    $this.parent().find('.close-button').show().addClass('err');
21421                    // setTimeout(function() { $this.focus(); },0);
21422                    return false;
21423                }
21424                var submit = false;
21425                if(type == 'org' || type == 'sale') {
21426                    var orig = (type == 'org') ? parseFloat(uncomma(s)) : parseFloat(uncomma(p_orig)),
21427                        price = (type == 'org') ? parseFloat(uncomma(p_price)) : parseFloat(uncomma(s));
21428                    if(orig < price) {
21429                        $this.parent().find('.close-button').show().addClass('err not');
21430                        // setTimeout(function() { $this.focus(); },0);
21431                        return false;
21432                    }
21433                }
21434
21435                $('.close-button').hide();
21436                $this.parent().find('.close-button').attr('data-val',s).removeClass('err not').hide();
21437                $this.parent().find('.prev-value').text(s); 
21438                $this.parents('.table-item').find('.edit-button').show();
21439                $this.remove();
21440
21441                if(s == t) return false;
21442                $.processON();
21443
21444                var paramData = { sid : SID, pid : pid, seqs : [seq], type : type, mark : 'change', v : s, p : t, fx : 'disc', c : 's'};
21445                if(type == 'quantity') paramData['t'] = $parent.find('.item-title-str').text();
21446                
21447                var route = (CONFIG_URL) ? '/_admin' : '';
21448                $.ajax({
21449                    url: route + '/shopping/setProduct',
21450                    type: 'post',
21451                    data: paramData,
21452                    async: true,
21453                    cache: false,
21454                    dataType: 'json',
21455                    success: function(data) {
21456                        $.processOFF();
21457                        if(typeof data.error != 'undefined' && data.error) {
21458                            $p.find('.prev-value').text(t);
21459                            alert(data.error);
21460                            return false;
21461                        }
21462                        var page = getStorageItem('gallery-product-page');
21463                        $.gallery.show($.gallery.block_id,page,$.gallery.category);
21464                        $.gallery.update = true;
21465                        $.gallery.reset();
21466                        var cmd = '';
21467                        switch(type) {
21468                            case "org":     cmd = "org-price"; break;
21469                            case "sale":    cmd = "sale-price"; break;
21470                            case "disc":    cmd = "disc-price"; break;
21471                        }
21472                        if(cmd) setLogs('ELEM','product.'+cmd +'.modify','modify','ELEM','product-manager','el');
21473                    },
21474                    error: function(request,status,error) {
21475                        $.processOFF();
21476                        alert('code:'+request.status+'\n'+'message:'+request.responseText+'\n'+'error:'+error);
21477                        return false;
21478                    }
21479                });
21480            });
21481            $(document).on('keyup','#user-edit',function(e) {
21482                if(e.key === 'Enter') {
21483                    $(this).parents('.table-item').find('.close-button').removeClass('err not');
21484                    $(this).blur(); 
21485                }
21486            });
21487            $(document).on('click','#section-top-menu .product-manager', function(e) { 
21488                clearLocalStorage();
21489                $.gallery.show('',1);
21490            });
21491            $(window).resize(function(e) { 
21492                if($('.gallery-items').length == 0) return;
21493                shoppingGalleryResize();
21494                // resizeGalleryModal();
21495            });
21496            $(document).on('click','.product-gallery-list-toggle',function(e) {
21497                var $list = $('.product-gallery-list'),
21498                    $category = $('.gallery-category'),
21499                    $more = $('.gallery-items-loadmore'),
21500                    $items = $('.gallery-items'),
21501                    $toggle = $('.product-gallery-list-toggle'),
21502                    $pagination = $('.pagination-wrap'),
21503                    $filter = $('.gallery-list-filter'),
21504                    $name = $('.selected-gallery-name'),
21505                    $lux_filter = $('.shop-filter-header'),
21506                    svg_open = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-chevron-right" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708z"/></svg>',
21507                    svg_close = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-chevron-left" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M11.354 1.646a.5.5 0 0 1 0 .708L5.707 8l5.647 5.646a.5.5 0 0 1-.708.708l-6-6a.5.5 0 0 1 0-.708l6-6a.5.5 0 0 1 .708 0"/></svg>';
21508                $toggle.toggleClass('open');
21509                $list.toggleClass('open');
21510                $category.toggleClass('open');
21511                $more.toggleClass('open');
21512                $items.toggleClass('open');
21513                $pagination.toggleClass('open');
21514                $filter.toggleClass('open');
21515                $name.toggleClass('open');
21516                $lux_filter.toggleClass('open');
21517                if($toggle.hasClass('open')) {
21518                    $toggle.html(svg_open);
21519                } else {
21520                    $toggle.html(svg_close);
21521                }
21522
21523                ($('.product-gallery-list-toggle').hasClass('open')) ? 
21524                    window.localStorage.setItem('product-gallery-closed',fal
21524se):
21525                    window.localStorage.setItem('product-gallery-closed',true);
21526            });
21527            $(document).bind('cut', '.gallery-modal', function(e) {
21528                if($('.cl-change-badge-design').length > 0) return;
21529                $.gallery.move = $.gallery.seqs;
21530                $.gallery.seqs = [];
21531                $.each($.gallery.move, function(i,v) {
21532                    $('.gallery-items .item[data-seq="' + v + '"]').removeClass('copy').addClass('move');
21533                    $('.gallery-toolbar.mod-gallery').remove();
21534                });
21535            });
21536            $(document).bind('copy', '.gallery-modal', function(e) {
21537                if($.gallery.block_id == -1 || $('.cl-common-modal').length) return;
21538                if($('.cl-change-badge-design').length > 0) return;
21539                $.gallery.copy = $.gallery.seqs;
21540                $.gallery.seqs = [];
21541                $.each($.gallery.copy, function(i,v) {
21542                    $('.gallery-items .item[data-seq="' + v + '"]').removeClass('move').addClass('copy');
21543                    $('.gallery-toolbar.mod-gallery').remove();
21544
21545                    $('.table-item .td-check input[type="checkbox"]').prop('checked',false); 
21546                    $('.table-item').removeClass('ui-selected return');
21547                    $('.table-toolbar .toolbar-cmd').addClass('hide');
21548                    $('.table-toolbar .toolbar-cmd i[data-glseq]').attr('data-glseq','');
21549                    $('.table-toolbar .toolbar-cmd i[data-cmd="link"]').attr('data-glink','').attr('data-glink-target','');
21550                    $('.table-toolbar .toolbar-cmd i[data-cmd="visible"]').attr('data-visible','0').text($.lang[LANG]['editor.gallery.icon.visible.off']);
21551                    $('.gallery-toolbar').removeClass('hide_col');
21552                    $('.gallery-toolbar').addClass('hide');
21553                    $('.gallery-items .item-header').removeClass('hide');
21554                    $('.check-all').prop('checked',false);
21555                    $.toast({'title' : ($.gallery.copy).length + '개의 데이터가 복사 되었습니다'});
21556                });
21557            });
21558            $(document).bind('paste', '.gallery-modal', function(e) {
21559                if($('.gallery-modal').length == 0 || $('.galleryController').length || $('.prod-modal').length || $('.cl-product-setting').length) return;
21560                if($('.edit-link-Content').length) return;
21561                if($('.cl-change-badge-design').length > 0) return;
21562
21563                if(($.gallery.copy).length) $.gallery.cp();
21564                if(($.gallery.move).length) $.gallery.mv();
21565            });
21566            $(document).bind('keydown', 'ctrl+a', function(e) {
21567                if( e.ctrlKey && 
21568                    !$(e.target).is('input:not([type="checkbox"])') &&
21569                    !$(e.target).is('textarea') &&
21570                    !$(e.target).is('.pace-disable.modal-open') &&
21571                    $('.prod-modal').length == 0 && 
21572                    $('.galleryController').length == 0 && 
21573                    $('.cl-category-modal.category-modal').length == 0
21574                ) {
21575                    if(e.keyCode == 65 || e.keyCode == 85) {
21576                        $.gallery.seqs = [];
21577
21578                        var item_selector = ($('.table-item').length) ? '.table-item' : '.gallery-items .item',
21579                            visible_button = false;
21580                        $(item_selector).find('.td-check input[type="checkbox"]').prop('checked',true);
21581                        $(item_selector).addClass('ui-selected');
21582                        $.each($(item_selector), function(i,v) {
21583                            $.gallery.seqs.push($(this).attr('data-seq'));
21584                            if($(this).attr('data-out-datetime') == "1") visible_button = true;
21585                        });
21586
21587                        if(item_selector == '.table-item') {
21588                            var firstItem = $('.gallery-items '+item_selector+'.ui-selected').eq(0),
21589                                first_seq = firstItem.attr('data-seq'),
21590                                link = firstItem.attr('data-link'),
21591                                target = firstItem.attr('data-target'),
21592                                visible = firstItem.attr('data-visible'),
21593                                grade = firstItem.attr('data-grade'),
21594                                vstr = (visible == '1') ? $.lang[LANG]['editor.gallery.icon.visible.on'] : $.lang[LANG]['editor.gallery.icon.visible.off'],
21595                                gstr = (grade == 'ON') ? $.lang[LANG]['editor.gallery.icon.grade.off'] : $.lang[LANG]['editor.gallery.icon.grade.on'];
21596
21597                            if(visible_button) {
21598                                $('.table-toolbar .toolbar-cmd.toolbar-visible').addClass('disabled');
21599                            } else $('.table-toolbar .toolbar-cmd.toolbar-visible').removeClass('disabled');
21600                            if($.gallery.block_id == -1) {
21601                                $('.table-toolbar .toolbar-cmd.toolbar-copy').addClass('disabled');
21602                            }
21603                            $('.table-toolbar .toolbar-cmd').removeClass('hide');
21604                            $('.table-toolbar .toolbar-cmd i[data-glseq]').attr('data-glseq',first_seq);
21605                            $('.table-toolbar .toolbar-cmd i[data-cmd="link"]').attr('data-glink',link).attr('data-glink-target',target);
21606                            $('.table-toolbar .toolbar-cmd i[data-cmd="visible"]').attr('data-visible',visible).text(vstr);
21607                            $('.table-toolbar .toolbar-cmd i[data-cmd="grade"]').attr('data-grade',grade).text(gstr);
21608                            $('.gallery-toolbar').addClass('hide_col');
21609                            $('.check-all').prop('checked',true);
21610                            $.gallery.setNumber();
21611                            $('.gallery-toolbar').removeClass('hide');
21612                            $('.gallery-items .item-header').addClass('hide');
21613                            stickyToolbar();
21614                        } else {
21615                            $.gallery.toolbar();
21616                            stickyToolbar();
21617                        }
21618                    }
21619                }
21620            });
21621            $(document).on('click','.gallery-category > .category-text', function(e) {
21622                var s = $(this).text().trim(),
21623                    pid = $('.gallery-modal').attr('data-pid');
21624                $.gallery.show(pid,1,s);
21625            });
21626            $(document).on('click', '.gallery-modal', function(e) {
21627                $('.table-item-status').hide();
21628                $('.status-change').removeClass('open');
21629                $(this).find('.gallery-toolbar.mod-gallery').remove();
21630                if($.gallery.mode == 'shopping') {
21631                    if(typeof e.target.className != 'object') {
21632                        if(e.target.className.indexOf('ui-selectable') === -1) {
21633                            $.gallery.seqs = [];
21634                            $('.gallery-items .table-item > div').removeClass('hide-text');
21635                            $('.gallery-items .table-item input').prop('checked',fal
21635se);
21636                            $('.gallery-items .check-all').prop('checked',false);
21637                            $('.gallery-items .table-item').removeClass('ui-selected return');
21638                            $('.table-toolbar > li').removeClass('open');
21639                            $('.table-toolbar .toolbar-cmd').addClass('hide');
21640                            $('.table-toolbar .toolbar-cmd i[data-glseq]').attr('data-glseq','');
21641                            $('.table-toolbar .toolbar-cmd i[data-cmd="link"]').attr('data-glink','').attr('data-glink-target','');
21642                            $('.table-toolbar .toolbar-cmd i[data-cmd="visible"]').attr('data-visible','0').text($.lang[LANG]['editor.gallery.icon.visible.off']);
21643                            $('.gallery-toolbar').removeClass('hide_col');
21644                            $('.col-check > input[type="checkbox"]').prop('checked',false);
21645                            $('.gallery-toolbar').addClass('hide');   
21646                            $('.gallery-items .item-header').removeClass('hide');
21647                        }
21648                    }
21649                } else {
21650                    if(typeof e.target.className == 'string' && e.target.className.indexOf('item') === -1) { 
21651                        $.gallery.seqs = [];
21652                        $('.gallery-items .item').removeClass('ui-selected return');    
21653                        $('.gallery-toolbar').empty();
21654                    } else {
21655                    }
21656                }
21657                $('.toolbar-sort').removeClass('open');
21658                $('.gallery-view-count').removeClass('open').find('.view-submenu').hide();
21659                // $('.table-toolbar > li').addClass('disabled').removeClass('open');
21660                $('.gallery-blocks .btn-group').removeClass('open');
21661            });
21662            $(document).on('mousemove', '.gallery-modal', function(e) {
21663                if($(".item-title").is(':focus') || clicking === false) return;
21664                if($('.gallery-modal .clone-item').length) {
21665                    $('.gallery-modal .clone-item').css({
21666                        'left' : e.pageX+10,
21667                        'top' : e.pageY+10
21668                    }).attr('data-count',($.gallery.seqs).length).find('input').remove();
21669                    if(($.gallery.seqs).length >1) $('.gallery-modal .clone-item').addClass('multi');
21670                    $('.gallery-items .table-item').removeClass('prev last');
21671                    if(window.innerHeight-80 < e.pageY) $('.gallery-modal').scrollTop($('.gallery-modal').scrollTop() + 30);
21672                    if(e.pageY < 80) $('.gallery-modal').scrollTop($('.gallery-modal').scrollTop() - 30);
21673                }
21674                if($('.ui-selectable-helper').length == 0) return;
21675                if(e.target.className.match(/(gallery-items ui-selectable|item-ctrl|img-responsive|ui-selected|ui-selectee|item-title|table-item|td-handle|item-handle|td-check|td-input|td-check|td-number|td-title|td-edit|td-img|info-link|td-edut|td-category|td-price|td-quantity)/)) { 
21676                    $('.gallery-modal, .gallery-items-loadmore, .gallery-category, .gallery-category li, .checkbox label, .gallery-toolbar .toolbar li, .btn, .gallery-button li').removeClass('not-allowed');
21677                } else { 
21678                    $('.gallery-modal, .gallery-items-loadmore, .gallery-category, .gallery-category li, .checkbox label, .gallery-toolbar .toolbar li, .btn, .gallery-button li').addClass('not-allowed');
21679                }
21680            }).on('mouseup', function(e) {
21681                if($('.gallery-modal .clone-item').length) {
21682                    $('.gallery-modal .clone-item').remove();
21683                    $('.gallery-items .item').removeClass('prev last drag');
21684                    $('.gallery-items .table-item').removeClass('prev last drag');
21685                    clicking = false;
21686                }
21687                // $('.gallery-items').selectable('enable');
21688                $('.gallery-modal, .gallery-items-loadmore, .gallery-category, .gallery-category li, .checkbox label, .gallery-toolbar .toolbar li, .btn, .gallery-button li').removeClass('not-allowed');
21689                stickyToolbar();
21690            });
21691            $(document).on('mousedown','.gallery-items',function(e) {
21692                if(typeof e.target.className == 'string' && typeof e.target.className != 'undefined' && e.target.className.indexOf('gallery-items') > -1) {
21693                    $.each($('.item-title'), function(i,v) {
21694                        if($(this).is(':focus')) {
21695                            $(this).blur();
21696                        }
21697                    });
21698                }
21699            });
21700            $(document).on('mouseup','.gallery-items',function(e) {
21701                $('.table-item-status').hide();
21702                $('.status-change').removeClass('open');
21703                var group = ($('.table-item').length) ? '.table-item' : '.gallery-items .item';
21704                if($(group + '.ui-selected').length == 0 && $(group).length) {
21705                    if($.gallery.mode == 'shopping') {
21706                        $('.gallery-items .table-item').removeClass('ui-selected return');
21707                        $('.table-toolbar > li').removeClass('open').find('.item-submenu').hide();
21708                        $('.gallery-view-count').removeClass('open').find('.view-submenu').hide();
21709                        $('.gallery-items .table-item > div').removeClass('hide-text');
21710                        $('.gallery-items .table-item input').prop('checked',fal
21710se);
21711                        $('.table-toolbar .toolbar-cmd').addClass('hide');
21712                        $('.table-toolbar .toolbar-cmd i[data-glseq]').attr('data-glseq','');
21713                        $('.table-toolbar .toolbar-cmd i[data-cmd="link"]').attr('data-glink','').attr('data-glink-target','');
21714                        $('.table-toolbar .toolbar-cmd i[data-cmd="visible"]').attr('data-visible','0').text($.lang[LANG]['editor.gallery.icon.visible.off']);
21715                        $('.gallery-toolbar').removeClass('hide_col');
21716                        $('.col-check > input[type="checkbox"]').prop('checked',false);
21717                        $('.gallery-toolbar').addClass('hide'); 
21718                        $('.gallery-items .item-header').removeClass('hide');
21719                    } else {
21720                        $.gallery.seqs = [];
21721                        $('.gallery-items .item').removeClass('ui-selected return');    
21722                        $('.gallery-toolbar').empty();
21723                        $('.gallery-toolbar').addClass('hide');
21724                        $('.gallery-items .item-header').removeClass('hide');
21725                    }
21726                }
21727                $('.ui-selectable-helper').removeClass('hide');
21728                // $(".gallery-items").selectable("enable");
21729                if($.gallery.seqs.length && ($('.gallery-items .item').hasClass('prev') || $('.gallery-items .item').hasClass('last'))) {
21730                    if($('.gallery-items .item.last').length) {
21731                        if($('.gallery-items .item.last').next().length) {
21732                            $.gallery.drag = $('.gallery-items .item.last').next().attr('data-seq');
21733                        } else {
21734                            $.gallery.drag = $('.gallery-items .item.last').attr('data-seq');
21735                            $.gallery.last = '-1';
21736                        }
21737                    } else if($('.gallery-items .item.prev').length) {
21738                        $.gallery.drag = $('.gallery-items .item.prev').attr('data-seq');
21739                    }
21740                    $('.gallery-modal .clone-item').remove();
21741                    $('.gallery-items .item').removeClass('prev drag last');
21742
21743                    $.gallery.move = $.gallery.seqs;
21744                    $.gallery.mv();
21745                }
21746                if(typeof e.target.className == 'string' && e.target.className.indexOf('gallery-items') > -1) {
21747                    $.each($('.item-title'), function(i,v) {
21748                        if($(this).is(':focus')) {
21749                            $(this).blur();
21750                        }
21751                    });
21752                }
21753            });
21754            var isDragging = false;
21755            var startingPos = [];
21756            $(document).on('mousedown','.gallery-items .table-item',function(e) {
21757                isDragging = false;
21758                clicking = true;
21759                startingPos = [e.pageX, e.pageY];
21760                if(e.shiftKey) {
21761                    var seq_start = $('.gallery-items .table-item[data-seq="' + $.gallery.seqs[0] + '"]').index(),
21762                        seq_end = $(this).index();
21763                    $.gallery.seqs = [];
21764                    $('.gallery-items .item').removeClass('ui-selected return');
21765
21766                    // header, sticky 요소 추가로 -2
21767                    seq_start = seq_start - 2;
21768                    seq_end = seq_end - 2;
21769                    var start = 0, end = 0;
21770                    if(seq_start<seq_end) {
21771                        for(var i=seq_start; i<=seq_end; i++) {
21772                            var $shifted_item = $('.gallery-items .table-item');
21773                            $shifted_item.eq(i).addClass('ui-selected');
21774                            // $.gallery.seqs.push($shifted_item.eq(i).attr('data-seq'));
21775                        }
21776                    } else {
21777                        for(var i=seq_start; i>=seq_end; i--) {
21778                            var $shifted_item = $('.gallery-items .table-item');
21779                            $shifted_item.eq(i).addClass('ui-selected');
21780                            // $.gallery.seqs.push($shifted_item.eq(i).attr('data-seq'));
21781                        }
21782                    }
21783                    $('.gallery-toolbar').removeClass('hide');
21784                    $('.gallery-items .item-header').addClass('hide');
21785                    stickyToolbar();
21786                }
21787            });
21788            $(document).on('mousedown','.gallery-items .item',function(e) {
21789                if($('.item-title').is(':focus')) return;
21790                isDragging = false;
21791                clicking = true;
21792                startingPos = [e.pageX, e.pageY];
21793                $('.gallery-modal .clone-item').remove();
21794                if(e.target.className.indexOf('item') === 0) {
21795                    $(".ui-selectable-helper").addClass('hide');
21796                    $(".gallery-items").selectable("disable");
21797                }
21798
21799                $('.gallery-blocks .btn-group').removeClass('open');
21800                var key = e.keyCode || e.which,
21801                    seq = $(this).attr('data-seq'),
21802                    seq_idx = ($.gallery.seqs).indexOf(seq);
21803
21804                if(e.ctrlKey) {
21805                    if(seq_idx > -1) {
21806                        $(this).removeClass('ui-selected return');
21807                        // ($.gallery.seqs).splice(seq_idx,1);
21808                    } else {
21809                        $(this).addClass('ui-selected');
21810                        // $.gallery.seqs.push(seq);
21811                    }
21812                    $.gallery.selected();
21813                    stickyToolbar();
21814                } else if(e.shiftKey) {
21815                    if(($.gallery.seqs).length > 0) {
21816                        var seq_start = $('.gallery-items .item[data-seq="' + $.gallery.seqs[0] + '"]').index(),
21817                            seq_end = $(this).index();
21818                        $.gallery.seqs = [];
21819                        $('.gallery-items .item').removeClass('ui-selected return');
21820                        // console.log(seq_start,seq_end);
21821                        // header, sticky 요소 추가로 -2
21822                        seq_start = seq_start - 1;
21823                        seq_end = seq_end - 1;
21824                            var start = 0, end = 0;
21825                        if(seq_start<seq_end) {
21826                            for(var i=seq_start; i<=seq_end; i++) {
21827                                var $shifted_item = $('.gallery-items .item');
21828                                $shifted_item.eq(i).addClass('ui-selected');
21829                                // $.gallery.seqs.push($shifted_item.eq(i).attr('data-seq'));
21830                            }
21831                        } else {
21832                            for(var i=seq_start; i>=seq_end; i--) {
21833                                var $shifted_item = $('.gallery-items .item');
21834                                $shifted_item.eq(i).addClass('ui-selected');
21835                                // $.gallery.seqs.push($shifted_item.eq(i).attr('data-seq'));
21836                            }
21837                        }
21838                        $.gallery.selected();
21839                        stickyToolbar();
21840                    }
21841                } else {
21842                    if(!$(this).hasClass('ui-selected')) {
21843                        $.gallery.seqs = []; 
21844                        $.gallery.seqs.push(seq);
21845                        $('.gallery-items .item').removeClass('ui-selected return');
21846                        // $(this).parent().removeClass('move').removeClass('copy');
21847                        $(this).addClass('ui-selected');
21848                        stickyToolbar();
21849
21850                        // cut, copy remove
21851                        var i = ($.gallery.copy).indexOf(seq);
21852                        if(i !== -1) ($.gallery.copy).splice(i,1);
21853
21854                        var i = ($.gallery.move).indexOf(seq);
21855                        if(i !== -1) ($.gallery.move).splice(i,1);
21856                    }
21857                }
21858            });
21859            $(document).on('mousedown','.gallery-items .td-handle',function(e) {
21860                // if($('.gallery-items .table-item.ui-selected').length == 0) {
21861                if($(this).parent().hasClass('ui-selected') == false) {
21862                    $(this).parent().addClass('ui-selected').find('.td-check input[type="checkbox"]').prop('checked',true);
21863                    $.gallery.seqs.push($(this).parent().attr('data-seq'));
21864                }
21865            });
21866            $(document).on('mousemove','.gallery-items .table-item',function(e) {
21867                if(clicking === false) return;
21868                $('.gallery-items .table-item').removeClass('prev');
21869
21870                if($('.gallery-modal .clone-item').length) {
21871                    var $clone = $('.gallery-modal .clone-item');
21872                    $clone.css({
21873                        'position' : 'fixed',
21874                        'cursor' : 'move',
21875                        'z-index' : '1090'
21876                    });
21877                    $clone.css({
21878                        'left' : e.pageX+5,
21879                        'top' : e.pageY-25
21880                    }).attr('data-count',($.gallery.seqs).length).find('input').remove();
21881                    if(($.gallery.seqs).length >1) $clone.addClass('multi');
21882
21883                    var this_top = e.pageY - $(this).offset().top;
21884                    if($(this).is(':last-child') && this_top > 45) {
21885                        $(this).removeClass('prev').addClass('last');
21886                    } else $(this).removeClass('last').addClass('prev');
21887                    if(window.innerHeight-80 < e.pageY) $('.gallery-modal').scrollTop($('.gallery-modal').scrollTop() + 30);
21888                    if(e.pageY < 80) $('.gallery-modal').scrollTop($('.gallery-modal').scrollTop() - 30);
21889                    e.stopPropagation();
21890                } 
21891            });
21892            $(document).on('mouseenter','.gallery-items .table-item',function(e) {
21893                if($('#user-edit').length == 0) { 
21894                    $('.edit-button').hide();
21895                    if($(this).hasClass('yet')) return;
21896                    $(this).find('.edit-button').show();
21897                } else $('.edit-button').hide();
21898            }).on('mouseleave','.gallery-items .table-item',function(e) {
21899                $('.edit-button').hide();
21900            });
21901            $(document).on('mouseenter','.gallery-items .td-category', function(e) {
21902                var cate_arr = $(this).text().trim().split(',');
21903                if(cate_arr.length < 2) return;
21904
21905                var cate_str = '';
21906                $.each(cate_arr, function(i,v) {
21907                    cate_str += '<li>' + v.trim() + '</li>';
21908                });
21909
21910                var gcate_tooltip_place = ($('.gallery-modal').height() <= $(this).closest('.table-item').offset().top + $(this).closest('.table-item').outerHeight()) ? 'top' : 'bottom'; 
21911                var gcate_tooltip_css = (gcate_tooltip_place == 'to
21911p') ? {
21912                    'top': (Math.floor($('.gallery-modal').scrollTop() + $(this).offset().top - (100 + ((cate_arr.length-2) * 20)))) + 'px',
21913                    'left': (Math.floor($(this).offset().left) -30) + 'px',
21914                } : {
21915                    'top': (Math.floor($('.gallery-modal').scrollTop() + $(this).offset().top + $(this).outerHeight()) - 7) + 'px',
21916                    'left': (Math.floor($(this).offset().left) -30) + 'px',
21917                }
21918
21919                $('.gcategory-tooltip ul').empty().html(cate_str);
21920                $('.gcategory-tooltip').attr('data-place',gcate_tooltip_place).css(gcate_tooltip_css).show();
21921            });
21922            $(document).on('mouseleave', '.gallery-items .td-category', function(e) {
21923                if($('.gcategory-tooltip').css('display') === 'none') return;
21924                $('.gcategory-tooltip').hide().removeAttr('style');
21925                $('.gcategory-tooltip ul').empty();
21926            });
21927            $(document).on('mousemove','.gallery-items .td-handle',function(e) {
21928                if($('.gallery-modal').attr('data-pid') == undefined) {
21929                    return false;
21930                }
21931                if(clicking === false || $('.gallery-items .table-item.ui-selected').length == 0) return;
21932                $('.td-edit .item-edit').css('display','none');
21933                if ((e.pageX  < startingPos[0]-10 || e.pageX  > startingPos[0]+10) ||
21934                    (e.pageY  < startingPos[1]-10 || e.pageY  > startingPos[1]+10)) {
21935                    $('.gallery-items .table-item.ui-selected').addClass('drag');
21936                    if($('.gallery-modal .clone-item').length == 0 && !LUX) {
21937                        var $clone = $(this).parent().clone();
21938                        $clone.css({
21939                            'position' : 'fixed',
21940                            'cursor' : 'move',
21941                            'z-index' : '1090'
21942                        }).addClass('clone-item').attr('data-count',($.gallery.seqs).length).find('input').remove();
21943                        $('.gallery-modal').append($clone);
21944
21945                        $clone.css({
21946                            'left' : e.pageX+10,
21947                            'top' : e.pageY+10
21948                        });
21949                        if(($.gallery.seqs).length >1) $clone.addClass('multi');
21950                    } 
21951                    isDragging = true;
21952                    // var parentOffset = $(this).parent().offset(); 
21953                    // var relX = e.pageX - parentOffset.left;
21954                    // var relY = e.pageY - parentOffset.top;
21955                    // $('.gallery-items .item').removeClass('prev last');
21956                    // var this_top = $(this).position().top,
21957                    //     next_top = ($(this).next().length) ? $(this).next().position() : -1;
21958                    // console.log(parentOffset);
21959                    // if(this_top == next_top) {
21960                    //     (relX - $(this).position().left < 62) ? $(this).addClass('prev') : $(this).next().addClass('prev');
21961                    // } else {
21962                    //     (relX - $(this).position().left < 62) ? $(this).addClass('prev') : $(this).addClass('last');
21963                    // }
21964                }
21965            });
21966            $(document).on('mousemove','.gallery-items .item',function(e) {
21967                if(clicking === false || $('.item-title').is(':focus')) return;
21968                if ((e.pageX  < startingPos[0]-10 || e.pageX  > startingPos[0]+10) ||
21969                    (e.pageY  < startingPos[1]-10 || e.pageY  > startingPos[1]+10)) {
21970                    $('.gallery-items .item.ui-selected').addClass('drag');
21971                    if($('.gallery-modal .clone-item').length == 0 && !LUX) {
21972                        var $clone = $(this).clone();
21973                        $clone.css({
21974                            'position' : 'fixed'
21975                        }).addClass('clone-item').attr('data-count',($.gallery.seqs).length).find('input').remove();
21976                        $('.gallery-modal').append($clone);
21977                        if(($.gallery.seqs).length >1) $clone.addClass('multi');
21978                    } 
21979                    isDragging = true;
21980                    var parentOffset = $(this).parent().offset(); 
21981                    var relX = e.pageX - parentOffset.left;
21982                    var relY = e.pageY - parentOffset.top;
21983                    $('.gallery-items .item').removeClass('prev last');
21984                    var this_top = $(this).position().top,
21985                        next_top = ($(this).next().length) ? $(this).next().position() : -1;
21986                    if(this_top == next_top) {
21987                        (relX - $(this).position().left < 62) ? $(this).addClass('prev') : $(this).next().addClass('prev');
21988                    } else {
21989                        (relX - $(this).position().left < 62) ? $(this).addClass('prev') : $(this).addClass('last');
21990                    }
21991                }
21992            });
21993            $(document).on('mouseup','.gallery-items .table-item',function(e) {
21994                clicking = false;
21995                if (isDragging) {
21996                    if($.gallery.seqs.length && $('.gallery-modal .clone-item').length) {
21997                        if($('.gallery-items .table-item.last').length) {
21998                            if($('.gallery-items .table-item.last').next().length) {
21999                                $.gallery.drag = $('.gallery-items .table-item.last').next().attr('data-seq');
22000                            } else {
22001                                $.gallery.drag = $('.gallery-items .table-item.last').attr('data-seq');
22002                                $.gallery.last = '-1';
22003                            }
22004                        } else if($('.gallery-items .table-item.prev').length) {
22005                            $.gallery.drag = $('.gallery-items .table-item.prev').attr('data-seq');
22006                        }
22007                        $('.gallery-modal .clone-table-item').remove();
22008                        $('.gallery-items .table-item').removeClass('prev drag last');
22009
22010                        $.gallery.move = $.gallery.seqs;
22011                        $.gallery.mv();
22012                    }
22013                } else {
22014                    $('.gallery-items .table-item.ui-selecting').removeClass('active').addClass('ui-selected');
22015                    $('.check-all').prop('checked',false);
22016                    stickyToolbar();
22017                }
22018                isDragging = false;
22019                startingPos = [];
22020
22021                var l = ($(this).index()%7 > 3) ? 'right' : '',
22022                    mode = $('.gallery-add-items').attr('data-mode');
22023
22024                if(typeof mode == 'undefined' || !mode) {
22025                    alert('Undefined gallery mode');
22026                    return false;
22027                }                        
22028                $.gallery.setNumber();     
22029                $('.ui-selectable-helper').removeClass('hide');
22030                if($('.gallery-modal').attr('data-pid') != undefined) {
22031                    $('.gallery-items').selectable('enable');    
22032                }
22033            });
22034            $(document).on('mouseup','.gallery-items .item',function(e) {
22035                e.preventDefault();
22036                clicking = false;
22037                if (isDragging) {
22038                    if($.gallery.seqs.length && $('.gallery-modal .clone-item').length) {
22039                        if($('.gallery-items .item.last').length) {
22040                            if($('.gallery-items .item.last').next().length) {
22041                                $.gallery.drag = $('.gallery-items .item.last').next().attr('data-seq');
22042                            } else {
22043                                $.gallery.drag = $('.gallery-items .item.last').attr('data-seq');
22044                                $.gallery.last = '-1';
22045                            }
22046                        } else if($('.gallery-items .item.prev').length) {
22047                            $.gallery.drag = $('.gallery-items .item.prev').attr('data-seq');
22048                        }
22049                        $('.gallery-modal .clone-item').remove();
22050                        $('.gallery-items .item').removeClass('prev drag last');
22051
22052                        $.gallery.move = $.gallery.seqs;
22053                        $.gallery.mv();
22054                    }
22055                } else {
22056                    var parentOffset = $(this).parent().offset(),
22057                        relX = e.pageX - parentOffset.left,
22058                        relY = e.pageY - parentOffset.top;
22059                    $('.gallery-items .item.ui-selecting').removeClass('active').addClass('ui-selected');
22060                    stickyToolbar();
22061                }
22062                isDragging = false;
22063                startingPos = [];
22064
22065                var l = ($(this).index()%7 > 3) ? 'right' : '',
22066                    mode = $('.gallery-add-items').attr('data-mode');
22067
22068                if(typeof mode == 'undefined' || !mode) {
22069                    alert('Undefined gallery mode');
22070                    return false;
22071                }                        
22072                // $.gallery.toolbar();
22073                
22074                $.gallery.setNumber();     
22075                $('.ui-selectable-helper').removeClass('hide');
22076                $('.gallery-items').selectable('enable');
22077            });
22078            $(document).on('click','.toolbar-cmd.null', function(e) {
22079                e.stopPropagation();
22080                $.gallery.seqs = [];
22081                $('.gallery-toolbar').addClass('hide');   
22082                $('.gallery-items .item-header').removeClass('hide');
22083                setTimeout(()=> {
22084                    $('.gallery-items .table-item input').prop('checked',fal
22084se);
22085                    $('.gallery-items .table-item').removeClass('ui-selected ui-selecting');
22086                },100);
22087            }); 
22088            $(document).on('click','.gallery-controller',function(e) { 
22089                $.gallery.show($.gallery.block_id);
22090            });
22091            $(document).on('click','.gallery-all',function(e) { 
22092                $.gallery.show($.gallery.block_id);
22093            });
22094            $(document).on('click','.gallery-button .modal-close', function(e) {
22095                $.gallery.close();
22096            });
22097            $(document).on('click','.gallery-button .modal-save', function(e) {
22098                $.gallery.save();
22099            });
22100            $(document).on('keyup','.item-title', function(e) {
22101                if(e.keyCode == 13) $('#empty-text').focus().blur();
22102            });
22103            $(document).on('focus','.item-title', function(e) {
22104                $.gallery.seqs = [];
22105                var seq = $(this).parent().attr('data-seq');
22106                $.gallery.seqs.push(seq);
22107                $('.gallery-items .item').removeClass('ui-selected');
22108                $(this).parent().addClass('ui-selected');
22109            });
22110            $(document).on('mouseenter', '.gallery-items .item > img', function(e) {
22111                // e.stopPropagation();
22112                $('.gallery-items .item .gallery-paste-icon').remove();
22113                var s = '<div class="item-ctrl"></div>',
22114                    $ctrl = $(s);
22115                if($(this).parent().find('.item-ctrl').length == 0)
22116                    $(this).parent().append($ctrl);
22117            });
22118            $(document).on('mouseleave', '.gallery-items .item', function(e) {
22119                $(this).find('.item-ctrl').remove();
22120                $('.gallery-paste-icon').remove();
22121            });
22122            $(document).on('click','.gallery-items .item .gallery-paste-icon', function(e) {
22123                e.stopPropagation();
22124                ($.gallery.seqs).push($(this).parents('.item').attr('data-seq'));
22125                if(($.gallery.copy).length) $.gallery.cp();
22126                if(($.gallery.move).length) $.gallery.mv();
22127            });
22128            $(document).on('click', '.gallery-items .item input', function(e) {
22129                e.stopPropagation();
22130                $('.gallery-toolbar.mod-gallery').remove();
22131            });
22132            $(document).on('keypress click', '.gallery-items .item .item-ctrl', function(e) {
22133                $('.gallery-blocks .btn-group').removeClass('open');
22134                var key = e.keyCode || e.which,
22135                    seq = $(this).parent().attr('data-seq'),
22136                    seq_idx = ($.gallery.seqs).indexOf(seq);
22137                if(e.ctrlKey) {
22138                    if(seq_idx > -1) {
22139                        $(this).parents().removeClass('ui-selected');
22140                        ($.gallery.seqs).splice(seq_idx,1);
22141                    } else {
22142                        $(this).parent().addClass('ui-selected');
22143                        $.gallery.seqs.push(seq);
22144                    }
22145                } else if(e.shiftKey) {
22146                    if(($.gallery.seqs).length > 0) {
22147                        var seq_start = $('.gallery-items .item[data-seq="' + $.gallery.seqs[0] + '"]').index(),
22148                            seq_end = $(this).parent().index();
22149                        $.gallery.seqs = [];
22150                        $('.gallery-items .item').removeClass('ui-selected');
22151                        // console.log(seq_start,seq_end);
22152                        var start = 0, end = 0;
22153                        if(seq_start<seq_end) {
22154                            for(var i=seq_start; i<=seq_end; i++) {
22155                                var $shifted_item = $('.gallery-items .item');
22156                                $shifted_item.eq(i).addClass('ui-selected');
22157                                $.gallery.seqs.push($shifted_item.eq(i).attr('data-seq'));
22158                            }
22159                        } else {
22160                            for(var i=seq_start; i>=seq_end; i--) {
22161                                var $shifted_item = $('.gallery-items .item');
22162                                $shifted_item.eq(i).addClass('ui-selected');
22163                                $.gallery.seqs.push($shifted_item.eq(i).attr('data-seq'));
22164                            }
22165                        }
22166                    }
22167                } else {
22168                    $.gallery.seqs = []; 
22169                    $.gallery.seqs.push(seq);
22170                    $('.gallery-items .item').removeClass('ui-selected return');
22171                    // $(this).parent().removeClass('move').removeClass('copy');
22172                    $(this).parent().addClass('ui-selected');
22173
22174                    // cut, copy remove
22175                    var i = ($.gallery.copy).indexOf(seq);
22176                    if(i !== -1) ($.gallery.copy).splice(i,1);
22177
22178                    var i = ($.gallery.move).indexOf(seq);
22179                    if(i !== -1) ($.gallery.move).splice(i,1);
22180                }
22181                var l = ($(this).index()%7 > 3) ? 'right' : '',
22182                    mode = $('.gallery-add-items').attr('data-mode');
22183
22184                if(typeof mode == 'undefined' || !mode) {
22185                    alert('Undefined gallery mode');
22186                    return false;
22187                }
22188                $(this).parents('.gallery-items').find('.toolbar.mod-gallery').remove();
22189                // var str = '', cmd = '';
22190                // if(($.gallery.move).length || ($.gallery.copy).length) {
22191                //     str = '붙여넣기'; cmd = 'paste';
22192                // } else {
22193                //     str = '잘라내기'; cmd = 'move';
22194                // }
22195
22196                var seq = $(this).parent().attr('data-seq'),
22197                    pid = $(this).parent().attr('data-pid'),
22198                    link = $(this).parent().attr('data-link'),
22199                    target = $(this).parent().attr('data-target'),
22200                    visible = $(this).parent().attr('data-visible');
22201
22202                var vstr = (visible == '1') ? $.lang[LANG]["editor.gallery.icon.visible.on"] : $.lang[LANG]["editor.gallery.icon.visible.off"],
22203                    vicon = (visible == '1') ? 'cl_icon_hide02' : 'cl_icon_show',
22204                    edit_name = ($.gallery.mode == 'gallery') ? $.lang[LANG]['editor.block.gallery.item.edit.image'] : $.lang[LANG]['editor.block.gallery.item.edit'];
22205                var outDatetime = $(this).parent().attr('data-out-datetime');
22206                if(outDatetime !== 'off') {
22207                    visible = outDatetime;
22208                    if(outDatetime == 1) vstr = $.lang[LANG]['editor.gallery.icon.visible.on'];
22209                }
22210                var s = '\
22211                    <ul>\
22212                        <li class="active gallery-item-edit">\
22213                            <i class="" data-glseq="' + seq + '" data-cmd="edit"></i>' + edit_name + '\
22214                        </li>\
22215                    ';
22216                s = s + '<li><i class="" data-glseq="' + seq + '" data-cmd="copy"></i>' + $.lang[LANG]['editor.gallery.icon.clone'] + '</li>';
22217
22218                s = s + '<li class="toolbar-sort item-sort">' + $.lang[LANG]['editor.gallery.icon.order'] + ' <i class="fa fa-caret-down" aria-hidden="true" data-glseq="" data-cmd="item-sort"></i>\
22219                            <ul class="item-submenu">\
22220                                <li class="sort-top">' + $.lang[LANG]['editor.gallery.icon.order.front'] + '</li>\
22221                                <li class="sort-bottom">' + $.lang[LANG]['editor.gallery.icon.order.end'] + '</li>\
22222                            </ul>\
22223                        </li>';
22224                s = s + '<li class="toolbar-category"><i class="" data-glseq="" data-cmd="category"></i>' + $.lang[LANG]['editor.block.gallery.category.change'] + ' <i class="fa fa-caret-down" aria-hidden="true"></i>';
22225                s = s + '<ul class="item-submenu">' + $.gallery.cates + '</ul>';
22226                s = s + '</li>';
22227                
22228                s = s + '\
22229                        <li><i class="" data-glseq="' + seq + '" data-glink="' + link + '" data-glink-target="' + target + '" data-cmd="link"></i>' + $.lang[LANG]['editor.gallery.icon.link'] + '</li>\
22230                ';
22231                        
22232                s = s + '\
22233                        <li><i class="" data-glseq="' + seq + '" data-visible="' + visible + '" data-cmd="visible">' + vstr + '</i></li>\
22234                        <li><i class="" data-glseq="' + seq + '" data-cmd="delete"></i>' + $.lang[LANG]['editor.gallery.icon.delete'] + '</li>\
22235                    </ul>\
22236                ';
22237                var $tool_back = $('<div class="toolbar mod-gallery ' + l + '">' + s + '</div>');
22238                $(this).parents('.container').find('.gallery-toolbar').empty();
22239                $(this).parents('.container').find('.gallery-toolbar').append($tool_back);
22240                
22241                // $(this).parent().prev().append($tool_back);
22242                $.gallery.selected();
22243                stickyToolbar();
22244                $.gallery.setNumber();
22245            });
22246            $(document).on('click','.gallery-modal .check-all', function(e) {
22247                e.stopPropagation();
22248                var check = $(this).prop('checked'),
22249                    disabled = false,
22250                    visible_button = false;
22251                if(check) {
22252                    $('.table-item .td-check input[type="checkbox"]').prop('checked',true);
22253                    $('.table-item').addClass('ui-selected');
22254                    $.each($('.table-item'), function(i,v) {
22255                        if($.gallery.seqs.indexOf($(this).attr('data-seq')) == -1) $.gallery.seqs.push($(this).attr('data-seq'));
22256                    });
22257
22258                    $.each($('.gallery-items .table-item.ui-selected'), function(i,v) {
22259                        if($(this).attr('data-product') == "false") disabled = true;
22260                        if($(this).attr('data-out-datetime') == "1") visible_button = true;
22261                    });
22262                    var firstItem = $('.gallery-items .table-item.ui-selected').eq(0),
22263                        first_seq = firstItem.attr('data-seq'),
22264                        link = firstItem.attr('data-link'),
22265                        target = firstItem.attr('data-target'),
22266                        visible = firstItem.attr('data-visible'),
22267                        grade = firstItem.attr('data-grade'),
22268                        vstr = (visible == '1') ? $.lang[LANG]['editor.gallery.icon.visible.on'] : $.lang[LANG]['editor.gallery.icon.visible.off'],
22269                        gstr = (grade == 'ON') ? $.lang[LANG]['editor.gallery.icon.grade.off'] : $.lang[LANG]['editor.gallery.icon.grade.on'];
22270                    if(visible_button) {
22271                        $('.table-toolbar .toolbar-cmd.toolbar-visible').addClass('disabled');
22272                    } else $('.table-toolbar .toolbar-cmd.toolbar-visible').removeClass('disabled');
22273                    if($.gallery.block_id == -1) {
22274                        $('.table-toolbar .toolbar-cmd.toolbar-copy').addClass('disabled');
22275                    }
22276                    $('.table-toolbar .toolbar-cmd').removeClass('hide');
22277                    $('.table-toolbar .toolbar-cmd i[data-glseq]').attr('data-glseq',first_seq);
22278                    $('.table-toolbar .toolbar-cmd i[data-cmd="link"]').attr('data-glink',link).attr('data-glink-target',target);
22279                    $('.table-toolbar .toolbar-cmd i[data-cmd="visible"]').attr('data-visible',visible).text(vstr);
22280                    $('.table-toolbar .toolbar-cmd i[data-cmd="grade"]').attr('data-grade',grade).text(gstr);
22281                    $('.gallery-toolbar').addClass('hide_col');
22282                    $('.gallery-toolbar').removeClass('hide');
22283                    $('.gallery-items .item-header').addClass('hide');
22284                    $('.checkbox-cmd .check-all').prop('checked',true);
22285                    stickyToolbar();
22286                } else {
22287                    $('.table-item .td-check input[type="checkbox"]').prop('checked',fal
22287se);   
22288                    $('.table-item').removeClass('ui-selected return');
22289                    $('.table-toolbar .toolbar-cmd').addClass('hide');
22290                    $('.table-toolbar .toolbar-cmd i[data-glseq]').attr('data-glseq','');
22291                    $('.table-toolbar .toolbar-cmd i[data-cmd="link"]').attr('data-glink','').attr('data-glink-target','');
22292                    $('.table-toolbar .toolbar-cmd i[data-cmd="visible"]').attr('data-visible','0').text($.lang[LANG]['editor.gallery.icon.visible.off']);
22293                    $('.gallery-toolbar').removeClass('hide_col');
22294                    $('.gallery-toolbar').addClass('hide');
22295                    $('.gallery-items .item-header').removeClass('hide');
22296                    $('.check-all').prop('checked',false);
22297                    $.gallery.seqs = [];
22298                }
22299                (disabled) ? $('.product-cmd').addClass('disabled') : $('.product-cmd').removeClass('disabled');
22300                if($('.gallery-modal').attr('data-pid') == undefined) {
22301                    $('.toolbar-sort.item-sort').addClass('disabled');
22302                }
22303
22304                $.gallery.setNumber();
22305            });
22306            $(document).on('click','.gallery-view-count', function(e) {
22307                e.stopPropagation();
22308                $(this).toggleClass('open');
22309                if($(this).hasClass('open')) {
22310                    $(this).find('.view-submenu').show();
22311                } else $(this).find('.view-submenu').hide();
22312            });
22313            $(document).on('click','.gallery-view-count li', function(e) {
22314                $('.gallery-view-count li').removeClass('active');
22315                $(this).addClass('active');
22316            });
22317            $(document).on('click','.gallery-move:not(.disabled)', function(e) {
22318                $('.gallery-move-list').removeClass('not-selected');
22319                $('.move-alert').text('');
22320                $('.gallery-move').removeClass('active');
22321                $(this).toggleClass('active');
22322
22323                var block_id = $(this).attr('data-gallery-id'),
22324                    first_title = '';
22325                $.gallery.ex_id = [];
22326
22327                // 선택된 상품 같은 갤러리 이동시 처리
22328                $.each($.gallery.move, function(i,v) {
22329                    var $product = $('.table-item[data-seq="' + v + '"]'),
22330                        product_pid = $product.attr('data-pid'),
22331                        product_title = $product.find('.td-title .item-title-str').text();
22332                    if(block_id == product_pid) {
22333                        if(first_title == '') first_title = "'" + product_title + "'";
22334                        $.gallery.ex_id.push(v);
22335                    }
22336                });
22337                if($.gallery.ex_id.length) {
22338                    $('.move-alert').append('<p>' + first_title + (($.gallery.ex_id.length == 1) ? ' 상품은<br>이미 갤러리에 존재하여 이동에서 제외됩니다.' : ' 외 ' + $.gallery.ex_id.length + '개 상품들은<br>이미 갤러리에 존재하여 이동에서 제외됩니다.</p>'));
22339                }
22340                ($.gallery.ex_id.length == $.gallery.move.length) ?
22341                    $('.ok-button-dialog').addClass('disabled') :
22342                    $('.ok-button-dialog').removeClass('disabled');
22343            });
22344            $(document).on('click', '.gallery-modal .toolbar li', function(e) {
22345                var check_disabled = ($(this).hasClass('product-cmd') && ($(this).hasClass('disabled') || $(this).hasClass('no_price'))) ? true : false;
22346                        
22347                if(check_disabled) {
22348                    var modal_str = ($(this).hasClass('disabled')) ? '상품 정보를 입력한 후에 이용 가능합니다.<br>상품 설정을 완료해주세요.' : '정가가 1원 이상이어야만 [할인] 및 [판매가] 설정이 가능합니다';
22349                    $(this).showModalFlat($.lang[LANG]["config.information"], modal_str, true, false, '', 'ok','','cl-p130 cl-cmmodal cl-s-btn w560 cl-p0 cl-okbtn-pbt70');
22350                    return false;
22351                }
22352
22353                if($(this).hasClass('toolbar-visible') && $(this).hasClass('disabled')) {
22354                    $(this).showModalFlat($.lang[LANG]["config.information"], '판매예정/판매종료인 기간한정판매 상품은 숨김/보이기 옵션을 이용할 수 없습니다.', true, false, '', 'ok','','cl-p130 cl-cmmodal cl-s-btn w560 cl-p0 cl-okbtn-pbt70');
22355                    return false;
22356                }
22357
22358                if($(this).hasClass('toolbar-copy') && $(this).hasClass('disabled')) {
22359                    $(this).showModalFlat($.lang[LANG]["config.information"], '상품 복제는 화면 좌측의 갤러리 목록에서 갤러리 선택 후 사용 가능합니다.', true, false, '', 'ok','','cl-p130 cl-cmmodal cl-s-btn w560 cl-p0 cl-okbtn-pbt70');
22360                    return false;
22361                }
22362
22363                if($(this).hasClass('toolbar-sort') && $(this).hasClass('disabled')) {
22364                    $(this).showModalFlat($.lang[LANG]["config.information"], '상품 순서 변경은 화면 좌측의 갤러리 목록에서 갤러리 선택 후 사용 가능합니다.', true, false, '', 'ok','','cl-p130 cl-cmmodal cl-s-btn w560 cl-p0 cl-okbtn-pbt70');
22365                    return false;
22366                }
22367
22368                $('.ui-selectable-helper').remove();
22369                e.stopPropagation();
22370                var cmd = $(this).find('i').attr('data-cmd'),
22371                    mode = $('.gallery-add-items').attr('data-mode'),
22372                    seq = $(this).find('i').attr('data-glseq'),
22373                    sub = ($(this).parent().hasClass('item-submenu')) ? true : false,
22374                    $this = $(this);
22375
22376                if(typeof cmd == 'undefined' && sub == false && !$(this).hasClass('disabled')) {
22377                    $('.item-submenu').hide();
22378                    $('.submenu').removeClass('open');
22379                    var $submenu = $(this).find('.item-submenu'),
22380                        display = $submenu.css('display');
22381                    (display == 'none') ? $submenu.css('display','block') : $submenu.css('display','none');
22382                    return;
22383                }
22384                if($(this).hasClass('disabled')) {
22385                    if($(this).hasClass('gallery-item-edit')) {
22386                        $(this).showModalFlat($.lang[LANG]["config.information"], $.lang[LANG]['editor.gallery.select.items.info'], true, false, '', 'ok','','cl-p130 cl-cmmodal cl-s-btn w560 cl-p0 cl-okbtn-pbt70');
22387                    }
22388                    return false;
22389                }
22390                if(($.gallery.seqs).length == 0 && cmd != 'checkall') {
22391                    $(this).showModalFlat($.lang[LANG]["config.information"], $.lang[LANG]["editor.gallery.select.item"], true, false,'','ok', '', 'cl-p130 cl-cmmodal cl-s-btn w560 cl-p0 cl-okbtn-pbt70');
22392                    return false;
22393                }
22394                switch(cmd) {
22395                    case "item-sort":
22396                        $(this).toggleClass('open');
22397                        $('.item-submenu').hide();
22398                        if($(this).hasClass('open')) {
22399                            $(this).find('.item-submenu').show();
22400                        }
22401                        $('.toolbar-category').removeClass('open');
22402                        $('.toolbar-category .item-submenu').hide();
22403                        break;
22404                    case "category":
22405                        $(this).toggleClass('open');
22406                        $('.item-submenu').hide();
22407                        $('.toolbar-category .item-submenu li').removeClass('active');
22408                        if($(this).hasClass('open')) {
22409                            $(this).find('.item-submenu').show();
22410                        }
22411                        $('.toolbar-sort').removeClass('open');
22412                        $('.toolbar-sort .item-submenu').hide();
22413                        if(($.gallery.seqs).length == 1) {
22414                            var s = ($('.table-item').length) ? $('.table-item[data-seq="' + $.gallery.seqs[0] + '"]').attr('data-category') : $('.gallery-items .item[data-seq="' + $.gallery.seqs[0] + '"]').attr('data-category');
22415                            if(s) {
22416                                $('.toolbar-category .item-submenu li').each(function() {
22417                                    if(s.includes(`|${$(this).text().trim()}|`)) $(this).addClass('active');
22418                                });
22419                            }
22420                        } else {
22421                            var category_active_text = $('.gallery-category-menu.active').text();
22422                            $('.toolbar-category .item-submenu li:contains("'+category_active_text+'")').addClass('active');
22423                        }
22424                        break;
22425                    case "checkall": 
22426                        var check = $(this).find('input').prop('checked');
22427                        if(check) {
22428                            $('.table-item input').prop('checked',true);
22429                            $('.table-item').addClass('ui-selected');
22430                            $.each($('.table-item'), function(i,v) {
22431                                $.gallery.seqs.push($(this).attr('data-seq'));
22432                            });
22433                            stickyToolbar();
22434                        } else {
22435                            $('.table-item input').prop('checked',fal
22435se);   
22436                            $('.table-item').removeClass('ui-selected return');
22437                            $.gallery.seqs = [];
22438                        }
22439                        break;
22440                    case "edit": 
22441                        ($.gallery.mode == 'shopping') ? $.products.add(seq) : galleryItemController(seq); break;
22442                    case "copy": 
22443                        $.gallery.copy = $.gallery.seqs; $.gallery.move = []; $.gallery.delete = []; // $.gallery.seqs = [];
22444                        $('.gallery-items .item').removeClass('move');
22445                        $('.gallery-toolbar.mod-gallery').remove();
22446                        $.gallery.cp();
22447                        break;
22448                    case "move":
22449                        $.gallery.move = $.gallery.seqs; $.gallery.copy = []; $.gallery.delete = []; $.gallery.seqs = []; $.gallery.ex_id = [];
22450                        $('.gallery-items .item').removeClass('copy');
22451                        $('.gallery-toolbar.mod-gallery').remove();
22452                        var escapeGalleryMoveHtml = function(value) {
22453                            return String(value == null ? '' : value)
22454                                .replace(/&/g, '&amp;')
22455                                .replace(/</g, '&lt;')
22456                                .replace(/>/g, '&gt;');
22457                        };
22458                        var escapeGalleryMoveAttr = function(value) {
22459                            return escapeGalleryMoveHtml(value)
22460                                .replace(/"/g, '&quot;')
22461                                .replace(/'/g, '&#39;');
22462                        };
22463                        var content = '<ul class="gallery-move-list ui-sortable">',
22464                            gallery_count = 0;
22465
22466                        $.each($.gallery.blocks, function(i,v) {
22467                            var m = v.name || v.page || '',
22468                                menu_name_html = v.displayNameHtml || escapeGalleryMoveHtml(m),
22469                                s = v.items || [];
22470                            if(s.length) {
22471                                $.each(s, function(k,n) {
22472                                    if(n.id == $.gallery.block_id && s.length == 1) {
22473                                        return true;
22474                                    }
22475                                    if(k == 0) {
22476                                        content+= '<li><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 4 8"><path d="m-.05-.06 4 4-4 4v-8z"/></svg> ' + menu_name_html + '</li>';
22477                                    }
22478                                    if(n.id != $.gallery.block_id) {
22479                                        switch(n.mode) {
22480                                            case 'shopping': icon = '<svg class="shopping" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 14"><path d="M9.82 2C9.4 0.84 8.3 0 7 0H6C4.7 0 3.6 0.84 3.18 2H0v12h13V2H9.82zM6 1h1c0.74 0 1.37 0.41 1.72 1H4.28C4.63 1.41 5.26 1 6 1zM12 13H1V3h2v3h1V3h5v3h1V3h2V13z"/></svg> '; break;
22481                                            case 'project' : icon = '<svg class="project" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="M13 0H3v3H0v13h13v-3h3V3L13 0zM13 1.41L14.59 3H13V1.41zM1 15V4h8v3h3v8H1zM10 4.41L11.59 6H10V4.41zM15 12h-2V6l-3-3H4V1h8v3h3V12z"/><rect x="3" y="9" width="7" height="1"/><rect x="3" y="12" width="7" height="1"/></svg> '; break;
22482                                            case 'gallery' : icon = '<svg class="gallery" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 13"><path d="M0 0v13h13V0H0zM12 1v7.29l-2-2 -2 2 -4-4 -3 3V1H12zM1 12V8.71l3-3 4 4 2-2 2 2V12H1z"/><circle cx="10" cy="3" r="1"/></svg> '; break;
22483                                        }
22484                                        icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 4 8"><path d="m-.05-.06 4 4-4 4v-8z"/></svg>';
22485                                        var move_disabled = (n.isActive) ? '' : 'disabled';
22486                                        if(LUX && n.mode == 'shopping') move_disabled = 'disabled';
22487                                        content+= '<li class="gallery-move ' + move_disabled + '" data-gallery-id="' + ((move_disabled == '') ? escapeGalleryMoveAttr(n.id) : '') + '"><span class="gallery-block-name">' + escapeGalleryMoveHtml(n.name) + '</span><span class="f-right gallery-name-edit"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="M15.41 0.76l-0.17-0.17C14.85 0.2 14.34 0 13.83 0s-1.02 0.2-1.41 0.59L1 12l-1 4 4-1L15.41 3.59C16.2 2.8 16.2 1.54 15.41 0.76zM3.49 14.1l-2.11 0.53 0.53-2.11 8.95-8.95 1.59 1.59L3.49 14.1zM14.71 2.88l-1.56 1.56 -1.59-1.59 1.56-1.56C13.31 1.1 13.56 1 13.83 1s0.52 0.1 0.71 0.29l0.17 0.17C15.1 1.85 15.1 2.49 14.71 2.88z"/></svg></span></li>';
22488                                        gallery_count++;
22489                                    }
22490                                });
22491                            }
22492                        });
22493                        if(gallery_count == 0) {
22494                            content+= "<li>" + $.lang[LANG]['editor.block.gallery.item.move.none'] + "</li>";
22495                        }
22496                        content+= "</ul><div class='move-alert error'></div>";
22497
22498                        if(gallery_count) {
22499                            content+= '\
22500                            <div class="gallery-confirm-str">' + $.lang[LANG]['editor.block.gallery.item.move.after'] + '</div>\
22501                            <div class="gallery-confirm-select">\
22502                                <div class="gallery-move-select radio">\
22503                                  <label><input type="radio" name="gallery_move_info" class="gallery-move-info" value="stay" checked>' + $.lang[LANG]['editor.block.gallery.item.move.after.1'] + '</label>\
22504                                </div>\
22505                                <div class="gallery-move-select radio">\
22506                                  <label><input type="radio" name="gallery_move_info" class="gallery-move-info" value="move">' + $.lang[LANG]['editor.block.gallery.item.move.after.2'] + '</label>\
22507                                </div>\
22508                            </div>\
22509                            ';
22510                        }
22511
22512                        var moveModal = $(this).showModalFlat($.lang[LANG]['editor.block.gallery.item.move.title'], $.lang[LANG]['editor.block.gallery.item.move.select.1'] + ($.gallery.move).length + $.lang[LANG]['editor.block.gallery.item.move.select.2'] + content, true, true, function() {
22513                            $('.gallery-move-list').removeClass('not-selected');
22514                            $('.move-alert').text('');
22515
22516                            var $active = $('.gallery-move.active:not(.disabled)');
22517                            if($active.length == 0 && gallery_count > 0) {
22518                                $('.gallery-move-list').addClass('not-selected');
22519                                $('.move-alert').text($.lang[LANG]['editor.block.gallery.item.move.error']);
22520                                return false;
22521                            }
22522                            var block_id = $active.attr('data-gallery-id'),
22523                                isMove = $("input.gallery-move-info:checked").val();
22524                            if(typeof block_id == "undefined") {
22525                                $('.move-alert').text($.lang[LANG]['editor.block.gallery.error']);
22526                                return false;
22527                            }
22528
22529                            if($.gallery.ex_id.length) {
22530                                $.gallery.move = $.gallery.move.filter(item => !$.gallery.ex_id.includes(item));
22531                            }
22532                            moveModal.modal('hide');
22533                            var move_block_id = (isMove == "stay") ? $.gallery.block_id : block_id;
22534                            $.progressON($.lang[LANG]['editor.block.gallery.moving.str.1']);
22535                            var total = ($.gallery.move).length, 
22536                                moving = $.lang[LANG]['editor.block.gallery.moving.str.2'], 
22537                                progress = 0,
22538                                loading = '<i class="fa fa-circle-o-notch fa-spin fa-3x fa-fw"></i> ',
22539                                done = 0,
22540                                group = ($('.table-item').length) ? '.table-item' : '.gallery-items .item',
22541                                item = $(group).length,
22542                                cpage = Math.ceil(item/30),
22543                                spos = $('.gallery-modal').scrollTop();
22544                                seqs = $.gallery.move;
22545
22546                            $('.progressModal .info1').html(loading + moving);
22547                            $.each($.gallery.move,function(i,v) {
22548                                var t = setTimeout(function() {
22549                                    if(CANCEL) {
22550                                        if(ABORT) {
22551                                            // 리스트 갱신 작업
22552                                            $.gallery.show($.gallery.block_id,cpage,$.gallery.category, function() {
22553                                                setTimeout(function() { 
22554                                                    $.gallery.move = [];
22555                                                    $('.gallery-modal').scrollTop(spos); 
22556                                                    $.processOFF();
22557                                                    $.gallery.update = true;
22558                                                }, 500);
22559                                            });
22560                                            ABORT = false;
22561                                            $.progressOFF();
22562                                        }
22563                                        i=0; return false;
22564                                    }
22565                                    galleryMoveItem(block_id,v,$.gallery.pages[block_id],function() {
22566                                        done++;
22567                                        progress = parseInt((done / total) * 100,10);
22568                                        $('.file-upload-progress .progress-bar').css('width',progress + "%");
22569                                        $('.progressModal .info2').text(done.toString() + ' / ' + total.toString());
22570                                        if(typeof VIEW == 'undefined') {
22571                                            $.gallery.unlink = true;
22572                                        } else if(v==VIEW) $.gallery.unlink = true;
22573                                        if(total == done) {
22574                                            $.gallery.show(move_block_id,1,$.gallery.category, function() {
22575                                                var group = ($('.table-item').length) ? '.table-item' : '.gallery-items .item';
22576                                                $.each($.gallery.move, function(i,v) {
22577                                                    $(group + '[data-seq="' + v + '"]').addClass('return');
22578                                                });
22579                                                setTimeout(function() { 
22580                                                    $.gallery.move = [];
22581                                                    $('.gallery-modal').scrollTop(spos); 
22582                                                    $.progressOFF();
22583                                                    $.gallery.update = true;
22584                                                }, 500);
22585                                            });
22586                                        } else {
22587                                            moving = $(group + '[data-seq="' + seqs[i+1] + '"] .td-title .item-title-str').text();
22588                                            if(moving == "") moving = $.lang[LANG]['editor.block.gallery.moving.str.2'];
22589                                            $('.progressModal .info1').html(loading + moving);
22590                                        }
22591                                    });
22592                                },500*i);
22593                            });                            
22594                        },'cancel', 'ok', 'cl-cmmodal cl-s-btn w560 cl-p70 cl-p0',true,'','',function() {
22595                            $.gallery.seqs = $.gallery.move;
22596                        });
22597
22598                        break;
22599                    case "paste":
22600                        if(($.gallery.copy).length) $.gallery.cp();
22601                        if(($.gallery.move).length) $.gallery.mv();
22602                        break;
22603                    case "delete":
22604                        $.gallery.delete = $.gallery.seqs; $.gallery.move = []; $.gallery.copy = [];
22605                        $('.gallery-toolbar.mod-gallery').remove();
22606                        $.gallery.del();
22607                        break;
22608                    case "grade":
22609                        var grade = $(this).find('i').attr('data-grade'),
22610                            visible = '',
22611                            mode = '';
22612                        var $this = $(this);
22613
22614                        visible = (grade == 'ON') ? 0 : 1;
22615                        mode = (visible == 1) ? 'ON' : 'OFF';
22616                        $(this).find('i').attr('data-visible', visible).attr('data-grade', mode);
22617                        $.each($.gallery.seqs, function(i,v) {
22618                            $('.gallery-items .table-item[data-seq="'+ v +'"]').attr('data-grade', mode);
22619                        });
22620                        if(visible == 1) $(this).find('i').text($.lang[LANG]['editor.gallery.icon.grade.off']);
22621                        else $(this).find('i').text($.lang[LANG]['editor.gallery.icon.grade.on']);
22622                        
22623                        $.post('/template/gallery/grade', { s: $.gallery.seqs, view: visible, mode: mode }, function (data) {
22624                            checkError(data);
22625                            
22626                        },'json');
22627
22628                        break;
22629                    case "visible":
22630                        var seq = $(this).find('i').attr('data-glseq'),
22631                            visible = $(this).find('i').attr('data-visible'),
22632                            mode = '';
22633                        var $this = $(this);
22634
22635                        visible = (visible == 1) ? 0 : 1;
22636
22637                        var limitCnt = 0;
22638                        if($('.table-item').length) {
22639                            mode = 'product';
22640                            $.each($.gallery.seqs, function(i,v) {
22641                                var outDatetime = $('.gallery-items .table-item[data-seq="' + v + '"]').attr('data-out-datetime');
22642                                if(visible == 0 && outDatetime == '1') {
22643                                    limitCnt++;
22644                                }
22645                            });
22646                        }
22647
22648                        if(limitCnt > 0) {
22649                            var modal_str = '선택된 상품은 기간한정판매 상품입니다.<br>\
22650                            판매기간 제외 상품노출 기능이 사용으로 변경됩니다.<br>\
22651                            선택한 상품을 노출 시키겠습니까?';
22652
22653                            if(limitCnt > 1) modal_str = '선택된 상품 중 기간한정판매 상품이 포함되어 있습니다.<br>\
22654                                기간한정판매 상품의 판매기간 제외 상품노출 기능이 사용으로 변경됩니다.<br>\
22655                                선택한 '+limitCnt+'개의 상품을 노출 시키겠습니까?';
22656
22657                            var modal = $(this).showModalFlat($.lang[LANG]['config.information'], modal_str, true, true, function(){
22658                                $.post('/template/gallery/visible', { s: $.gallery.seqs, view: visible, mode: mode }, function (data) {
22659                                    checkError(data);
22660                                    updateItem(data.item);
22661                                },'json');
22662
22663                                var type = 'ELEM',
22664                                    checked = (visible) ? false : true;
22665                                setLogs(type,'gallery.item.visible.'+checked,'visible-'+checked,type,'product-manager','el');
22666
22667                                $.each($.gallery.seqs, function(i,v) {
22668                                    if($('.table-item').length) {
22669                                        var outDatetime = $('.gallery-items .table-item[data-seq="' + v + '"]').attr('data-out-datetime');
22670                                        switch (outDatetime) {
22671                                            case 'off':
22672                                                if(visible == '1') {
22673                                                    $('.gallery-items .table-item[data-seq="' + v + '"]').addClass('invisible').attr('data-visible','1');
22674                                                    // $('.gallery-items .table-item[data-seq="' + v + '"] .td-note').text('숨김');
22675                                                } else {
22676                                                    $('.gallery-items .table-item[data-seq="' + v + '"]').removeClass('invisible').attr('data-visible','0');
22677                                                    // $('.gallery-items .table-item[data-seq="' + v + '"] .td-note').text('');
22678                                                }
22679                                                break;
22680                                            case '0':
22681                                                if(visible == '1') {
22682                                                    $('.gallery-items .table-item[data-seq="' + v + '"]').addClass('invisible').attr('data-visible','1');
22683                                                } else {
22684                                                    $('.gallery-items .table-item[data-seq="' + v + '"]').removeClass('invisible').attr('data-visible','0');
22685                                                }
22686                                                break;
22687
22688                                            case '1':
22689                                                (visible == '1') ? $('.gallery-items .table-item[data-seq="' + v + '"]').addClass('invisible').attr('data-out-datetime','1')
22690                                                                : $('.gallery-items .table-item[data-seq="' + v + '"]').removeClass('invisible').attr('data-out-datetime','0');
22691                                                break;
22692                                        }
22693                                    } else {
22694                                        (visible == '1') ? $('.gallery-items .item[data-seq="' + v + '"]').addClass('invisible').attr('data-visible','1')
22695                                                         : $('.gallery-items .item[data-seq="' + v + '"]').removeClass('invisible').attr('data-visible','0');
22696                                    }
22697                                });
22698                                
22699                                (visible == '1') ? $this.find('i').attr('data-visible','1') : $this.find('i').attr('data-visible','0');
22700                                (visible == '1') ? $('.gallery-modal .toolbar li > i[data-cmd="visible"]').text($.lang[LANG]["editor.gallery.icon.visible.on"])
22701                                                 : $('.gallery-modal .toolbar li > i[data-cmd="visible"]').text($.lang[LANG]["editor.gallery.icon.visible.off"]);
22702                                $.gallery.update = true;
22703                                $.gallery.unlink = true;
22704                                modal.modal('hide');
22705                            }, 'cancel', 'ok', 'cl-p70 cl-cmmodal cl-s-btn w560 cl-p0');
22706
22707                            return false;
22708                        }
22709                        
22710                        $.post('/template/gallery/visible', { s: $.gallery.seqs, view: visible, mode: mode }, function (data) {
22711                            checkError(data);
22712                            updateItem(data.item);
22713                        },'json');
22714                        // showPageCallback(showPage);
22715                        var type = 'ELEM',
22716                            checked = (visible) ? false : true;
22717                        setLogs(type,'gallery.item.visible.'+checked,'visible-'+checked,type,'product-manager','el');
22718
22719                        $.each($.gallery.seqs, function(i,v) {
22720                            if($('.table-item').length) {
22721                                var outDatetime = $('.gallery-items .table-item[data-seq="' + v + '"]').attr('data-out-datetime');
22722                                switch (outDatetime) {
22723                                    case 'off':
22724                                        if(visible == '1') {
22725                                            $('.gallery-items .table-item[data-seq="' + v + '"]').addClass('invisible').attr('data-visible','1');
22726                                            // $('.gallery-items .table-item[data-seq="' + v + '"] .td-note').text('숨김');
22727                                        } else {
22728                                            $('.gallery-items .table-item[data-seq="' + v + '"]').removeClass('invisible').attr('data-visible','0');
22729                                            // $('.gallery-items .table-item[data-seq="' + v + '"] .td-note').text('');
22730                                        }
22731                                        break;
22732                                    case '0':
22733                                        if(visible == '1') {
22734                                            $('.gallery-items .table-item[data-seq="' + v + '"]').addClass('invisible').attr('data-visible','1');
22735                                        } else {
22736                                            $('.gallery-items .table-item[data-seq="' + v + '"]').removeClass('invisible').attr('data-visible','0');
22737                                        }
22738                                        break;
22739
22740                                    case '1':
22741                                        (visible == '1') ? $('.gallery-items .table-item[data-seq="' + v + '"]').addClass('invisible').attr('data-out-datetime','1')
22742                                                        : $('.gallery-items .table-item[data-seq="' + v + '"]').removeClass('invisible').attr('data-out-datetime','0');
22743                                        break;
22744                                }
22745                                // if(outDatetime != 'off') {
22746                                //     (visible == '1') ? $('.gallery-items .table-item[data-seq="' + v + '"]').addClass('invisible').attr('data-out-datetime','1')
22747                                //                     : $('.gallery-items .table-item[data-seq="' + v + '"]').removeClass('invisible').attr('data-out-datetime','0');
22748
22749                                // } else {
22750                                //     console.log($('.gallery-items .table-item[data-seq="' + v + '"] .td-note'));
22751                                //     if(visible == '1') {
22752                                //         $('.gallery-items .table-item[data-seq="' + v + '"]').addClass('invisible').attr('data-visible','1');
22753                                //         $('.gallery-items .table-item[data-seq="' + v + '"] .td-note').text('숨김');
22754                                //     } else {
22755                                //         $('.gallery-items .table-item[data-seq="' + v + '"]').removeClass('invisible').attr('data-visible','0');
22756                                //         $('.gallery-items .table-item[data-seq="' + v + '"] .td-note').text('');
22757                                //     }
22758                                // }
22759                            } else {
22760                                (visible == '1') ? $('.gallery-items .item[data-seq="' + v + '"]').addClass('invisible').attr('data-visible','1')
22761                                                 : $('.gallery-items .item[data-seq="' + v + '"]').removeClass('invisible').attr('data-visible','0');
22762                            }
22763                        });
22764
22765                        (visible == '1') ? $this.find('i').attr('data-visible','1') : $this.find('i').attr('data-visible','0');
22766                        (visible == '1') ? $('.gallery-modal .toolbar li > i[data-cmd="visible"]').text($.lang[LANG]["editor.gallery.icon.visible.on"])
22767                                         : $('.gallery-modal .toolbar li > i[data-cmd="visible"]').text($.lang[LANG]["editor.gallery.icon.visible.off"]);
22768                        // $('.gallery-toolbar').empty();
22769                        // galleryStatusInit();
22770                        $.gallery.update = true;
22771                        $.gallery.unlink = true;
22772                        // $.gallery.reset();
22773
22774                        break;
22775                    case "link":
22776                        var config_icon = ($(this).hasClass('gl-item-link')) ? 'gl-item-link' : 'gallery-item-link-icon',
22777                            seq = $(this).find('i').attr('data-glseq'),
22778                            glink = $(this).find('i').attr('data-glink'),
22779                            is_glink_target = $(this).find('i').attr('data-glink-target'),
22780                            glmode = $('.gallery-modal').attr('data-mode'),
22781                            glpid = $('.gallery-modal').attr('data-pid'),
22782                            glpage = $('.gallery-modal').attr('data-page'),
22783                            glel = $('.' + $.gallery.block_id),
22784                            prev_glink = '', input_glink = '',
22785                            prev_glink_id = '',
22786                            target_check = (typeof is_glink_target != 'undefined' && is_glink_target == '_blank') ? 'checked' : '',
22787                            link_content = '',
22788                            glname = $.gallery.block_name;
22789
22790                        var group = ($('.table-item').length) ? '.table-item' : '.gallery-items .item';
22791                        $select_glink = $('.gallery-item[data-seq="'+seq+'"]').find('a');
22792                        if(typeof glink != 'undefined' && glink) {
22793                            if($select_glink.attr('data-user-link')) {
22794                                prev_glink = glink;
22795                                prev_glink_id = $select_glink.attr('data-user-link-id') || '';
22796                            } else if ($select_glink.attr('attr-bookmark')) {
22797                                prev_glink = $select_glink.attr('href');
22798                            } else if ($select_glink.attr('attr-flink')) {
22799                                prev_glink = 'flink@' + $select_glink.attr('attr-flink');
22800                            } else if ($select_glink.attr('attr-link')) {
22801                                prev_glink = $select_glink.attr('attr-link');
22802                            } else {
22803                                prev_glink = glink;
22804                            }
22805                        }
22806                        var site_smenu = (typeof SMENU == 'undefined') ? $.gallery.SMENU : SMENU,
22807                            block_el = (typeof selectEL == 'undefined') ? $.gallery.block_el : selectEL;
22808                        link_content = '<ul class="link-content gallery edit-link-Content" data-type="' + glmode + '" data-name="' + glname + '">\
22809                                        ' + makeLinkList(site_smenu,'gallery',glname,prev_glink,[],prev_glink_id);
22810                        link_content = link_content + '\
22811                            </ul>\
22812                            <div class="link-target">\
22813                                <div class="newcheckbox hand ">\
22814                                    <label>\
22815                                        <div class="newcheckboxSvg">\
22816                                            <input type="checkbox" class="img-link-target" id="linktarget-onoff" '+target_check+' data-el="'+block_el+'" />\
22817                                            <svg viewBox="0 0 16 16" width="16" height="16">\
22818                                                <path class="st6" d="M3 0h10c1.66 0 3 1.34 3 3v10c0 1.66-1.34 3-3 3H3c-1.66 0-3-1.34-3-3V3C0 1.34 1.34 0 3 0z"/>\
22819                                                <path class="st19" d="M13 1c1.1 0 2 0.9 2 2v10c0 1.1-0.9 2-2 2H3c-1.1 0-2-0.9-2-2V3c0-1.1 0.9-2 2-2H13M13 0H3C1.34 0 0 1.34 0 3v10c0 1.66 1.34 3 3 3h10c1.66 0 3-1.34 3-3V3C16 1.34 14.66 0 13 0L13 0z"/>\
22820                                            </svg>\
22821                                            <svg class="active" viewBox="0 0 16 16" width="16" height="16">\
22822                                                <rect x="2" y="2" class="st6" width="12" height="12"/>\
22823                                                <path  class="st19" d="M13 0H3C1.34 0 0 1.34 0 3v10c0 1.66 1.34 3 3 3h10c1.66 0 3-1.34 3-3V3C16 1.34 14.66 0 13 0zM13.03 6.03l-5.5 5.5C7.38 11.68 7.19 11.75 7 11.75s-0.38-0.07-0.53-0.22l-3.5-3.5c-0.29-0.29-0.29-0.77 0-1.06s0.77-0.29 1.06 0L7 9.94l4.97-4.97c0.29-0.29 0.77-0.29 1.06 0S13.32 5.74 13.03 6.03z"/>\
22824                                            </svg>\
22825                                        </div>\
22826                                        <span>'+ $.lang[LANG]['editor.link.open.target'] +'</span>\
22827                                    </label>\
22828                                </div>\
22829                            </div>\
22830                        \
22831                        ';
22832
22833                        var modal = $(this).showModalFlat($.lang[LANG]['editor.link.modal.title.gallery'], link_content, true, true, function() {
22834                            var input_type = $('.link-content').find('.link-type.active').children().attr('class');
22835	                            var result = getInputLink(input_type);
22836	                                link = result[0], isOkay = result[1], isActive = result[2], link_id = result[3],
22837	                                target_val = '', target_change = '';
22838
22839                            target_val = ($('#linktarget-onoff').prop('checked')) ? '_blank' : '';
22840                            target_change = (((target_check=='checked') ? 'on' : 'off') == ((target_val=='_blank') ? 'on' : 'off')) ? false : true;
22841
22842                            if(isOkay) {
22843                                $.each($.gallery.seqs, function(i,v) {
22844                                    if((isActive && prev_glink==link || isActive==false && prev_glink=='') && !target_change && ($.gallery.seqs).length == 1) {
22845                                        modal.modal('hide'); 
22846                                        return true;
22847                                    }
22848
22849                                    var gsettings = {
22850                                        'glink' : (checkBase64Encode(decodeURIComponent(link))) ? link : Base64.encode(link),
22851                                        'glink_target' : target_val
22852                                    }
22853                                    $.post('/template/settings', {sid: SID, settings: JSON.stringify(gsettings), el: 'gallery_settings', seq: v}, function(data) {
22854                                        checkError(data);
22855
22856	                                        $select_glink.removeAttr('data-gallery').removeAttr('data-user-link').removeAttr('data-user-link-id').removeAttr('attr-link').removeAttr('attr-bookmark').removeAttr('attr-flink');
22857                                        $select_glink_config = $('#el-property[data-element="'+block_el+'"] #gallery-list-config');
22858
22859                                        if(link) {
22860                                            var gallery_link = makeLinkUrl(link, ONE, VIEW);
22861
22862                                            $select_glink.attr('href',gallery_link);
22863                                            if(isModalMenuPageLink(link)) {
22864	                                                $select_glink.attr('data-user-link',gallery_link);
22865	                                                $select_glink.attr('data-user-link-id',link_id);
22866	                                            } else if(link.match(/^\@/g) !== null) {
22867                                                $select_glink.attr('attr-bookmark',link.replace(/^\@/g,''));
22868                                            } else if(link.match(/^flink\@/g) !== null) {
22869                                                $select_glink.attr('attr-flink',link.replace(/^flink\@/g,''));
22870                                            }else {
22871                                                $select_glink.attr('attr-link',link);
22872                                            }
22873
22874                                            $select_glink_config.find('.gl-item-link[data-glseq="'+v+'"]').attr('data-glink',link).addClass('active');
22875                                            if(config_icon == 'gallery-item-link-icon') $('.gallery-item-link-icon[data-glseq="'+v+'"]').attr('data-glink',link);
22876                                            
22877                                        } else {
22878                                            $select_glink_config.find('.gl-item-link[data-glseq="'+v+'"]').attr('data-glink',link).removeClass('active');
22879                                            if(config_icon == 'gallery-item-link-icon') $('.gallery-item-link-icon[data-glseq="'+v+'"]').attr('data-glink',link);
22880                                            var imgURL =  $('.gallery-item[data-seq="' + v + '"]').find('img').prop('src');
22881                                            if(glmode == 'gallery') {
22882                                                if((typeof imgURL=='undefined' || !imgURL) && glmode == 'gallery') {
22883                                                    var imgURL_popup = $('.ui-selectee[data-seq="' + v + '"]').find('img').prop('src');
22884                                                    imgURL = imgURL_popup.split('=')[0] + '=s0';
22885                                                }
22886                                                $select_glink.attr({'href': imgURL ,'data-gallery': '#gframe-' + glpid});
22887                                            } else {
22888                                                $select_glink.removeAttr('data-gallery');
22889                                                $select_glink.attr('href', '/'+CONFIG_URL+'config/page/' + glpage + '/view/' + v);
22890                                            }
22891
22892                                        }
22893
22894                                        $(group + '[data-seq="' + v + '"]').attr('data-link',Base64.decode(data.data.glink)).attr('data-target',data.data.glink_target);
22895                                        $('.gallery-modal .gallery-toolbar li [data-cmd="link"]').attr('data-glink',Base64.decode(data.data.glink)).attr('data-glink-target',data.data.glink_target);
22896                                        $('.cl_icon_link').attr('data-glink',data.data.glink).attr('data-glink-target',data.data.glink_target);
22897
22898                                        if(data.data.glink == '') {
22899                                            $('.gallery-items .item[data-seq="' + v + '"]').find('.info').remove();
22900                                            $('.gallery-items .table-item[data-seq="' + v + '"]').find('.info-link').remove();
22901                                        }
22902                                        else {
22903                                            if($('.gallery-items .item[data-seq="' + v + '"]').find('.info-link').length == 0) {
22904                                                // $('.gallery-items .item[data-seq="' + v + '"]').find('.info').append('<span class="info-link"><svg class="svg" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 15 15"><path d="M6 9.85c-0.22 0-0.44-0.08-0.6-0.25 -0.33-0.33-0.33-0.87 0-1.2l3-3c0.33-0.33 0.87-0.33 1.2 0 0.33 0.33 0.33 0.87 0 1.2l-3 3C6.44 9.77 6.22 9.85 6 9.85z"/><path d="M3.85 15c-1.03 0-2-0.4-2.72-1.13C0.4 13.15 0 12.18 0 11.15s0.4-2 1.13-2.72l2-2C3.46 6.1 4 6.1 4.33 6.43c0.33 0.33 0.33 0.87 0 1.2l-2 2c-0.41 0.41-0.63 0.95-0.63 1.52s0.22 1.11 0.63 1.52c0.81 0.81 2.23 0.81 3.04 0l2-2c0.33-0.33 0.87-0.33 1.2 0 0.33 0.33 0.33 0.87 0 1.2l-2 2C5.85 14.6 4.88 15 3.85 15z"/><path d="M11.2 8.85c-0.22 0-0.44-0.08-0.6-0.25 -0.33-0.33-0.33-0.87 0-1.2l2.07-2.07c0.41-0.41 0.63-0.95 0.63-1.52s-0.22-1.11-0.63-1.52c-0.81-0.81-2.23-0.81-3.04 0L7.56 4.36c-0.33 0.33-0.87 0.33-1.2 0 -0.33-0.33-0.33-0.87 0-1.2l2.07-2.07c1.45-1.46 3.99-1.46 5.44 0C14.6 1.82 15 2.78 15 3.81s-0.4 2-1.13 2.72L11.8 8.61C11.64 8.77 11.42 8.85 11.2 8.85z"/></svg></span>');
22905                                                $('.gallery-items .item[data-seq="' + v + '"]').append('<div class="info"><span class="info-link"><svg class="svg" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 15 15"><path d="M6 9.85c-0.22 0-0.44-0.08-0.6-0.25 -0.33-0.33-0.33-0.87 0-1.2l3-3c0.33-0.33 0.87-0.33 1.2 0 0.33 0.33 0.33 0.87 0 1.2l-3 3C6.44 9.77 6.22 9.85 6 9.85z"/><path d="M3.85 15c-1.03 0-2-0.4-2.72-1.13C0.4 13.15 0 12.18 0 11.15s0.4-2 1.13-2.72l2-2C3.46 6.1 4 6.1 4.33 6.43c0.33 0.33 0.33 0.87 0 1.2l-2 2c-0.41 0.41-0.63 0.95-0.63 1.52s0.22 1.11 0.63 1.52c0.81 0.81 2.23 0.81 3.04 0l2-2c0.33-0.33 0.87-0.33 1.2 0 0.33 0.33 0.33 0.87 0 1.2l-2 2C5.85 14.6 4.88 15 3.85 15z"/><path d="M11.2 8.85c-0.22 0-0.44-0.08-0.6-0.25 -0.33-0.33-0.33-0.87 0-1.2l2.07-2.07c0.41-0.41 0.63-0.95 0.63-1.52s-0.22-1.11-0.63-1.52c-0.81-0.81-2.23-0.81-3.04 0L7.56 4.36c-0.33 0.33-0.87 0.33-1.2 0 -0.33-0.33-0.33-0.87 0-1.2l2.07-2.07c1.45-1.46 3.99-1.46 5.44 0C14.6 1.82 15 2.78 15 3.81s-0.4 2-1.13 2.72L11.8 8.61C11.64 8.77 11.42 8.85 11.2 8.85z"/></svg></span></div>');
22906                                            }
22907                                            if($('.gallery-items .table-item[data-seq="' + v + '"] .td-img .info-link').length == 0) {
22908                                                $('.gallery-items .table-item[data-seq="' + v + '"]').find('.td-img').append('<span class="info-link"><svg class="svg" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 15 15"><path d="M6 9.85c-0.22 0-0.44-0.08-0.6-0.25 -0.33-0.33-0.33-0.87 0-1.2l3-3c0.33-0.33 0.87-0.33 1.2 0 0.33 0.33 0.33 0.87 0 1.2l-3 3C6.44 9.77 6.22 9.85 6 9.85z"/><path d="M3.85 15c-1.03 0-2-0.4-2.72-1.13C0.4 13.15 0 12.18 0 11.15s0.4-2 1.13-2.72l2-2C3.46 6.1 4 6.1 4.33 6.43c0.33 0.33 0.33 0.87 0 1.2l-2 2c-0.41 0.41-0.63 0.95-0.63 1.52s0.22 1.11 0.63 1.52c0.81 0.81 2.23 0.81 3.04 0l2-2c0.33-0.33 0.87-0.33 1.2 0 0.33 0.33 0.33 0.87 0 1.2l-2 2C5.85 14.6 4.88 15 3.85 15z"/><path d="M11.2 8.85c-0.22 0-0.44-0.08-0.6-0.25 -0.33-0.33-0.33-0.87 0-1.2l2.07-2.07c0.41-0.41 0.63-0.95 0.63-1.52s-0.22-1.11-0.63-1.52c-0.81-0.81-2.23-0.81-3.04 0L7.56 4.36c-0.33 0.33-0.87 0.33-1.2 0 -0.33-0.33-0.33-0.87 0-1.2l2.07-2.07c1.45-1.46 3.99-1.46 5.44 0C14.6 1.82 15 2.78 15 3.81s-0.4 2-1.13 2.72L11.8 8.61C11.64 8.77 11.42 8.85 11.2 8.85z"/></svg></span>');
22909                                            }
22910                                        }
22911
22912                                        if(target_val == '_blank') $select_glink.attr('target','_blank');
22913                                        else $select_glink.removeAttr('target');
22914                                        
22915                                        // if(target_change) {
22916                                        //     if(target_val) $select_glink.attr('target',target_val);
22917                                        //     else $select_glink.removeAttr('target');
22918                                        //     // $select_glink_config.find('.gl-item-link[data-glseq="'+seq+'"]').attr('data-glink-target',target_val);
22919                                        //     // if(config_icon == 'gallery-item-link-icon') $('.gallery-item-link-icon[data-glseq="'+seq+'"]').attr('data-glink-target',target_val);
22920                                        // }
22921
22922                                        var log_text = (isActive || !isActive && target_change) ? 'active' : 'broken',
22923                                            type = getElementType();
22924                                        setLogs(type,'gallery.link.'+log_text,'link-'+log_text,type,'product-manager','el');
22925
22926                                        // galleryStatusInit();
22927                                    }, 'json');
22928                                });
22929
22930                                modal.modal('hide');
22931                            }
22932                        } ,'cancel', 'ok', 'cl-cmmodal cl-s-btn w560 cl-p70 cl-p0 cl-edit-link modal-portfolio-link site-popup-link cover fullcover-modal',true,'',function(){
22933                            $('[data-toggle="popover"]').popover();
22934                        });
22935                        break;
22936                    case "org-price":
22937                    case "disc-price":
22938                    case "sale-price":
22939                        if($this.hasClass('disabled')) return;
22940                        var price_type = cmd.replace('-price','');
22941                            selectedProduct_html = getSelectedProductList(SID,price_type,$.gallery.seqs),
22942                            config_icon = ($(this).hasClass('gl-item-discount')) ? 'gl-item-discount' : 'gallery-item-discount-icon',
22943                            seq = $(this).find('i').attr('data-glseq'),
22944                            discount = $(this).find('i').attr('data-discount'),
22945                            is_discount_target = $(this).find('i').attr('data-discount-target'),
22946                            glmode = $('.gallery-modal').attr('data-mode'),
22947                            glpid = $('.gallery-modal').attr('data-pid'),
22948                            glpage = $('.gallery-modal').attr('data-page'),
22949                            glel = $('.'+ $.gallery.block_id),
22950                            prev_discount = '', input_discount = '',
22951                            target_check = (typeof is_discount_target != 'undefined' && is_discount_target == '_blank') ? 'checked' : '';
22952                            
22953                        var price_content = '';
22954
22955                        price_content += '<div class="price_setting_box modal-contents-box">'+ selectedProduct_html + '</div>';                       
22956
22957                        var modal = $(this).showModalFlat($.lang[LANG]['editor.block.gallery.product.'+price_type] + $.lang[LANG]['editor.block.gallery.product.price'], price_content, false, true, function() { //confirm
22958                            var useDiscount = $('input[name="use_discount"]:checked').val(),
22959                                discountRate = Number(removeCommas($('#prod-price-rate').val())),
22960                                discountUnit = $('#prod-price-unit').attr('data-value');                 
22961
22962                            if($('.price_setting_box').find('.error_text').length > 0) return false;
22963
22964                            var category_type = $('.price_setting_input_box').attr('data-category'), 
22965                                price_input_val = Number(removeCommas($('#prod-price-rate').val())),
22966                                price_unit = $('#prod-price-unit').attr('data-value'),
22967                                price_mark = $('#price-setting-mark-select').attr('data-value'),
22968                                price_fixtype = (category_type=='org') ? $('input[name="pr_detail_fix_type"][checked="checked"]').attr('data-fix') : '',
22969                                ch_val = (price_mark=='change') ? price_input_val : (price_mark=='raise' ? price_input_val : -price_input_val);
22970
22971                            if(!$('.setting_product_list').hasClass('change_price')) {
22972                                modal.modal('hide');
22973                                return false;
22974                            }
22975
22976                            var route = (CONFIG_URL) ? '/_admin' : '';
22977                            // $.processON();
22978                            // $.ajax({
22979                            //     type: 'POST',
22980                            //     url : route + '/shopping/setProduct',
22981                            //     data :  unit_obj,
22982                            //     dataType : 'json',
22983                            //     async: true,
22984                            //     cache: false,
22985                            //     success : function(data) {
22986                            //         checkError(data);
22987                            //         var page = getStorageItem('gallery-product-page');
22988                            //         $.gallery.show($.gallery.block_id,page,$.gallery.cateogry);
22989                            //         $.gallery.update = true;
22990                            //         $.gallery.reset();
22991                            //         $.processOFF();
22992                            //         modal.modal('hide');
22993                            //     },
22994                            //     error : function(xhr, status, error) {
22995                            //         $.processOFF();
22996                            //         alert("Error " + xhr.status + " : 관리자
22996에게 문의");
22997                            //     }
22998                            // });
22999
23000                            var list_html = ``;
23001                            var list_items = modal.find('.setting_product_list ul[data-gseq]').map(function(){ return {'seq' : $(this).data('gseq'),'pname':$(this).find('.product_title').text()}}).toArray();
23002                            $(list_items).each(function(k, v) {
23003                                list_html += `
23004                                <div class="process" data-seq="${v.seq}">
23005                                    <div class="bar">
23006                                        <div class="progressbar"></div>
23007                                    </div>
23008                                    <div class="desc">
23009                                        <span class="name" style="">${v.pname}</span>
23010                                        <div class="status">변경 중</div>
23011                                    </div>
23012                                </div>
23013                                `;
23014                            });
23015
23016                            var html = `
23017                            <div>
23018                                <div class="main-progress">
23019                                    <div class="bar">
23020                                        <div></div>
23021                                    </div>
23022                                    <div class="spin">
23023                                        <span><i class="fa fa-circle-o-notch fa-spin fa-3x fa-fw"></i></span>
23024                                        <div class="counter"><span>0</span>/${list_items.length}</div>
23025                                    </div>
23026                                </div>
23027                                <div class="detail-progress">
23028                                    ${list_html}
23029                                </div>
23030                            </div>
23031                            `;
23032
23033                            var total_cnt = list_items.length;
23034                            var cur_cnt = 0;
23035                            var ajaxController;
23036                            var cancelFlag = false;
23037                            var hasError = false;
23038                            var product_modal_title = '정가를 변경 중입니다.';
23039                            if(category_type == 'disc') {
23040                                product_modal_title = (price_unit == 'P') ? '할인율을 변경 중입니다.' : '할인가를 변경 중입니다.';
23041                            } else if(category_type == 'sale') {
23042                                product_modal_title = '판매가를 변경 중입니다.';
23043                            }
23044
23045                            var product_modal = $(this).showModalFlat(product_modal_title, html, true, true, function() {
23046                                product_modal.modal('hide');
23047                            },'cancel', 'ok', 'cl-cmmodal cl-product-price-setting cl-s-btn cl-p0 w700 zindex1045 cover fullcover-modal', true, function() {
23048                                // close callback
23049                                console.log('중간에 꺼버림')
23050                                if(ajaxController) ajaxController.abort();
23051                                cancelFlag = true;
23052                            },'',function(){
23053                                modal.modal('hide');
23054                                var page = getStorageItem('gallery-product-page');
23055                                $.gallery.show($.gallery.block_id,page,$.gallery.cateogry);
23056                                $.gallery.update = true;
23057                                $.gallery.reset();
23058                            });
23059
23060                            product_modal.find('.ok-button-dialog').hide();
23061
23062                            function ajaxRequest(item) {
23063                                return new Promise((resolve, reject) => {
23064                                    if(cancelFlag) {
23065                                        reject();
23066                                        return;
23067                                    }
23068                                    ajaxController = $.ajax({
23069                                        url : route + '/shopping/setProduct',
23070                                        async:false,
23071                                        dataType:'json',
23072                                        type:'post',
23073                                        data: {
23074                                            sid: SID, 
23075                                            seqs: item.seq,
23076                                            type: category_type, 
23077                                            mark : price_mark, 
23078                                            v : ch_val, 
23079                                            unit : price_unit,
23080                                            fx : category_type == 'org' ? price_fixtype : '',
23081                                        },
23082                                        success: function(response) {
23083                                            // AJAX 성공 시 애니메이션 효과 추가
23084                                            product_modal.find(`.process[data-seq="${item.seq}"]`).find('.progressbar').css('width', '100%');
23085                                            if(!response.error) {
23086                                                setTimeout(function() {
23087                                                    product_modal.find(`.process[data-seq="${item.seq}"]`).find('.status').addClass('info').text('변경 완료')
23088                                                },500);
23089                                            } else {
23090                                                hasError = true;
23091                                                setTimeout(function() {
23092                                                    product_modal.find(`.process[data-seq="${item.seq}"]`).find('.progressbar').addClass('danger');
23093                                                    product_modal.find(`.process[data-seq="${item.seq}"]`).find('.status').addClass('danger').text('변경 실패');
23094                                                    product_modal.find(`.process[data-seq="${item.seq}"]`).append(
23095                                                        `
23096                                                        <div class="desc">
23097                                                            <span class="error">
23098                                                                <svg viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"></path><rect x="6" y="3" width="1" height="5"></rect><rect x="6" y="9" width="1" height="1"></rect></svg>
23099                                                                ${response.error}
23100                                                            </span>
23101                                                        </div>
23102                                                        `
23103                                                    );
23104                                                }, 500);
23105                                            }
23106                                        },
23107                                        error: function(error) {
23108                                            console.log(error);
23109                                            if(error.statusText === 'abort') {
23110                                                reject();
23111                                                return;
23112                                            }
23113                                            hasError = true;
23114                                            product_modal.find(`.process[data-seq="${item.seq}"]`).find('.progressbar').addClass('danger').css('width', '100%');
23115                                            product_modal.find(`.process[data-seq="${item.seq}"]`).find('.status').addClass('danger').text('변경 실패');
23116                                        },
23117                                        complete:function() {
23118                                            cur_cnt++;
23119                                            product_modal.find(`.main-progress .bar`).find('div').css('width', (cur_cnt/total_cnt*100) + '%');
23120                                            product_modal.find(`.main-progress .counter span`).text(cur_cnt)
23121                                            setTimeout(function() {
23122                                                resolve();
23123                                            },600);
23124                                        }
23125                                    });
23126                                });
23127                            }
23128                            async function runAjaxRequests(items) {
23129                                try {
23130                                    for (var item of items) {
23131                                        await ajaxRequest(item); // 각 요청이 완료될 때까지 기다림
23132                                    }
23133                                } catch (error) {
23134                                    console.log('중지시켜버림')
23135                                }
23136                            }
23137
23138                            setTimeout(function() {
23139                                runAjaxRequests(list_items).then(function() {
23140                                    if(cancelFlag) return;
23141                                    if(hasError) {
23142                                        product_modal.find('.ok-button-dialog').show();
23143                                        product_modal.find('.close-button-dialog').hide();
23144                                    } else {
23145                                        product_modal.modal('hide');
23146                                    }
23147                                });
23148                            },1100)
23149                        } ,'cancel', 'config.change', 'cl-cmmodal cl-s-btn cl-p0 w900 cl-edit-discount modal-product-discount site-popup-discount cl-product-setting cover fullcover-modal fixed', true, '',function(){
23150                            
23151                            var scrollHeight = document.querySelector('.product_contents').scrollHeight,
23152                                clientHeight = document.querySelector('.product_contents').clientHeight;
23153                                
23154                            if(scrollHeight > clientHeight) $('.product_contents').addClass('pr_scroll');
23155                            else $('.product_contents').removeClass('pr_scroll');
23156
23157                        }, function(){ //hide
23158                            // $('[data-toggle="popover"]').popover();
23159                        },true);
23160                        break;
23161                    case "badge":
23162                        var badgeInput = 'change';
23163                        var badgeArr = ['new', 'best', 'md', 'free', 'hot'];
23164                        var product_list = '';
23165                        var badge_head = '';
23166                        var badge_settings = $.parseJSON(localStorage.getItem('badge_settings'));
23167
23168                        $.each(badgeArr, function(idx, type) {
23169                            var bsettings = (typeof badge_settings[type] != 'undefined')? badge_settings[type] : {};
23170                            var badgeType = (typeof bsettings.type != 'undefined' && bsettings.type)? bsettings.type : 'edit';
23171                            var badgeStyle = (typeof bsettings.style != 'undefined' && bsettings.style)? bsettings.style : 'default-1 small';
23172                            var badgeText = (typeof bsettings.badge_text != 'undefined' && bsettings.badge_text)? bsettings.badge_text : $.lang[LANG]['gallery.shopping.badge.'+type];
23173                            var badgeBorderColor = (typeof bsettings.border_color != 'undefined' && bsettings.border_color)? bsettings.border_color : '';
23174                            var badgeBackgroundColor = (typeof bsettings.background_color != 'undefined' && bsettings.background_color)? bsettings.background_color : '';
23175                            var badgeFontColor = (typeof bsettings.font_color != 'undefined' && bsettings.font_color)? bsettings.font_color : '';
23176                            var badgeImgSrc = (typeof bsettings.image_src != 'undefined' && bsettings.image_src)? bsettings.image_src : '';
23177                            var $badge = (badgeType == 'edit')? $('<span class="change-badge-design hand product-badge ' + badgeStyle + '" data-type="'+type+'" data-style="' + badgeStyle + '" data-border_color="' + bsettings.border_color + '" data-background_color="' + bsettings.background_color + '" data-font_color="' + bsettings.font_color + '">' + badgeText + '</span>') : $('<span class="change-badge-design hand product-badge" data-type="'+type+'"><img src="' + bsettings.image_src + '"></span>');
23178                            var badgeCnt = $('.table-item.ui-selected .product-badge[data-type="'+type+'"]').length;
23179                            var checkedAll = '';
23180                            if(badgeBorderColor) $badge.css('border-color', badgeBorderColor);
23181                            if(badgeBackgroundColor) $badge.css('background-color', badgeBackgroundColor);
23182                            if(badgeFontColor) $badge.css('color', badgeFontColor);
23183
23184                            if($.gallery.seqs.length == badgeCnt) {
23185                                checkedAll = 'checked';
23186                            }
23187
23188                            badge_head += '\
23189                                    <div class="divTableHead">\
23190                                        <div class="badge-view">' + $badge[0].outerHTML + '</div>\
23191                                        <div class="newcheckbox">\
23192                                            <label>\
23193                                                <input type="checkbox" class="check-all" data-type="' + type + '" '+checkedAll+'>\
23194                                                <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\
23195                                                    <path d="M13 0H3C1.3 0 0 1.3 0 3v10c0 1.7 1.3 3 3 3h10c1.7 0 3-1.3 3-3V3C16 1.3 14.7 0 13 0zM15 13c0 1.1-0.9 2-2 2H3c-1.1 0-2-0.9-2-2V3c0-1.1 0.9-2 2-2h10c1.1 0 2 0.9 2 2V13z"/>\
23196                                                </svg>\
23197                                                <svg class="active" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\
23198                                                    <path d="M13 0H3C1.34 0 0 1.34 0 3v10c0 1.66 1.34 3 3 3h10c1.66 0 3-1.34 3-3V3C16 1.34 14.66 0 13 0zM13.03 6.03l-5.5 5.5C7.38 11.68 7.19 11.75 7 11.75s-0.38-0.07-0.53-0.22l-3.5-3.5c-0.29-0.29-0.29-0.77 0-1.06s0.77-0.29 1.06 0L7 9.94l4.97-4.97c0.29-0.29 0.77-0.29 1.06 0S13.32 5.74 13.03 6.03z"/>\
23199                                                </svg>\
23200                                            </label>\
23201                                        </div>\
23202                                    </div>\
23203                            ';
23204                        });
23205                        $.each($.gallery.seqs, function(i,v) {
23206                            var badge_list = '';
23207
23208                            $.each(badgeArr, function(idx, type) {
23209                                var $badge = $('.table-item[data-seq="'+v+'"] .product-badge[data-type="'+type+'"]');
23210                                badge_list += '\
23211                                    <div class="divTableCell product-badge-item" data-seq="'+v+'">\
23212                                        <div class="newcheckbox">\
23213                                            <label>\
23214                                                <input type="checkbox" class="product-badge badge-' + type + '" data-type="' + type + '" '+ (($badge.length > 0)? 'checked' : '') +'>\
23215                                                <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\
23216                                                    <path d="M13 0H3C1.3 0 0 1.3 0 3v10c0 1.7 1.3 3 3 3h10c1.7 0 3-1.3 3-3V3C16 1.3 14.7 0 13 0zM15 13c0 1.1-0.9 2-2 2H3c-1.1 0-2-0.9-2-2V3c0-1.1 0.9-2 2-2h10c1.1 0 2 0.9 2 2V13z"/>\
23217                                                </svg>\
23218                                                <svg class="active" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\
23219                                                    <path d="M13 0H3C1.34 0 0 1.34 0 3v10c0 1.66 1.34 3 3 3h10c1.66 0 3-1.34 3-3V3C16 1.34 14.66 0 13 0zM13.03 6.03l-5.5 5.5C7.38 11.68 7.19 11.75 7 11.75s-0.38-0.07-0.53-0.22l-3.5-3.5c-0.29-0.29-0.29-0.77 0-1.06s0.77-0.29 1.06 0L7 9.94l4.97-4.97c0.29-0.29 0.77-0.29 1.06 0S13.32 5.74 13.03 6.03z"/>\
23220                                                </svg>\
23221                                            </label>\
23222                                        </div>\
23223                                    </div>\
23224                                ';
23225                            });
23226                            var num = i + 1;
23227                            product_list += '<div class="divTableRow display-flex space-between align-items-center" data-seq="' + v + '">\
23228                                <div class="divTableCell row-num">' + ((num < 10)? '0' + num : num) + '</div>\
23229                                <div class="divTableCell product-title">' + $('.table-item[data-seq="'+v+'"] .td-title .item-title-str').text() + '</div>\
23230                            ' + badge_list + '</div>';
23231                        });
23232                        var badge_content = '\
23233                            <div class="badge-setting-header display-flex space-between align-items-center">\
23234                                <h2>' + $.lang[LANG]['editor.block.gallery.product.badge'] + '</h2>\
23235                                <ul class="badge-setting-button">\
23236                                    <li class="modal-close">취소</li>\
23237                                    <li class="modal-save ok-button-dialog">저장</li>\
23238                                </ul>\
23239                            </div>\
23240                            <div class="badge-setting-table thin-scroll-bar">\
23241                                <div class="badge-setting-top display-flex space-between align-items-center">\
23242                                    <div class="row-cnt">선택목록<span>' + ($.gallery.seqs.length) + '개</span></div>\
23243                                    <button class="change-badge-design"><svg viewBox="0 0 12 12" width="13" height="12"><path d="M11.56 0.57l-0.13-0.13C11.14 0.15 10.76 0 10.37 0 9.99 0 9.6 0.15 9.31 0.44L0.75 9 0 12l3-0.75 8.56-8.56C12.15 2.1 12.15 1.15 11.56 0.57zM2.49 10.35l-1.11 0.28 0.28-1.11 6.58-6.58 0.84 0.84L2.49 10.35zM10.85 1.98L9.77 3.06 8.94 2.23l1.08-1.08C10.15 1.02 10.29 1 10.37 1s0.23 0.02 0.35 0.15l0.13 0.13C11.05 1.47 11.05 1.79 10.85 1.98z"></path></svg>뱃지 디자인 변경</button>\
23244                                </div>\
23245                                <div class="divTable">\
23246                                    <div class="divTableHeading display-flex space-between align-items-center">\
23247                                        <div class="divTableHead row-num">번호</div>\
23248                                        <div class="divTableHead product-title">상품</div>'
23249                                        + badge_head +
23250                                    '</div>\
23251                                    <div class="divTableBody">' + product_list + '</div>\
23252                                </div>\
23253                                <div class="badge-setting-bottom"></div>\
23254                            </div>\
23255                        ';
23256
23257                        var badgeSettingModal = $(this).showModalFlat('', badge_content, false, true, function() { //confirm
23258                            var same = 0;
23259                            var total = $.gallery.seqs.length;
23260                            var spos = $('.gallery-modal').scrollTop();
23261
23262                            var useBadge_obj = {};
23263                            var before_useBadge_obj = {};
23264                            var update_obj = {};
23265                            $.each($.gallery.seqs, function(i,v) {
23266                                var productName = $('.table-item[data-seq="'+v+'"] .td-title .item-title-str').text();
23267                                var useBadge = [];
23268                                var beforeUseBadge = [];
23269                                $('.product-badge-item[data-seq="'+v+'"]').each(function(idx, badge){
23270                                    var badgeType = $(badge).find('input.product-badge:checked').attr('data-type');
23271                                    if(typeof badgeType != 'undefined' && badgeType) useBadge.push(badgeType);
23272                                });
23273                                
23274                                $.each(badgeArr, function(idx, type) {
23275                                    var $badge = $('.table-item[data-seq="'+v+'"] .product-badge[data-type="'+type+'"]');
23276                                    if ($badge.length > 0) beforeUseBadge.push(type);
23277                                });
23278
23279                                if (JSON.stringify(useBadge) === JSON.stringify(beforeUseBadge)) {
23280                                    same ++;    
23281                                } else {
23282                                    update_obj[v] = useBadge;
23283                                    useBadge_obj[v] = {'pname': productName, 'use_badge': useBadge};
23284                                    before_useBadge_obj[v] = {'pname': productName, 'use_badge': beforeUseBadge};
23285                                }
23286                                
23287                            });
23288
23289                            if(total <= same) {
23290                                if($('.modal-product-badge').eq(0).hasClass('design-update')) {
23291                                    var p = $.gallery.pages;
23292                                    $.gallery.show($.gallery.block_id, p.page, '', function() {
23293                                        setTimeout(function() { 
23294                                            $('.gallery-modal').scrollTop(spos); 
23295                                        }, 200);
23296                                    });
23297
23298                                    $.gallery.update = true;
23299                                    $.gallery.reset();
23300                                }
23301
23302                                badgeSettingModal.modal('hide');
23303                                return false;
23304                            }
23305                            
23306                            $.progressON('뱃지 설정 적용중입니다...', '', '', true);
23307
23308                            var done = 0;
23309                            var progress = 0;
23310                            var route = (CONFIG_URL) ? '/_admin' : '';
23311                            total = Object.keys(update_obj).length;
23312                            $.each(update_obj, function(seq, useBadge) {
23313                                var gsettings = {'use_badge' : useBadge};
23314                                setTimeout(function(){
23315                                    $.ajax({
23316                                        type: 'POST',
23317                                        url: '/template/settings',
23318                                        data: {sid: SID, settings: JSON.stringify(gsettings),  el: 'gallery_settings', seq: seq, screenupdate: 'directupload'},
23319                                        dataType: 'json',
23320                                        async: true,
23321                                        success: function(data) {
23322                                            checkError(data);
23323                                            done++;
23324                                            progress = parseInt((done / total) * 100,10);
23325                                            $('.progressModal .progress-bar').css('width', progress+'%');
23326                                            $('.progressModal .info2').html('<span class="progressCnt">' + done + '</span>' + ' / ' + total);
23327
23328                                            if(total == done) {
23329                                                $.ajax({
23330                                                    type: 'POST',
23331                                                    url: route + '/shopping/badge_design',
23332                                                    data: {sid: SID, type: 'use_badge_slog', slog: JSON.stringify(useBadge_obj), before_slog: JSON.stringify(before_useBadge_obj)},
23333                                                    dataType: 'json',
23334                                                    async: true,
23335                                                    success: function(data) {
23336                                                    }
23337                                                });
23338
23339                                                var p = $.gallery.pages;
23340                                                setTimeout(function(){
23341                                                    $.gallery.show($.gallery.block_id, p.page, '', function() {
23342                                                        setTimeout(function() { 
23343                                                            $('.gallery-modal').scrollTop(spos); 
23344                                                        }, 200);
23345                                                    });
23346
23347                                                    $.gallery.update = true;
23348                                                    $.gallery.reset();
23349                                                    $.progressOFF();
23350
23351                                                    badgeSettingModal.modal('hide');
23352                                                }, 400);
23353                                            }
23354                                        }
23355                                    });
23356                                }, 200*done);
23357                            });
23358                        }, '', '', 'cl-cmmodal cover cl-s-btn cl-p70 cl-p0 cl-edit-badge modal-product-badge', true, '', function() { //show
23359
23360                            $(document).on('change', '.modal-product-badge-wrap .divTableHead .check-all', function() {
23361                                var type = $(this).attr('data-type');
23362                                if($(this).prop('checked') == true) {
23363                                    // $('input.check-all').prop('checked', true);
23364                                    $('.modal-product-badge-wrap input[data-type="'+type+'"]').prop('checked', true);
23365                                } else {
23366                                    $('.modal-product-badge-wrap input[data-type="'+type+'"]').prop('checked', false);
23367                                }
23368                            });
23369                            
23370                            $(document).on('change', '.modal-product-badge-wrap .product-badge-item input[type="checkbox"]', function() {
23371                                var type = $(this).attr('data-type');
23372                                if($(this).prop('checked') == true && ($.gallery.seqs.length == $('.modal-product-badge-wrap .product-badge-item input[type="checkbox"][data-type="'+type+'"]:checked').length)) {
23373                                    $('.modal-product-badge-wrap .divTableHead .check-all[data-type="'+type+'"]').prop('checked', true);
23374                                } else {
23375                                    $('.modal-product-badge-wrap .divTableHead .check-all[data-type="'+type+'"]').prop('checked', false);
23376                                }
23377                            });
23378
23379                            var chBadgeDsgnContent = '\
23380                            <div class="badge-setting-header display-flex space-between align-items-center">\
23381                                <h2>뱃지 디자인 변경</h2>\
23382                                <ul class="badge-setting-button">\
23383                                    <li class="modal-close">취소</li>\
23384                                    <li class="modal-save ok-button-dialog">저장</li>\
23385                                </ul>\
23386                            </div>\
23387                            <div class="badge-setting-top display-flex space-between">\
23388                                <div class="return-default-design hand"><svg viewBox="0 0 20 20" width="20" height="20"><path d="M11.18 3C7.54 3 4.55 5.78 4.21 9.33L2.53 7.65l-.71.7 2.85 2.85 2.85-2.85-.7-.7-1.59 1.59C5.61 6.29 8.13 4 11.18 4c3.31 0 6 2.69 6 6s-2.69 6-6 6c-1.66 0-3.17-.68-4.26-1.78l-.71.71A6.981 6.981 0 0 0 11.
2338818 17c3.87 0 7-3.13 7-7s-3.14-7-7-7z"></path></svg>뱃지 디자인 초기화</div>\
23389                            </div>\
23390                            <div class="divTable">\
23391                                <div class="divTableHeading display-flex space-between align-items-center">\
23392                                    <div class="divTableHead">뱃지</div>\
23393                                    <div class="divTableHead">스타일</div>\
23394                                    <div class="divTableHead">문구</div>\
23395                                    <div class="divTableHead">선</div>\
23396                                    <div class="divTableHead">ë°°ê²½</div>\
23397                                    <div class="divTableHead">텍스트</div>\
23398                                </div>\
23399                                <div class="divTableBody">\
23400                                </div>\
23401                            </div>\
23402                            \
23403                            ';
23404
23405                            // $('.modal-product-badge-wrap .return-prev-setting').on('click', function(){
23406                            //     $('.divTableCell.product-badge-item input[type="checkbox"]').prop('checked', false);
23407                            //     $.each($.gallery.seqs, function(i,v) {
23408                            //         $.each(badgeArr, function(idx, type) {
23409                            //             var $badge = $('.table-item[data-seq="'+v+'"] .product-badge[data-type="'+type+'"]');
23410                            //             var checked = ($badge.length > 0)? 'checked' : '';
23411                            //             $('.divTableCell.product-badge-item[data-seq="'+v+'"] input.product-badge[data-type="'+type+'"]').prop('checked', checked);
23412
23413                            //             var badgeCnt = $('.table-item.ui-selected .product-badge[data-type="'+type+'"]').length;
23414                            //             if($.gallery.seqs.length == badgeCnt) {
23415                            //                 $('.check-all[data-type="'+type+'"]').prop('checked', checked);
23416                            //             }
23417                            //         });
23418                            //     });
23419
23420                            //     var settings = localStorage.getItem('badge_settings');
23421                            //     var before_settings = localStorage.getItem('before_badge_settings');
23422                            //     $('.modal-product-badge').eq(0).addClass('return-prev');
23423                            //     localStorage.setItem('badge_settings', before_settings);
23424                            //     $.badgeSettings.init($.parseJSON(before_settings));
23425
23426                            //     // $.ajax({
23427                            //     //     type: 'POST',
23428                            //     //     url: '/shopping/badge_design',
23429                            //     //     data: { sid: SID, type: 'add', settings: before_settings, before_settings: settings },
23430                            //     //     dataType: 'json',                    
23431                            //     //     async: true,
23432                            //     //     success: function(data) {
23433                            //     //         localStorage.setItem('badge_settings', before_settings);
23434                            //     //         $.badgeSettings.init($.parseJSON(before_settings));
23435                            //     //     }
23436                            //     // });
23437                            // });
23438
23439                            $(document).off('click', '.modal-product-badge-wrap .change-badge-design');
23440                            $(document).on('click', '.modal-product-badge-wrap .change-badge-design', function(e){
23441                                e.stopPropagation();
23442                                if($('.cl-change-badge-design').length > 0) return false;
23443                                var chBadgeModal = $(this).showModalFlat('', chBadgeDsgnContent, false, true, function(){ //confirm
23444                                    var before_settings = localStorage.getItem('before_badge_settings');
23445                                    var input_data = new Object();
23446                                    $('.badge-option-row').each(function(idx, v) {
23447                                        var key = $(v).attr('data-default');
23448                                        input_data[key] = {
23449                                            'type': $(v).find('input[name="type"]').val(),
23450                                            'style': ($(v).find('input[name="type"]').val() == 'edit')? $(v).find('input[name="style"]').val() : '',
23451                                            'badge_text': $(v).find('input[name="badge_text"]').val(),
23452                                            'border_color': $(v).find('input[name="border_color"]').val(),
23453                                            'background_color': $(v).find('input[name="background_color"]').val(),
23454                                            'font_color': $(v).find('input[name="font_color"]').val(),
23455                                            'image_src': $(v).find('input[name="image_src"]').val(),
23456                                            'image_name': $(v).find('input[name="image_name"]').val(),
23457                                        };
23458                                    });
23459                                    var isReset = $('.cl-change-badge-design').hasClass('reset-design');
23460                                    var route = (CONFIG_URL) ? '/_admin' : '';
23461                                    $.ajax({
23462                                        type: 'POST',
23463                                        url: route + '/shopping/badge_design',
23464                                        data: { sid: SID, type: 'add', settings: JSON.stringify(input_data), before_settings: before_settings, is_reset: isReset},
23465                                        dataType: 'json',                    
23466                                        async: true,
23467                                        success: function(data) {
23468                                            if(Object.keys(data).length > 0) {
23469                                                // console.log(data);
23470                                                var badge_settings = data;
23471                                                $.badgeSettings.init(badge_settings);
23472                                                localStorage.setItem('badge_settings', JSON.stringify(badge_settings));
23473                                                $('.modal-product-badge').eq(0).addClass('design-update');
23474                                                $.gallery.update = true;
23475                                            }
23476
23477                                            chBadgeModal.modal('hide');
23478                                        }
23479                                    });
23480                                }, '', '', 'cl-cmmodal cover cl-s-btn cl-p70 cl-p0 cl-edit-badge cl-change-badge-design modal-product-badge', true, '', function() { //show
23481                                    var badge_settings = $.parseJSON(localStorage.getItem('badge_settings'));
23482                                    var changeBadgeDsgnRow = $.badgeSettings.initDesign(badgeArr, badge_settings);
23483                                    $('.cl-change-badge-design .divTableBody').html(changeBadgeDsgnRow);
23484                                    $('.cl-change-badge-design .divTable').after('<div class="text-right">※ 뱃지 디자인 변경 시, 모든 갤러리 블럭의 뱃지 디자인에 반영됩니다.</div>');
23485
23486                                    $('.cl-change-badge-design').closest('.modal-default').css('z-index', 1043);
23487                                    // $('.cl-change-badge-design').closest('.cl-common-modal').next('.modal-backdrop.fade.in').css('z-index', 1044);
23488
23489                                    $('.badge-option-row').each(function(idx, v){
23490                                        if($(v).find('input[name="type"]').val() == 'edit') {
23491                                            var $badge = $(v).find('.product-badge');
23492                                            var badgeBorderColor = style.getHex($badge.css('border-color'));
23493                                            var badgeBackgroundColor = style.getHex($badge.css('background-color'));
23494                                            var badgetextColor = style.getHex($badge.css('color'));
23495                                            
23496                                            $(v).find('.color-picker-badge[pn="border-color"]').css('background-color', badgeBorderColor);
23497                                            $(v).find('.color-picker-badge[pn="background-color"]').css('background-color', badgeBackgroundColor);
23498                                            $(v).find('.color-picker-badge[pn="color"]').css('background-color', badgetextColor);
23499                                        }
23500                                    });
23501
23502                                    $('input[name="badge_text"]').on({
23503                                        focusout: function(){
23504                                            $('.cl-change-badge-design').removeClass('reset-design');
23505                                            // $('.modal-product-badge').eq(0).removeClass('return-prev');
23506
23507                                            var badgeText = $(this).val().trim();
23508                                            if(badgeText) $(this).closest('.badge-option-row').find('.product-badge').text(badgeText);
23509                                        },
23510                                        keyup: function(e){
23511                                            if(e.keyCode == 13) {
23512                                                $('.cl-change-badge-design').removeClass('reset-design');
23513                                                // $('.modal-product-badge').eq(0).removeClass('return-prev');
23514
23515                                                var badgeText = $(this).val().trim();
23516                                                if(badgeText) $(this).closest('.badge-option-row').find('.product-badge').text(badgeText);
23517                                            }
23518                                        }
23519                                    });
23520
23521                                    setBadgeColorPicker();
23522
23523                                    //뱃지 스타일 변경
23524                                    $(document).off('click', '.modal-product-badge-wrap .cl-change-badge-design .select-style-btn');
23525                                    $(document).on('click', '.modal-product-badge-wrap .cl-change-badge-design .select-style-btn', function(){
23526                                        var uploadedImgs = '';
23527                                        if(localStorage.getItem('badge_imgs')) {
23528                                            var uploadedImgsArr = localStorage.getItem('badge_imgs').split('||');
23529                                            // console.log(uploadedImgsArr);
23530                                            $.each(uploadedImgsArr, function(idx, v){
23531                                                var img = v.split('::');
23532                                                var src = (typeof img[1] != 'undefined') ? img[1] : img[0];
23533                                                uploadedImgs += '\
23534                                                <div class="select-badge user-upload hand">\
23535                                                    <span class="product-badge"><img src="'+src+'" alt="'+img[0]+'"></span>\
23536                                                    <span class="delete-badge"><svg viewBox="0 0 12 13" width="12" height="13" data-idx="0"><path d="M12 2h-1H9V0H3.02v2H1 0v1h1v8c0 1.1 0.9 2 2 2h6c1.1 0 2-0.9 2-2V3h1V2zM4.02 1H8v1H4.02V1zM10 11c0 0.55-0.45 1-1 1H3c-0.55 0-1-0.45-1-1V3h1.02H9h1V11z"></path><rect x="4" y="4" width="1" height="7"></rect><rect x="7" y="4" width="1" height="7"></rect></svg></span>\
23537                                                </div>';
23538                                            });
23539                                        }
23540                                        var badgeStylePopup = '\
23541                                        <div class="badge-style-popup">\
23542                                            <div class="badge-style-header display-flex align-items-center space-between">\
23543                                                <div class="badge-style-title">스타일 선택</div>\
23544                                                <div class="modal-close hand"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path d="M8.71 8l7.15-7.15c0.2-0.2 0.2-0.51 0-0.71s-0.51-0.2-0.71 0L8 7.29 0.85 0.15c-0.2-0.2-0.51-0.2-0.71 0s-0.2 0.51 0 0.71L7.29 8l-7.15 7.15c-0.2 0.2
23544-0.2 0.51 0 0.71C0.24 15.95 0.37 16 0.5 16s0.26-0.05 0.35-0.15L8 8.71l7.15 7.15c0.1 0.1 0.23 0.15 0.35 0.15s0.26-0.05 0.35-0.15c0.2-0.2 0.2-0.51 0-0.71L8.71 8z"></path></svg></div>\
23545                                            </div>\
23546                                            <ul class="badge-type-tab display-flex align-items-center">\
23547                                                <li class="hand active" data-tab="edit">편집형</li>\
23548                                                <li class="hand" data-tab="image">이미지형</li>\
23549                                            </ul>\
23550                                            <div class="badge-type-tab-content badge-tab-edit">\
23551                                                <div class="badge-size-tab display-flex align-items-center">\
23552                                                    <span class="select-badge-size hand active" data-size="small">작은</span>\
23553                                                    <span>·</span>\
23554                                                    <span class="select-badge-size hand" data-size="medium">중간</span>\
23555                                                    <span>·</span>\
23556                                                    <span class="select-badge-size hand" data-size="large">큰</span>\
23557                                                </div>\
23558                                                <div class="select-badge-table display-flex" data-size="small">\
23559                                                    <div class="hand select-badge selected" data-style="default-1"><span class="product-badge default-1 small">NEW</span></div>\
23560                                                    <div class="hand select-badge" data-style="red-1"><span class="product-badge red-1 small">NEW</span></div>\
23561                                                    <div class="hand select-badge" data-style="blue-1"><span class="product-badge blue-1 small">NEW</span></div>\
23562                                                    <div class="hand select-badge" data-style="black-1"><span class="product-badge black-1 small">NEW</span></div>\
23563                                                    \
23564                                                    <div class="hand select-badge" data-style="default-2"><span class="product-badge default-2 small">NEW</span></div>\
23565                                                    <div class="hand select-badge" data-style="red-2"><span class="product-badge red-2 small">NEW</span></div>\
23566                                                    <div class="hand select-badge" data-style="blue-2"><span class="product-badge blue-2 small">NEW</span></div>\
23567                                                    <div class="hand select-badge" data-style="black-2"><span class="product-badge black-2 small">NEW</span></div>\
23568                                                    \
23569                                                    <div class="hand select-badge" data-style="default-3"><span class="product-badge default-3 small">NEW</span></div>\
23570                                                    <div class="hand select-badge" data-style="red-3"><span class="product-badge red-3 small">NEW</span></div>\
23571                                                    <div class="hand select-badge" data-style="blue-3"><span class="product-badge blue-3 small">NEW</span></div>\
23572                                                    <div class="hand select-badge" data-style="black-3"><span class="product-badge black-3 small">NEW</span></div>\
23573                                                    \
23574                                                    <div class="hand select-badge" data-style="default-4"><span class="product-badge default-4 small">NEW</span></div>\
23575                                                    <div class="hand select-badge" data-style="red-4"><span class="product-badge red-4 small">NEW</span></div>\
23576                                                    <div class="hand select-badge" data-style="blue-4"><span class="product-badge blue-4 small">NEW</span></div>\
23577                                                    <div class="hand select-badge" data-style="black-4"><span class="product-badge black-4 small">NEW</span></div>\
23578                                                    \
23579                                                    <div class="hand select-badge" data-style="default-5"><span class="product-badge default-5 small">NEW</span></div>\
23580                                                    <div class="hand select-badge" data-style="red-5"><span class="product-badge red-5 small">NEW</span></div>\
23581                                                    <div class="hand select-badge" data-style="blue-5"><span class="product-badge blue-5 small">NEW</span></div>\
23582                                                    <div class="hand select-badge" data-style="black-5"><span class="product-badge black-5 small">NEW</span></div>\
23583                                                    \
23584                                                    <div class="hand select-badge" data-style="default-6"><span class="product-badge default-6 small">NEW</span></div>\
23585                                                    <div class="hand select-badge" data-style="red-6"><span class="product-badge red-6 small">NEW</span></div>\
23586                                                    <div class="hand select-badge" data-style="blue-6"><span class="product-badge blue-6 small">NEW</span></div>\
23587                                                    <div class="hand select-badge" data-style="black-6"><span class="product-badge black-6 small">NEW</span></div>\
23588                                                    \
23589                                                    <div class="hand select-badge" data-style="red-7"><span class="product-badge red-7 small">NEW</span></div>\
23590                                                    <div class="hand select-badge" data-style="red-8"><span class="product-badge red-8 small">NEW</span></div>\
23591                                                    <div class="hand select-badge" data-style="red-9"><span class="product-badge red-9 small">NEW</span></div>\
23592                                                    <div class="hand select-badge" data-style="blue-7"><span class="product-badge blue-7 small">NEW</span></div>\
23593                                                    <div class="hand select-badge" data-style="blue-8"><span class="product-badge blue-8 small">NEW</span></div>\
23594                                                    <div class="hand select-badge" data-style="blue-9"><span class="product-badge blue-9 small">NEW</span></div>\
23595                                                </div>\
23596                                            </div>\
23597                                            <div class="badge-type-tab-content badge-tab-image hide">\
23598                                                <div class="select-badge-table display-flex">\
23599                                                    <div class="hand select-badge"><span class="product-badge"><img src="https://storage.googleapis.com/i.addblock.net/shopping_mall/badge/new.gif" alt="new.gif"></span></div>\
23600                                                    <div class="hand select-badge"><span class="product-badge"><img src="https://storage.googleapis.com/i.addblock.net/shopping_mall/badge/new_r.gif" alt="new_r.gif"></span></div>\
23601                                                    <div class="hand select-badge"><span class="product-badge"><img src="https://storage.googleapis.com/i.addblock.net/shopping_mall/badge/new_g.gif" alt="new_g.gif"></span></div>\
23602                                                    <div class="hand select-badge"><span class="product-badge"><img src="https://storage.googleapis.com/i.addblock.net/shopping_mall/badge/new_b.gif" alt="new_b.gif"></span></div>\
23603                                                    \
23604                                                    <div class="hand select-badge"><span class="product-badge"><img src="https://storage.googleapis.com/i.addblock.net/shopping_mall/badge/best.gif" alt="best.gif"></span></div>\
23605                                                    <div class="hand select-badge"><span class="product-badge"><img src="https://storage.googleapis.com/i.addblock.net/shopping_mall/badge/best_r.gif" alt="best_r.gif"></span></div>\
23606                                                    <div class="hand select-badge"><span class="product-badge"><img src="https://storage.googleapis.com/i.addblock.net/shopping_mall/badge/best_g.gif" alt="best_g.gif"></span></div>\
23607                                                    <div class="hand select-badge"><span class="product-badge"><img src="https://storage.googleapis.com/i.addblock.net/shopping_mall/badge/best_b.gif" alt="best_b.gif"></span></div>\
23608                                                    \
23609                                                    <div class="hand select-badge"><span class="product-badge"><img src="https://storage.googleapis.com/i.addblock.net/shopping_mall/badge/sale.gif" alt="sale.gif"></span></div>\
23610                                                    <div class="hand select-badge"><span class="product-badge"><img src="https://storage.googleapis.com/i.addblock.net/shopping_mall/badge/sale_r.gif" alt="sale_r.gif"></span></div>\
23611                                                    <div class="hand select-badge"><span class="product-badge"><img src="https://storage.googleapis.com/i.addblock.net/shopping_mall/badge/sale_g.gif" alt="sale_g.gif"></span></div>\
23612                                                    <div class="hand select-badge"><span class="product-badge"><img src="https://storage.googleapis.com/i.addblock.net/shopping_mall/badge/sale_b.gif" alt="sale_b.gif"></span></div>\
23613                                                    \
23614                                                    <div class="hand select-badge"><span class="product-badge"><img src="https://storage.googleapis.com/i.addblock.net/shopping_mall/badge/md.gif" alt="md.gif"></span></div>\
23615                                                    <div class="hand select-badge"><span class="product-badge"><img src="https://storage.googleapis.com/i.addblock.net/shopping_mall/badge/md_r.gif" alt="md_r.gif"></span></div>\
23616                                                    <div class="hand select-badge"><span class="product-badge"><img src="https://storage.googleapis.com/i.addblock.net/shopping_mall/badge/md_g.gif" alt="md_g.gif"></span></div>\
23617                                                    <div class="hand select-badge"><span class="product-badge"><img src="https://storage.googleapis.com/i.addblock.net/shopping_mall/badge/md_b.gif" alt="md_b.gif"></span></div>\
23618                                                    \
23619                                                    <div class="hand select-badge"><span class="product-badge"><img src="https://storage.googleapis.com/i.addblock.net/shopping_mall/badge/hot.gif" alt="hot.gif"></span></div>\
23620                                                    <div class="hand select-badge"><span class="product-badge"><img src="https://storage.googleapis.com/i.addblock.net/shopping_mall/badge/hot_g.gif" alt="hot_g.gif"></span></div>\
23621                                                    <div class="hand select-badge"><span class="product-badge"><img src="https://storage.googleapis.com/i.addblock.net/shopping_mall/badge/hot_b.gif" alt="hot_b.gif"></span></div>\
23622                                                    <div class="hand select-badge"><span class="product-badge"><img src="https://storage.googleapis.com/i.addblock.net/shopping_mall/badge/hit.gif" alt="hit.gif"></span></div>\
23623                                                    \
23624                                                    ' + uploadedImgs + '\
23625                                                </div>\
23626                                                <div class="upload-badge-image hand">이미지 직접 올리기<svg viewBox="0 0 12 10" width="12" height="10"><polygon points="10 6 10 8 2 8 2 6 0 6 0 10 12 10 12 6 "></polygon><polygon points="10 3 7 3 7 0 5 0 5 3 2 3 6 7 "></polygon></svg></div>\
23627                                            </div>\
23628                                            <div class="badge-style-footer display-flex align-items-center">\
23629                                                <span class="hide">권장 이미지 높이 : 20px 이하</span>\
23630                                                <ul class="display-flex align-items-center">\
23631                                                    <li class="modal-close hand">취소</li>\
23632                                                    <li class="modal-save hand">저장</li>\
23633                                                </ul>\
23634                                            </div>\
23635                                        </div>\
23636                                        ';
23637
23638                                        $('.badge-style-popup').remove();
23639                                        $(this).toggleClass('active');
23640                                        if($(this).hasClass('active')) {
23641                                            $(this).after(badgeStylePopup);
23642                                            $.badgeSettings.initStylePopup($(this));
23643                                        }
23644                                    });
23645                                    
23646                                    $('.modal-product-badge-wrap .cl-change-badge-design .return-default-design').on('click', function(e) {
23647                                        e.stopPropagation();
23648                                        if($('.cl-reset-badge-design').length > 0) return false;
23649                                        var modal = $(this).showModalFlat('뱃지 디자인 초기화', '모든 갤러리 블록에 적용된 뱃지 디자인이 초기화됩니다.<br>정말 초기화하시겠습니까?', true, true, function(){ //confirm
23650                                            $('.badge-option-row').each(function(idx, v){
23651                                                var $badge = $(v).find('.product-badge-view > .product-badge');
23652                                                var defaultType = $(v).attr('data-default');
23653                                                $badge.attr('class', 'product-badge default-1 small');
23654                                                $badge.removeAttr('style');
23655                                                $badge.html($.lang[LANG]['gallery.shopping.badge.'+defaultType]);
23656
23657                                                $(v).find('input[name="badge_text"]').prop('disabled', false);
23658                                                $(v).find('input[name="badge_text"]').val($.lang[LANG]['gallery.shopping.badge.'+defaultType]);
23659                                                $(v).find('input[name="type"]').val('edit');
23660                                                $(v).find('input[name="style"]').val('default-1 small');
23661                                                $(v).find('input[name="border_color"]').val('#bebebe');
23662                                                $(v).find('input[name="background_color"]').val('#ffffff');
23663                                                $(v).find('input[name="font_color"]').val('#000000');
23664                                                $(v).find('input[name="image_src"]').val('');
23665                                                $(v).find('input[name="image_name"]').val('');
23666
23667                                                $(v).find('.color-picker-badge').removeClass('disabled');
23668                                                $(v).find('.color-picker-badge[pn="border-color"]').css('background-color', '#bebebe');
23669                                                $(v).find('.color-picker-badge[pn="background-color"]').css('background-color', '#ffffff');
23670                                                $(v).find('.color-picker-badge[pn="color"]').css('background-color', '#000000');
23671                                            });
23672                                            $('.cl-change-badge-design').addClass('reset-design');
23673                                            modal.modal('hide');
23674                                        }, 'cancel', 'ok', 'cl-cmmodal cl-reset-badge-design cl-s-btn w560 cl-p70 cl-p0', false, '', function(){ //show
23675                                            $('.cl-reset-badge-design').closest('.modal-default').css('z-index', 1046);
23676                                            $('.cl-reset-badge-design').closest('.cl-common-modal').next('.modal-backdrop.fade.in').css('z-index', 1045);
23677                                        });
23678                                        
23679                                    });
23680
23681                                    $(document).off('click', '.badge-style-popup .modal-save');
23682                                    $(document).on('click', '.badge-style-popup .modal-save', function(){
23683                                        var $selectedBadge = $('.badge-style-popup .badge-type-tab-content:not(.hide) .select-badge-table .select-badge.selected');
23684                                        if($selectedBadge.length > 0) $.badgeSettings.handleSelection($selectedBadge);
23685
23686                                        $('.select-style-btn').removeClass('active');
23687                                        $('.badge-style-popup').remove();
23688                                    });
23689
23690                                    $(document).off('click', '.badge-style-popup .modal-close');
23691                                    $(document).on('click', '.badge-style-popup .modal-close', function(){
23692                                        $('.select-style-btn').removeClass('active');
23693                                        $('.badge-style-popup').remove();
23694                                    });
23695
23696                                    // $('.cl-change-badge-design .modal-body').off('click');
23697                                    // $('.cl-change-badge-design .modal-body').on('click', function(e){
23698                                    //     if(!$(e.target).is('.select-style-btn') && $(e.target).closest('.badge-style-popup').length == 0) {
23699                                    //         $('.select-style-btn').removeClass('active');
23700                                    //         $('.badge-style-popup').remove();
23701                                    //     }
23702                                    // });
23703
23704                                    $(document).off('click', '.badge-type-tab > li');
23705                                    $(document).on('click', '.badge-type-tab > li', function(){ //편집형, 이미지형 탭
23706                                        var optionIdx = $(this).closest('.badge-option-row').attr('data-idx');
23707                                        var badgeText = $('.badge-option-row[data-idx="'+optionIdx+'"] input[name="badge_text"]').val();
23708                                        var badgeType = $('.badge-option-row[data-idx="'+optionIdx+'"] input[name="type"]').val();
23709                                        var badgeStyle = $('.badge-option-row[data-idx="'+optionIdx+'"] input[name="style"]').val();
23710                                        var badgeStyleArr = badgeStyle.split(' ');
23711                                        var style = badgeStyleArr[0];
23712                                        var size = badgeStyleArr[1];
23713
23714                                        $('.badge-type-tab > li').removeClass('active');
23715                                        $(this).addClass('active');
23716                                        $('.badge-type-tab-content').addClass('hide');
23717                                        $('.badge-style-popup .badge-style-footer > span').addClass('hide');
23718
23719                                        $('.badge-tab-' + $(this).attr('data-tab')).removeClass('hide');
23720                                        if($(this).attr('data-tab') == 'edit') {
23721                                            if(!style) style = 'default-1';
23722                                            if(!size) {
23723                                                size = 'small';
23724                                                $('.badge-size-tab .select-badge-size').removeClass('active');
23725                                                $('.badge-size-tab .select-badge-size[data-size="'+size
23725+'"]').addClass('active');
23726                                                $('.select-badge-table').attr('data-size', size);
23727                                            }
23728                                            if(!badgeText) badgeText = $.lang[LANG]['gallery.shopping.badge.'+ $(this).closest('.badge-option-row').attr('data-default')]
23729                                            $('.badge-style-popup .badge-tab-edit .select-badge .product-badge').html(badgeText);
23730                                            $('.badge-style-popup .badge-tab-edit .select-badge .product-badge').addClass(size);
23731                                        } else {
23732                                            $('.badge-style-popup .badge-style-footer > span').removeClass('hide');
23733                                            $('.badge-style-popup .select-badge-table .product-badge').removeClass('small medium large');
23734                                        }
23735                                    });
23736
23737                                    $(document).off('click', '.badge-style-popup .badge-size-tab .select-badge-size');
23738                                    $(document).on('click', '.badge-style-popup .badge-size-tab .select-badge-size', function() { //뱃지 사이즈 탭
23739                                        $('.badge-size-tab .select-badge-size').removeClass('active');
23740                                        $(this).addClass('active');
23741
23742                                        var badgeSize = $(this).attr('data-size');
23743                                        $('.select-badge-table').attr('data-size', badgeSize);
23744                                        $('.select-badge-table .product-badge').removeClass('small medium large');
23745                                        $('.select-badge-table .product-badge').addClass(badgeSize);
23746                                    });
23747
23748                                    $(document).off('click', '.badge-style-popup .select-badge-table .select-badge');
23749                                    $(document).on('click', '.badge-style-popup .select-badge-table .select-badge', function() {
23750                                        if($(this).find('.product-badge > img').attr('src') == '//storage.googleapis.com/i.addblock.net/icon_broken_img.png') {
23751                                            return false;
23752                                        }
23753                                        $('.badge-style-popup .select-badge-table .select-badge').removeClass('selected');
23754                                        $(this).addClass('selected');
23755
23756                                        // $.badgeSettings.handleSelection($(this));
23757                                    });
23758
23759                                    $(document).off('click', '.badge-style-popup .select-badge-table .select-badge .delete-badge');
23760                                    $(document).on('click', '.badge-style-popup .select-badge-table .select-badge .delete-badge', function() {
23761                                        var $this = $(this);
23762                                        var modal = $(this).showModalFlat('뱃지 이미지 삭제', '선택한 이미지를 삭제하시겠습니까?', true, true, function(){ //confirm
23763                                            var optionIdx = Number($this.closest('.badge-option-row').attr('data-idx'));
23764                                            var imgSrc = $this.closest('.select-badge').find('img').attr('src');
23765                                            var imgName = $this.closest('.select-badge').find('img').attr('alt');
23766                                            var beforeImgSrcArr = $('.badge-option-row input[name="image_src"]').map(function(idx, v){
23767                                                return $(v).val();
23768                                            }).get();
23769                                            // console.log(optionIdx, imgSrc, beforeImgSrcArr);
23770                                            $this.closest('.select-badge').remove();
23771                                            
23772                                            var badgeImgsArr = new Array();
23773                                            $('.badge-tab-image .select-badge-table .select-badge.user-upload .product-badge img').each(function(idx, v){
23774                                                var imgData = (typeof $(v).attr('alt') != 'undefined' && $(v).attr('alt')) ? $(v).attr('alt') + '::' + $(v).attr('src') : $(v).attr('src');
23775                                                badgeImgsArr.push(imgData);
23776                                            });
23777                                            // console.log('badgeImgsArr', badgeImgsArr);
23778                                            var badge_imgs = (badgeImgsArr.length > 0)? badgeImgsArr.join('||') : '';
23779                                            var route = (CONFIG_URL) ? '/_admin' : '';
23780                                            $.ajax({
23781                                                type: 'POST',
23782                                                url: route + '/shopping/badge_design',
23783                                                data: { sid: SID, type: 'delete-image', settings: badge_imgs, file_name: imgName, },
23784                                                dataType: 'json',                    
23785                                                async: true,
23786                                                success: function(data) {
23787                                                    // console.log(data);
23788                                                    localStorage.setItem('badge_imgs', badge_imgs);
23789                                                    var imgIdx = beforeImgSrcArr.indexOf(imgSrc);
23790
23791                                                    if(imgIdx > -1) {
23792                                                        var badgeText = $('.badge-option-row[data-idx="'+imgIdx+'"] input[name="badge_text"]').val();
23793
23794                                                        if(imgIdx == optionIdx) {
23795                                                            $('.badge-style-popup .select-badge-table .select-badge').removeClass('selected');
23796                                                            $('.badge-style-popup .badge-tab-edit .select-badge-table').attr('data-size', 'small');
23797                                                            $('.badge-style-popup .badge-tab-edit .select-badge-table .select-badge .product-badge').addClass('small');
23798                                                            $('.badge-style-popup .badge-tab-edit .select-badge-table .select-badge .product-badge').html(badgeText);
23799
23800                                                            var defaultBadge = $('.badge-style-popup .badge-tab-edit .select-badge-table[data-size="small"] .select-badge[data-style="default-1"]');
23801                                                            defaultBadge.addClass('selected');
23802                                                            // console.log('defaultBadge', defaultBadge);
23803                                                            $.badgeSettings.handleSelection(defaultBadge);
23804                                                        } else {
23805                                                            var badgeEL = $('<span class="product-badge default-1 small">' + badgeText + '</span>');
23806                                                            $('.badge-option-row[data-idx="'+imgIdx+'"] .product-badge-view').html(badgeEL);
23807
23808                                                            $('.badge-option-row[data-idx="'+imgIdx+'"]').find('.color-picker-badge').removeClass('disabled');
23809                                                            $('.badge-option-row[data-idx="'+imgIdx+'"]').find('input[name="badge_text"]').prop('disabled', false);
23810
23811                                                            $('.badge-option-row[data-idx="'+imgIdx+'"]').find('.color-picker-badge[pn="border-color"]').css('background-color', '#bebebe');
23812                                                            $('.badge-option-row[data-idx="'+imgIdx+'"]').find('.color-picker-badge[pn="background-color"]').css('background-color', '#ffffff');
23813                                                            $('.badge-option-row[data-idx="'+imgIdx+'"]').find('.color-picker-badge[pn="color"]').css('background-color', '#000000');
23814
23815                                                            $('.badge-option-row[data-idx="'+imgIdx+'"] input[name="type"]').val('edit');
23816                                                            $('.badge-option-row[data-idx="'+imgIdx+'"] input[name="style"]').val('default-1 small');
23817                                                            $('.badge-option-row[data-idx="'+imgIdx+'"] input[name="border_color"]').val('#bebebe');
23818                                                            $('.badge-option-row[data-idx="'+imgIdx+'"] input[name="background_color"]').val('#ffffff');
23819                                                            $('.badge-option-row[data-idx="'+imgIdx+'"] input[name="font_color"]').val('#000000');
23820                                                            $('.badge-option-row[data-idx="'+imgIdx+'"] input[name="image_src"]').val('');
23821                                                            $('.badge-option-row[data-idx="'+imgIdx+'"] input[name="image_name"]').val('');
23822                                                        }
23823                                                    }
23824                                                }
23825                                            });
23826                                            modal.modal('hide');
23827                                        }, 'cancel', 'ok', 'cl-cmmodal cl-delete-badge-image cl-s-btn w560 cl-p70 cl-p0', false);
23828                                    });
23829                                    $(document).on('click', '.upload-badge-image', function(){
23830                                        setResourceBtn(true,{maxcount:0, property:'upload-badge-image', element:'.product-badge'});
23831                                    });
23832                                    
23833                                    
23834                                }, function(){ //hide
23835                                    $('[data-toggle="popover"]').popover();
23836                                });
23837                                
23838                                $('.cl-change-badge-design .badge-setting-button > .modal-close').on('click', function() { 
23839                                    chBadgeModal.modal('hide');
23840                                });
23841                            });
23842                        }, function(){ //hide
23843                            $('[data-toggle="popover"]').popover();
23844                        });
23845
23846                        $('.modal-product-badge-wrap .badge-setting-header .modal-close').on('click', function() {
23847                            badgeSettingModal.modal('hide');
23848                            if($(this).closest('.modal-product-badge').hasClass('design-update')) $.gallery.show($.gallery.block_id);
23849                        });
23850
23851                        break;
23852                    case "margin":
23853                        var route = (CONFIG_URL) ? '/_admin' : '';
23854                        var firstItem = $('.gallery-items .table-item.ui-selected').eq(0),
23855                            margin_rate = firstItem.find('.margin-info .rate').text().trim().replace(/[^0-9.]/g,'') * 1,
23856                            margin_add = firstItem.find('.margin-info .add').text().trim().replace(/[^0-9.]/g,'') * 1,
23857                            margin_seqs = $.gallery.seqs,
23858                            margin_html = '\
23859                                <ul>\
23860                                    <li>\
23861                                        <span class="title">마진율</span>\
23862                                        <span class="prod-margin-price cal-margin">\
23863                                            <svg xmlns="http://www.w3.org/2000/svg" width="17" height="17" fill="currentColor" class="bi bi-plus-lg plus" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M8 2a.5.5 0 0 1 .5.5v5h5a.5.5 0 0 1 0 1h-5v5a.5.5 0 0 1-1 0v-5h-5a.5.5 0 0 1 0-1h5v-5A.5.5 0 0 1 8 2Z"/></svg>\
23864                                            <input type="text" class="prod-user-margin input-margin" value="'+ margin_rate +'" numberOnly>%\
23865                                            <svg xmlns="http://www.w3.org/2000/svg" width="17" height="17" fill="currentColor" class="bi bi-dash-lg minus" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M2 8a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11A.5.5 0 0 1 2 8Z"/></svg>\
23866                                        </span>\
23867                                    </li>\
23868                                    <li>\
23869                                        <span class="title">마진값</span>\
23870                                        <span class="prod-margin-price cal-price">\
23871                                            <svg xmlns="http://www.w3.org/2000/svg" width="17" height="17" fill="currentColor" class="bi bi-plus-lg plus" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M8 2a.5.5 0 0 1 .5.5v5h5a.5.5 0 0 1 0 1h-5v5a.5.5 0 0 1-1 0v-5h-5a.5.5 0 0 1 0-1h5v-5A.5.5 0 0 1 8 2Z"/></svg>\
23872                                            <input type="text" class="prod-user-price input-margin" value="'+ addCommas(margin_add) +'" numberOnly>원\
23873                                            <svg xmlns="http://www.w3.org/2000/svg" width="17" height="17" fill="currentColor" class="bi bi-dash-lg minus" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M2 8a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11A.5.5 0 0 1 2 8Z"/></svg>\
23874                                        </span>\
23875                                    </li>\
23876                                </ul>\
23877                            ';
23878
23879                        var marginModal = $(this).showModalFlat('마진 설정', margin_html, true, true, function() {
23880                            var new_mrate = marginModal.find('.prod-user-margin').val().trim().replace(/[^0-9.]/g,'') * 1,
23881                                new_madd = marginModal.find('.prod-user-price').val().trim().replace(/[^0-9.]/g,'') * 1;
23882                            $.processON();
23883                            setTimeout(function() {
23884                                $.post(route + '/shopping/setMargin', {sid: SID, seqs: margin_seqs, rate: new_mrate, val: new_madd}, function(data) {
23885                                    if(typeof data.error != 'undefined' && data.error) {
23886                                        var marginError = $(this).showModalFlat('ERROR','실패',true,false,'','close','','cl-cmmodal cl-s-btn w560 cl-p130 cl-p0');
23887                                        marginModal.modal('hide');
23888                                        return false;
23889                                    }
23890
23891                                    var changed_seqs = margin_seqs;
23892                                    $('.gallery-modal .table-item.ui-selected').each(function() {
23893                                        // if($.inArray($(this).attr('data-seq'), margin_seqs.i) > -1 || $.inArray($(this).attr('data-seq'), margin_seqs.u) > -1) {
23894                                        if($.inArray($(this).attr('data-seq'), data.list.edit) > -1) {
23895                                            var p_retail = $(this).find('.td-title .add-info .sale-rate').attr('data-retail').trim() * 1,
23896                                                p_supply = $(this).find('.td-title .add-info .margin-info .price').attr('data-supply').trim() * 1,
23897                                                tmp_cal = p_supply * (new_mrate/100),
23898                                                tmp_five = (tmp_cal - Math.floor(tmp_cal) == 0.5) ? true : false,
23899                                                tmp_r = (tmp_five) ? Math.floor(tmp_cal) : Math.round(tmp_cal),
23900                                                new_margin = tmp_r + new_madd,
23901                                                new_price = p_supply + new_margin,
23902                                                new_srate = (p_retail - new_price > 0) ? Math.floor((p_retail - new_price) / p_retail  * 100) : 0;
23903
23904                                            var new_price_span = (new_price > 0) ? '<span class="price-val">' + addCommas(new_price) + '원</span>' : '<span class="price-val">-</span>',
23905                                                new_srate_span = (new_price < p_retail) ? '할인율 <span class="rate">' + new_srate + '</span>%' : '',
23906                                                new_sale_span = (new_price < p_retail) ? '<span class="price-sale">' + addCommas(p_retail) + '원</span>' : '';
23907
23908                                            var p_name = $(this).find('.td-title .item-title-str').text().trim(),
23909                                                p_seq = $(this).attr('data-seq'),
23910                                                pid = $(this).closest('.gallery-modal').attr('data-pid'),
23911                                                before_margin = '미지정',
23912                                                after_margin = '마진율 : ' + new_mrate + '% / 마진값 : ' + addCommas(new_madd) + '원';
23913                                            
23914                                            if($(this).find('.margin-info .rate').length > 0) {
23915                                                var old_mrate = $(this).find('.margin-info .rate').text().trim().replace(/[^0-9.]/g,'') * 1,
23916                                                    old_madd = $(this).find('.margin-info .add').text().trim().replace(/[^0-9.]/g,'') * 1,
23917                                                    before_margin = '마진율 : ' + old_mrate + '% / 마진값 : ' + addCommas(old_madd) + '원';
23918                                            }
23919                                            var slog_obj = {'pname':p_name, 'seq':p_seq, 'pid':pid, 'supply_price': addCommas(p_supply)+'원', 'before_margin':before_margin, 'margin':after_margin};
23920                                            setSiteLogs('sh.product.edit','margin',slog_obj,'sh.config',p_seq);
23921
23922                                            $(this).attr('data-pcase','M');
23923                                            $(this).find('.td-title .add-info .sale-rate').html(new_srate_span);
23924                                            $(this).find('.td-title .add-info .margin-info .rate').text(new_mrate);
23925                                            $(this).find('.td-title .add-info .margin-info .add').text(addCommas(new_madd));
23926                                            $(this).find('.td-title .add-info .margin-info .price').text(addCommas(new_margin));
23927                                            $(this).find('.td-price').html(new_price_span + new_sale_span);
23928                                        }
23929
23930                                    });
23931
23932                                    $.processOFF();
23933                                    marginModal.modal('hide');
23934
23935                                    if(typeof data.list.error != 'undefined' && data.list.error.length > 0) {
23936                                        var error_msg = '판매가가 10억이 넘게 적용되는 일부 상품(들)이 존재합니다.<br>마진 설정은 최종 판매가가 10억 이하의 상품들에만 적용되고,<br>10억이 넘는 상품들은 가격 또는 마진 설정을 재 검토해 주세요.';
23937                                        // var error_msg = (data.list.error.length == $.gallery.seqs.length) ? '문구요청1. 선택 상품 마진 변경 불가. 금액 10억 이상 이라서' : '문구요청1. 선택 상품 중 일부 상품 마진 변경 불가. 금액 10억 이상 이라서';
23938                                        $(this).showModalFlat('마진 설정', error_msg, true, false, '', 'ok', '', 'cl-cmmodal cl-s-btn w560 cl-p70 cl-p0 cl-shopping-margin-error');
23939                                    }
23940
23941                                }, 'json');
23942                            });
23943                        } ,'cancel', 'ok', 'cl-cmmodal cl-s-btn w560 cl-p70 cl-p0 cl-shopping-margin','','',function(){
23944
23945                            $('.cl-shopping-margin .prod-margin-price > svg.bi').off('click').on({
23946                                click: function(e) {
23947                                    var margin_type = ($(this).closest('.prod-margin-price').hasClass('cal-margin')) ? 'margin' : 'price',
23948                                        marginInput = $(this).closest('.prod-margin-price').find('.prod-user-'+margin_type),
23949                                        isPlus = (($(this).attr('class')).indexOf('plus') > -1) ? true : false,
23950                                        margin = marginInput.val().trim(),
23951                                        r = Number(margin.replace(/[^0-9.]/g,''));
23952                                    if(margin_type == 'margin') {
23953                                        r = (isPlus) ? r + 1 : r - 1;
23954                                        if(r < 0) r = 0;
23955                                        if(r > 100) r = 100;
23956                                    } else {
23957                                        r = (isPlus) ? r + 10000 : r - 10000;
23958                                        if(r < 0) r = 0;
23959                                        r = addCommas(r);
23960                                    }
23961                                    marginInput.val(r);
23962                                }
23963                            });
23964
23965                            $('.cl-shopping-margin .prod-user-margin, .cl-shopping-margin .prod-user-price').off('blur').on({
23966                                blur: function(e) {
23967                                    if($(this).val().trim() == '') $(this).val('0');
23968                                    if($(this).hasClass('prod-user-margin')) {
23969                                        if(Number(removeCommas($('.prod-user-margin').val())) > 100) $(this).val('100');
23970                                    }
23971                                    if($(this).hasClass('prod-user-price')) {
23972                                        if(Number(removeCommas($('.prod-user-price').val())) > 1000000000) $(this).val('1,000,000,000');
23973                                    }
23974                                }
23975                            });
23976
23977                        });
23978                        break;
23979                    case "stock" :
23980                        setQuantity();
23981                        break;
23982                    default:
23983                        break;
23984                }
23985            });
23986            $(document).on('click','.gallery-add-items', function(e) {
23987                if($(this).hasClass('disabled')) {
23988                    ($(this).hasClass('gallery-need')) 
23989                    ? $(this).showModalFlat('안내', '화면 좌측의 갤러리 목록에서 갤러리 선택 후 상품을 추가할 수 있습니다.', true, false, '', 'ok','','cl-cmmodal cl-s-btn w560 cl-p130 cl-p0 cl-okbtn-pbt70')
23990                    : $(this).showModalFlat('안내', '상품관리를 사용하려면 쇼핑갤러리가 필요합니다.<br><a href="/config" style="text-decoration:underline;color:#4789e7;font-weight:600;">[편집모드]</a>에서 쇼핑 갤러리를 먼저 생성하세요', true, false, '', 'ok','','cl-cmmodal cl-s-btn w560 cl-p130 cl-p0 cl-okbtn-pbt70');
23991                    return false;
23992                }
23993
23994                var mode = $(this).attr('data-mode');
23995                if(typeof mode == 'undefined' || !mode) {
23996                    alert('Undefined gallery mode');
23997                    return false;
23998                }
23999                switch(mode) {
24000                    case 'shopping' : $.products.add(-1); break;
24001                    default:
24002                        setResourceBtn(false,{maxcount:0});
24003                        selectID = $('.gallery-modal').attr('data-pid');
24004                        $.resource.open();
24005                        break;
24006                }
24007            });
24008            $(document).on('blur','.item-title', function(e) {
24009                var title = $(this).val().trim(),
24010                    s = $(this).attr('data-title'),
24011                    seq = $(this).attr('data-seq'),
24012                    caption = $(this).attr('data-caption'),
24013                    hashtag = $(this).attr('data-hashtag'),
24014                    category = $(this).attr('data-category'),
24015                    datetime = $(this).attr('data-datetime'),
24016                    thumb = $(this).attr('data-url'),
24017                    file = (thumb.indexOf('googleusercontent') > -1) ? thumb : thumb.replace(/^.*[\\\/]/, ''),
24018                    $gitem = $('.' + $.gallery.block_id).find('.gallery-item[data-seq="'+seq+'"]'),
24019                    pathinfo = thumb.split('/');
24020
24021                    if($gitem.length == 0) {
24022                    if($(this).parents('.gallery-modal').attr('data-mode')=='gallery') {
24023                        $gitem = $('.gallery-popup').find('.gallery-item[data-seq="'+seq+'"]');
24024                    }
24025                }
24026
24027                if($('.' + $.gallery.block_id).attr('data-msny') == 'true') $.gallery.update = true;
24028
24029                if(title != s && title) {
24030                    if(typeof seq == 'undefined' || !seq) {
24031                        alert('Invalid item');
24032                        return false;
24033                    }
24034
24035                    $gitem.find('[data-gallery]').attr({'data-title':title});
24036                    if($('.gallery-items .item').length < 3) $('.gallery-popup').find('.gallery-item[data-seq="'+seq+'"]').find('[data-gallery]').attr({'data-title':title});
24037                    var type = 'ELEM',
24038                        s = '';
24039                    if(pathinfo[4]!= 'free') s = 'false';
24040                    else {
24041                        var p = pathinfo.slice(1,6);
24042                        p.unshift('');
24043                        p.push('');
24044                        s = p.join('/');
24045                    }
24046
24047                    $.post('/template/update/type/gallery',{ s: seq, id : SID, title : title, caption : caption, datetime : datetime, hashtag : hashtag, category : category, file : file, storage : s}, function(data) {
24048                        var isCheck = checkError(data);
24049                        if(!isCheck) return false;
24050                        setLogs(type,'gallery.data.edit','modify',type,'product-manager','el');
24051                    }, 'json');    
24052
24053                    (title.length>0) ? $gitem.find('h5.figure').html(title) :  $gitem.find('h5.figure').text('Title');
24054                    $(this).attr({'value':title,'data-title':title});
24055                }
24056                $('.gallery-items').selectable('enable');
24057            });
24058            $(document).on('click', '.prod-button .modal-save, .prod-detail-edit', function(e) {
24059                var hasEmoji = false;
24060                $('.prod-input, .prod-input-value').each(function() {
24061                    var passEmoji = ($.inArray($(this).attr('id'),['prod-title', 'prod-desc']) > -1) ? true : false,
24062                        check_val = ($(this).is('div')) ? $(this).text().trim() : $(this).val().trim();
24063                    
24064                    if(!passEmoji && checkEmojis(check_val)) {
24065                        hasEmoji = true;
24066                        return false;
24067                    }
24068                });
24069                if(hasEmoji) {
24070                    e.preventDefault();
24071                    errorEmojisModal();
24072                    return false;
24073                }
24074
24075                var go = $(this).hasClass('prod-detail-edit') ? true : false;
24076                // var modal = $(this).showModalFlat('INFORMATION', '편집한 내용 저장 시 실 사이트에도 반영이 됩니다.<br>저장 하시겠습니까?', true, true, function() {
24077                //     modal.modal('hide');
24078                    $.products.save(go);
24079                // });
24080            });
24081            $(document).on('click', '.gallery-blocks .gallery-name[data-gallery-id]:not(.disabled)', function(e) {
24082                e.stopPropagation();
24083                var id = $(this).attr('data-gallery-id');
24084                if(typeof id == 'undefined') return false;
24085                $.gallery.block_id = id;
24086                $('#prod-pid').val(id);
24087                if(LUX) {
24088                    setProductParams({'category_no' : $(this).attr('data-category')});
24089                }
24090                clearLocalStorage();
24091                $.gallery.show($.gallery.block_id);
24092            });
24093            $(document).on('click','.gallery-items-loadmore', function(e) {
24094                var id = $(this).attr('data-pid'),
24095                    page = Number($(this).attr('data-page')),
24096                    cate_str = $(this).attr('data-category-str');
24097                page++;
24098                $.gallery.list(id,page,cate_str);
24099            });
24100            $(document).on('hover','.gallery-items .table-item', function(e) {
24101                if (e.type == "mouseenter") {
24102                    if(!LUX && $('.gallery-modal').attr('data-pid') != undefined) $(this).find('.item-handle').show();
24103                    $(this).find('.item-edit').show();
24104                } else { // mouseleave
24105                    if(!LUX) $(this).find('.item-handle').hide();
24106                    $(this).find('.item-edit').hide();
24107                    $(this).find('.item-edit').find('.item-submenu').hide();
24108                }
24109            });
24110            $(document).on('click', '.gallery-modal .item-edit li', function(e) {
24111                $('.item-submenu').hide();
24112                $('.submenu').removeClass('open');
24113                var $submenu = $(this).find('.item-submenu'),
24114                    display = $submenu.css('display');
24115                (display == 'none') ? $submenu.css('display','block') : $submenu.css('display','none');
24116                return;
24117            });
24118            $(document).on('click', '.gallery-modal .product-item-edit li', function(e) {
24119                var group = ($('.table-item').length) ? '.table-item' : '.gallery-items .item';
24120                var mode = $(this).attr('data-mode'),
24121                    seq = $(this).parent().attr('data-seq'),
24122                    // page = $('.gallery-modal').attr('data-page'),
24123                    page = $(group).attr('data-page'),
24124                    config_url = (CONFIG_URL) ? '_config' : 'config';
24125                if(typeof seq == 'undefined' || seq == '' || typeof page == 'undefined' || page == '') {
24126                    alert('Undefined product seq or page!');
24127                    return false;
24128                }
24129                page = encodeURIComponent(page);
24130                if(mode == 'prodInfo') {
24131                    $.gallery.item_of_page = $(this).parents('.table-item').attr('data-page');
24132                    $.products.add(seq);
24133                } else {
24134                    if(LUX) page = '_product';
24135                    // location.href = '/'+config_url+'/page/'+page+'/view/'+seq;
24136                    $.detail.open('/'+config_url+'/page/'+page+'/view/'+seq, mode);
24137                }
24138            });
24139            $(document).on('click', '.td-check input[type="checkbox"]', function(e) {
24140                e.stopPropagation();
24141                var seq = $(this).parents('.table-item').attr('data-seq'),
24142                    seq_idx = ($.gallery.seqs).indexOf(seq),
24143                    disabled = false, visible_button = false, no_price = false;
24144                    // disabled = ($(this).parents('.table-item').attr('data-product') == "false") ? true : false;
24145
24146                if($(this).is(':checked')) {
24147                    $(this).parents('.table-item').addClass('ui-selected return');
24148                    if(typeof seq != 'undefined')
24149                        $.gallery.seqs.push(seq);
24150                    $('.gallery-toolbar').addClass('hide_col');
24151                } else {
24152                    if(seq_idx > -1) ($.gallery.seqs).splice(seq_idx,1);
24153                    $(this).parents('.table-item').removeClass('ui-selected return');
24154                    if($.gallery.seqs.length == 0) $('.gallery-toolbar').removeClass('hide_col');
24155                }
24156                stickyToolbar();
24157
24158                $.each($('.gallery-items .table-item.ui-selected'), function(i,v) {
24159                    if($(this).attr('data-product') == "false") disabled = true;
24160                    if($(this).attr('data-out-datetime') == "1") visible_button = true;                    
24161                    if($(this).attr('data-pricechk') == "false") no_price = true;
24162                });
24163
24164                $('.gallery-items .table-item > div').addClass('hide-text');
24165                $('.table-toolbar > li').removeClass('open').find('.item-submenu').hide();
24166                $('.gallery-view-count').removeClass('open').find('.view-submenu').hide();
24167
24168                if($('.gallery-items .table-item.ui-selected').length == 0) {
24169                    $.gallery.seqs = [];
24170                    $('.gallery-toolbar').removeClass('hide_col');
24171                    $('.gallery-items .table-item > div').removeClass('hide-text');
24172                    $('.table-toolbar .toolbar-cmd').addClass('hide'); 
24173                    $('.table-toolbar .toolbar-cmd i[data-glseq]').attr('data-glseq','');
24174                    $('.table-toolbar .toolbar-cmd i[data-cmd="link"]').attr('data-glink','').attr('data-glink-target','');
24175                    $('.table-toolbar .toolbar-cmd i[data-cmd="visible"]').attr('data-visible','0').text($.lang[LANG]['editor.gallery.icon.visible.off']);
24176                    $('.gallery-toolbar').addClass('hide');
24177                    $('.gallery-items .item-header').removeClass('hide');
24178                } else { 
24179                    var firstItem = $('.gallery-items .table-item.ui-selected').eq(0),
24180                        first_seq = firstItem.attr('data-seq'),
24181                        link = firstItem.attr('data-link'),
24182                        target = firstItem.attr('data-target'),
24183                        visible = firstItem.attr('data-visible'),
24184                        grade = firstItem.attr('data-grade'),
24185                        vstr = (visible == '1') ? $.lang[LANG]['editor.gallery.icon.visible.on'] : $.lang[LANG]['editor.gallery.icon.visible.off'],
24186                        gstr = (grade == 'ON') ? $.lang[LANG]['editor.gallery.icon.grade.off'] : $.lang[LANG]['editor.gallery.icon.grade.on'];
24187                    if(visible_button) {
24188                        $('.table-toolbar .toolbar-cmd.toolbar-visible').addClass('disabled');
24189                    } else $('.table-toolbar .toolbar-cmd.toolbar-visible').removeClass('disabled');
24190                    if($.gallery.block_id == -1) {
24191                        $('.table-toolbar .toolbar-cmd.toolbar-copy').addClass('disabled');
24192                    }
24193                    $('.table-toolbar .toolbar-cmd').removeClass('hide');
24194                    $('.table-toolbar .toolbar-cmd i[data-glseq]').attr('data-glseq',first_seq);
24195                    $('.table-toolbar .toolbar-cmd i[data-cmd="link"]').attr('data-glink',link).attr('data-glink-target',target);
24196                    $('.table-toolbar .toolbar-cmd i[data-cmd="visible"]').attr('data-visible',visible).text(vstr);
24197                    $('.table-toolbar .toolbar-cmd i[data-cmd="grade"]').attr('data-grade',grade).text(gstr);
24198                    $('.gallery-toolbar').removeClass('hide');
24199                    $('.gallery-items .item-header').addClass('hide');
24200                }
24201                (no_price) ? $('.product-cmd').not('.toolbar-org-price').not('.toolbar-stock').addClass('no_price') : $('.product-cmd').removeClass('no_price');
24202                (disabled) ? $('.product-cmd').addClass('disabled') : $('.product-cmd').removeClass('disabled');
24203                if($('.gallery-modal').attr('data-pid') == undefined) {
24204                    $('.toolbar-sort.item-sort').addClass('disabled');
24205                }
24206                if($('.gallery-modal .table-item').length == $('.gallery-modal .table-item .td-input:checked').length) $('.table-toolbar .check-all').prop('checked', true);
24207                $.gallery.setNumber();
24208            });
24209            $(document).on('change','.category-onoff-check', function(e) {
24210                var gc = $(this).prop('checked'),
24211                    g_category_onoff = (gc) ? 'ON' : 'OFF',
24212                    settings = {
24213                        category_display : g_category_onoff
24214                    };
24215                $.gallery.update = true;
24216                if(gc) {
24217                    $('.gallery-category-menu').removeClass('hide');
24218                    $('.category-title-str').addClass('on');
24219                    $('.td-category').removeClass('hide');
24220                } else {
24221                    $('.gallery-category-menu').addClass('hide');
24222                    $('.category-title-str').removeClass('on');
24223                    $('.td-category').addClass('hide');
24224                }
24225                $.post('/template/settings', {sid: SID, settings : JSON.stringify(settings), el: $.gallery.block_id}, function(data) {
24226                    checkError(data);
24227                    $.gallery.show($.gallery.block_id);
24228                }, 'json');
24229                
24230                var type = (typeof selectEL != 'undefined') ? getElementType() : 'ELEM';
24231                setLogs(type,'gallery.category.' + gc,'toggle-' + gc, type,'product-manager','el');
24232            });
24233            $(document).on('click','.toolbar-category ul.item-submenu li', function(e) {
24234                if(($.gallery.seqs).length) {
24235                    $(this).toggleClass('active');
24236                    var click_cate = $(this).text(),
24237                        cate_str = $('.toolbar-category ul.item-submenu li.active').map(function() { return $(this).text(); }).get(),
24238                        text_str = cate_str.join(),
24239                        data_str = '|' + text_str.replace(/\,/g,'|,|') + '|';
24240
24241                    $.each($.gallery.seqs, function(i,v) {
24242                        if($('.gallery-modal').hasClass('shopping')) {
24243                            $('.table-item[data-seq="' + v + '"]').attr('data-category', data_str).find('.td-category').text(text_str).attr('data-original-title',text_str);
24244                            
24245                            if(text_str.indexOf(',') > -1) $('.table-item[data-seq="' + v + '"] .td-category').addClass('line');
24246                            else $('.table-item[data-seq="' + v + '"] .td-category').removeClass('line');
24247                        } else {
24248                            $('.gallery-items .item[data-seq="' + v + '"]').attr('data-category', data_str).find('.td-category').text(text_str);
24249                        }
24250
24251                        $.post('/template/gallery/category', { sid : SID, s : cate_str, mode : 'gallery', seq : v }, function(r) {
24252
24253                            if($('.element[data-id="' + $.gallery.block_id + '"] .gallery-category-nav li:nth-child(1)').hasClass('hide')) {
24254                                if($('.element[data-id="' + $.gallery.block_id + '"] .gallery-category-nav li.active a').text() == click_cate) {
24255                                    $.gallery.update = true;
24256                                }
24257                            }
24258
24259                        }, 'json');
24260                    });
24261                }
24262            });
24263            $(document).on('click','.toolbar-sort ul.item-submenu li', function(e) {
24264                if(($.gallery.seqs).length) {
24265                    var group = ($('.table-item').length) ? '.table-item' : '.gallery-items .item';
24266                    $.gallery.move = $.gallery.seqs;
24267                    if($(this).hasClass('sort-top')) {
24268                        $.gallery.drag = $(group).first().attr('data-seq');
24269                        // $.gallery.seqs = [];
24270                        var modal = $(this).showModalFlat($.lang[LANG]['config.gallery.order.move'],$.lang[LANG]['editor.gallery.move'],true,true,function() {
24271                            modal.modal('hide');
24272                            // $.gallery.mv();
24273                            var spos = $('.gallery-modal').scrollTop();
24274                            $.processON('move gallery item(s)...');
24275                            $.ajax({
24276                                url: '/template/gallery/sort-top',
24277                                data: { sid : SID, seq : $.gallery.seqs, block_id : $.gallery.block_id },
24278                                dataType: 'json',
24279                                type: 'POST',
24280                                async: false,
24281                                cache: false,
24282                                success: function (data) {
24283                                    checkError(data);
24284                                    var p = $.gallery.pages;
24285                                    $.gallery.show($.gallery.block_id,p.page,$.gallery.category, function() {
24286                                        $.each(data.seqs, function(i,v) {
24287                                            $(group + '[data-seq="' + v + '"]').addClass('return');
24288                                        });
24289                                        setTimeout(function() { 
24290                                            $('.gallery-modal').scrollTop(spos); 
24291                                            $.processOFF();
24292                                        }, 500);
24293                                    });
24294                                    $.gallery.update = true;
24295                                    $.gallery.reset();
24296                                    $.processOFF();
24297                                }
24298                            });                            
24299                        }, 'cancel','ok','cl-cmmodal cl-s-btn w560 cl-p130 cl-p0',false, function() {
24300                            // cancel callback
24301                            $.gallery.seqs = $.gallery.move;
24302                        });
24303                    } else if($(this).hasClass('sort-bottom')) {
24304                        if($('.gallery-items-loadmore').length == 0) {
24305                            var last = $(group).last().attr('data-seq');
24306                            if($.gallery.seqs[0] == last) {
24307                                var s = (group == '.gallery-items .item') ? $.lang[LANG]['editor.gallery.select.front.last.1'] : $.lang[LANG]['editor.gallery.select.front.last.2'],
24308                                    contents2_str = (LANG =='ko') ? $.lang[LANG]['editor.gallery.select.contents.2'] : '';
24309
24310                                $(this).showModalFlat($.lang[LANG]['config.gallery.order.move'], $.lang[LANG]['editor.gallery.select.contents.1'] + s + contents2_str, true, false, '', 'ok','','cl-cmmodal cl-s-btn w560 cl-p130 cl-p0 cl-okbtn-pbt70');
24311                                return false;
24312                            }
24313                        }
24314
24315                        var modal = $(this).showModalFlat($.lang[LANG]['config.gallery.order.move'],$.lang[LANG]['editor.gallery.move'],true,true,function() {
24316                            var item = $(group).length,
24317                                cpage = Math.ceil(item/30),
24318                                spos = $('.gallery-modal').scrollTop();
24319
24320                            modal.modal('hide');
24321                            $.processON('move gallery item(s)...');
24322                            $.ajax({
24323                                url: '/template/gallery/sort-bottom',
24324                                data: { sid : SID, seq : $.gallery.seqs, block_id : $.gallery.block_id },
24325                                dataType: 'json',
24326                                type: 'POST',
24327                                async: false,
24328                                cache: false,
24329                                success: function (data) {
24330                                    checkError(data);
24331                                    var p = $.gallery.pages;
24332                                    $.gallery.show($.gallery.block_id,p.page,$.gallery.category, function() {
24333                                        $.each(data.seqs, function(i,v) {
24334                                            $(group + '[data-seq="' + v + '"]').addClass('return');
24335                                        });
24336                                        setTimeout(function() { 
24337                                            $('.gallery-modal').scrollTop(spos); 
24338                                            $.processOFF();
24339                                        }, 500);
24340                                    });
24341                                    $.gallery.update = true;
24342                                    $.gallery.reset();
24343                                    $.processOFF();
24344                                }
24345                            });
24346                        }, 'cancel','ok','cl-cmmodal cl-s-btn w560 cl-p130 cl-p0', false, function() {
24347                            // cancel callback
24348                            $.gallery.seqs = $.gallery.move;
24349                        });
24350                    }
24351                }
24352            });
24353            $(document).on('click','.view-submenu li', function(e) {
24354                $.processON();
24355
24356                var view = (typeof $(this).attr('data-view') != 'undefined' && $(this).attr('data-view')) ? $(this).attr('data-view') : 30;
24357
24358                window.localStorage.setItem('gallery-product-view',view);
24359                $.gallery.show($.gallery.block_id,'',$.gallery.category,function() {
24360                    setTimeout(function() { 
24361                        $.processOFF();
24362                    }, 500);
24363                });
24364            });
24365            $(document).on('click', '.gallery-modal .edit-gallery-detail', function(e) {
24366                var seq = $(this).attr('data-seq'),
24367                    mode = $(this).attr('data-mode');
24368                var page = $('.gallery-modal').attr('data-page');
24369                var config_url = (CONFIG_URL) ? '_config' : 'config';
24370                if(typeof seq == 'undefined') return;
24371                // location.href = '/'+config_url+'/page/' + page + '/view/' + seq;
24372                $.detail.open('/'+config_url+'/page/' + page + '/view/' + seq, 'gallery');
24373            });
24374            $(document).on('click','.gallery-name-edit', function(e) {
24375                e.stopPropagation();
24376                $('.gallery-name-edit-input').remove();
24377                var v = $(this).parents('.gallery-name').text(),
24378                    s = '<div class="gallery-name-edit-input"><input type="text" class="gallery-name-edit-inputbox" value="' + v.trim() + '" maxlength="20"><div class="gallery-name-edit-close"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 12 12"><polygon points="12 0.71 11.29 0 6 5.29 0.71 0 0 0.71 5.29 6 0 11.29 0.71 12 6 6.71 11.29 12 12 11.29 6.71 6 "/></svg></div><div class="gallery-name-edit-save"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 15 10"><path d="M14.29 0L5.5 8.79 0.71 4 0 4.71l5.15 5.15C5.24 9.95 5.37 10 5.5 10s0.26-0.05 0.35-0.15L15 0.71 14.29 0z"/></svg></div></div>';
24379                $(this).parents('.gallery-name').append(s);
24380            });
24381            $(document).on('click','.gallery-name-edit-inputbox',function(e) {
24382                e.stopPropagation();
24383            });
24384            $(document).on('keypress', '.gallery-name-edit-inputbox', function(e) {
24385                var keyCode = e.keyCode,
24386                    blockname = $(this).val().trim();
24387
24388                if(keyCode == 13) {
24389                    saveGalleryBlockName($(this), blockname);
24390                }
24391            });
24392            $(document).on('click','.gallery-name-edit-save',function(e) {
24393                e.stopPropagation();
24394                var blockname = $('.gallery-name-edit-inputbox').val().trim(),
24395                    $input = $('.gallery-name-edit-inputbox');
24396
24397                if(checkEmojis(blockname)) {
24398                    e.preventDefault();
24399                    var open_el = $(this).closest('.gallery-blocks').find('.btn-group'),
24400                        focus_el = $(this).closest('.gallery-name-edit-input').find('.gallery-name-edit-inputbox');
24401                    errorEmojisModal('','','',function() {
24402                        open_el.addClass('open');
24403                        focus_el.focus();
24404                    });
24405                    return false;
24406                }
24407                saveGalleryBlockName($input, blockname);
24408            });
24409            $(document).on('click','.gallery-name-edit-close',function(e) {
24410                e.stopPropagation();
24411                $(this).parents('.gallery-name-edit-input').remove();
24412            });
24413        },
24414        cp : function() {
24415            var seqs = $.gallery.copy,
24416                page = $('.gallery-modal').attr('data-page'),
24417                pid = $('.gallery-modal').attr('data-pid');
24418
24419            seqs = seqs.reverse();
24420            if(typeof seqs.length == 0 || seqs == '') {
24421                alert('Invalid variable');
24422                return false;
24423            }
24424            var modal = $(this).showModalFlat($.lang[LANG]['editor.gallery.clone.title'],($.gallery.mode == 'shopping' ? $.lang[LANG]['editor.gallery.shoppingclone' + (LUX ? '.lux' : '')] : $.lang[LANG]['editor.gallery.clone']),true,true,function() {
24425                var count = seqs.length;
24426
24427                modal.modal('hide');
24428                var group = ($('.table-item').length) ? '.table-item' : '.gallery-items .item',
24429                    item = $(group).length,
24430                    cpage = Math.ceil(item/30),
24431                    spos = $('.gallery-modal').scrollTop();
24432
24433                $.processON('copy gallery item(s)...');
24434                // console.log('ModalPlugin cp ');
24435                // console.log(seqs);
24436                $.ajax({
24437                    url: '/template/gallery/copy',
24438                    data: { s: seqs, sid : SID, page : page, block_id : $.gallery.block_id },
24439                    dataType: 'json',
24440                    type: 'POST',
24441                    async: true,
24442                    cache: false,
24443                    success: function (data) {
24444                        checkError(data);
24445                        // console.log(data);
24446                        galleryStatusInit();
24447                        $.gallery.copy = [];
24448                        var type = (typeof selectEL != 'undefined') ? getElementType() : 'ELEM';
24449                        setLogs(type,'gallery.item.clone','clone',type,'product-manager','el');
24450
24451                        $.gallery.show($.gallery.block_id,cpage,$.gallery.category,function() {
24452                            $.each(data.r, function(i,v) {
24453                                // console.log(v.seq);
24454                                $(group + '[data-seq="' + v.seq + '"]').addClass('return');
24455                            });
24456                            setTimeout(function() { 
24457                                $('.gallery-modal').scrollTop(spos); 
24458                                $.processOFF();
24459                            }, 500);
24460                        });
24461    
24462                        $.gallery.update = true;                        
24463                    }
24464                });
24465            }, 'cancel','ok','cl-cmmodal cl-s-btn w560 cl-p130 cl-p0');
24466        },
24467        mv : function(func) {
24468            var seqs = $.gallery.move,
24469                page = $('.gallery-modal').attr('data-page');
24470            // seqs = seqs.reverse();
24471            if(typeof seqs.length == 0 || seqs == '') {
24472                alert('Invalid variable');
24473                return false;
24474            }
24475            clicking = false;
24476            var group = ($('.table-item').length) ? '.table-item' : '.gallery-items .item';
24477
24478            if($.gallery.drag) {
24479                if(($.gallery.drag == seqs[0] || 
24480                    $.gallery.drag == $(group + '[data-seq="' + seqs[0] + '"]').next().attr('data-seq')) ||
24481                    $.gallery.drag == $(group + '[data-seq="' + seqs[0] + '"]').next().hasClass('prev')) {
24482                    if($('.clone-item').length) {
24483                        $('.clone-item').remove();
24484                        // $.gallery.seqs = [];
24485                        return false;
24486                    } else {
24487                        if($('.item-sort').hasClass('open')) {
24488                            var s = (group == '.gallery-items .item') ? $.lang[LANG]['editor.gallery.select.front.first.1'] : $.lang[LANG]['editor.gallery.select.front.first.2'],
24489                                contents2_str = (LANG =='ko') ? $.lang[LANG]['editor.gallery.select.contents.2'] : '';
24490                            $.gallery.seqs = $.gallery.move;
24491                            $(this).showModalFlat($.lang[LANG]['config.gallery.order.move'], $.lang[LANG]['editor.gallery.select.contents.1'] + s + contents2_str, true, false, '', 'ok','','cl-cmmodal cl-s-btn w560 cl-p130 cl-p0 cl-okbtn-pbt70');
24492                            return false;
24493                        }
24494                    }
24495                }
24496            }
24497            var count = seqs.length,
24498                selected = $.gallery.drag;
24499
24500            var item = $(group).length
24501                cpage = Math.ceil(item/30),
24502                spos = $('.gallery-modal').scrollTop();
24503
24504            // modal.modal('hide');
24505            $.processON('move gallery item(s)...');
24506            $.ajax({
24507                url: '/template/gallery/move',
24508                data: { s: seqs, sid : SID, page : page, block_id : $.gallery.block_id, selected : selected, last : $.gallery.last },
24509                dataType: 'json',
24510                type: 'POST',
24511                async: true,
24512                cache: false,
24513                success: function (data) {
24514                    checkError(data);
24515                    $.gallery.update = true;
24516                    $.gallery.drag = '';
24517                    $.gallery.last = '';
24518                    if(typeof func == 'function') {
24519                        func();
24520                    } else {
24521                        $.gallery.show($.gallery.block_id,cpage,$.gallery.category, function() {
24522                            $.each(data.seqs, function(i,v) {
24523                                $(group + '[data-seq="' + v + '"]').addClass('return');
24524                            });
24525                            setTimeout(function() { 
24526                                $('.gallery-modal').scrollTop(spos); 
24527                                $.processOFF();
24528                            }, 500);
24529                        });
24530                    }
24531
24532                }
24533            });
24534        },
24535        del : function() {
24536            var seqs = $.gallery.delete,
24537                page = $('.gallery-modal').attr('data-page'),
24538                pid = $('.gallery-modal').attr('data-pid'),
24539                total = seqs.length,
24540                title = (LANG == 'ko') ? '갤러리 데이터를 삭제중입니다...' : 'Deleting gallery data...',
24541                sub_des = (LANG == 'ko') ? '데이터를 삭제중입니다' : 'Deleting',
24542                loading = '<i class="fa fa-circle-o-notch fa-spin fa-3x fa-fw"></i> ';
24543
24544            if(typeof seqs.length == 0 || seqs == '') {
24545                alert('Invalid variable');
24546                return false;
24547            }   
24548            var modal = $(this).showModalFlat($.lang[LANG]['config.delete'],$.lang[LANG]['editor.gallery.selected.1'] + (seqs.length) + $.lang[LANG]['editor.gallery.selected.2'] + $.lang[LANG]['editor.gallery.selected.delete'],true,true, function() {
24549                var count = seqs.length;
24550                modal.modal('hide');
24551                $.progressON(title);
24552
24553                var group = ($('.table-item').length) ? '.table-item' : '.gallery-items .item',
24554                    item = $(group).length,
24555                    item = ((item - count) < 0) ? 1 : item - count,
24556                    cpage = Math.ceil(item/30),
24557                    spos = $('.gallery-modal').scrollTop(),
24558                    done = 0,
24559                    pid = $('.gallery-modal').attr('data-pid'),
24560                    mode = $('.gallery-modal').attr('data-mode');
24561
24562                $.each(seqs, function(i,v) {
24563                    $(group + '[data-seq="' + v + '"]').fadeOut(100, function() { $(this).remove(); });
24564
24565                    var t = setTimeout(function() {
24566                        if(CANCEL) {
24567                            if(ABORT) {
24568                                // 리스트 갱신 작업
24569                                $.gallery.show($.gallery.block_id,cpage,$.gallery.category, function() {
24570                                    setTimeout(function() { 
24571                                        $.gallery.move = [];
24572                                        $('.gallery-modal').scrollTop(spos); 
24573                                        $.processOFF();
24574                                    }, 500);
24575                                });
24576                                ABORT = false;
24577                                $.progressOFF();
24578                            }
24579                            i=0; return false;
24580                        }
24581                        galleryDeleteItem(v,function(data) {
24582                            done++;
24583                            progress = parseInt((done / total) * 100,10);
24584                            $('.file-upload-progress .progress-bar').
24584css('width',progress + "%");
24585                            $('.progressModal .info2').text(done.toString() + ' / ' + total.toString());
24586
24587                            var d = data.data;
24588                            $.each(d, function(i,o) {
24589                                blockBookmarkDelete(o.sid,o.seq);
24590                            });
24591
24592                            glItemDelete(v,page);
24593                            if(v==VIEW) $.gallery.unlink = true;
24594
24595                            if(total == done) {
24596                                var type = getElementType();
24597                                setLogs(type,'gallery.item.delete','delete',type,'product-manager','el');
24598                                $.gallery.reset();
24599                                $.gallery.update = true;
24600
24601                                $.gallery.show($.gallery.block_id,cpage,$.gallery.category, function() {
24602                                    setTimeout(function() { 
24603                                        $.gallery.move = [];
24604                                        $('.gallery-modal').scrollTop(spos); 
24605                                        $.progressOFF();
24606                                    }, 500);
24607                                });
24608                            } else {
24609                                moving = $(group + '[data-seq="' + seqs[i+1] + '"] .td-title .item-title-str').text();
24610                                if(moving == "") moving = sub_des;
24611                                $('.progressModal .info1').html(loading + moving);
24612                            }
24613                        });
24614                    },500*i);
24615                });
24616            }, 'cancel', 'ok', 'cl-cmmodal cl-s-btn w560 cl-p130 cl-p0');
24617        },
24618        show : function(id,page,category,func) {
24619            // if(typeof id == 'undefined' || !id) {
24620            //     alert('Undefined gallery ID');
24621            //     return false;
24622            // }
24623
24624            if(typeof page =='undefined' || !page) page = 1;
24625            if(typeof category =='undefined') category = '';
24626            if(typeof id == 'undefined') id = '';
24627            // var params = ($('.gallery-modal').length) ? getProductParams() : getSearchURL();
24628
24629            var params = getProductParams(),
24630                product_name = getStorageItem('gallery-product-name'),
24631                product_filter = getStorageItem('gallery-product-filter'),
24632                product_view = getStorageItem('gallery-product-view'),
24633                sort = getStorageItem('gallery-product-sort'),
24634                by = getStorageItem('gallery-product-by'),
24635                manager = (id == '' || id == -1) ? SID : '';
24636
24637            $.gallery.seqs = [];
24638            $.gallery.block_id = (id == '') ? -1 : id;
24639            $.gallery.category = category;
24640            $.processON();
24641            $.ajax({
24642                type: 'POST',
24643                url : '/template/gallery/show',
24644                data :  { mode : 'show', id : id, page : page, category : category, params : params, manager : manager, product_name : product_name, product_filter : product_filter, product_view : product_view, sort : sort, by : by },
24645                dataType : 'json',
24646                async: true,
24647                cache: false,
24648                success : function(data) {
24649                    $.processOFF();
24650                    if(LUX && data.mode == 'shopping' && params) {
24651                        setProductParams(params);
24652                    }
24653                    if(data.error != 'undefined' && data.error) {
24654                        alert(data.error);
24655                        return false;
24656                    }
24657                    $.gallery.site_settings = data.settings;
24658                    // premium block
24659                    if( !$('#el-blockConfig').hasClass('open') && 
24660                        $('.element[data-id="' + $.gallery.block_id + '"][data-type="gallery"] input.gjs').length > 0 
24661                    ) {
24662                        stopGalleryJS($('.element[data-id="' + $.gallery.block_id + '"]'));
24663                    }
24664
24665                    $.gallery.mode = data.mode;
24666                    $.gallery.SMENU = data.SMENU;
24667                    $.gallery.SFOLDER = data.SFOLDER;
24668                    $.gallery.valid_plan = data.valid_plan;
24669                    $.gallery.valid_type = data.valid_type;
24670                    $.gallery.one = data.one;
24671                    $.gallery.service = data.service;
24672                    $.gallery.block_el = ($.gallery.block_id == '-1') ? 'el_prod' : data.gallerys[$.gallery.block_id].el;
24673                    var $backdrop = $('<div id="dummy-drop" style="position:fixed;top:0;left:0;right:0;bottom:0;background-color:#fff;z-index:1039;"></div>');
24674                    if($('#dummy-drop').length == 0)
24675                        $('body').append($backdrop);
24676    
24677                    $('.gallery-modal').hide().remove();
24678                    $('#gallery-style').remove();
24679                    $('#gallery-modal-script').remove();
24680                    $m = $(data.r).hide();
24681                    $('body').append($m);
24682                    
24683                    if($.gallery.mode != 'shopping') $('.gallery-list-filter').remove();
24684                    if(data.name) $('.selected-gallery-name').text(data.name);
24685                    if(typeof id == 'undefined' || !id || id == -1) {
24686                        $('.gallery-category').addClass('product-all-items');
24687                        $('.gallery-category .category-title-str').hide();
24688                        $('.gallery-category .gallery-category-onoff').hide();
24689                        $('.gallery-blocks .all-items').addClass('active');
24690                        $('.gallery-block-select, .selected-gallery-name').text('전체상품');
24691                        $('.gallery-add-items').addClass('disabled gallery-need');
24692                    } else {
24693                        $('.gallery-blocks .all-items').removeClass('active');  
24694                        $('.gallery-category').show();
24695                        $('.gallery-category').removeClass('product-all-items');
24696                        $('.gallery-add-items').removeClass('disabled gallery-need');
24697                    }
24698
24699                    $('.gallery-modal').attr('data-page',data.page).attr('data-pid',data.pid).attr('data-mode',data.mode).attr('data-category',data.category).attr('data-total',data.total);
24700                    (data.mode == 'shopping') ? $('.gallery-modal').addClass('shopping') : $('.gallery-modal .gallery-items').addClass('mod-gallery');
24701                    if(data.mode == 'shopping' && LUX) $('.gallery-modal').addClass('lux');
24702                    $('#gallery-name').text(data.name);
24703                    $('.gallery-add-items').attr('data-mode',data.mode).attr('data-page',data.page);
24704                    var check_only_cate = (typeof data.only_category != 'undefined' && data.only_category === true) ? true : false;
24705                    if(!check_only_cate && data.id == '') $('.gallery-add-items').hide();
24706                    (data.mode == 'shopping') ? $('.gallery-modal-title').text($.lang[LANG]['bc.tp.gallery-contents.shopping']) : $('.gallery-modal-title').text($.lang[LANG]['editor.block.gallery.title']);
24707                    $('.view-submenu li[data-view="' + data.view + '"]').addClass('active');
24708                    $('#gallery_view').text(data.view);
24709                    var galleryMenuSeparator = (typeof MENU_ROUTE_SEPARATOR != 'undefined') ? MENU_ROUTE_SEPARATOR : '~',
24710                        escapeGalleryMenuHtml = (typeof escapeMenuDisplayHtml == 'function') ? escapeMenuDisplayHtml : function(value) {
24711                            return String(value == null ? '' : value)
24712                                .replace(/&/g, '&amp;')
24713                                .replace(/</g, '&lt;')
24714                                .replace(/>/g, '&gt;');
24715                        },
24716                        escapeGalleryMenuAttr = (typeof escapeMenuDisplayAttr == 'function') ? escapeMenuDisplayAttr : function(value) {
24717                            return escapeGalleryMenuHtml(value)
24718                                .replace(/"/g, '&quot;')
24719                                .replace(/'/g, '&#39;');
24720                        },
24721                        getGalleryMenuDisplayPathHtml = function(page, fallbackName, pathNames) {
24722                            if($.isArray(pathNames) && pathNames.length) {
24723                                if(typeof getMenuDisplayPathHtml == 'function') return getMenuDisplayPathHtml(pathNames);
24724                                return escapeGalleryMenuHtml(pathNames.join(' > ').replace(/-/g, ' '));
24725                            }
24726
24727                            var exactPathNames = [],
24728                                namePathNames = [],
24729                                nameMatchCount = 0,
24730                                smenu = data.SMENU || $.gallery.SMENU || ((typeof SMENU != 'undefined') ? SMENU : []);
24731
24732                            var getPage = function(menu) {
24733                                if(typeof getMenuPage == 'function') return getMenuPage(menu);
24734                                if(!menu) return '';
24735                                return menu.page || String(menu.name || '').replace(/ /g, '-');
24736                            };
24737                            var walk = function(menus, parents) {
24738                                $.each(menus || [], function(i, menu) {
24739                                    if(!menu) return true;
24740                                    var names = parents.slice(0);
24741                                    names.push(menu.name || '');
24742
24743                                    if(getPage(menu) == page) {
24744                                        exactPathNames = names;
24745                                        return false;
24746                                    }
24747
24748                                    if(menu.name == page) {
24749                                        nameMatchCount++;
24750                                        if(!namePathNames.length) namePathNames = names;
24751                                    }
24752
24753                                    if(menu.children && menu.children.length) {
24754                                        walk(menu.children, names);
24755                                        if(exactPathNames.length) return false;
24756                                    }
24757                                });
24758                            };
24759
24760                            walk(smenu, []);
24761
24762                            if(exactPathNames.length) pathNames = exactPathNames;
24763                            else if(nameMatchCount == 1) pathNames = namePathNames;
24764
24765                            if(!pathNames || !pathNames.length) {
24766                                if(String(page || '').indexOf(galleryMenuSeparator) > -1) pathNames = String(page || '').split(galleryMenuSeparator);
24767                                else pathNames = [fallbackName || page || ''];
24768                            }
24769
24770                            if(typeof getMenuDisplayPathHtml == 'function') return getMenuDisplayPathHtml(pathNames);
24771                            return escapeGalleryMenuHtml(pathNames.join(' > ').replace(/-/g, ' '));
24772                        };
24773                    var icon = '';
24774                    $.gallery.blocks = []; var idx = 0, menu_name = '';
24775                    $.gallery.pages = [];
24776                    $.each(data.lists, function(i,v) {
24777                        var groups = [];
24778                        if(typeof v.name != 'undefined' && typeof v.items != 'undefined') {
24779                            groups.push(v);
24780                        } else {
24781                            $.each(v, function(m, menus) {
24782                                groups.push({ name : m, page : m, items : menus });
24783                            });
24784                        }
24785
24786                        $.each(groups, function(group_idx, group) {
24787                            var m = group.name || group.page || '',
24788                                group_page = group.page || m,
24789                                menus = group.items || [],
24790                                $menu_group = $('<ul class="menus"></ul>').attr('data-page', group_page),
24791                                gallery_menu_name_html = getGalleryMenuDisplayPathHtml(group_page, m, group.path);
24792                            $.gallery.blocks.push({ name : m, page : group_page, displayNameHtml : gallery_menu_name_html, items : menus });
24793                            $menu_group.append('<li><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 4 8"><path d="m-.05-.06 4 4-4 4v-8z"/></svg> ' + gallery_menu_name_html + '</li>');
24794                            $('.gallery-blocks').append($menu_group);
24795
24796                            if(menus.length) {
24797                                menu_name = group_page;
24798                                for(var key in menus) {
24799                                    var value = menus[key];
24800                                    switch(value.mode) {
24801                                        case 'shopping': icon = '<svg class="shopping" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 14"><path d="M9.82 2C9.4 0.84 8.3 0 7 0H6C4.7 0 3.6 0.84 3.18 2H0v12h13V2H9.82zM6 1h1c0.74 0 1.37 0.41 1.72 1H4.28C4.63 1.41 5.26 1 6 1zM12 13H1V3h2v3h1V3h5v3h1V3h2V13z"/></svg> '; break;
24802                                        case 'project' : icon = '<svg class="project" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="M13 0H3v3H0v13h13v-3h3V3L13 0zM13 1.41L14.59 3H13V1.41zM1 15V4h8v3h3v8H1zM10 4.41L11.59 6H10V4.41zM15 12h-2V6l-3-3H4V1h8v3h3V12z"/><rect x="3" y="9" width="7" height="1"/><rect x="3" y="12" width="7" height="1"/></svg> '; break;
24803                                        case 'gallery' : icon = '<svg class="gallery" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 13"><path d="M0 0v13h13V0H0zM12 1v7.29l-2-2 -2 2 -4-4 -3 3V1H12zM1 12V8.71l3-3 4 4 2-2 2 2V12H1z"/><circle cx="10" cy="3" r="1"/></svg> '; break;
24804                                    }
24805                                    if(value.id == id) $.gallery.block_name = value.name;
24806                                    var gb_li_class = (value.id == id) ? 'active' : '',
24807                                        gb_li_attr = '';
24808
24809                                    if(gb_li_class == 'active') $('.gallery-block-select').text(value.name);
24810
24811                                    if(!value.isActive) {
24812                                        gb_li_class += 'disabled editor-upgrade-popup';
24813                                        gb_li_attr = 'data-mode="gallery.primeum"';
24814                                    }
24815
24816                                    if(LUX) {
24817                                        gb_li_attr += ' data-category="' + value.lux_category_no + '" ';
24818                                    }
24819    
24820                                    var gb_li_html = '\
24821                                        <li class="gallery-name ' + gb_li_class + '" data-gallery-id="' + escapeGalleryMenuAttr(value.id) + '" ' + gb_li_attr + '>\
24822                                            <span class="gallery-block-name">' + escapeGalleryMenuHtml(value.name) + '</span>\
24823                                            <span class="f-right gallery-name-edit"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="M15.41 0.76l-0.17-0.17C14.85 0.2 14.34 0 13.83 0s-1.02 0.2-1.41 0.59L1 12l-1 4 4-1L15.41 3.59C16.2 2.8 16.2 1.54 15.41 0.76zM3.49 14.1l-2.11 0.53 0.53-2.11 8.95-8.95 1.59 1.59L3.49 14.1zM14.71 2.88l-1.56 1.56 -1.59-1.59 1.56-1.56C13.31 1.1 13.56 1 13.83 1s0.52 0.1 0.71 0.29l0.17 0.17C15.1 1.85 15.1 2.49 14.71 2.88z"/></svg></span>\
24824                                        </li>\
24825                                    ';
24826    
24827                                    $menu_group.append(gb_li_html);
24828                                    cates = cates + '<li class="gallery-name" data-gallery-id="' + escapeGalleryMenuAttr(value.id) + '">' + escapeGalleryMenuHtml(value.name) + '</li>';
24829                                    // if(value.id == id) $.gallery.blocks[idx][menu_name].splice(k,1);
24830                                    $.gallery.pages[value.id] = value.page || menu_name;
24831                                }
24832                            }
24833                        });
24834                        idx++;
24835                    });
24836
24837                    if((data.lists).length == 0) $('.gallery-modal .gallery-add-items').addClass('disabled');
24838                    var cates = '';
24839                    var show = (data.cate_onoff == 'ON') ? '' : 'hide';
24840                    if(show) $('.gallery-cog').addClass('hide');
24841                    $.each(data.category, function(i,v) {
24842                        var active = (data.cate_str == v) ? 'active' : '';
24843                        $('.gallery-category .gallery-category-onoff').before('<li class="category-text gallery-category-menu ' + show + ' ' + active + '">' + v + '</li>');
24844                        cates = cates + '<li>' + v + '</li>';
24845                        if(data.cate_str == '') {
24846                            $('.gallery-category > li:nth-child(2)').addClass('active');
24847                        }
24848                    });
24849                    $.gallery.cates = cates;
24850                    if(data.cate_onoff == 'ON') {
24851                        $('.category-onoff-check').prop('checked','checked');
24852                        $('.category-title-str').addClass('on');
24853                    } else {
24854                        $('.category-onoff-check').prop('checked','');
24855                        $('.gallery-category > li:nth-child(2)').addClass('hide');
24856                        // $('.gallery-category > li:last-child').addClass('hide');
24857                    }
24858                    var selected_category = '',
24859                        $tag = $('.gallery-modal > .container');
24860
24861                    // lux shopping
24862                    if(LUX) {
24863                        $('.gallery-category').hide();
24864                        $tag.prepend('<div class="shop-filter-header open"></div>');
24865                        shopHeaderDisplay($tag.find('.shop-filter-header'),data);
24866
24867                        $('.gallery-list-filter').hide();
24868                        $('.selected-gallery-name').hide();
24869                        $('.gallery-category').hide();
24870                    } else {
24871                        // shopping filter
24872                        if(data.mode == 'shopping') {                        
24873                            var s = '\
24874                                <ul class="filter">\
24875                                    <li data-val="all" class="active">전체</li>\
24876                                    <li data-val="on">판매중</li>\
24877                                    <li data-val="off">판매중지</li>\
24878                                    <li data-val="out">품절</li>\
24879                                    <li data-val="hide">숨김</li>\
24880                                    <li data-val="wait">판매예정</li>\
24881                                    <li data-val="end">판매종료</li>\
24882                                </ul>\
24883                            ';
24884                            $('.gallery-list-filter').append(s);
24885                        }
24886                    }
24887
24888                    var keys = {'title' : '', 'date' : '', 'orig' : '', 'disc' : '', 'price' : ''},
24889                        keys_by = {'title' : '', 'date' : '', 'orig' : '', 'disc' : '', 'price' : ''},
24890                        checked = {'title' : '','date' : '', 'orig' : '', 'disc' : '', 'price' : ''},
24891                        icons = {
24892                            'title' : $.gallery.sort_icon_desc,
24893                            'date' : $.gallery.sort_icon_desc,
24894                            'orig' : $.gallery.sort_icon_desc,
24895                            'disc' : $.gallery.sort_icon_desc,
24896                            'price' : $.gallery.sort_icon_desc
24897                        };
24898                    switch(sort) {
24899                        case '' : break;
24900                        default : 
24901                            keys[sort] = 'sorted';
24902                            checked[sort] = '\
24903                                <span class="product-sort-checked">' + 
24904                                $.gallery.sort_icon_checked + '</span>\
24905                            ';
24906                        break;
24907                    }
24908                    if(sort) {
24909                        keys_by[sort] = by;
24910                        icons[sort] = (by == 'desc') ? $.gallery.sort_icon_desc : $.gallery.sort_icon_asc;
24911                    }
24912
24913                    var filter = getStorageItem('gallery-product-filter');
24914                    if(filter != null && filter.length) {
24915                        $('.gallery-list-filter .filter li').removeClass('active');
24916                        $('.gallery-list-filter .filter li[data-val="' + filter + '"]').addClass('active');
24917                    }
24918                    var s = '<ul class="table-toolbar">';
24919                    // lux shopping
24920                    if(LUX) {
24921                        s = s + '<li class="checkbox-cmd toolbar-cmd hide"><i class="" data-glseq="" data-cmd="checkall"></i> <input type="checkbox" class="check-all"></li>';
24922                        s = s + '<li class="toolbar-copy toolbar-cmd hide"><i class="" data-glseq="" data-cmd="copy"></i>' + $.lang[LANG]['editor.gallery.icon.clone'] + '</li>';
24923                        s = s + '<li class="toolbar-margin toolbar-cmd hide"><i class="" data-glseq="" data-cmd="margin"></i>마진율</li>';
24924                        s = s + '<li class="toolbar-delete toolbar-cmd hide"><i class="" data-glseq="" data-cmd="delete"></i>' + $.lang[LANG]['editor.gallery.icon.delete'] + '</li>';
24925                    } else {
24926                        s = s + '<li class="checkbox-cmd toolbar-cmd hide"><i class="" data-glseq="" data-cmd="checkall"></i> <input type="checkbox" class="check-all"></li>';
24927                        s = s + '<li class="toolbar-org-price product-cmd toolbar-cmd hide"><i class="" data-glseq="" data-discount="" data-discount-target="" data-cmd="org-price"></i>' + $.lang[LANG]['editor.gallery.icon.org.price'] + '</li>';
24928                        s = s + '<li class="toolbar-disc-price product-cmd toolbar-cmd hide"><i class="" data-glseq="" data-discount="" data-discount-target="" data-cmd="disc-price"></i>' + $.lang[LANG]['editor.gallery.icon.disc.price'] + '</li>';
24929                        s = s + '<li class="toolbar-sale-price product-cmd toolbar-cmd hide"><i class="" data-glseq="" data-discount="" data-discount-target="" data-cmd="sale-price"></i>' + $.lang[LANG]['editor.gallery.icon.sale.price'] + '</li>';
24930                        s = s + '<li class="toolbar-grade product-cmd toolbar-cmd hide"><i class="" data-glseq="" data-visible="" data-discount="" data-discount-target="" data-cmd="grade">' + $.lang[LANG]['editor.gallery.icon.grade.on'] + '</i></li>';
24931                        s = s + '<li class="toolbar-stock product-cmd toolbar-cmd hide"><i class="" data-glseq="" data-discount="" data-discount-target="" data-cmd="stock"></i>' + $.lang[LANG]['editor.gallery.icon.stock'] + '</li>';
24932
24933                        if(!$('.gallery-modal .gallery-category .gallery-all').hasClass('hide')) {
24934                            s = s + '<li class="toolbar-category toolbar-cmd submenu hide"><i class="" data-glseq="" data-cmd="category"></i>' + $.lang[LANG]['editor.block.gallery.category.change'] + ' <i class="fa fa-caret-down" aria-hidden="true"></i>';
24935                            s = s + '<ul class="item-submenu">' + cates + '</ul>';
24936                            s = s + '</li>';
24937                        }                        
24938
24939                        s = s + '<li class="toolbar-sort item-sort toolbar-cmd submenu hide">' + $.lang[LANG]['editor.gallery.icon.order'] + ' <i class="fa fa-caret-down" aria-hidden="true" data-glseq="" data-cmd="item-sort"></i>\
24940                                    <ul class="item-submenu">\
24941                                        <li class="sort-top">' + $.lang[LANG]['editor.gallery.icon.order.shopping.front'] + '</li>\
24942                                        <li class="sort-bottom">' + $.lang[LANG]['editor.gallery.icon.order.shopping.end'] + '</li>\
24943                                    </ul>\
24944                                </li>';
24945                        // s = s + '<li class="toolbar-discount toolbar-cmd hide"><i class="" data-glseq="" data-discount="" data-discount-target="" data-cmd="discount"></i>' + $.lang[LANG]['editor.gallery.icon.discount'] + '</li>';
24946
24947                        s = s + '<li class="toolbar-badge toolbar-cmd hide"><i class="" data-glseq="" data-badge="" data-badge-target="" data-cmd="badge"></i>' + $.lang[LANG]['editor.gallery.icon.badge'] + '</li>';
24948                                               
24949                        s = s + '\
24950                                <li class="toolbar-visible toolbar-cmd hide"><i class="" data-glseq="" data-visible="" data-cmd="visible">' + $.lang[LANG]['editor.gallery.icon.visible.off'] + '</i></li>\
24951                                <li class="toolbar-move toolbar-cmd hide"><i class="" data-glseq="" data-visible="" data-cmd="move">' + $.lang[LANG]['editor.block.gallery.item.move'] + '</i></li>\
24952                                <li class="toolbar-link toolbar-cmd hide"><i class="" data-glseq="" data-glink="" data-glink-target="" data-cmd="link"></i>' + $.lang[LANG]['editor.gallery.icon.link'] + '</li>\
24953                                <li class="toolbar-copy toolbar-cmd hide"><i class="" data-glseq="" data-cmd="copy"></i>' + $.lang[LANG]['editor.gallery.icon.clone'] + '</li>\
24954                                <li class="toolbar-delete toolbar-cmd hide"><i class="" data-glseq="" data-cmd="delete"></i>' + $.lang[LANG]['editor.gallery.icon.delete'] + '</li>\
24955                        ';
24956                        if(id == '') {
24957                            s = s + '<li class="dummy dm-gallery all">갤러리</li><li class="dummy dm-date all">등록일<span class="product-sort ' + keys['date'] + '" data-sort="date" data-by="' + keys_by['date'] + '">' + icons['date'] + '</span>' + checked['date'] + '</li><li class="dummy dm-category">카테고리</li>';
24958                        } else {
24959                            s = s + ((data.cate_onoff == 'ON' || !id || id == -1) ? 
24960                                '<li class="dummy dm-date select">등록일<span class="product-sort ' + keys['date'] + '" data-sort="date" data-by="' + keys_by['date'] + '">' + icons['date'] + '</span>' + checked['date'] + '</li><li class="dummy dm-category">카테고리</li>' : 
24961                                '<li class="dummy dm-date">등록일<span class="product-sort ' + keys['date'] + '" data-sort="date" data-by="' + keys_by['date'] + '">' + icons['date'] + '</span>' + checked['date'] + '</li>');
24962                        }
24963                        s = s + '\
24964                                <li class="dummy dm-orig-price">정가<span class="product-sort ' + keys['orig'] + '" data-sort="orig" data-by="' + keys_by['orig'] + '">' + icons['orig'] + '</span>' + checked['orig'] + '</li>\
24965                                <li class="dummy dm-discount">할인율<span class="product-sort ' + keys['disc'] + '" data-sort="disc" data-by="' + keys_by['disc'] + '">' + icons['disc'] + '</span>' + checked['disc'] + '</li>\
24966                                <li class="dummy dm-price">판매가<span class="product-sort ' + keys['price'] + '" data-sort="price" data-by="' + keys_by['price'] + '">' + icons['price'] + '</span>' + checked['price'] + '</li>\
24967                                <li class="dummy dm-quantity">재고</li>\
24968                                <li class="dummy dm-status">상태</li>\
24969                            </ul>\
24970                        ';
24971                    }
24972                    var $tool_back = $('<div class="toolbar sort
24972-disabled sticky">' + s + '</div>');
24973                    if(data.mode == 'shopping') {
24974                        $('.gallery-toolbar').append($tool_back).addClass('hide');
24975                    }
24976
24977                    var badge_settings = (data.badge_settings !== undefined && data.badge_settings)? JSON.stringify(data.badge_settings) : '{}';
24978                    var badge_imgs = (data.badge_imgs !== undefined && data.badge_imgs)? data.badge_imgs : '';
24979                    localStorage.setItem('badge_settings', badge_settings);
24980                    localStorage.setItem('badge_imgs', badge_imgs);
24981                    localStorage.setItem('before_badge_settings', badge_settings);
24982
24983                    var num = (page > 1) ? data.total : data.total - ((page-1) * data.view);
24984                    if((data.items).length && data.mode == 'shopping') {
24985                        var item_header = '\
24986                        <div class="item-header sticky">\
24987                            <div class="td-handle"></div>\
24988                            <div class="td-check"><input type="checkbox" class="check-all"></div>\
24989                            <div class="td-number">번호</div>\
24990                            <div class="td-img"></div>\
24991                            <div class="td-title">제목<span class="product-sort ' + keys['title'] + '" data-sort="title" data-by="' + keys_by['title'] + '">' + icons['title'] + '</span>' + checked['title'] + '\
24992                            </div>\
24993                        ';
24994
24995                        item_header+= (typeof id == 'undefined' || !id || id == -1) ? '<div class="td-gallery">갤러리</div>' : '';
24996                        item_header+='\
24997                            <div class="td-date">등록일<span class="product-sort ' + keys['date'] + '" data-sort="date" data-by="' + keys_by['date'] + '">' + icons['date'] + '</span>' + checked['date'] + '</div>\
24998                        ';
24999                        item_header+= (data.cate_onoff == 'ON' || !id || id == -1) ? '<div class="td-category">카테고리</div>' : '';
25000                        item_header+= '\
25001                            <div class="td-orig-price">정가<span class="product-sort ' + keys['orig'] + '" data-sort="orig" data-by="' + keys_by['orig'] + '">' + icons['orig'] + '</span>' + checked['orig'] + '</div>\
25002                            <div class="td-discount">할인율<span class="product-sort ' + keys['disc'] + '" data-sort="disc" data-by="' + keys_by['disc'] + '">' + icons['disc'] + '</span>' + checked['disc'] + '</div>\
25003                            <div class="td-price">판매가<span class="product-sort ' + keys['price'] + '" data-sort="price" data-by="' + keys_by['price'] + '">' + icons['price'] + '</span>' + checked['price'] + '</div>\
25004                            <div class="td-quantity">재고</div>\
25005                            <div class="td-status">상태</div>\
25006                        </div>\
25007                        ';
25008                        $('.gallery-items').append(item_header);
25009                    }
25010
25011                    if(window.localStorage.getItem('product-gallery-closed') == 'true' || $(document).width() < 1440) {
25012                        var $list = $('.product-gallery-list'),
25013                            $category = $('.gallery-category'),
25014                            $more = $('.gallery-items-loadmore'),
25015                            $items = $('.gallery-items'),
25016                            $toggle = $('.product-gallery-list-toggle'),
25017                            $pagination = $('.pagination-wrap'),
25018                            $filter = $('.gallery-list-filter'),
25019                            $name = $('.selected-gallery-name'),
25020                            $lux_filter = $('.shop-filter-header');
25021                        $list.removeClass('open');
25022                        $category.removeClass('open');
25023                        $more.removeClass('open');
25024                        $items.removeClass('open');
25025                        $toggle.removeClass('open');
25026                        $pagination.removeClass('open');
25027                        $filter.removeClass('open');
25028                        $name.removeClass('open');
25029                        $lux_filter.removeClass('open');
25030                    }
25031                    $.each(data.items, function(i,v) {
25032                        var settings = (v.gsettings) ? $.parseJSON(v.gsettings) : {},
25033                            link = (typeof settings.glink != 'undefined') ? settings.glink : '',
25034                            link_icon = (typeof settings.glink != 'undefined' && settings.glink) ? clSVG('gallery-link','20','20',true,'info-link') : '',
25035                            target = (typeof settings.glink_target != 'undefined') ? settings.glink_target : '',
25036                            cp_class = ($.inArray(v.seq,$.gallery.copy) > -1) ? ' active copy' : '',
25037                            mv_class = ($.inArray(v.seq,$.gallery.move) > -1) ? ' active move' : '',
25038                            invisible = (v.visible == '1') ? true : false;
25039                            // file = ((v.image).indexOf('googleusercontent') > -1) ? v.image : v.url
25040                            imgPATH = (typeof settings.storage == 'undefined') ? RPATH : settings.storage,
25041                            // src_s250 = getServeImage(v.image,'250',imgPATH);
25042                            src_s250 = v.url,
25043                            grade_onoff = (settings.grade_onoff) ? settings.grade_onoff : '';
25044
25045                        link = Base64.decode(link);
25046                        if(data.mode == 'shopping') {
25047                            var yet = (v.price == null) ? 'yet' : '';
25048                            $table = $('<div class="table-item ' + yet + '" data-page="' + v.page + '" data-product="' + v.is_product + '" data-pos="' + v.pos + '" data-page="' + v.page + '" data-pid="' + v.pid + '" data-seq="' + v.seq + '" data-link="' + link + '" data-target="' + target + '" data-visible="' + v.visible + '" data-category="' + v.category + '" data-out-datetime="off" data-pricechk="' + v.price_check + '" data-grade="'+ grade_onoff +'">');
25049                            // lux
25050                            if(LUX) {
25051                                v.sale = (v.price < v.sale) ? v.sale : '';
25052                                if(v.prod_case) $table.attr('data-pcase',v.prod_case);
25053                            }
25054
25055                            var title = (v.title) ? v.title : '상품명을 입력하세요',
25056                                price = (v.price != null && v.price !== '') ? addCommas(v.price) : '-',
25057                                sale = (v.sale != null && v.sale !== '') ? addCommas(v.sale) : '-',
25058                                soldout = '',
25059                            
25060                            quantity = (v.quantity_on == 'on' && v.quantity) ? addCommas(v.quantity) : 0;
25061                            var discount_settings = (settings.discount)? settings.discount : '';
25062                            var discount_rate = (discount_settings.rate !== undefined && discount_settings.rate)? discount_settings.rate : '';
25063                            var discount_unit = (discount_settings.unit !== undefined && discount_settings.unit)? discount_settings.unit : '';
25064
25065                            var discount = addCommas(discount_rate) + discount_unit;
25066                            var use_badge = (settings.use_badge)? settings.use_badge : '';
25067                            var status = '';
25068
25069                            if(invisible) $table.addClass('invisible');
25070
25071                            var is_soldout = false,
25072                                is_soldout_label = false,
25073                                saleStatus = '',
25074                                badgeList = '';
25075
25076                            quantity = (v.quantity_on == 'off' || v.quantity_on == null)  ? '-' : quantity;
25077
25078                            if(LUX) {
25079                                if(v.soldout) is_soldout = is_soldout_label = true;
25080                            } else {
25081                                if(v.quantity_on == 'off' || v.quantity_on == null || v.quantity_on == '') {
25082                                    if(v.status == 'off' || v.status == '') is_soldout = true;
25083                                } else {
25084                                    if(v.status == 'off' || v.status == '') is_soldout = true;
25085                                    if(v.quantity == 0) is_soldout = is_soldout_label = true;
25086                                }
25087                                if(v.status == 'lim') {
25088                                    saleStatus = '<span class="item-limit" data-toggle="tooltip" data-placement="top" data-original-title="' + v.sales_start + ' ~ ' + v.sales_end + '">기간한정판매</span>';
25089                                    $table.attr('data-out-datetime', (v.sale_now) ? '0' : '1');
25090                                }
25091
25092                                if(use_badge) {
25093                                    var badge_settings = $.parseJSON(localStorage.getItem('badge_settings'));
25094                                    badgeList = drawBadgeList(use_badge, badge_settings);
25095                                }
25096                            }
25097                            if(is_soldout) {
25098                                $table.addClass('soldout');
25099                                if(is_soldout_label) soldout = '<span class="item-soldout">품절</span>';
25100                            }
25101
25102                            switch(v.status) {
25103                                case "on": status = "판매중"; break;
25104                                case "off": status = "판매중지"; break;
25105                                default: status = "판매중지"; break;
25106                            }
25107                            // if(v.quantity_on == 'on' && v.quantity == 0) status = "품절";
25108                            if(sale == '') sale = price;
25109                            if(price == 0 && sale == 0) {
25110                                v.sale_per = 0;
25111                                sale = price;
25112                            }
25113                            if(invisible) $table.addClass('invisible');
25114
25115                            if(LUX) {
25116                                var margin_str = (v.prod_case == 'O' || v.price_sync == 'F') ? '' : '<span class="margin-info">마진율 <span class="rate">' + v.margin.rate + '</span>% + <span class="add">' + addCommas(v.margin.value) + '</span> = 마진금액 <span class="price" data-supply="' + v.supply_price + '">' + addCommas(v.margin_price) + '</span>원</span/>',
25117                                    add_info = '\
25118                                <div class="add-info">\
25119                                    <span class="brand">' + v.brand_name + '</span/>\
25120                                    <span class="sale-rate" data-retail="' + v.retail_price + '">' + ((v.price < v.sale) ? '할인율 <span class="rate">' + v.sale_rate + '</span>%' : '') + '</span/>\
25121                                    '+ margin_str + '\
25122                                </div>';
25123                                soldout += add_info;
25124                            }
25125    
25126                            var empty_title = (v.title == '' || price == '-') ? ' empty' : '';
25127                            var s = '\
25128                                <div class="td-handle"><div class="item-handle cl-sort-handle">' + clSVG('move_handle', 20, 20) + '</div></div>\
25129                                <div class="td-check"><input type="checkbox" name="item_check[]" class="td-input" data-ownproduct="' + (LUX && v.seq >= 1000000000 ? 'Y' : 'N') + '"></div>\
25130                                <div class="td-number">' + (num - i) + '</div>\
25131                                <div class="td-img"><img src="' + src_s250 + '" class="img-responsive">' + link_icon + '</div>\
25132                                <div class="td-title' + empty_title + '"><span class="item-title-str">' + title + '</span>' + saleStatus + badgeList + soldout +'\
25133                                    <ul class="product-item-edit" data-seq="' + v.seq + '">\
25134                                        <li class="edit-gallery-item" data-mode="prodDetail">'+ $.lang[LANG]['editor.block.gallery.product.detail'] +'</li>\
25135                                        <li class="edit-gallery-item" data-mode="prodInfo">'+ $.lang[LANG]['editor.block.gallery.product.info'] +'</li>\
25136                                    </ul>\
25137                                </div>\
25138                                ';
25139                            if(typeof id == 'undefined' || !id || id == -1)
25140                                if(typeof data.gallerys[v.pid] != 'undefined')
25141                                    s+= '<div class="td-gallery"><span title="' + data.gallerys[v.pid].title + '" alt="' + data.gallerys[v.pid].title + '">' + data.gallerys[v.pid].title + '</span></div>';
25142                                else 
25143                                    s+= '<div class="td-gallery"></div>';
25144
25145                            s+= '<div class="td-date">' + v.datetime2 + '</div>';
25146                            if(LUX) {
25147                                s+= '\
25148                                <div class="td-category">' + v.category_name + '</div>\
25149                                ';
25150                            } else {
25151                                if(typeof data.gallerys[v.pid] != 'undefined') {
25152                                    s+= '\
25153                                    <div class="td-category' + empty_title + ((data.cate_onoff == 'OFF') ? ' hide' : '') + ((v.item_category.indexOf(',') > -1) ? ' line' : '') + '">' + ((data.gallerys[v.pid].cate_onoff == 'ON') ? v.item_category : '') + '</div>\
25154                                    ';
25155                                } else {
25156                                    s+= '\
25157                                    <div class="td-category' + empty_title + ((data.cate_onoff == 'OFF') ? ' hide' : '') + ((v.item_category.indexOf(',') > -1) ? ' line' : '') + '"></div>\
25158                                    ';
25159                                }
25160                            }
25161                            var edit_button = '', str_quantity = '', hint_quantity = '';
25162                                quantity_need = (v.quantity_on == 'on' && (parseInt(uncomma(quantity)) < 6 || parseInt(uncomma(v.quantity_add_op)) < 6)) ? '<span class="need">' + ((v.add_options == true) ? $.gallery.info_icon_option_true : $.gallery.info_icon_option_false) + '</span>' : '';
25163                            if(v.quantity_on == 'on') {
25164                                if(v.normal_options == false && v.add_options == false) {
25165                                    edit_button = '<div class="edit-button">' + $.gallery.edit_icon + '</div><div class="close-button" data-val="' + quantity + '">' + $.gallery.close_icon + '</div>';
25166                                } else {
25167                                    edit_button = '<div class="edit-button conf">' + $.gallery.edit_icon + '</div>';
25168                                }
25169                            }
25170
25171                            str_quantity = (v.add_options == true && v.quantity_on == "on") ? quantity + '|' + addCommas(v.quantity_add_op) : addCommas(quantity);
25172                            hint_quantity = (v.add_options == true && v.quantity_on == "on") ? ' data-toggle="tooltip" data-html="true" data-placement="top" data-original-title="일반 재고 옵션 : ' + quantity + '<br>추가 옵션 재고 : ' + addCommas(v.quantity_add_op) + '"' : '';
25173                            var product_status = status;
25174                            if(v.status == 'lim') {
25175                                product_status = ((v.sale_now) ? '판매중' : (v.sale_fin) ? '판매종료' : '판매예정'); 
25176                                if(v.sale_now) product_status = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-clock" viewB
25176ox="0 0 16 16"><path d="M8 3.5a.5.5 0 0 0-1 0V9a.5.5 0 0 0 .252.434l3.5 2a.5.5 0 0 0 .496-.868L8 8.71z"/><path d="M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16m7-8A7 7 0 1 1 1 8a7 7 0 0 1 14 0"/></svg> ' + product_status;
25177                            }
25178                            var status_select = changeStatus(v.status, v.seq);
25179                            if(LUX) {
25180                                s+= '\
25181                                    <div class="td-orig-price' + empty_title + '">' + sale + '</div>\
25182                                    <div class="td-discount' + empty_title + '">' + (LUX ? v.sale_rate : v.sale_per) + '</div>\
25183                                    <div class="td-price' + empty_title + '">' + price + '</div>\
25184                                    <div class="td-quantity' + empty_title + '">' + quantity_need  + str_quantity + '</div>\
25185                                    <div class="td-status">' + product_status + '</div>\
25186                                ';
25187                            } else {
25188                                var sale_per = (v.sale_per) ? v.sale_per : ((typeof v.sale_per === 'number') ? 0 : '-');
25189                                s+= '\
25190                                    <div class="td-orig-price' + empty_title + '"><span class="prev-value">' + sale + '</span><div class="edit-button">' + $.gallery.edit_icon + '</div><div class="close-button" data-val="' + sale + '">' + $.gallery.close_icon + '</div></div>\
25191                                    <div class="td-discount' + empty_title + '"><span class="prev-value">' + sale_per + '</span><div class="edit-button">' + $.gallery.edit_icon + '</div><div class="close-button" data-val="' + (LUX ? v.sale_rate : sale_per) + '">' + $.gallery.close_icon + '</div></div>\
25192                                    <div class="td-price' + empty_title + '"><span class="prev-value">' + price + '</span><div class="edit-button">' + $.gallery.edit_icon + '</div><div class="close-button" data-val="' + price + '">' + $.gallery.close_icon + '</div></div>\
25193                                    <div class="td-quantity' + empty_title + '">' + quantity_need + '<span class="prev-value" ' + hint_quantity + '>' + str_quantity + '</span>' + edit_button + '</div>\
25194                                    <div class="td-status">' + product_status + status_select + '</div>\
25195                                ';
25196                            }
25197    
25198                            $table.append(s);
25199                            
25200                            if ($table.find('.td-title > span').length > 4) {
25201                                $table.find('.td-title .item-title-str').addClass('fw-title-block')
25202                            }
25203
25204                            $('.gallery-items').append($table);
25205                        } else {
25206                            var $info = $('<div class="info"></div>'),
25207                                $item = $('<div class="item" data-pos="' + v.pos + '" data-page="' + v.page + '" data-pid="' + v.pid + '" data-seq="' + v.seq + '" data-link="' + link + '" data-target="' + target + '" data-visible="' + v.visible + '" data-category="' + v.category.split(", ").map(item => `|${item}|`).join(",") + '"><img src="' + src_s250 + '" class="img-responsive"><input type="text" name="item_name" class="item-title" value="' + v.title + '" placeholder="' + $.lang[LANG]['board.enter-title'] + '" data-seq="' + v.seq + '" data-title="' + v.title + '" data-caption="' + v.content + '" data-category="' + v.category + '" data-date="' + v.datetime2 + '" data-hash="' + v.hashtag + '" data-url="' + src_s250 + '"></div>');
25208
25209                            // if(mv_class) $item.addClass('active move');
25210                            // if(cp_class) $item.addClass('active copy');
25211                            $info.empty();
25212                            if(invisible) $item.addClass('invisible');
25213                            if(typeof settings.glink != 'undefined' && settings.glink) {
25214                                $info.append(link_icon);
25215                                $item.append($info);
25216                            }
25217    
25218                            $('.gallery-items').append($item);
25219                        }
25220                    });
25221                    
25222                    $('.gallery-items-loadmore').remove();
25223                    if(data.mode == 'shopping') {
25224                        if($('.gallery-modal').find('.pagination-wrap').length == 0 && data.total > 0) {
25225                            $('.gallery-items').after('<div class="pagination-wrap open"><ul class="pagination" id="product-pagination"></ul></div>');
25226                            var totalPage = (data.total > 0) ? Math.ceil(data.total/data.view) : 1;
25227                            $.jqPaginator('#product-pagination', {
25228                                totalPages: totalPage,
25229                                totalCounts: data.total,
25230                                currentPage: 1,
25231                                visiblePages: 10,
25232                                onPageChange: function (num, type) {
25233                                    if(type == 'change') {
25234                                        $.gallery.list($.gallery.block_id,num,$.gallery.category,'list');   
25235                                        $.gallery.update = true;
25236                                    }
25237                                    window.localStorage.setItem('gallery-product-page',num);
25238                                }
25239                            });
25240                        }
25241                        if(data.total == 0) {
25242                            var msg = (data.mode == 'shopping') ? $.lang[LANG]['editor.gallery.product.empty'] : $.lang[LANG]['editor.gallery.list.empty'];
25243                            msg = (data.search) ? '결과가 없습니다' : msg;
25244                            $('.gallery-items').append('<p class="text-center sort-disabled category-empty"> ' + msg + '</p>');
25245                        }
25246                    } else {
25247                        if((data.items).length == 0) {
25248                            var msg = (data.mode == 'shopping') ? $.lang[LANG]['editor.gallery.product.empty'] : $.lang[LANG]['editor.gallery.list.empty'];
25249                            msg = (data.search) ? '결과가 없습니다' : msg;
25250                            $('.gallery-items').append('<p class="text-center sort-disabled category-empty"> ' + msg + '</p>');
25251                        } else {
25252                            if((data.items).length < data.total) {
25253                                var count = (data.mode == 'shopping') ? $('.gallery-items .table-item').length : $('.gallery-items .item').length;
25254                                $('.gallery-items').after('<div class="gallery-items-loadmore open" data-pid="' + data.pid + '" data-category-str="' + data.cate_str + '" data-page="1">' + $.lang[LANG]['data.loadmore'] + ' (' + count + ' / ' + number_format(data.total) + ')</div>');
25255                            }
25256                        }
25257                    }
25258                    if(product_name != null && product_name.length) {
25259                        $('.gallery-list-search-text').val(product_name);
25260                        // $('.gallery-list-search-submit').hide();
25261                        // $('.gallery-list-search-cancel').show();
25262                    }
25263                    $('.gallery-ctrl-category').attr('data-category',data.category.toString()).attr('data-pid',data.pid);
25264    
25265                    var handle = (data.mode == 'shopping') ? '.td-handle' : '.item-ctrl';
25266                    var $item = $('.gallery-items .item');
25267                    
25268                    var gallery_items_handle = (LUX) ? '' : ', .td-handle';
25269                    $('.gallery-items').selectable({
25270                        // distance: 3,
25271                        filter : '.table-item,.item',
25272                        cancel : '.gallery-toolbar, .td-orig-price, .td-discount, .td-price, .td-quantity, .item-edit, .product-item-edit, .item.ui-selected, .table-item-status, .td-check, .td-status, .item-title, .item .info, svg'+gallery_items_handle,
25273                        stop : function(event,ui) {
25274                            if($('#user-edit').length) $('#user-edit').blur(); 
25275                            $.gallery.selected(event,ui);
25276                        }
25277                    });
25278                    $('.item-header').removeClass('ui-selectee');
25279    
25280                    $m.fadeIn(300, function() {
25281                        if(typeof func == 'function') func();
25282                        $('#dummy-drop').remove();
25283                    });
25284    
25285                    $('.gallery-modal').off('scroll').on('scroll', function(e) {
25286                        if($('.gallery-blocks').length && $(this).scrollTop() < 65) {
25287                            $('.product-gallery-list').css('top','93px'); 
25288                        } else $('.product-gallery-list').css('top','0px'); 
25289                        stickyToolbar();
25290                    });
25291                    // resizeGalleryModal();
25292                    setLanguage(LANG);
25293
25294                    if(typeof GALLERY_MODE != 'undefined') {
25295                        GALLERY_MODE.push({
25296                            seq : data.pid,
25297                            mode : data.mode
25298                        });
25299                    }
25300                    
25301                    if(data.gallery_mode != 'shopping' || LUX) {
25302                        $('.gallery-blocks .all-items').addClass('hide');
25303                        if(data.pid) {
25304                            $('.gallery-blocks .menus li[data-gallery-id="' + data.pid +'"]').addClass('active');
25305                            $.gallery.block_id = data.pid;
25306                        }
25307                    }
25308                },
25309                error : function(xhr, status, error) {
25310                    $.processOFF();
25311                    alert("Error " + xhr.status + " : 관리자에게 문의");
25312                }
25313            });
25314        },
25315        list : function(id, page, category, type) {
25316            // if(typeof id == 'undefined' || !id) {
25317            //     alert('Undefined gallery ID');
25318            //     return false;
25319            // }
25320            $.gallery.seqs = [];
25321            if(typeof page =='undefined') page = 1;
25322            if(typeof category =='undefined') category = '';
25323            if(typeof type == 'undefined') type = 'load';
25324            // $('.gallery-items-loadmore').addClass('spinner');
25325            var params = ($('.gallery-modal').length) ? getProductParams() : getSearchURL(),
25326                product_name = getStorageItem('gallery-product-name'),
25327                product_filter = getStorageItem('gallery-product-filter'),
25328                product_view = getStorageItem('gallery-product-view'),
25329                sort = getStorageItem('gallery-product-sort'),
25330                by = getStorageItem('gallery-product-by'),
25331                manager = (id == '' || id == -1) ? SID : '';
25332
25333            $.processON();                
25334            $.ajax({
25335                type: 'POST',
25336                url : '/template/gallery/show',
25337                data :  { mode : 'list', id : id, page : page, category : category, params : params, manager : manager, product_name : product_name, product_filter : product_filter, product_view : product_view, sort : sort, by : by },
25338                dataType : 'json',
25339                async: true,
25340                cache: false,
25341                success : function(data) {
25342                    $.processOFF();
25343                    if(data.error != 'undefined' && data.error) {
25344                        alert(data.error);
25345                        return false;
25346                    }
25347                    (typeof id == 'undefined' || !id) ? $('.gallery-category').hide() : $('.gallery-category').show();
25348                    if(LUX) {
25349                        $('.gallery-list-filter').hide();
25350                        $('.selected-gallery-name').hide();
25351                        $('.gallery-category').hide();
25352                    }
25353                    if(type == 'list') $('.gallery-items').find('.table-item').remove();
25354                    var num = data.total - ((page-1) * data.view);
25355                    $.each(data.items, function(i,v) {
25356                        var settings = (v.gsettings) ? $.parseJSON(v.gsettings) : {},
25357                            link = (typeof settings.glink != 'undefined') ? settings.glink : '',
25358                            link_icon = (typeof settings.glink != 'undefined' && settings.glink) ? clSVG('gallery-link','16','16',true,'info-link') : '',
25359                            target = (typeof settings.glink_target != 'undefined') ? settings.glink_target : '',
25360                            cp_class = ($.inArray(v.seq,$.gallery.copy) > -1) ? ' active copy' : '',
25361                            mv_class = ($.inArray(v.seq,$.gallery.move) > -1) ? ' active move' : '',
25362                            invisible = (v.visible == '1') ? true : false;
25363                            // file = ((v.image).indexOf('googleusercontent') > -1) ? v.image : v.url
25364                            imgPATH = (typeof settings.storage == 'undefined') ? RPATH : settings.storage,
25365                            // src_s250 = getServeImage(v.image,'250',imgPATH);
25366                            src_s250 = v.url,
25367                            grade_onoff = (settings.grade_onoff) ? settings.grade_onoff : '';
25368
25369                        link = Base64.decode(link);
25370                        if(data.mode == 'shopping') {
25371                            var yet = (v.price == null) ? 'yet' : '';
25372                            $table = $('<div class="table-item ' + yet + '" data-product="' + v.is_product + '" data-pos="' + v.pos + '" data-page="' + v.page + '" data-pid="' + v.pid + '" data-seq="' + v.seq + '" data-link="' + link + '" data-target="' + target + '" data-visible="' + v.visible + '" data-category="' + v.category + '" data-out-datetime="off"  data-pricechk="' + v.price_check + '" data-grade="'+ grade_onoff +'">');
25373                            // lux
25374                            if(LUX) {
25375                                v.sale = (v.price < v.sale) ? v.sale : '';
25376                                if(v.prod_case) $table.attr('data-pcase',v.prod_case);
25377                            }
25378
25379                            var title = (v.title) ? v.title : '상품명을 입력하세요',
25380                                price = (v.price != null && v.price !== '') ? addCommas(v.price) : 0,
25381                                sale = (v.sale != null && v.sale !== '') ? addCommas(v.sale) : 0,
25382                                soldout = '',
25383                                quantity = (v.quantity_on == 'on' && v.quantity) ? addCommas(v.quantity) : '-';
25384                            var discount_settings = (settings.discount)? settings.discount : '';
25385                            var discount_rate = (discount_settings.rate !== undefined && discount_settings.rate)? discount_settings.rate : '';
25386                            var discount_unit = (discount_settings.unit !== undefined && discount_settings.unit)? discount_settings.unit : '';
25387                            var discount = addCommas(discount_rate) + discount_unit;
25388
25389                            var use_badge = (settings.use_badge)? settings.use_badge : '';
25390                            // console.log('use_badge', use_badge);
25391                            if(invisible) $table.addClass('invisible');
25392
25393                            var is_soldout = false,
25394                                is_soldout_label = false,
25395                                saleStatus = '',
25396                                badgeList = '';
25397
25398                            quantity = (v.quantity_on == 'off' || v.quantity_on == null)  ? '-' : quantity;
25399                            if(LUX) {
25400                                if(v.soldout) is_soldout = is_soldout_label = true;
25401                            } else {
25402                                if(v.quantity_on == 'off' || v.quantity_on == null || v.quantity_on == '') {
25403                                    if(v.status == 'off' || v.status == '') is_soldout = true;
25404                                } else {
25405                                    if(v.status == 'off' || v.status == '') is_soldout = true;
25406                                    if(v.quantity == 0) is_soldout = is_soldout_label = true;
25407                                }
25408                                if(v.status == 'lim') {
25409                                    saleStatus = '<span class="item-limit" data-toggle="tooltip" data-placement="top" data-original-title="' + v.sales_start + ' ~ ' + v.sales_end + '">기간한정판매</span>';
25410                                    $table.attr('data-out-datetime', (v.sale_now) ? '0' : '1');
25411                                }
25412
25413                                if(use_badge) {
25414                                    var badge_settings = $.parseJSON(localStorage.getItem('badge_settings'));
25415                                    badgeList = drawBadgeList(use_badge, badge_settings);
25416                                }
25417                            }
25418                            if(is_soldout) {
25419                                $table.addClass('soldout');
25420                                if(is_soldout_label) soldout = '<span class="item-soldout">품절</span>';
25421                            }
25422
25423                            switch(v.status) {
25424                                case "on": status = "판매중"; break;
25425                                case "off": status = "판매중지"; break;
25426                                default: status = "판매중지"; break;
25427                            }
25428                            // if(v.quantity_on == 'on' && v.quantity == 0) status = "품절";
25429                            if(sale == '') sale = price;
25430                            if(price == 0 && sale == 0) {
25431                                v.sale_per = 0;
25432                                sale = price
25433                            }
25434                            if(invisible) $table.addClass('invisible');
25435
25436                            if(LUX) {
25437                                var margin_str = (v.prod_case == 'O' || v.price_sync == 'F') ? '' : '<span class="margin-info">마진율 <span class="rate">' +  v.margin.rate + '</span>% + <span class="add">' + addCommas(v.margin.value) + '</span> = 마진금액 <span class="price" data-supply="' + v.supply_price + '">' + addCommas(v.margin_price) + '</span>원</span/>',
25438                                    add_info = '\
25439                                <div class="add-info">\
25440                                    <span class="brand">' + v.brand_name + '</span/>\
25441                                    <span class="sale-rate" data-retail="' + v.retail_price + '>' + ((v.price < v.sale) ? '할인율 <span class="rate">' + v.sale_rate + '</span>%' : '') + '</span/>\
25442                                    ' + margin_str + '\
25443                                </div>';
25444                                soldout += add_info;
25445                            }
25446    
25447                            var empty_title = (v.title == '' || price == '-') ? ' empty' : '';
25448                            var s = '\
25449                                <div class="td-handle"><div class="item-handle cl-sort-handle">' + clSVG('move_handle', 20, 20) + '</div></div>\
25450                                <div class="td-check"><input type="checkbox" name="item_check[]" class="td-input" data-ownproduct="' + (LUX && v.seq >= 1000000000 ? 'Y' : 'N') + '"></div>\
25451                                <div class="td-number">' + (num - i) + '</div>\
25452                                <div class="td-img"><img src="' + src_s250 + '" class="img-responsive">' + link_icon + '</div>\
25453                                <div class="td-title' + empty_title + '"><span class="item-title-str">' + title + '</span>' + saleStatus + badgeList + soldout + '\
25454                                    <ul class="product-item-edit" data-seq="' + v.seq + '">\
25455                                        <li class="edit-gallery-item" data-mode="prodDetail">상세페이지</li>\
25456                                        <li class="edit-gallery-item" data-mode="prodInfo">상품설정</li>\
25457                                    </ul>\
25458                                </div>\
25459                            ';
25460                                // <!--<div class="td-edit' + empty_title + '"><div class="item-edit" data-seq="' + v.seq + '"><span class="cl-icon cl_icon_edit04"></span>&nbsp;&nbsp;' + $.lang[LANG]['editor.block.gallery.item.edit'] + '</div></div>-->\
25461                            s+= '<div class="td-date">' + v.datetime2 + '</div>';
25462                            if(LUX) {
25463                                s+= '\
25464                                <div class="td-category">' + v.category_name + '</div>\
25465                                ';
25466                            } else {
25467                                s+= '\
25468                                <div class="td-category' + empty_title + ((data.cate_onoff == 'OFF') ? ' hide' : '') + ((v.item_category.indexOf(',') > -1) ? ' line' : '') + '">' + ((data.gallerys[v.pid].cate_onoff == 'ON') ? v.item_category : '') + '</div>\
25469                                ';
25470                            }
25471                            var edit_button = '', str_quantity = '', hint_quantity = '';
25472                                quantity_need = (v.quantity_on == 'on' && (parseInt(uncomma(quantity)) < 6 || parseInt(uncomma(v.quantity_add_op)) < 6)) ? '<span class="need">' + ((v.add_options == true) ? $.gallery.info_icon_option_true : $.gallery.info_icon_option_false) + '</span>' : '';
25473                            if(v.quantity_on == 'on') {
25474                                if(v.normal_options == false && v.add_options == false) {
25475                                    edit_button = '<div class="edit-button">' + $.gallery.edit_icon + '</div><div class="close-button" data-val="' + quantity + '">' + $.gallery.close_icon + '</div>';
25476                                } else {
25477                                    edit_button = '<div class="edit-button conf">' + $.gallery.edit_icon + '</div>';
25478                                }
25479                            }
25480
25481                            str_quantity = (v.add_options == true && v.quantity_on == "on") ? addCommas(quantity) + '|' + addCommas(v.quantity_add_op) : addCommas(quantity);
25482                            hint_quantity = (v.add_options == true && v.quantity_on == "on") ? ' data-toggle="tooltip" data-html="true" data-placement="top" data-original-title="일반 재고 옵션 : ' + quantity + '<br>추가 옵션 재고 : ' + addCommas(v.quantity_add_op) + '"' : '';
25483                            var product_status = status;
25484                            if(v.status == 'lim') {
25485                                product_status = ((v.sale_now) ? '판매중' : (v.sale_fin) ? '판매종료' : '판매예정');
25486                                if(v.sale_now) product_status = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-clock" viewB
25486ox="0 0 16 16"><path d="M8 3.5a.5.5 0 0 0-1 0V9a.5.5 0 0 0 .252.434l3.5 2a.5.5 0 0 0 .496-.868L8 8.71z"/><path d="M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16m7-8A7 7 0 1 1 1 8a7 7 0 0 1 14 0"/></svg> ' + product_status;
25487                            }
25488                            var status_select = changeStatus(v.status, v.seq);
25489                            if(LUX) {
25490                                s+= '\
25491                                    <div class="td-orig-price' + empty_title + '">' + sale + '</div>\
25492                                    <div class="td-discount' + empty_title + '">' + (LUX ? v.sale_rate : v.sale_per) + '</div>\
25493                                    <div class="td-price' + empty_title + '">' + price + '</div>\
25494                                    <div class="td-quantity' + empty_title + '">' + quantity_need  + str_quantity + '</div>\
25495                                    <div class="td-status">' + product_status + '</div>\
25496                                ';
25497                            } else {
25498                                var sale_per = (v.sale_per) ? v.sale_per : ((typeof v.sale_per === 'number') ? 0 : '-');
25499                                s+= '\
25500                                    <div class="td-orig-price' + empty_title + '"><span class="prev-value">' + sale + '</span><div class="edit-button">' + $.gallery.edit_icon + '</div><div class="close-button" data-val="' + sale + '">' + $.gallery.close_icon + '</div></div>\
25501                                    <div class="td-discount' + empty_title + '"><span class="prev-value">' + sale_per + '</span><div class="edit-button">' + $.gallery.edit_icon + '</div><div class="close-button" data-val="' + (LUX ? v.sale_rate : sale_per) + '">' + $.gallery.close_icon + '</div></div>\
25502                                    <div class="td-price' + empty_title + '"><span class="prev-value">' + price + '</span><div class="edit-button">' + $.gallery.edit_icon + '</div><div class="close-button" data-val="' + price + '">' + $.gallery.close_icon + '</div></div>\
25503                                    <div class="td-quantity' + empty_title + '">' + quantity_need + '<span class="prev-value" ' + hint_quantity + '>' + str_quantity + '</span>' + edit_button + '</div>\
25504                                    <div class="td-status">' + product_status + status_select + '</div>\
25505                                ';
25506                                /*                                
25507                                s+= '\
25508                                    <div class="td-orig-price' + empty_title + '"><span class="prev-value">' + sale + '</span><div class="edit-button">' + $.gallery.edit_icon + '</div><div class="close-button" data-val="' + sale + '">' + $.gallery.close_icon + '</div></div>\
25509                                    <div class="td-discount' + empty_title + '"><span class="prev-value">' + (LUX ? v.sale_rate : v.sale_per) + '</span><div class="edit-button">' + $.gallery.edit_icon + '</div><div class="close-button" data-val="' + (LUX ? v.sale_rate : v.sale_per) + '">' + $.gallery.close_icon + '</div></div>\
25510                                    <div class="td-price' + empty_title + '"><span class="prev-value">' + price + '</span><div class="edit-button">' + $.gallery.edit_icon + '</div><div class="close-button" data-val="' + price + '">' + $.gallery.close_icon + '</div></div>\
25511                                    <div class="td-quantity' + empty_title + '">' + quantity_need + '<span class="prev-value">' + str_quantity + '</span>' + edit_button + '</div>\
25512                                    <div class="td-status">' + product_status + status_select + '</div>\
25513                                ';
25514                                */
25515                            }
25516
25517                            $table.append(s);
25518                            $('.gallery-items').append($table);
25519                        } else {
25520                            var $info = $('<div class="info"></div>'),
25521                                $item = $('<div class="item" data-pos="' + v.pos + '" data-pid="' + v.pid + '" data-seq="' + v.seq + '" data-link="' + link + '" data-target="' + target + '" data-visible="' + v.visible + '" data-category="' + v.category + '"><img src="' + src_s250 + '" class="img-responsive"><input type="text" name="item_name" class="item-title" value="' + v.title + '" placeholder="' + $.lang[LANG]['board.enter-title'] + '" data-seq="' + v.seq + '" data-title="' + v.title + '" data-caption="' + v.content + '" data-category="' + v.category + '" data-date="' + v.datetime2 + '" data-hash="' + v.hashtag + '" data-url="' + src_s250 + '"></div>');
25522    
25523                            $info.empty();
25524                            if(invisible) $item.addClass('invisible');
25525                            if(typeof settings.glink != 'undefined' && settings.glink) {
25526                                $info.append(link_icon);
25527                                $item.append($info);
25528                            }
25529    
25530                            $('.gallery-items').append($item);
25531                        }
25532                    });
25533                    
25534                    $('.gallery-toolbar').addClass('hide');
25535                    if(product_name != null && product_name.length) {
25536                        $('.gallery-list-search-text').val(product_name);
25537                        // $('.gallery-list-search-submit').hide();
25538                        // $('.gallery-list-search-cancel').show();
25539                    }
25540
25541                    if(type == 'load') {
25542                        $('.gallery-items-loadmore').remove();
25543                        var itemCheck = (data.mode == 'shopping') ? '.table-item' : '.item';
25544        
25545                        if($('.gallery-items ' + itemCheck).length < data.total) {
25546                            $('.gallery-items').after('<div class="gallery-items-loadmore" data-pid="' + data.pid + '" data-category-str="' + data.cate_str + '" data-page="' + data.page_num + '">' + $.lang[LANG]['data.loadmore'] + ' (' + $('.gallery-items ' + itemCheck).length + ' / ' + number_format(data.total) + ')</div>');
25547                        }
25548                    }
25549    
25550                    // $('.gallery-items').sortable('refresh');                
25551                },
25552                error : function(xhr, status, error) {
25553                    $.processOFF();
25554                    alert("Error " + xhr.status + " : 관리자에게 문의");
25555                }
25556            });
25557        },
25558        setNumber: function() {
25559            var items = $.gallery.seqs;
25560            if(items.length) {
25561                var group = ($('.table-item').length) ? '.table-item' : '.gallery-items .item';
25562                $.each(items, function(i,v) {
25563                    $(group+'[data-seq="' + v + '"]').attr('data-index',(i+1));
25564                });
25565            }
25566
25567            if(LUX) {
25568                if($.gallery.seqs.length > 0) {
25569                    var checkDefault = ($('.gallery-items .table-item.ui-selected:not([data-pcase="O"])').length > 0) ? true : false,
25570                        checkPcaseO = ($('.gallery-items .table-item.ui-selected[data-pcase="O"]').length > 0) ? true : false,
25571                        checkMargin = ($('.gallery-items .table-item.ui-selected:not([data-pcase="O"])').length == $('.gallery-items .table-item.ui-selected:not([data-pcase="O"]) .margin-info').length) ? true : false;
25572
25573                    if(checkPcaseO && !checkDefault) $('.table-toolbar .toolbar-delete').removeClass('hide');
25574                    else $('.table-toolbar .toolbar-delete').addClass('hide');
25575
25576                    if(!checkPcaseO && checkDefault && checkMargin) $('.table-toolbar .toolbar-margin').removeClass('hide');
25577                    else $('.table-toolbar .toolbar-margin').addClass('hide');
25578
25579                    if($('.gallery-items .table-item.ui-selected').length == $('.gallery-items .table-item').length) $('.checkbox-cmd > input[type="checkbox"]').prop('checked',true);
25580                    else $('.checkbox-cmd > input[type="checkbox"]').prop('checked',false);
25581                } else {
25582                    $('.gallery-toolbar').removeClass('hide_col');
25583                    $('.table-toolbar .toolbar-cmd').addClass('hide');
25584                    $('.table-toolbar .toolbar-cmd i[data-glseq]').attr('data-glseq','');
25585                    $('.table-toolbar .toolbar-cmd i[data-cmd="link"]').attr('data-glink','').attr('data-glink-target','');
25586                    $('.table-toolbar .toolbar-cmd i[data-cmd="visible"]').attr('data-visible','0').text($.lang[LANG]['editor.gallery.icon.visible.off']);
25587                    $('.checkbox-cmd > input[type="checkbox"], .col-check > input[type="checkbox"]').prop('checked',false);
25588                    $('.gallery-toolbar').addClass('hide');
25589                    $('.gallery-items .item-header').removeClass('hide');
25590                }
25591            }
25592        },
25593        selected: function(e,ui) {
25594            $.gallery.seqs = [];
25595            var disabled = false, visible_button = false; no_price = false;
25596            if($.gallery.mode == 'shopping') {
25597                $('.table-item .td-check > input[type="checkbox"]').prop('checked',false);
25598                $.each($('.gallery-items .table-item.ui-selected'), function(i,v) {
25599                    if($(this).attr('data-product') == "false") disabled = true;
25600                    if($(this).attr('data-out-datetime') == "1") visible_button = true;
25601                    if($(this).attr('data-pricechk') == "false") no_price = true;
25602                    $(this).find('.td-check > input[type="checkbox"]').prop('checked',true);
25603                    ($.gallery.seqs).push($(v).attr('data-seq'));
25604                });
25605
25606                if($.gallery.seqs.length > 0) {
25607                    if($('.gallery-items .table-item.ui-selected').length && $('.gallery-items .table-item').length) {
25608                        $('.table-toolbar li').removeClass('hide open');
25609                        $('.gallery-toolbar').addClass('hide_col');
25610                    }
25611                    var firstItem = $('.gallery-items .table-item.ui-selected').eq(0),
25612                        first_seq = firstItem.attr('data-seq'),
25613                        seq = firstItem.attr('data-seq'),
25614                        pid = firstItem.attr('data-pid'),
25615                        link = firstItem.attr('data-link'),
25616                        target = firstItem.attr('data-target'),
25617                        visible = firstItem.attr('data-visible'),
25618                        grade = firstItem.attr('data-grade'),
25619                        vstr = (visible == '1') ? $.lang[LANG]['editor.gallery.icon.visible.on'] : $.lang[LANG]['editor.gallery.icon.visible.off'],
25620                        gstr = (grade == 'ON') ? $.lang[LANG]['editor.gallery.icon.grade.off'] : $.lang[LANG]['editor.gallery.icon.grade.on'];
25621                    if(visible_button) {
25622                        $('.table-toolbar .toolbar-cmd.toolbar-visible').addClass('disabled');
25623                    } else $('.table-toolbar .toolbar-cmd.toolbar-visible').removeClass('disabled');
25624                    if($.gallery.block_id == -1) {
25625                        $('.table-toolbar .toolbar-cmd.toolbar-copy').addClass('disabled');
25626                    }
25627                    $('.table-toolbar .toolbar-cmd').removeClass('hide');
25628                    $('.table-toolbar .toolbar-cmd i[data-glseq]').attr('data-glseq',first_seq);
25629                    $('.table-toolbar .toolbar-cmd i[data-cmd="link"]').attr('data-glink',link).attr('data-glink-target',target);
25630                    $('.table-toolbar .toolbar-cmd i[data-cmd="visible"]').attr('data-visible',visible).text(vstr);
25631                    $('.table-toolbar .toolbar-cmd i[data-cmd="grade"]').attr('data-grade',grade).text(gstr);
25632                    $('.gallery-toolbar').removeClass('hide');
25633                    $('.gallery-items .item-header').addClass('hide');
25634                    stickyToolbar();
25635                    $.gallery.setNumber();
25636                } else {
25637                    $('.gallery-items .table-item > div').removeClass('hide-text');
25638                    $('.table-toolbar .toolbar-cmd').addClass('hide');
25639                    $('.table-toolbar .toolbar-cmd i[data-glseq]').attr('data-glseq','');
25640                    $('.table-toolbar .toolbar-cmd i[data-cmd="link"]').attr('data-glink','').attr('data-glink-target','');
25641                    $('.table-toolbar .toolbar-cmd i[data-cmd="visible"]').attr('data-visible','0').text($.lang[LANG]['editor.gallery.icon.visible.off']);
25642                    $('.gallery-toolbar').addClass('hide');
25643                    $('.gallery-items .item-header').removeClass('hide');
25644                }
25645            } else {
25646                $.each($('.gallery-items .item.ui-selected'), function(i,v) {
25647                    ($.gallery.seqs).push($(v).attr('data-seq'));
25648                });
25649                $.gallery.toolbar();
25650                stickyToolbar();
25651            }
25652
25653            (no_price) ? $('.product-cmd').not('.toolbar-org-price').not('.toolbar-stock').addClass('no_price') : $('.product-cmd').removeClass('no_price');
25654            (disabled) ? $('.product-cmd').addClass('disabled') : $('.product-cmd').removeClass('disabled');
25655            if($('.gallery-modal').attr('data-pid') == undefined) {
25656                $('.toolbar-sort.item-sort').addClass('disabled');
25657            }
25658
25659            $('.item-submenu, .view-submenu').hide();
25660            $('.toolbar-sort, .gallery-view-count').removeClass('open');
25661            $('.gallery-blocks .btn-group').removeClass('open');
25662        },
25663        toolbar : function() {
25664            $('.gallery-list-filter').remove();
25665            $('.gallery-items').find('.toolbar.mod-gallery').remove();
25666            if($.gallery.seqs.length == 0) return false;
25667            var $s = $('.gallery-items .item[data-seq="' + $.gallery.seqs[0] + '"]'),
25668                seq = $s.attr('data-seq'),
25669                pid = $s.attr('data-pid'),
25670                link = $s.attr('data-link'),
25671                target = $s.attr('data-target'),
25672                visible = $s.attr('data-visible'),
25673                edit_name = ($.gallery.mode == 'gallery') ? $.lang[LANG]['editor.block.gallery.item.edit.image'] : $.lang[LANG]['editor.block.gallery.item.edit'];
25674
25675            var l = ($s.index()%7 > 3) ? 'right' : '',
25676                mode = $('.gallery-add-items').attr('data-mode');
25677
25678            var vstr = (visible == "1") ? $.lang[LANG]["editor.gallery.icon.visible.on"] : $.lang[LANG]["editor.gallery.icon.visible.off"],
25679                vicon = (visible == "1") ? 'cl_icon_hide02' : 'cl_icon_show',
25680                editable = ($.gallery.seqs.length > 1) ? "disabled" : "";
25681
25682            var s = '\
25683                <ul>\
25684                    <li class="active gallery-item-edit submenu' + editable + ' edit-'+ $.gallery.mode +'">\
25685                ';
25686            if($.gallery.mode == 'project') {
25687                s = s + '\
25688                        ' + $.lang[LANG]['editor.block.gallery.item.edit'] + '</span> <i class="fa fa-caret-down"></i>\
25689                        <ul class="item-submenu">\
25690                            <li class="edit-gallery-item"><i class="" data-glseq="' + seq + '" data-cmd="edit">'+$.lang[LANG]["editor.gallery.icon.thumnail.config"]+'</i></li>\
25691                            <li class="edit-gallery-detail" data-seq="' + seq + '" >'+$.lang[LANG]["editor.gallery.icon.Project.page"]+'</li>\
25692                        </ul>\
25693                    </li>\
25694                ';
25695            } else {
25696                s = s + '\
25697                        <i class="" data-glseq="' + seq + '" data-cmd="edit"></i>' + edit_name + '\
25698                    </li>\
25699                ';
25700            }
25701            s = s + '<li><i class="" data-glseq="' + seq + '" data-cmd="copy"></i>' + $.lang[LANG]['editor.gallery.icon.clone'] + '</li>';
25702
25703            s = s + '<li class="toolbar-sort item-sort submenu">' + $.lang[LANG]['editor.gallery.icon.order'] + ' <i class="fa fa-caret-down" aria-hidden="true" data-glseq="" data-cmd="item-sort"></i>\
25704                        <ul class="item-submenu">\
25705                            <li class="sort-top">' + $.lang[LANG]['editor.gallery.icon.order.front'] + '</li>\
25706                            <li class="sort-bottom">' + $.lang[LANG]['editor.gallery.icon.order.end'] + '</li>\
25707                        </ul>\
25708                    </li>';
25709            if(!$('.gallery-modal .gallery-category .gallery-all').hasClass('hide')) {
25710                s = s + '<li class="toolbar-category submenu"><i class="" data-glseq="" data-cmd="category"></i>' + $.lang[LANG]['editor.block.gallery.category.change'] + ' <i class="fa fa-caret-down" aria-hidden="true"></i>';
25711                s = s + '<ul class="item-submenu">' + $.gallery.cates + '</ul>';
25712                s = s + '</li>';
25713            }
25714            
25715            s = s + '\
25716                    <li><i class="" data-glseq="' + seq + '" data-glink="' + link + '" data-glink-target="' + target + '" data-cmd="link"></i>' + $.lang[LANG]['editor.gallery.icon.link'] + '</li>\
25717            ';
25718            s = s + '\
25719                    <li><i class="" data-glseq="' + seq + '" data-visible="' + visible + '" data-cmd="visible">' + vstr + '</i></li>\
25720                    <li><i class="" data-glseq="' + seq + '" data-cmd="move">' + $.lang[LANG]['editor.block.gallery.item.move'] + '</i></li>\
25721                    <li><i class="" data-glseq="' + seq + '" data-cmd="delete"></i>' + $.lang[LANG]['editor.gallery.icon.delete'] + '</li>\
25722                </ul>\
25723            ';
25724            var $tool_back = $('<div class="toolbar mod-gallery ' + l + '">' + s + '</div>');
25725            $('.gallery-toolbar').empty();
25726            $('.gallery-toolbar').append($tool_back).removeClass('hide');
25727
25728            if($.gallery.seqs.length > 1) { 
25729                $('.gallery-toolbar .toolbar .gallery-item-edit').addClass('disabled');
25730            } else {
25731                $('.gallery-toolbar .toolbar .gallery-item-edit').removeClass('disabled');
25732            }
25733            // $('.gallery-items').selectable('disable');
25734        },
25735        pages : function() {
25736            var group = ($('.table-item').length) ? '.table-item' : '.gallery-items .item',
25737                item = $(group).length,
25738                cpage = Math.ceil(item/30),
25739                spos = $('.gallery-modal').scrollTop();
25740            return {
25741                page : cpage, pos : spos
25742            }
25743        },
25744        close : function() {
25745            $.gallery.mode = '';
25746            localStorage.removeItem('gallery-product-view');
25747
25748            if($('.gallery-modal').hasClass('view-detail') && $.gallery.unlink) { // 상세페이지가 삭제됐을경우 리스트로 이동
25749                var go_url = PAGE.split(",");
25750                location.replace('/'+CONFIG_URL+'config/page/' + go_url[0]);
25751            } else {
25752                if($('.gallery-modal').length) {
25753                    localStorage.removeItem('badge_settings');
25754                    localStorage.removeItem('badge_imgs');
25755                    localStorage.removeItem('before_badge_settings');
25756                    $('.gallery-modal').fadeOut(300, function() {
25757                        $('#gallery-style').remove();
25758                        $('#gallery-modal-script').remove();
25759                        $(this).remove();
25760                    });
25761                }
25762
25763                var reloadGalleryPage = $.gallery.update && typeof showPageCallback == 'function';
25764                if(reloadGalleryPage) {
25765                    showPageCallback(showPage);
25766                }
25767
25768                // 갱신 시에는 elPush에서 초기화한다. 이전 DOM을 동시에 재생성하지 않는다.
25769                if( !reloadGalleryPage && !$('#el-blockConfig').hasClass('open') && $('.element[data-id="' + $.gallery.block_id + '"][data-type="gallery"][data-type2="premium"]').length > 0) {
25770                    if(typeof elGalleryJS[$.gallery.block_id] != 'undefined') elGalleryJS[$.gallery.block_id] = true;
25771                    startGalleryJS($('.element[data-id="' + $.gallery.block_id + '"]'));
25772                }
25773            }
25774        },
25775        save : function() {
25776            var dlink = (typeof PUBDOMAIN != 'undefined' && PUBDOMAIN)? PUBDOMAIN.replace('http://', '') : $('#pubhost a').text();
25777            var publish_str = $.lang[LANG]['editor.publish.info'] + '<p class="publish-site-link">' + dlink + '</p>' + $.lang[LANG]['editor.publish.confirm'];
25778            var modal = $(this).showModalFlat($.lang[LANG]['config.information'], publish_str, true, true, function() {
25779                modal.modal('hide');
25780                $(this).sitePublishByConfig(SID);
25781            }, 'cancel', '', 'cl-cmmodal cl-s-btn w560 cl-p130 cl-p0 cl-publish-confirm');
25782        },
25783    }
25784
25785    $.detail = {
25786        open : function(product, mode) {
25787            var $detail = $('.product-detail-modal'),
25788                title = '';
25789            if($.gallery.mode) {
25790                title = ($.gallery.mode == 'shopping') ? '상품 상세페이지' : '상세페이지';
25791            } else {
25792                title = (mode == 'shopping') ? '상품 상세페이지' : '상세페이지';
25793            }
25794            if($detail.length == 0) {
25795                var s = '\
25796                <div class="product-detail-modal">\
25797                    <div class="detail-page"><iframe class="detail-iframe" src="' + product + '#detail"></iframe></div>\
25798                </div>\
25799                ';
25800                $('body').append(s);
25801                setTimeout(function() { 
25802                    $('.product-detail-modal').addClass('open'); 
25803                },50);
25804            }
25805            $(document).on('click', '.product-detail-modal .modal-close', function(e) {
25806                $.detail.close();
25807            });
25808        },
25809        close : function() {
25810            if($('.product-detail-modal').length) {
25811                $('.product-detail-modal').removeClass('open');
25812                setTimeout(function() { $('.product-detail-modal').remove(); },750);
25813            }            
25814        }
25815    }
25816
25817    var setBadgeColorPicker = function() {
25818        // console.log('setBadgeColorPicker');
25819        $('.color-picker-badge').each(function(idx, v){
25820            $(v).colpick({
25821                onBeforeShow: function(picker) {
25822                    var this_color = style.getHex($(v).css('background-color'));
25823                    $(this).colpickSetColor(this_color);
25824                },
25825                onShow: function(picker) {
25826                    if($(v).hasClass('disabled')){
25827                        $(picker).colpickHide();
25828                        return false;
25829                    }
25830                },
25831                onSubmit: function(hsb, hex, rgb, root_picker) {
25832                    var $optionRow = $(root_picker).closest('.badge-option-row');
25833                    var pn = $(root_picker).attr('pn');
25834                    var val = '#'+hex;
25835
25836                    switch(pn) {
25837                        case 'border-color':
25838                            $optionRow.find('input[name="border_color"]').val(val);
25839                            break;
25840                        case 'background-color':
25841                            $optionRow.find('input[name="background_color"]').val(val);
25842                            break;
25843                        case 'color':
25844                            $optionRow.find('input[name="font_color"]').val(val);
25845                            break;
25846                    }
25847                    // console.log($optionRow.find('.product-badge'), pn, val);
25848                    $optionRow.find('.product-badge-view > .product-badge').css(pn, val);
25849                    $('.cl-change-badge-design').removeClass('reset-design');
25850                    // $('.modal-product-badge').eq(0).removeClass('return-prev');
25851
25852                    $(root_picker).css('background-color', val);
25853                    $(root_picker).colpickHide();
25854                }
25855            });
25856        });
25857    }
25858    $.badgeSettings = {
25859        init: function(badge_settings){
25860            $.each(badge_settings, function(k, v) {
25861                var $badge = $('.badge-view .product-badge[data-type="'+k+'"]');
25862                if(v.type == 'edit') {
25863                    var badgeType = (v.type)? v.type : 'edit';
25864                    var badgeStyle = (v.style)? v.style : 'default-1 small';
25865                    var badgeText = (v.badge_text)? v.badge_text : $.lang[LANG]['gallery.shopping.badge.'+k]
25866                    var badgeBorderColor = (v.border_color)? v.border_color : '';
25867                    var badgeBackgroundColor = (v.background_color)? v.background_color : '';
25868                    var badgeFontColor = (v.font_color)? v.font_color : '';
25869
25870                    $badge.attr('class', 'change-badge-design hand product-badge '+badgeStyle);
25871                    if(badgeBorderColor) $badge.css('border-color', badgeBorderColor);
25872                    if(badgeBackgroundColor) $badge.css('background-color', badgeBackgroundColor);
25873                    if(badgeFontColor) $badge.css('color', badgeFontColor);
25874                    $badge.html(badgeText);
25875                } else {
25876                    // console.log('img',v.image_src);
25877                    $badge.attr('class', 'change-badge-design hand product-badge');
25878                    $badge.removeAttr('style');
25879                    $badge.html('<img src="'+v.image_src+'">');
25880                }
25881            });
25882        },
25883        initDesign: function(badgeArr, badge_settings) {
25884            var changeBadgeDsgnRow = '';
25885            $.each(badgeArr, function(idx, type) {
25886                var bsettings = (typeof badge_settings[type] != 'undefined')? badge_settings[type] : {};
25887                        
25888                var badgeType = (typeof bsettings.type != 'undefined' && bsettings.type)? bsettings.type : 'edit';
25889                var badgeStyle = (typeof bsettings.style != 'undefined' && bsettings.style)? bsettings.style : 'default-1 small';
25890                var badgeText = (typeof bsettings.badge_text != 'undefined' && bsettings.badge_text)? bsettings.badge_text : $.lang[LANG]['gallery.shopping.badge.'+type];
25891                var badgeBorderColor = (typeof bsettings.border_color != 'undefined' && bsettings.border_color)? bsettings.border_color : '';
25892                var badgeBackgroundColor = (typeof bsettings.background_color != 'undefined' && bsettings.background_color)? bsettings.background_color : '';
25893                var badgeFontColor = (typeof bsettings.font_color != 'undefined' && bsettings.font_color)? bsettings.font_color : '';
25894                var badgeImgSrc = (typeof bsettings.image_src != 'undefined' && bsettings.image_src)? bsettings.image_src : '';
25895                var badgeImgName = (typeof bsettings.image_name != 'undefined' && bsettings.image_name)? bsettings.image_name : '';
25896                var $badge = (badgeType == 'edit')? $('<span class="product-badge ' + badgeStyle + '" data-style="' + badgeStyle + '" data-border_color="' + bsettings.border_color + '" data-background_color="' + bsettings.background_color + '" data-font_color="' + bsettings.font_color + '">' + badgeText + '</span>')
25897                                                : $('<span class="product-badge"><img src="'+badgeImgSrc+'"></span>');
25898                if(badgeBorderColor) $badge.css('border-color', badgeBorderColor);
25899                if(badgeBackgroundColor) $badge.css('background-color', badgeBackgroundColor);
25900                if(badgeFontColor) $badge.css('color', badgeFontColor);
25901                var disabled = (badgeType == 'image')? 'disabled' : '';
25902
25903                changeBadgeDsgnRow += '\
25904                    <div class="divTableRow badge-option-row" data-idx="' + idx + '" data-default="' + type + '">\
25905                        <div class="divTableCell product-badge-view">'+ $badge[0].outerHTML +'</div>\
25906                        <div class="divTableCell product-badge-option">\
25907                            <div class="select-style-btn hand">선택</div>\
25908                        </div>\
25909                        <div class="divTableCell product-badge-option">\
25910                            <input type="text" name="badge_text" value="'+ badgeText +'" maxlength="7" ' + disabled + '>\
25911                        </div>\
25912                        <div class="divTableCell product-badge-option">\
25913                            <span class="color tooltips color-picker-badge '+disabled+'" el=".product-badge" pn="border-color" data-toggle="tooltip" data-placement="top" title="" style="" data-original-title="color"></span>\
25914                        </div>\
25915                        <div class="divTableCell product-badge-option">\
25916                            <span class="color tooltips color-picker-badge '+disabled+'" el=".product-badge" pn="background-color" data-toggle="tooltip" data-placement="top" title="" style="" data-original-title="color"></span>\
25917                        </div>\
25918                        <div class="divTableCell product-badge-option">\
25919                            <span class="color tooltips color-picker-badge '+disabled+'" el=".product-badge" pn="color" data-toggle="tooltip" data-placement="top" title="" style="" data-original-title="color"></span>\
25920                        </div>\
25921                        <input type="hidden" name="type" value="' + badgeType + '">\
25922                        <input type="hidden" name="style" value="' + badgeStyle + '">\
25923                        <input type="hidden" name="border_color" value="' + badgeBorderColor + '">\
25924                        <input type="hidden" name="background_color" value="' + badgeBackgroun
25924dColor + '">\
25925                        <input type="hidden" name="font_color" value="' + badgeFontColor + '">\
25926                        <input type="hidden" name="image_src" value="'+badgeImgSrc+'">\
25927                        <input type="hidden" name="image_name" value="'+badgeImgName+'">\
25928                    </div>\
25929                ';
25930            });
25931
25932            return changeBadgeDsgnRow;
25933        },
25934        initStylePopup: function($selection) {
25935            var optionIdx = $selection.closest('.badge-option-row').attr('data-idx');
25936            var badgeText = $('.badge-option-row[data-idx="'+optionIdx+'"] input[name="badge_text"]').val();
25937            var badgeType = $('.badge-option-row[data-idx="'+optionIdx+'"] input[name="type"]').val();
25938            var badgeStyle = $('.badge-option-row[data-idx="'+optionIdx+'"] input[name="style"]').val();
25939            var badgeImgSrc = (badgeType == 'image')? $('.badge-option-row[data-idx="'+optionIdx+'"] input[name="image_src"]').val() : '';
25940
25941            if(!badgeText) badgeText = $.lang[LANG]['gallery.shopping.badge.'+$selection.closest('.badge-option-row').attr('data-default')]
25942            $('.badge-style-popup .badge-tab-edit .select-badge .product-badge').html(badgeText);
25943
25944            if(badgeType) {
25945                $('.badge-type-tab li').removeClass('active');
25946                $('.badge-type-tab li[data-tab="'+badgeType+'"]').addClass('active');
25947            }
25948            // console.log('initStylePopup', localStorage.getItem('badge_imgs'))
25949
25950            var popoverObj = {
25951                trigger: 'hover',
25952                container: '.cl-change-badge-design',
25953                placement: 'top',
25954                html: true,
25955                content: '이미지가 삭제되었습니다.'
25956            };
25957
25958            $('.badge-style-popup .select-badge-table img').each(function(idx, v){
25959                // console.log($(v).attr('src'));
25960                $(v).error(function(){
25961                    $(this).attr('src', '//storage.googleapis.com/i.addblock.net/icon_broken_img.png');
25962                    $(this).closest('.product-badge').popover(popoverObj);
25963                });
25964
25965                if($(v).attr('src').indexOf('//storage.googleapis.com/i.addblock.net/icon_broken_img.png') > -1) {
25966                    $(v).closest('.product-badge').popover(popoverObj);
25967                }
25968
25969                if(badgeType == 'image' && badgeImgSrc == $(v).attr('src') && !$('.badge-style-popup .badge-tab-image .select-badge').hasClass('selected')) {
25970                    $(v).closest('.select-badge').addClass('selected');
25971                }
25972            });
25973
25974            if(badgeType == 'edit') {
25975                $('.badge-type-tab > li').removeClass('active');
25976                $('.badge-type-tab > li[data-tab="edit"]').addClass('active');
25977                $('.badge-type-tab-content').addClass('hide');
25978                $('.badge-style-popup .badge-style-footer > span').addClass('hide');
25979                $('.badge-tab-edit').removeClass('hide');
25980
25981                var badgeStyleArr = badgeStyle.split(' ');
25982                var style = badgeStyleArr[0];
25983                var size = badgeStyleArr[1];
25984                // console.log(style, size);
25985                $('.badge-style-popup .badge-size-tab > span').removeClass('active');
25986                $('.badge-style-popup .select-badge-table .product-badge').removeClass('small medium large');
25987                $('.badge-style-popup .select-badge-table .select-badge').removeClass('selected');
25988                
25989                $('.badge-style-popup .badge-size-tab > span[data-size="'+size+'"]').addClass('active');
25990                $('.badge-style-popup .select-badge-table').attr('data-size', size);
25991                $('.badge-style-popup .select-badge-table .product-badge').addClass(size);
25992                $('.badge-style-popup .select-badge-table .select-badge').removeClass('selected');
25993                $('.badge-style-popup .select-badge-table .select-badge[data-style="'+style+'"]').addClass('selected');
25994            } else { //이미지형
25995                $('.badge-type-tab > li').removeClass('active');
25996                $('.badge-type-tab > li[data-tab="image"]').addClass('active');
25997                $('.badge-type-tab-content').addClass('hide');
25998                $('.badge-tab-image').removeClass('hide');
25999                $('.badge-style-popup .badge-style-footer > span').removeClass('hide');
26000            }
26001        },
26002        handleSelection: function($selection, idx){
26003            var optionIdx = $selection.closest('.badge-option-row').attr('data-idx');
26004            var badgeTab = $selection.closest('.badge-type-tab-content');
26005            var badgeEL = $selection.find('.product-badge').clone();
26006
26007            $('.badge-option-row[data-idx="'+optionIdx+'"] .product-badge-view > .product-badge').attr('class', 'product-badge');
26008            $('.cl-change-badge-design').removeClass('reset-design');
26009            // $('.modal-product-badge').eq(0).removeClass('return-prev');
26010
26011            if($selection.closest('.badge-type-tab-content').hasClass('badge-tab-edit')) { //편집형
26012                var $selectedBadge = $selection.find('.product-badge');
26013                var badgeStyle = $selectedBadge.attr('class').replace('product-badge ', '');
26014
26015                var badgeBorderColor = style.getHex($selectedBadge.css('border-color'));
26016                var badgeBackgroundColor = style.getHex($selectedBadge.css('background-color'));
26017                var badgetextColor = style.getHex($selectedBadge.css('color'));
26018
26019                $('.badge-option-row[data-idx="'+optionIdx+'"] .product-badge-view').html(badgeEL);
26020
26021                $('.badge-option-row[data-idx="'+optionIdx+'"]').find('.color-picker-badge').removeClass('disabled');
26022                $('.badge-option-row[data-idx="'+optionIdx+'"]').find('input[name="badge_text"]').prop('disabled', false);
26023
26024                $('.badge-option-row[data-idx="'+optionIdx+'"]').find('.color-picker-badge[pn="border-color"]').css('background-color', badgeBorderColor);
26025                $('.badge-option-row[data-idx="'+optionIdx+'"]').find('.color-picker-badge[pn="background-color"]').css('background-color', badgeBackgroundColor);
26026                $('.badge-option-row[data-idx="'+optionIdx+'"]').find('.color-picker-badge[pn="color"]').css('background-color', badgetextColor);
26027
26028                $('.badge-option-row[data-idx="'+optionIdx+'"] input[name="type"]').val('edit');
26029                $('.badge-option-row[data-idx="'+optionIdx+'"] input[name="style"]').val(badgeStyle.trim());
26030                $('.badge-option-row[data-idx="'+optionIdx+'"] input[name="border_color"]').val(badgeBorderColor);
26031                $('.badge-option-row[data-idx="'+optionIdx+'"] input[name="background_color"]').val(badgeBackgroun
26031dColor);
26032                $('.badge-option-row[data-idx="'+optionIdx+'"] input[name="font_color"]').val(badgetextColor);
26033                $('.badge-option-row[data-idx="'+optionIdx+'"] input[name="image_src"]').val('');
26034                $('.badge-option-row[data-idx="'+optionIdx+'"] input[name="image_name"]').val('');
26035            } else { //이미지형
26036                var imgSrc = $selection.find('.product-badge > img').attr('src');
26037                var imgName = $selection.find('.product-badge > img').attr('alt');
26038                if(imgSrc == '//storage.googleapis.com/i.addblock.net/icon_broken_img.png') {
26039                    return false;
26040                }
26041                
26042                $('.badge-option-row[data-idx="'+optionIdx+'"] .product-badge-view').html(badgeEL);
26043
26044                $('.badge-option-row[data-idx="'+optionIdx+'"]').find('.color-picker-badge').addClass('disabled');
26045                // $('.badge-option-row[data-idx="'+optionIdx+'"]').find('input[name="badge_text"]').val('');
26046                $('.badge-option-row[data-idx="'+optionIdx+'"]').find('input[name="badge_text"]').prop('disabled', true);
26047
26048                $('.badge-option-row[data-idx="'+optionIdx+'"] input[name="type"]').val('image');
26049                $('.badge-option-row[data-idx="'+optionIdx+'"] input[name="style"]').val('');
26050                $('.badge-option-row[data-idx="'+optionIdx+'"] input[name="border_color"]').val('');
26051                $('.badge-option-row[data-idx="'+optionIdx+'"] input[name="background_color"]').val('');
26052                $('.badge-option-row[data-idx="'+optionIdx+'"] input[name="font_color"]').val('');
26053                $('.badge-option-row[data-idx="'+optionIdx+'"] input[name="image_src"]').val(imgSrc);
26054                $('.badge-option-row[data-idx="'+optionIdx+'"] input[name="image_name"]').val(imgName);
26055            }
26056
26057            setBadgeColorPicker();
26058        }
26059    }    
26060})(jQuery);
26061
26062var getSelectedProductList = function(sid, cmd, gallery_seqs) {
26063    var returnHtml = '';
26064    var route = (CONFIG_URL) ? '/_admin' : '';
26065    $.ajax({
26066        url: route  + '/shopping/productListInfo',
26067        type: 'post',
26068        data: { sid : sid, cmd : cmd, gseqs : JSON.stringify(gallery_seqs) },
26069        dataType: 'html',
26070        success: function (list_html) {
26071            // $('.order-list-area').html(list_html);
26072            returnHtml += list_html;
26073        }, error: function () {
26074
26075        }, complete: function () {
26076            // $.processOFF();
26077        }
26078    });
26079   
26080    return returnHtml;
26081}
26082
26083var SFOLDER_ACTIVE = '';
26084var updateOutputFolder = function (e) {
26085    var list = e.length ? e : $(e.target),
26086        output = list.data('output');
26087
26088    if (window.JSON && list.attr('class') == 'dd') {
26089        output.val(window.JSON.stringify(list.nestable('serialize')));
26090    } else {
26091        if (typeof output != 'undefined') output.val('JSON browser support required');
26092    }
26093
26094    if (SID) {
26095        SFOLDER = JSON.parse($('#nestableFolder-output').val());
26096        $.ajaxSetup({ async : false });
26097        $.post('/template/update/type/folder', { s: $('#nestableFolder-output').val(), id: SID }, function (data) {
26098            checkError(data);
26099        }, 'json');
26100    }
26101}
26102
26103function sortFolderFavoritesTop() {
26104    var $list = $('#nestableFolder > .dd-list');
26105    if (!$list.length) return null;
26106
26107    var $items = $list.children('li.dd-item');
26108    if (!$items.length) return null;
26109
26110    var $all = $items.filter(function () {
26111        return String($(this).attr('data-id')) === 'all';
26112    });
26113
26114    var $rest = $items.not($all);
26115    var $fav = $rest.filter(function () {
26116        return String($(this).attr('data-favorite') || '0') === '1';
26117    });
26118    var $non = $rest.not($fav);
26119
26120    $list.append($all).append($fav).append($non);
26121    $list.children('li.dd-item').removeClass('fli-favorite fli-nonfavorite fli-group-divider');
26122    $fav.addClass('fli-favorite');
26123    $non.addClass('fli-nonfavorite');
26124    if ($fav.length && $non.length) {
26125        $non.first().addClass('fli-group-divider');
26126    }
26127
26128    var raw = $('#nestableFolder-output').val() || '[]';
26129    var data = [];
26130    if (SFOLDER && Array.isArray(SFOLDER) && SFOLDER.length) {
26131        data = $.extend(true, [], SFOLDER);
26132    } else {
26133        try { data = JSON.parse(raw); } catch (e) { data = []; }
26134    }
26135
26136    if (!data.length) return raw;
26137
26138    var map = {};
26139    for (var i = 0; i < data.length; i++) {
26140        map[String(data[i].id)] = data[i];
26141    }
26142
26143    var order = [];
26144    $list.children('li.dd-item').each(function () {
26145        var fid = $(this).attr('data-fid');
26146        if (fid !== undefined && fid !== null && String(fid).trim() !== '') {
26147        order.push(String(fid));
26148        }
26149    });
26150
26151    if (order.indexOf('0') === -1 && map['0']) order.unshift('0');
26152
26153    var out = [];
26154    for (var j = 0; j < order.length; j++) {
26155        var key = order[j];
26156        if (map[key]) out.push(map[key]);
26157    }
26158
26159    for (var k in map) {
26160        if (!map.hasOwnProperty(k)) continue;
26161        var exists = false;
26162        for (var t = 0; t < out.length; t++) {
26163            if (String(out[t].id) === String(k)) { exists = true; break; }
26164        }
26165        if (!exists) out.push(map[k]);
26166    }
26167
26168    var nextVal = JSON.stringify(out);
26169    $('#nestableFolder-output').val(nextVal);
26170    SFOLDER = out;
26171
26172    return nextVal;
26173}
26174
26175var setResourceSelectedBox = function(mode) {
26176    var setResourceTab = $('.modal-resourcebox #'+mode+'storage'),
26177        setResourceSelectedInfo = setResourceTab.find('.resource-ctrl-selectedinfo'),
26178        setResourceSelected = setResourceTab.find('.resource-selected-ul');
26179    setResourceTab.find('.resource-ctrl-btns').removeClass('active');
26180    setResourceSelected.find('.selected-hover').popover('destroy');
26181    if(setResourceSelected.children('li').length > 0) {
26182        if(mode == 'my') {
26183            setResourceTab.find('.resource-ctrl-btns').addClass('active');
26184            var size = 0; 
26185            setResourceSelected.children('li').map(function() { return $(this).data('size')}).each(function(){ size += this;});
26186            setResourceSelectedInfo.find('.size').text('('+formatFileSize(size,2,'str')+')');
26187
26188        }
26189        setResourceTab.find('.resource-useit').addClass('active');
26190        setResourceSelectedInfo.find('.count').text(setResourceSelected.children('li').length);
26191        setResourceSelectedInfo.find('label').show();
26192
26193        setResourceSelected.find('.selected-hover').popover({
26194            container: 'body',
26195            trigger: 'hover',
26196            html: true,
26197            content: $.lang[LANG]['editor.resource.selected.cancel'],
26198            placement: function(context, source) {
26199                $(context).addClass('resource-selected-cancel-popover');
26200                return 'auto top';
26201            }
26202        });
26203
26204    } else {
26205        setResourceTab.find('.resource-useit').removeClass('active');
26206        if(setResourceSelectedInfo.length > 0) {
26207            setResourceSelectedInfo.find('label').hide()
26208            setResourceSelectedInfo.find('.count').text('0');
26209        }
26210    }
26211}
26212
26213var resourceGetPage = function(page,ffolder,fsort,fsearch) {
26214    if(typeof fsort == 'undefined') fsort = 'date_desc';
26215    if(typeof fsearch == 'undefined') fsearch = '';
26216
26217    var activeResourceTab = $('.modal.in .modal-resourcebox .tab-content > .tab-pane.active').last(),
26218        activeResourceTabId = activeResourceTab.attr('id') || '',
26219        iconStorageActive = (
26220            activeResourceTabId == 'iconstorage' ||
26221            $('#el-iconstorage').hasClass('in') ||
26222            $('#el-iconstorage').is(':visible') ||
26223            $('#el-iconstorage').attr('aria-hidden') == 'false'
26224        ),
26225        property = $('.resource-useit').eq(0).attr('data-property'),
26226        checkFileLink = (!iconStorageActive && property == 'flink-change') ? true : false,
26227        checkIconStorage = (iconStorageActive || (typeof property!='undefined' && property.indexOf('icon') > -1)) ? true : false,
26228        // checkGabia = (HOST.indexOf('gabia') > -1 || SERVICE.indexOf('gabia') > -1) ? true : false,
26229        checkGabia = (window.getServiceHost().indexOf('gabia') > -1) ? true : false,
26230        sfl = 'default';
26231                        
26232    var thisResourceTab = (checkFileLink) ?  $('#filestorage') : $('#mystorage');
26233    thisResourceTab = (checkIconStorage) ? $('#iconstorage') : thisResourceTab;
26234
26235    var thisResourceFiles = thisResourceTab.find('ul.files'),
26236        thisResourceSelected = thisResourceTab.find('.resource-selected-ul');
26237
26238    thisResourceFiles.removeClass('empty');
26239    ffolder = (typeof ffolder == 'undefined') ? SFOLDER_ACTIVE : ffolder;
26240    if(checkFileLink) {
26241        ffolder = 'flink@';
26242        if(thisResourceFiles.find('.fitem.selected').length == 0) thisResourceTab.find('.resource-useit').removeClass('active');
26243        if(thisResourceTab.find('#flink-sfl').length > 0) sfl = thisResourceTab.find('#flink-sfl option:selected').val();
26244    } else {
26245        if(thisResourceTab.find('#nestableFolder .fln-group').length > 0) thisResourceTab.find('#nestableFolder .fln-group .btn-fln-cancel').click();
26246    }
26247
26248    if(checkIconStorage) {
26249        fsearch = (typeof fsearch == 'string') ? fsearch.trim() : '';
26250        sfl = (typeof getIconStorageType == 'function') ? getIconStorageType() : ($('#iconstorage .icon_type.active').attr('data-icontype') || 'default');
26251        if(typeof normalizeIconStorageType == 'function') sfl = normalizeIconStorageType(sfl);
26252        else if($.inArray(sfl, ['default', 'google', 'fontawesome']) < 0) sfl = 'default';
26253        fsort = (fsort && fsort != 'date_desc') ? fsort : (thisResourceTab.find('.fitem-category.active').attr('data-category') || 'total');
26254        if(fsearch) {
26255            fsort = 'total';
26256            sfl = 'all';
26257            if(typeof setIconStorageSearchState == 'function') setIconStorageSearchState(true, true);
26258        } else {
26259            if(typeof setIconStorageMaterialState == 'function') setIconStorageMaterialState(sfl);
26260            if(typeof setIconStorageSearchState == 'function') setIconStorageSearchState(false, false);
26261        }
26262    }
26263    var iconstorage_url = (checkIconStorage) ? `/type/icon/category/${encodeURIComponent(fsort)}` : '';
26264
26265    fsearch = (checkIconStorage && typeof fsearch == 'string') ? fsearch.trim() : fsearch;
26266
26267    if(checkIconStorage && !fsearch && typeof isIconStorageHybridType == 'function' && isIconStorageHybridType(sfl) && typeof loadIconStorageCategoryPage == 'function') {
26268        if(page == 1 && (!fsort || fsort == 'total') && typeof getIconImage == 'function') {
26269            getIconImage(fsort, sfl);
26270            cPage = page;
26271            setResourceSelectedBox('my');
26272            thisResourceTab.find('.resource-search-btn').removeClass('clicked');
26273            return;
26274        }
26275
26276        loadIconStorageCategoryPage(fsort, sfl, page, { render: true })
26277            .always(function() {
26278                thisResourceTab.find('.resource-search-btn').removeClass('clicked');
26279                thisResourceFiles.removeClass('ready');
26280                thisResourceFiles.find('.listprogress:not([data-category])').remove();
26281                if(thisResourceFiles.data('uiSelectableScroll')) thisResourceFiles.data('uiSelectableScroll').refresh();
26282                fillResourceViewport(thisResourceTab, thisResourceFiles, page, ffolder, fsort, fsearch);
26283            });
26284
26285        cPage = page;
26286        setResourceSelectedBox('my');
26287        return;
26288    }
26289
26290    if(checkIconStorage && fsearch && typeof stopIconStoragePrefetch == 'function') stopIconStoragePrefetch();
26291
26292    $.ajax({
26293        type : 'post',
26294        url: '/template/resource/files/page/' + page + iconstorage_url +'/sfl/' + encodeURIComponent(sfl) + '/ffolder/' + ffolder,
26295        data: { fsort: fsort, fsearch: fsearch },
26296        dataType: 'json',
26297        async: false,
26298        success: function (data) {
26299            if (typeof(data.error) != 'undefined' && data.error) {
26300                checkError(data);
26301                $.resource.modalFilesEmpty(thisResourceFiles, 'No files uploaded');
26302            } else {
26303                if(page == 1) thisResourceFiles.empty();
26304
26305                cTotal = (!checkFileLink) ? $.resource.getMystorageFlc() : data.total;
26306                if(cTotal <= 0) cTotal = data.total;
26307                var active_category = fsort;
26308                if(checkIconStorage) {
26309                    active_category = (typeof getIconStorageActiveCategory == 'function') ? getIconStorageActiveCategory(data, fsort, sfl) : (data.active_category || fsort);
26310                    cTotal = (typeof data.category_total != 'undefined') ? Number(data.category_total) : ((data.icon_count && typeof data.icon_count[active_category] != 'undefined') ? data.icon_count[active_category] : data.total);
26311                }
26312                var path = data.path;
26313
26314                if(checkFileLink) {
26315                    var checkPlan = (typeof property.VALIDPLAN == 'undefined') ? ((typeof VALIDPLAN == 'undefined') ? $.gallery.valid_plan : VALIDPLAN) : property.VALIDPLAN,
26316                        checkPType = (typeof property.VALIDTYPE == 'undefined') ? ((typeof VALIDTYPE == 'undefined') ? $.gallery.valid_type : VALIDTYPE) : property.VALIDTYPE,
26317                        flink_max = (checkPlan) ? 15 : 0;
26318
26319                    if(checkPType == 'BN') flink_max = 100;
26320                    else if(checkPType == 'SM') flink_max = $.lang[LANG]['editor.link.file.unlimited'];
26321    
26322                    thisResourceTab.find('.flink-capacity .flink-cnt').text(cTotal);
26323                    thisResourceTab.find('.flink-capacity .flink-max').text(flink_max);
26324    
26325                    if(cTotal >= flink_max) thisResourceTab.find('.flink-fileinput').addClass('flink-disabled');
26326                    else thisResourceTab.find('.flink-fileinput').removeClass('flink-disabled');
26327    
26328                    if(cTotal > page * 100) {
26329                        thisResourceTab.find('.resource-row.bottom').addClass('active');
26330                        thisResourceTab.find('.resource-loadmore').attr('onclick', 'resourceGetPage(' + (page+1) + ')');
26331                    } else {
26332                        thisResourceTab.find('.resource-row.bottom').removeClass('active');
26333                        thisResourceTab.find('.resource-loadmore').removeAttr('onclick');
26334                    }
26335    
26336                    if(data.file.length == 0) $.resource.modalFilesEmpty(thisResourceFiles, $.lang[LANG]['editor.link.file.list.empty']);
26337                    $.each(data.file, function (idx, val) {
26338
26339                        var file_s = (/^[0-9.]*$/.test(val.filesize)) ? val.filesize * 1 : 0,
26340                            fsize_obj = formatFileSize(file_s, 2, 'obj'),
26341                            tag = '\
26342                                    <li class="fitem">\
26343                                        <div class="fitem-wrap">\
26344                                            <p class="fitem-name" data-seq="' + val.seq + '" data-source="' + val.f
26344ilename + '">' + val.origname + '</p>\
26345                                            <p class="fitem-size"><span class="size" data-size="' +file_s +'" data-unit="' + fsize_obj['unit'] + '">' + fsize_obj['val'] + '</span></p>\
26346                                            <span class="fitem-ctrl-del" data-page="' + page + '"><svg viewBox="0 0 12 12" width="12" height="12"><path d="M11 2H9V0H3v2H1 0v1h1v7c0 1.1 0.9 2 2 2h6c1.1 0 2-0.9 2-2V3h1V2H11zM4 1H8v1H4V1zM10 10c0 0.6-0.4 1-1 1H3c-0.5 0-1-0.4-1-1V3h1H9h1V10z"></path><rect x="4" y="4" width="1" height="6"></rect><rect x="7" y="4" width="1" height="6"></rect></svg></span>\
26347                                        </div>\
26348                                    </li>\
26349                        ';
26350
26351                        thisResourceFiles.append(tag);
26352                    });
26353    
26354                } else if(checkIconStorage) {
26355                    if(fsearch != thisResourceTab.find('.resource-search-stx').val()) thisResourceTab.find('.resource-search-stx').val(fsearch);
26356                    if(typeof renderIconStorageCategories == 'function') renderIconStorageCategories(thisResourceTab, data, active_category, sfl);
26357
26358                    if(data.total == 0 && fsearch) {
26359                        var no_result_str = `<span class="no_result_data">${$.lang[LANG]['editor.resource.noresult']}</span>`;
26360                        $('#iconstorage ul.files').html(no_result_str);
26361                    } else {
26362                        if(typeof renderIconStorageFiles == 'function') renderIconStorageFiles(thisResourceTab, data, sfl, page > 1);
26363                    }
26364                    thisResourceTab.find('.resource-search-btn').removeClass('clicked');
26365
26366                } else {
26367                    if(fsort != thisResourceTab.find('.resource-ctrl-sort select').val()) thisResourceTab.find('.resource-ctrl-sort select').val(fsort).change();
26368
26369                    if(thisResourceTab.find('#nestableFolder').hasClass('ready')) {
26370                        $.resource.setMystorageFolder('set_fll');
26371                        if(ffolder && thisResourceTab.find('#nestableFolder .fli[data-id="' + ffolder + '"]').length > 0) thisResourceTab.find('#nestableFolder .fli[data-id="' + ffolder + '"]').addClass('active').siblings().removeClass('active');
26372                        else thisResourceTab.find('#nestableFolder .fli[data-id="all"]').addClass('active').siblings().removeClass('active');
26373                    }
26374                    
26375                    var selected = new Array();
26376                    thisResourceSelected.children('li').each(function() {
26377                        selected.push($(this).attr('data-seq'));
26378                    });
26379    
26380                    page = (data.file.length < 2) ? page-1 : page;
26381                    page = (page) ? page : 1;
26382                    
26383                    thisResourceFiles.removeClass('empty');
26384                    thisResourceFiles.find('.resource-empty-area').remove();
26385                    $.each(data.file, function (idx, val) {
26386                        var tag = resourceFileTag(val.filename, val.seq, path, selected, val.ffolder, page, val.origname, val.filesize, val.w, val.h, val.magic, val.date);
26387                        thisResourceFiles.append(tag);
26388                    });
26389    
26390                    if(cTotal==0) {
26391                        var empty_msg = (fsearch) ? $.lang[LANG]['editor.resource.files.empty'] : $.lang[LANG]['editor.resource.notice.text.top'] + '<br>' + $.lang[LANG]['editor.resource.notice.text.bottom'];
26392                        $.resource.modalFilesEmpty(thisResourceFiles, empty_msg);
26393                    } else {
26394                        var upgrade_link = (checkGabia) ? 'https://www.gabia.com/mygabia/service' : '/upgrade/site/' + SID,
26395                            load_btn = '\
26396                                    <img src="https://storage.googleapis.com/i.addblock.net/image-upload.gif">&nbsp;&nbsp;\
26397                                    <span class="resource-info"><span data-lang="config.file.browse">' + $.lang[LANG]["config.file.browse"] + '</span></span>\
26398                                    <input id="mystorageUploadBtn" class="upload-resource-button" type="file" name="files[]" multiple>\
26399                            ',
26400                            upgrade_btn = '\
26401                                <a href="' + upgrade_link + '" style="color: #fff; text-decoration:none;">\
26402                                    <i class="fa fa-level-up" aria-hidden="true" style="margin-right: 5px;"></i>\
26403                                    <span class="resource-info">' + $.lang[LANG]["plan.upgrade"] + '</span>\
26404                                </a>\
26405                            ';
26406    
26407                        if(typeof thisResourceTab.find('.fileinput-button').attr('data-limit') == 'undefined') {
26408                            var check_langs = (typeof SLANG != 'undefined' && !$.isEmptyObject(SLANG.lists) && SLANG.lists.length > 1) ? true : false;
26409                            var str = (data.is_limit) ? upgrade_btn : load_btn,
26410                                css_str = (data.is_limit) ? { 'background-color':'#4889e7', 'margin-left':'5px' } : {}, 
26411                                max_str = (data.is_limit) ? '<span class="error">' + $.lang[LANG]['plan.disk-space.limit.info'] + '</span> ' : '';
26412                            if(data.is_limit && check_langs) max_str = '<span class="error" style=" line-height: 1.4; display: inline-block; text-align: right;">' + $.lang[LANG]['plan.disk-space.limit.info.lang'] + '</span>';
26413
26414                            thisResourceTab.find('.fileinput-button').attr('data-limit',data.is_limit).html(str).css(css_str);
26415                            thisResourceTab.find('.upload-max-size').html(max_str);
26416                        }
26417                    }
26418                    thisResourceTab.find('.resource-search-btn').removeClass('clicked');
26419                
26420                }
26421                if(thisResourceFiles.data('uiSelectableScroll')) thisResourceFiles.data('uiSelectableScroll').refresh();
26422            }
26423            thisResourceFiles.removeClass('ready');
26424            thisResourceFiles.find('.listprogress').remove();
26425        },
26426        error: function() {
26427            $.resource.modalFilesEmpty(thisResourceFiles, 'No files uploaded');
26428        },
26429        complete: function() {
26430            thisResourceTab.find('.resource-search-btn').removeClass('clicked');
26431            thisResourceFiles.removeClass('ready');
26432            thisResourceFiles.find('.listprogress').remove();
26433        }
26434    });
26435
26436    cPage = page;
26437    setResourceSelectedBox('my');
26438    if(!(checkIconStorage && fsearch)) fillResourceViewport(thisResourceTab, thisResourceFiles, page, ffolder, fsort, fsearch);
26439}
26440
26441var fillResourceViewport = function(thisResourceTab, thisResourceFiles, page, ffolder, fsort, fsearch) {
26442    if(!thisResourceTab.length || !thisResourceFiles.length) return;
26443    if(!thisResourceFiles.closest('.modal.in').length) return;
26444    if(thisResourceFiles.hasClass('empty') || thisResourceFiles.find('.resource-empty-area').length > 0) return;
26445    if(thisResourceFiles.find('.listprogress').length > 0 || thisResourceFiles.data('resourceAutoFill')) return;
26446
26447    var rmode = thisResourceTab.attr('id').replace(/storage$/gi,'');
26448    if($.inArray(rmode, ['my','icon']) < 0) return;
26449    if(rmode == 'icon' && typeof isIconStorageHybridMode == 'function' && isIconStorageHybridMode()) return;
26450
26451    var fitem_cnt = thisResourceFiles.find('.fitem').length,
26452        filesEl = thisResourceFiles.get(0);
26453
26454    if(!filesEl || fitem_cnt <= 0 || fitem_cnt >= cTotal) return;
26455    if(filesEl.scrollHeight > filesEl.clientHeight + 1) return;
26456
26457    thisResourceFiles.data('resourceAutoFill', true);
26458    setTimeout(function() {
26459        thisResourceFiles.removeData('resourceAutoFill');
26460
26461        if(!thisResourceFiles.closest('.modal.in').length) return;
26462        if(thisResourceFiles.find('.listprogress').length > 0) return;
26463
26464        fitem_cnt = thisResourceFiles.find('.fitem').length;
26465        if(fitem_cnt >= cTotal) return;
26466        if(filesEl.scrollHeight > filesEl.clientHeight + 1) return;
26467
26468        thisResourceFiles.append('<li class="listprogress"><svg version="1.1" xmlns="http://www.w3.org/svg/2000" viewBox="0 0 30 30" width="60" style="width:30px; height: 30px;"><circle cy="15" cx="15" r="14" style="stroke:#00baff;"></circle></svg></li>');
26469        resourceGetPage(page + 1, ffolder, fsort, fsearch);
26470    }, 0);
26471}
26472
26473var resourcePaging = function(page,total,ffolder) {
26474    view = RVIEW;
26475    $('.modal.in .modal-resourcebox .resource-paging').empty();
26476
26477    page_view = 10;
26478    start = Math.floor((page-1) / page_view) * page_view;
26479    pages = Math.ceil(total/view);
26480    end = (Math.floor((page-1) / page_view) + 1) * page_view;
26481    end = (end>pages) ? pages : end;
26482
26483    prev = (start > 0) ? start : 1;
26484    next = ((end+1) > pages) ? pages : end+1;
26485
26486    ffolder = (ffolder) ? 'ffolder' : 'all';
26487
26488    var str = '\
26489    <ul class="pagination pagination-sm" data-pages="'+pages+'">\
26490        <li><a href="javascript:;" onclick="resourceGetPage(' + prev + ')">&laquo;</a></li>\
26491    ';
26492    for(i=start;i<end;i++) {
26493        active = ((i+1)==page) ? 'active' : '';
26494        str = str + '\
26495        <li class="' + active + '"><a href="javascript:;" onclick="resourceGetPage(' + (i+1) + ')">' + (i+1) + '</a></li>\
26496        ';
26497    }
26498    str = str + '\
26499        <li><a href="javascript:;" onclick="resourceGetPage(' + next+ ')">&raquo;</a></li>\
26500    </ul>\
26501    ';
26502
26503    if(total) $('.modal.in .modal-resourcebox .resource-paging').append(str);
26504}
26505
26506function formatFileSize(bytes,decimalPoint,return_style) {
26507    if(typeof return_style == 'undefined' || !return_style)  return_style = 'str';
26508
26509    var return_val = {'val': 0, 'unit': 'Bytes'};
26510    
26511    if(bytes == 0) {
26512        return (return_style == 'obj') ? return_val : '0 KB';
26513    }
26514
26515    var k = 1024,
26516        dm = decimalPoint || 2,
26517        sizes = ['KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
26518        i = Math.floor(Math.log(bytes) / Math.log(k));
26519
26520    return_val['val'] = parseFloat((bytes / Math.pow(k, i)).toFixed(dm));
26521    return_val['unit'] = sizes[i];
26522
26523    if(return_style == 'obj') return return_val
26524    else return return_val['val'] + ' ' + return_val['unit'];
26525}
26526
26527var resourceFileTag = function (source, seq, path, selected, ffolder, page, origname, filesize, file_w, file_h, magic, date) {
26528
26529    filesize = (/^[0-9.]*$/.test(filesize)) ? filesize * 1 : 0;
26530    file_w = (/^[0-9.]*$/.test(file_w)) ? file_w * 1 : 0;
26531    file_h = (/^[0-9.]*$/.test(file_h)) ? file_h * 1 : 0;
26532
26533    var active = ($.inArray(seq,selected)>-1) ? ' ui-selected' : '',
26534        blank = (magic == '') ? path + '/' + source : getServeImage(magic,'0','');
26535        image = (magic == '') ? path + '/800/' + source : magic,
26536        fsize_obj = formatFileSize(filesize, 2, 'obj');
26537    
26538    var ftag_str = '\
26539        <li class="fitem' + active + '">\
26540            <div class="fitem-wrap">\
26541                <div class="fitem-visual">\
26542                    <div class="fitem-thumb">\
26543                        <div class="fitem-mold"><img src="https://storage.googleapis.com/i.addblock.net/sample/sns_cm_1.png"/></div>\
26544                        <img class="fitem-img" src="' + image + '" alt="' + source + '">\
26545                    </div>\
26546                    <div class="fitem-name visible-layout-list"><span>'+origname+'</span></div>\
26547                    <div class="fitem-ctrl">\
26548                        <ul data-ffolder="'+ffolder+'" data-page="'+page+'" data-source="'+source+'" data-seq="'+seq+'" data-fsize="'+filesize+'">\
26549                            <li class="hover">\
26550                                <a class="fitem-ctrl-imgview" data-url="' + blank + '" data-img-original="ON">\
26551                                    <svg viewBox="0 0 13 13" width="13" height="13"><path d="M5.14 1c2.28 0 4.14 1.86 4.14 4.14 0 2.28-1.86 4.14-4.14 4.14S1 7.43 1 5.14C1 2.86 2.86 1 5.14 1m0-1C2.3 0 0 2.3 0 5.14s2.3 5.14 5.14 5.14 5.14-2.3 5.14-5.14S7.98 0 5.14 0z"/><path d="M12.5 13a.47.47 0 0 1-.35-.15L8.22 8.92c-.2-.2-.2-.51 0-.71s.51-.2.71 0l3.93 3.93c.2.2.2.51 0 .71-.1.1-.23.15-.36.15z"/></svg>\
26552                                </a>\
26553                            </li>\
26554                            <li class="hover">\
26555                                <a class="fitem-ctrl-down" href="/down/fetchimg?s=' + blank + '" alt="' + source + '" download="' + origname + '" target="_self">\
26556                                    <svg viewBox="0 0 13 13" width="13" height="13"><path d="M6.46 7.59 2.71 3.83 2 4.54l3.76 3.75.7.71.71-.71 3.76-3.75-.71-.71z"/><path d="M6 8V0h1v8z"/><path d="M12 12V7h1v5z"/><path d="M0 12V7h1v5z"/><path d="M13 13H0v-1h13z"/></svg>\
26557                                </a>\
26558                            </li>\
26559                            <li class="hover">\
26560                                <span class="fitem-ctrl-del">\
26561                                    <svg viewBox="0 0 12 13" width="12" height="13"><path d="M12 2H9V0H3.02v2H0v1h1v8c0 1.1.9 2 2 2h6c1.1 0 2-.9 2-2V3h1V2zM4.02 1H8v1H4.02V1zM10 11c0 .55-.45 1-1 1H3c-.55 0-1-.45-1-1V3h8v8z"></path><path d="M4 4h1v7H4z"></path><path d="M7 4h1v7H7z"></path></svg>\
26562                                </span>\
26563                            </li>\
26564                            <li class="visible-layout-list w132"><span class="fitem-date">' + date + '</span></li>\
26565                            <li class="visible-layout-list w85"><span class="fitem-size2">' + file_w + 'x' + file_h + '</span></li>\
26566                            <li class="visible-layout-list w82"><span class="fitem-size3" data-unit="'+fsize_obj['unit']+'">'+fsize_obj['val']+'</span></li>\
26567                        </ul>\
26568                    </div>\
26569                </div>\
26570                <div class="fitem-content visible-layout-grid">\
26571                    <p class="fitem-name" data-seq="' + seq + '" data-source="' + source + '" data-magic="' + magic + '" data-toggle="tooltip" data-placement="top" data-original-title="' + origname + '">' + origname + '</p>\
26572                    <p class="fitem-size"><span class="size" data-size="'+filesize+'" data-unit="'+fsize_obj['unit']+'">'+fsize_obj['val']+'</span><span class="width">'+file_w+'</span><span class="height">'+file_h+'</span></p>\
26573                    <p class="visible-layout-grid fitem-date2">' + date + '</p>\
26574                </div>\
26575            </div>\
26576        </li>\
26577    ';
26578
26579    return $(ftag_str);
26580}
26581
26582
26583var myStorageActive = function() {
26584    return ($('#mystorage').hasClass('active')) ? true : false;
26585}
26586
26587var frStorageUpload = function(v,w,id) {
26588    var deferred = $.Deferred(),
26589        id = (typeof id != 'undefined' && id) ? id : $('li[data-source="' + v + '"]').attr('data-id');
26590
26591    var ex = v.split("|"),
26592        s = [];
26593    if(ex.length>1) {
26594        $.each(ex, function(i,d) {
26595            s[i] = $('li[data-source="' + d + '"]').attr('data-id');
26596        });
26597    } else {
26598        s[0] = id;
26599    }
26600    var ids = s.join("|");
26601
26602    setTimeout(function() {
26603        $.ajax({
26604            type : 'post',
26605            url: '/template/frstorage/upload',
26606            data: { img : v, sid : SID, w : w, ids : ids },
26607            dataType: 'json',
26608            timeout: 45000,
26609            success: function (data) {
26610                $.processOFF();
26611                if(data.error) { 
26612                    alert(data.error);
26613                    deferred.reject(data.error);
26614                    return false;
26615                }
26616                deferred.resolve(data);
26617            },
26618            error: function(xhr, status, error) {
26619                $.processOFF();
26620                var msg = (status == 'timeout')
26621                    ? '이미지 처리 요청 시간이 초과되었습니다.'
26622                    : (status == 'parsererror')
26623                        ? '이미지 업로드 응답을 처리하지 못했습니다.'
26624                        : '이미지 업로드 중 오류가 발생했습니다.';
26625                alert(msg);
26626                deferred.reject(msg);
26627            }
26628        });
26629    });
26630    return deferred.promise();
26631}
26632
26633var uploadReviewQnaImg = function (e) {
26634    var mode = e.data.mode;
26635    if(mode != 'qna' && mode != 'review'){
26636        return false;
26637    }
26638    var imageCnt = $('.'+mode+'-files-list').children('li').length;
26639    if (imageCnt >= 5) {
26640        alert('이미지는 최대 5개까지 등록이 가능합니다.');
26641        return false;
26642    }
26643
26644    var sid = $('#'+mode+'-file').attr('data-sid'),
26645        uid = $('#'+mode+'-file').attr('data-uid');
26646
26647    $.uploadON();
26648    $(this).fileupload({
26649        url: '/_upload/type/'+mode+'/sid/'+sid+'/uid/'+uid,
26650        dataType: 'json',
26651        pasteZone: null,
26652        async: true,
26653        sequentialUploads: true,
26654        change: function(e, data) {
26655            var fileCount = $('.'+mode+'-files-list>li').length + data.files.length;
26656            if(fileCount > 5) {
26657                alert('이미지는 최대 5개까지 등록이 가능합니다.');
26658                return false;
26659            }
26660
26661            var ext = ['gif', 'jpg', 'jpeg', 'png', 'webp'];
26662            var maxSize  = 1024 * 1024 * 10;
26663            var flag = true;
26664            $.each(data.fileInput[0]['files'], function(idx, item){
26665                var extAry = item['name'].toLowerCase().split('.');
26666                if (ext.indexOf(extAry[extAry.length - 1]) == -1) {
26667                    alert($.lang[LANG]['editor.upload.error.ext']);
26668                    flag = false;
26669                    return false;
26670                }
26671
26672                var fileSize = item['size'];
26673                if (fileSize > maxSize) {
26674                    alert($.lang[LANG]['editor.upload.max.1'] + $.lang[LANG]['editor.upload.max.2']);
26675                    flag = false;
26676                    return false;
26677                }
26678            });
26679            
26680            if(flag === false) {
26681                return false;
26682            }
26683            
26684        },
26685        add: function(e, data) {
26686            var r = $.upload_add(e,data,'image');
26687
26688            if(r.submit) {
26689                var jqXHR = data.submit();
26690                UPLOAD++;
26691            } else {
26692                data.context.find('.loading').html('<i class="fa fa-times error"></i>');
26693                data.context.find('.ing').addClass('error').text(r.err);
26694            }
26695
26696            $('.uploadModal .upload-cancel .btn, .uploadModal .upload-close').off('click').on('click', function(e) {
26697                if(jqXHR != undefined) jqXHR.abort();
26698                data.context.fadeOut().remove();
26699                $('.uploadModal #file-upload-progress').css('width','0%');
26700                $.uploadOFF();
26701                UPLOAD = 0;
26702                UPLOADED = 0;
26703                PROGRESS = 0;
26704            });
26705        },
26706        progress: function(e, data) {
26707            $.upload_progress(e,data);
26708        },                        
26709        done: function(e, data) {
26710            $.upload_done(e,data);
26711            if(typeof data.result.error != 'undefined' && data.result.error) {
26712                $.processOFF();
26713                return false;
26714            }
26715            
26716            UPLOADED++;
26717            var src = (typeof data.result.magic != 'undefined') ? data.result.magic : data.result.src;
26718            var src_orig = (typeof data.result.magic != 'undefined') ? data.result.src_orig : '';
26719            var uploadedImg = '\
26720                <li id="'+mode+'-image-'+imageCnt+'">\
26721                    <img src="'+src+'" class="img-responsive" />\
26722                    <input type="hidden" name="'+mode+'_image[]" value="'+src+'" />\
26723                    <input type="hidden" name="'+mode+'_image_orig[]" value="'+src_orig+'" />\
26724                    <div class="cl-s-files-img-close '+mode+'-img-close"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 8 8" width="8" height="8"><path d="M4.71 4l3.15-3.15c0.2-0.2 0.2-0.51 0-0.71s-0.51-0.2-0.71 0L4 3.29 0.85 0.15c-0.2-0.2-0.51-0.2-0.71 0s-0.2 0.51 0 0.71L3.29 4 0.15 7.15c-0.2 0.2
26724-0.2 0.51 0 0.71C0.24 7.95 0.37 8 0.5 8s0.26-0.05 0.35-0.15L4 4.71l3.15 3.15C7.24 7.95 7.37 8 7.5 8s0.26-0.05 0.35-0.15c0.2-0.2 0.2-0.51 0-0.71L4.71 4z"/></svg></div>\
26725                </li>\
26726            ';
26727
26728            $('.'+mode+'-files-list').append(uploadedImg);
26729            imageCnt++;
26730
26731            if(UPLOADED) {
26732                if(UPLOAD==UPLOADED) {
26733                    setTimeout(function() {
26734                        $.uploadOFF();
26735                        UPLOAD = 0;
26736                        UPLOADED = 0;
26737                        PROGRESS = 0;
26738                    },1000);
26739                }
26740            }
26741        },
26742        progressall: function (e, data) {
26743            $.upload_progressall(e,data);
26744        },
26745        start : function(e, data) {
26746            $.upload_start(e,data);
26747            progress1 = 0; progress2 = 0; PROGRESS = 0;
26748        },
26749        dragover : function(e, data) {
26750            e.preventDefault();
26751        },
26752    }).prop('disabled', !$.support.fileInput)
26753        .parent().addClass($.support.fileInput ? undefined : 'disabled');
26754}
26755
26756var deleteReviewQnaImg = function(e) {
26757    var mode = e.data.mode;
26758    if(mode != 'qna' && mode != 'review'){
26759        return false;
26760    }
26761    var parent = $(this).closest('li');
26762    var src_orig = parent.find('input[name="'+mode+'_image_orig[]"]').val();
26763    var seq = $('#'+mode+'-file').data('seq');
26764    var src_files = '';
26765    var src_files_orig = '';
26766
26767    if(seq) {
26768        if($('.'+mode+'-files-list').children('li').length > 0) {
26769            $('.'+mode+'-files-list').children('li').each(function() {
26770                if(src_orig != $(this).find('input[name="'+mode+'_image_orig[]"]').val()) {
26771                    if(src_files != '')  src_files +='||';
26772                    src_files += $(this).find('input[name="'+mode+'_image[]"]').val();
26773                    if(src_files_orig != '')  src_files_orig +='||';
26774                    src_files_orig += $(this).find('input[name="'+mode+'_image_orig[]"]').val();
26775                }
26776            });
26777        }
26778    }
26779
26780    $.processON('Deleting File...');
26781    $.ajax({
26782        type: 'POST',
26783        url: '/_image_delete',
26784        data: {
26785            s: src_orig,
26786            seq: seq,
26787            src_files: src_files,
26788            src_files_orig: src_files_orig,
26789            mode: mode,
26790        },
26791        async: true,
26792        success: function(data) {
26793            // console.log(data);
26794            checkError(data);
26795            parent.remove();
26796            $.processOFF();
26797        }
26798    });
26799}
26800
26801var addrSearchModal = function(input_mode) {
26802    if(typeof input_mode == 'undefined' || input_mode.length == 0)  input_mode = 'input';
26803
26804    if($('script[src="https://t1.kakaocdn.net/mapjsapi/bundle/postcode/prod/postcode.v2.js"]').length === 0) {
26805        $.getScript('https://t1.kakaocdn.net/mapjsapi/bundle/postcode/prod/postcode.v2.js')
26806            .done(function() { 
26807                $('head').append('<script src="https://t1.kakaocdn.net/mapjsapi/bundle/postcode/prod/postcode.v2.js"></script>'); 
26808                setTimeout(function() { addrSearchModal(input_mode); }, 500);
26809            }).fail(function() { console.log('daum maps script fail'); });
26810    } else {
26811
26812        if($('#addr-modal').length === 0) {
26813            var add_position = ($('.mall-mypage-wrap').length > 0) ? $('.mall-mypage-wrap') : $('body'),
26814                as_backdrop = '<div class="addr-modal-backdrop" style="display: none;"></div>';
26815                as_modal = '<div id="addr-modal" style="display: none;">\
26816                                <div class="close">\
26817                                    주소 찾기\
26818                                    <div id="btn-addr-close"><img src="https://storage.googleapis.com/i.addblock.net/fa-close-modal.png" alt="close"></div>\
26819                                </div>\
26820                                <div id="addr-body"></div>\
26821                            </div>';
26822
26823            add_position.append(as_backdrop + as_modal);
26824        } else {
26825            $('#addr-body').html('');
26826        }
26827
26828
26829        $(document).on('click','#btn-addr-close, .addr-modal-backdrop', function() {
26830            $('#addr-modal').fadeOut(300);
26831            $('.addr-modal-backdrop').fadeOut(300, function() { $(this).removeClass('in'); });
26832        });
26833
26834
26835
26836        // Internet Explorer 6-11
26837        var isIE = /*@cc_on!@*/false || !!document.documentMode;
26838
26839        if(isIE && input_mode == 'my-input') {
26840
26841            kakao.postcode.load(function(){
26842                new kakao.Postcode({
26843                    oncomplete: function(data) {
26844                        var addr = ''; // 주소 변수
26845                        var extraAddr = ''; // 참고항목 변수
26846
26847                        if (data.userSelectedType === 'R') { // 사용자가 도로명 주소를 선택했을 경우
26848                            addr = data.roadAddress;
26849                        } else { // 사용자가 지번 주소를 선택했을 경우(J)
26850                            addr = data.jibunAddress;
26851                        }
26852
26853                        if(data.userSelectedType === 'R'){
26854                            if(data.bname !== '' && /[동|로|가]$/g.test(data.bname)){
26855                                extraAddr += data.bname;
26856                            }
26857
26858                            if(data.buildingName !== '' && data.apartment === 'Y'){
26859                                extraAddr += (extraAddr !== '' ? ', ' + data.buildingName : data.buildingName);
26860                            }
26861
26862                            if(extraAddr !== ''){
26863                                extraAddr = ' (' + extraAddr + ')';
26864                            }
26865                        }
26866
26867                        $('#'+input_mode+"-postcode").attr('value',data.zonecode);
26868                        $('#'+input_mode+"-addr1").attr('value',addr+extraAddr).addClass('has-value');
26869
26870                        setTimeout(function() {
26871                            $('#'+input_mode+"-addr2").focus();
26872                        },200);
26873
26874                    },
26875                    width : '100%',
26876                    height : '100%',
26877                    maxSuggestItems : 5
26878                }).open();
26879            });
26880
26881        } else if(input_mode =="addrPopup"){
26882           kakao.postcode.load(function(){
26883                new kakao.Postcode({
26884                    oncomplete: function(data) {
26885                        var addr = ''; // 주소 변수
26886                        var extraAddr = ''; // 참고항목 변수
26887
26888                        if (data.userSelectedType === 'R') { // 사용자가 도로명 주소를 선택했을 경우
26889                            addr = data.roadAddress;
26890                        } else { // 사용자가 지번 주소를 선택했을 경우(J)
26891                            addr = data.jibunAddress;
26892                        }
26893
26894                        if(data.userSelectedType === 'R'){
26895                            if(data.bname !== '' && /[동|로|가]$/g.test(data.bname)){
26896                                extraAddr += data.bname;
26897                            }
26898
26899                            if(data.buildingName !== '' && data.apartment === 'Y'){
26900                                extraAddr += (extraAddr !== '' ? ', ' + data.buildingName : data.buildingName);
26901                            }
26902
26903                            if(extraAddr !== ''){
26904                                extraAddr = ' (' + extraAddr + ')';
26905                            }
26906                        }
26907                         $('#'+input_mode+"-postcode").attr('value',data.zonecode);
26908                        $('#'+input_mode+"-addr1").attr('value',addr+extraAddr).addClass('has-value');  
26909                        
26910                        $('#addr-modal').fadeOut(300);
26911                        $('.addr-modal-backdrop').fadeOut(300, function() { $(this).removeClass('in'); });
26912
26913                         setTimeout(function() {
26914                             $('#'+input_mode+"-addr2").focus();
26915                         },200);
26916
26917                    },
26918                    width : '100%',
26919                    height : '100%',
26920                    maxSuggestItems : 5
26921                }).embed(document.getElementById('addr-body'));
26922
26923                $('#addr-modal').fadeIn(300);
26924                $('.addr-modal-backdrop').fadeIn(300, function() { $(this).addClass('in'); });
26925            });            
26926        } else {
26927            kakao.postcode.load(function(){
26928                new kakao.Postcode({
26929                    oncomplete: function(data) {
26930                        var addr = ''; // 주소 변수
26931                        var extraAddr = ''; // 참고항목 변수
26932
26933                        if (data.userSelectedType === 'R') { // 사용자가 도로명 주소를 선택했을 경우
26934                            addr = data.roadAddress;
26935                        } else { // 사용자가 지번 주소를 선택했을 경우(J)
26936                            addr = data.jibunAddress;
26937                        }
26938
26939                        if(data.userSelectedType === 'R'){
26940                            if(data.bname !== '' && /[동|로|가]$/g.test(data.bname)){
26941                                extraAddr += data.bname;
26942                            }
26943
26944                            if(data.buildingName !== '' && data.apartment === 'Y'){
26945                                extraAddr += (extraAddr !== '' ? ', ' + data.buildingName : data.buildingName);
26946                            }
26947
26948                            if(extraAddr !== ''){
26949                                extraAddr = ' (' + extraAddr + ')';
26950                            }
26951                        }
26952                         $('#'+input_mode+"-postcode").attr('value',data.zonecode);
26953                        $('#'+input_mode+"-addr1").attr('value',addr+extraAddr).addClass('has-value');  
26954                        $('#addr-modal').fadeOut(300);
26955                        $('.addr-modal-backdrop').fadeOut(300, function() { $(this).removeClass('in'); });
26956
26957                        setTimeout(function() {
26958                            $('#'+input_mode+"-addr2").focus();
26959                        },200);
26960
26961                    },
26962                    width : '100%',
26963                    height : '100%',
26964                    maxSuggestItems : 5
26965                }).embed(document.getElementById('addr-body'));
26966
26967                $('#addr-modal').fadeIn(300);
26968                $('.addr-modal-backdrop').fadeIn(300, function() { $(this).addClass('in'); });
26969            });
26970
26971        }
26972    }
26973}
26974var stickyToolbar = function() {
26975    if($('.gallery-header').length == 0) return;
26976    var sticky = $('.gallery-modal > .container').offset().top - 50,
26977        w = $('.gallery-items .table-item').width();
26978    if($('.gallery-modal > .container').outerHeight() + sticky < 0) { 
26979        $('.gallery-modal .toolbar, .gallery-modal .table-col').addClass('sticky');
26980        $('.table-toolbar').css('width',w + 'px');
26981    } else {
26982        $('.gallery-modal .toolbar, .gallery-modal .table-col').removeClass('sticky');
26983        $('.table-toolbar').css('width','auto');
26984    }
26985}            
26986
26987var saveGalleryBlockName = function($this,blockname) {
26988    var blockID = $this.parents('.gallery-name').attr('data-gallery-id');
26989    if(typeof blockID == "undefined" || !blockID) {
26990        $this.showModalFlat('ERROR',$.lang[LANG]['board.error-setting-value'],true,false,'','ok');
26991        return false;
26992    }
26993    var settings = (typeof SETTINGS =='undefined') ? $.gallery.site_settings : SETTINGS;
26994    var bookmark_list = (typeof settings.blockBookmarkList != 'undefined' && settings.blockBookmarkList) ? settings.blockBookmarkList : {},
26995        isBookmark = (typeof bookmark_list['bookmark'+blockID] != 'undefined' && bookmark_list['bookmark'+blockID]) ? true : false,
26996        before_bookmark_name_arr = [],
26997        blockname_list = (typeof settings.blocknameList != 'undefined' && settings.blocknameList) ? settings.blocknameList : {},
26998        regex = /[\{\}\[\]\/!?.,;:|\)*~`^\-+<>@\#$%&\\\=\(\'\"]/gi,
26999        err_str = '', 
27000        isUpdate = false;
27001
27002    if(!$.isEmptyObject(bookmark_list)) { // 이전 bookmark name 설정한 블럭 이름 포함
27003        $.each(bookmark_list, function(k,v) { 
27004            if(typeof blockname_list[k.replace('bookmark','blockname')] == 'undefined') {
27005                before_bookmark_name_arr.push(v);
27006            }
27007        });
27008    }
27009
27010    var blockname_list_arr = (!$.isEmptyObject(blockname_list)) ? Object.keys(blockname_list).map(function(e) { return blockname_list[e]; }) : new Array();
27011
27012    if(typeof blockname_list['blockname'+blockID] != 'undefined' && blockname_list['blockname'+blockID] == blockname) {
27013        $('.blockname-edit').remove();
27014        return false;
27015    } else if (blockname.length == 0 || blockname.length > 20) {
27016        err_str = $.lang[LANG]['config.blockinfo.name.length'];
27017    } else if (regex.test(blockname)) {
27018        err_str = $.lang[LANG]['config.blockinfo.name.specialchar'];
27019    } else if ($.inArray(blockname,blockname_list_arr) > -1 || $.inArray(blockname,before_bookmark_name_arr) > -1) {
27020        err_str = $.lang[LANG]['config.blockinfo.name.overlap'];
27021    } else {
27022        $.post('/template/element/type/blockname/seq/'+blockID, { sid: SID, val: blockname }, function(data) {
27023            if(typeof data.error != 'undefined' && data.error) {
27024                err_str = data.error;
27025            } else {
27026                isUpdate = true;
27027            }
27028        }, 'json');
27029    }
27030
27031    if(err_str.length > 0 ) {
27032        $this.showModalFlat($.lang[LANG]['config.information'],err_str,true,false,'','ok', '', 'cl-p130 cl-cmmodal cl-s-btn w560 cl-p0 cl-okbtn-pbt70');
27033    } else {
27034        $this.parents('.gallery-name').find('.gallery-block-name').text(blockname);
27035        $this.parents('.gallery-name-edit-input').remove();
27036        if($.gallery.block_id == blockID) {
27037            $('#gallery-name').text(blockname);
27038        }
27039    }
27040
27041    if(!isUpdate) return false;
27042    blocknameUpdate(SID,blockID,blockname);
27043    blocknameListUpdate('update',SID,blockID,blockname);
27044    if(isBookmark) blockBookmarkListUpdate('update',SID,blockID,blockname);
27045}
27046
27047var blocknameDelete = function(sid, seq) {
27048    var settings = (typeof SETTINGS =='undefined') ? $.gallery.site_settings : SETTINGS;
27049    if (typeof seq == 'undefined' || typeof sid == 'undefined' || !seq || !sid) return false;
27050
27051    var hasBookmark = (typeof settings.blockBookmarkList != 'undefined' && typeof settings.blockBookmarkList['bookmark' + seq] != 'undefined');
27052    if (hasBookmark && $('#tpl-menu li a[href="@' + seq + '"][attr-bookmark]').length > 0) {
27053        resetLink($('#tpl-menu li a[href="@' + seq + '"][attr-bookmark]').text());
27054    }
27055
27056    blocknameUpdate(sid, seq, '');
27057    blocknameListUpdate('delete', sid, seq);
27058}
27059
27060var blocknameUpdate = function(sid, id, name) {
27061    var elsettings = { blockname: name },
27062        delete_key = (typeof name == 'undefined' || !name) ? 'blockname' : '';
27063
27064    $.post('/template/settings', { sid: sid, settings: JSON.stringify(elsettings), el: id, delete: delete_key }, function(data) {
27065        var isCheck = checkError(data);
27066        if (!isCheck) return false;
27067
27068        $('.property-blockname-wrap .blockname-txt').text(name);
27069    }, 'json');
27070}
27071
27072var blocknameListUpdate = function(fn, sid, id, name) {
27073    var settings = (typeof SETTINGS =='undefined') ? $.gallery.site_settings : SETTINGS;
27074
27075    if (typeof settings.blocknameList == 'undefined') { settings.blocknameList = {}; }
27076    var blockname_list = {};
27077
27078    if (fn == 'update') {
27079        var blockname_item = {};
27080        blockname_item['blockname' + id] = name;
27081        blockname_list = $.extend({}, settings.blocknameList, blockname_item);
27082    } else if (fn == 'delete') {
27083        if (typeof settings.blocknameList['blockname' + id] == 'undefined') { return false; }
27084        delete settings.blocknameList['blockname' + id];
27085        blockname_list = settings.blocknameList;
27086    }
27087
27088    var update = { blocknameList: blockname_list },
27089        delete_key = ($.isEmptyObject(blockname_list)) ? 'blocknameList' : '';
27090
27091    $.post('/template/settings', { sid: sid, settings: JSON.stringify(update), el: 'site_settings', delete: delete_key }, function(data) {
27092        var isCheck = checkError(data);
27093        if (!isCheck) return false;
27094        settings.blocknameList = blockname_list;
27095    }, 'json');
27096}
27097
27098var blockBookmarkDelete = function(sid, seq) {
27099    var settings = (typeof SETTINGS =='undefined') ? $.gallery.site_settings : SETTINGS;
27100    if (typeof seq == 'undefined' || typeof sid == 'undefined' || !seq || !sid || typeof settings.blockBookmarkList == 'undefined' || typeof settings.blockBookmarkList['bookmark' + seq] == 'undefined') return false;
27101    if ($('#tpl-menu li a[href="@' + seq + '"][attr-bookmark]').length > 0) {
27102        resetLink($('#tpl-menu li a[href="@' + seq + '"][attr-bookmark]').text());
27103    }
27104    blockBookmarkUpdate(sid, seq, false);
27105    blockBookmarkListUpdate('delete', sid, seq);
27106}
27107
27108var blockBookmarkUpdate = function(sid, id, onoff) {
27109    var elsettings = { bookmark: onoff };
27110    var delete_key = (onoff) ? '' : 'bookmark';
27111
27112    $.post('/template/settings', { sid: sid, settings: JSON.stringify(elsettings), el: id, delete: delete_key }, function(data) {
27113        var isCheck = checkError(data);
27114        if (!isCheck) return false;
27115
27116        if (onoff) $('.element[data-id="' + id + '"]').attr('data-bookmark', id);
27117        else $('.element[data-id="' + id + '"]').removeAttr('data-bookmark');
27118    }, 'json');
27119}
27120
27121var blockBookmarkListUpdate = function(fn, sid, id, name) {
27122    var settings = (typeof SETTINGS =='undefined') ? $.gallery.site_settings : SETTINGS;
27123    if (typeof settings.blockBookmarkList == 'undefined') { settings.blockBookmarkList = {}; }
27124    var bookmark_list = {};
27125
27126    if (fn == 'update') {
27127        var bookmark_item = {};
27128        bookmark_item['bookmark' + id] = name;
27129        bookmark_list = $.extend({}, settings.blockBookmarkList, bookmark_item);
27130    } else if (fn == 'delete') {
27131        if (typeof settings.blockBookmarkList['bookmark' + id] == 'undefined') { return false; }
27132        delete settings.blockBookmarkList['bookmark' + id];
27133        bookmark_list = settings.blockBookmarkList;
27134    }
27135
27136    var update = { blockBookmarkList: bookmark_list },
27137        delete_key = ($.isEmptyObject(bookmark_list)) ? 'blockBookmarkList' : '';
27138
27139    $.post('/template/settings', { sid: sid, settings: JSON.stringify(update), el: 'site_settings', delete: delete_key }, function(data) {
27140        var isCheck = checkError(data);
27141        if (!isCheck) return false;
27142        settings.blockBookmarkList = bookmark_list;
27143    }, 'json');
27144
27145    if (fn == 'delete') { //gallery item - link(attr-bookmark) unset
27146        $.post('/template/element/type/gitem-bookmarklink-delete/seq/' + id, { sid: SID }, function(data) {
27147            checkError(data);
27148        }, 'json');
27149    }
27150}
27151
27152var makeBookmarkList = function(bookmarklist, type, id, link) {
27153    var str = '',
27154        isActive = '';
27155
27156    if (typeof bookmarklist == 'undefined' || !bookmarklist) return str;
27157    if (bookmarklist == '{}') bookmarklist = {};
27158    var hideArray = bookmarklist?.hide || [];
27159
27160    $.each(bookmarklist, function(k, v) {
27161        var n_k = k.replace('bookmark', '');
27162        if (k != 'hide') {
27163            isActive = (k == link.replace(/^\@/g, 'bookmark')) ? 'active' : '';
27164            if (hideArray.length > 0) {
27165                if (hideArray.includes(n_k)) {
27166                    return true;
27167                } else {
27168                    str = str + '<li class="' + isActive + '" data-bookmark="' + k + '" data-bookmark-name="' + v + '"><a href="javascript:;">' + v + '</a></li>';
27169                }
27170            } else {
27171                str = str + '<li class="' + isActive + '" data-bookmark="' + k + '" data-bookmark-name="' + v + '"><a href="javascript:;">' + v + '</a></li>';
27172            }
27173        }
27174    });
27175    return str;
27176}
27177
27178var galleryStatusInit = function() {
27179    $('.gallery-items > div').removeClass('active ui-selected').find('input').prop('checked','');
27180    // $('.table-toolbar > li').addClass('disabled').find('i[data-cmd="visible"]').text('숨김');
27181    $('.table-toolbar > li').find('i[data-cmd="visible"]').text('숨김');
27182    $('.gallery-toolbar .toolbar.mod-gallery').remove();
27183}
27184
27185var shoppingGalleryResize = function() {
27186    var $list = $('.product-gallery-list'),
27187        $category = $('.gallery-category'),
27188        $more = $('.gallery-items-loadmore'),
27189        $items = $('.gallery-items'),
27190        $toggle = $('.product-gallery-list-toggle'),
27191        $pagination = $('.pagination-wrap'),
27192        $filter = $('.gallery-list-filter'),
27193        $name = $('.selected-gallery-name'),
27194        $lux_filter = $('.shop-filter-header'),
27195        svg_open = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-chevron-right" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708z"/></svg>',
27196        svg_close = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-chevron-left" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M11.354 1.646a.5.5 0 0 1 0 .708L5.707 8l5.647 5.646a.5.5 0 0 1-.708.708l-6-6a.5.5 0 0 1 0-.708l6-6a.5.5 0 0 1 .708 0"/></svg>',
27197        status = window.localStorage.getItem('product-gallery-closed');
27198    var w = $('.gallery-modal')[0]['clientWidth'],
27199        t = ($('.gallery-modal').hasClass('shopping')) ? true : false,
27200        g = (t) ? 1440 : 0,
27201        o = ($('.product-gallery-list').hasClass('open')) ? true : false;
27202
27203    if(g > 0 && w <= g && o == true) {
27204        $toggle.removeClass('open');
27205        $list.removeClass('open');
27206        $category.removeClass('open');
27207        $more.removeClass('open');
27208        $items.removeClass('open');
27209        $pagination.removeClass('open');
27210        $filter.removeClass('open');
27211        $name.removeClass('open');
27212        $lux_filter.removeClass('open');
27213        if($toggle.hasClass('open')) {
27214            $toggle.html(svg_open);
27215        } else {
27216            $toggle.html(svg_close);
27217        }
27218    } 
27219    if(w > g && status == 'false') {
27220        $toggle.addClass('open');
27221        $list.addClass('open');
27222        $category.addClass('open');
27223        $more.addClass('open');
27224        $items.addClass('open');
27225        $pagination.addClass('open');
27226        $filter.addClass('open');
27227        $name.addClass('open');
27228        $lux_filter.addClass('open');
27229        if($toggle.hasClass('open')) {
27230            $toggle.html(svg_open);
27231        } else {
27232            $toggle.html(svg_close);
27233        }
27234    }
27235}
27236
27237var resizeGalleryModal = function() {
27238    var w = $('.gallery-modal')[0]['clientWidth'],
27239        $c_p = $('.gallery-modal > .gallery-header'),
27240        $c_m = $('.gallery-modal > .container, .gallery-modal > .gallery-items, .gallery-modal > .gallery-items-loadmore'),
27241        t = ($('.gallery-modal').hasClass('shopping')) ? true : false,
27242        g = (t) ? 1124 : 1146,
27243        p = ((w-g) > 0) ? (w-g)/2 : 0,
27244        scroll_bar = ($.browser.safari == undefined) ? 17 : 8;
27245    if(p < 50) p = 50;
27246    $c_p.css({'padding-left': p + 'px', 'padding-right': p + 'px'});
27247    $c_m.css({'margin-left': p + 'px', 'margin-right': p + 'px', 'width': 'auto', 'max-width': '100%'});
27248    document.querySelector('.gallery-modal').style.setProperty('--gallery-modal-pl', p+'px', null);
27249    document.querySelector('.gallery-modal').style.setProperty('--gallery-modal-pr', (p+scroll_bar)+'px', null);
27250}
27251
27252var switchDownload = function(option_onoff) {
27253    if($('#download-product').is(':checked') === true) { //다운로드 상품
27254        var firstOption = $('.prod-option[data-option_mode="normal"] .prod-option-list > li').eq(1);
27255        var noneOption = $('.prod-option[data-option_mode="normal"] .prod-option-list > li').eq(0);
27256        
27257        var downloadContent = '';
27258        var state = false;
27259
27260        if ($('#none-option-file').length > 0 && option_onoff == 'on') {
27261            if ($('#none-option-file .file-name').length > 0) {
27262                // var optionSeq = (firstOption.find('.prod-option-title').attr('data-seq')!='')? firstOption.find('.prod-option-title').attr('data-seq') : '';
27263                var fileUrl = $('#none-option-file .file-url').text(),
27264                    fileSize = $('#none-option-file .file-size').text(),
27265                    fileNameDetail = $('#none-option-file .file-name-detail').text(),
27266                    realFileName = $('#none-option-file .real-file-name').text();
27267                state = true;
27268            } else if($('#none-option-file .none-file-name').length > 0) {
27269                // var optionSeq = (firstOption.find('.prod-option-title').attr('data-seq')!='')? firstOption.find('.prod-option-title').attr('data-seq') : '';
27270                var fileUrl = $('#none-option-file .none-file-url').text(),
27271                    fileSize = $('#none-option-file .none-file-size').text(),
27272                    fileNameDetail = $('#none-option-file .none-file-name-detail').text(),
27273                    realFileName = $('#none-option-file .none-real-file-name').text();
27274
27275                state = true;        
27276            }
27277
27278            var dataPn = $('#none-option-file .cl_icon_close').attr('data-pn'),
27279                dataFile = $('#none-option-file .cl_icon_close').attr('data-file');
27280            var fileCnt = 2;
27281            var optionSeq = $('#none-option-file .cl_icon_close').attr('data-seq');
27282        }
27283        if(firstOption.find('.file-name').length > 0 && option_onoff == 'off'){
27284            var optionSeq = (noneOption.find('.prod-option-title').attr('data-seq')!='')? noneOption.find('.prod-option-title').attr('data-seq') : '';
27285            var fileUrl = firstOption.find('.file-url').text(),
27286                fileSize = firstOption.find('.file-size').text(),
27287                fileNameDetail = firstOption.find('.file-name-detail').text(),
27288                realFileName = firstOption.find('.real-file-name').text(),
27289                dataPn = firstOption.find('.cl_icon_close').attr('data-pn'),
27290                dataFile = firstOption.find('.cl_icon_close').attr('data-file');
27291            var fileCnt = 1;
27292            state = true;
27293        }
27294        // console.log(state);
27295        if(state === true) {
27296            downloadContent = '\
27297                <div class="file-name file-name-'+fileCnt+'">\
27298                    <span class="real-file-name">'+realFileName+'</span>\
27299                    <span class="file-name-detail" title="'+realFileName+'">'+fileNameDetail+'</span>\
27300                    <span class="file-size">'+fileSize+'</span>\
27301                    <span class="cl-icon cl_icon_close" data-cnt="1" data-pn="'+dataPn+'" data-file="'+dataFile+'" data-seq="'+optionSeq+'"></span>\
27302                    <span class="file-url">'+fileUrl+'</span>\
27303                </div>\
27304            ';
27305        }
27306        // console.log(downloadContent);
27307        if ($('#normal-option').is(':checked') === true) {
27308            // console.log(firstOption.find('.file-box-list'));
27309            firstOption.find('.file-box-list').html(downloadContent);
27310            firstOption.find('.prod-option-status').text('판매').attr('data-val', 'S');
27311
27312            $('#add-upload-check .product-upload').remove();
27313            noneOption.find('.file-name').remove();   
27314        } else {
27315            var html = '\
27316                <div class="product-upload">\
27317                    <div class="title">파일 업로드</div>\
27318                    <div class="download-contents">\
27319                        <span class="cl_icon_upload02" data-cnt="0">업로드</span>\
27320                        <div id="none-option-file">'+downloadContent+'</div>\
27321                    </div>\
27322                </div>';
27323
27324            $('#add-upload-check').prepend(html);
27325            noneOption.find('.file-box-list').html(downloadContent);
27326            if ($('#none-option-file').length == 0) {
27327                $('.switch-product[value="off"]').prop('checked', true);
27328                $('#status-append').fadeOut(0);
27329                $('#sale-calendar').hide();
27330            }
27331            // firstOption.find('.file-name').remove();;
27332        }
27333    }
27334}
27335
27336var prodOptionMoveSvg = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path d="M8 6c0-.83.67-1.5 1.5-1.5S11 5.17 11 6s-.67 1.5-1.5 1.5S8 6.83 8 6m5 0c0-.83.67-1.5 1.5-1.5S16 5.17 16 6s-.67 1.5-1.5 1.5S13 6.83 13 6m-5 6c0-.83.67-1.5 1.5-1.5s1.5.67 1.5 1.5-.67 1.5-1.5 1.5S8 12.83 8 12m5 0c0-.83.67-1.5 1.5-1.5s1.5.67 1.5 1.5-.67 1.5-1.5 1.5S13 12.83 13 12m-5 6c0-.83.67-1.5 1.5-1.5s1.5.67 1.5 1.5-.67 1.5-1.5 1.5S8 18.83 8 18m5 0c0-.83.67-1.5 1.5-1.5s1.5.67 1.5 1.5-.67 1.5-1.5 1.5S13 18.83 13 18"/></svg>';
27337
27338var addProductOption = function(optionMode) {
27339    var $parent;
27340    var option_mode; //일반, 입력, 추가
27341    
27342    if(optionMode=='normal' || optionMode=='text' || optionMode=='additional'){
27343        $parent = $('.prod-option[data-option_mode="'+optionMode+'"]');
27344        option_mode = optionMode; //일반, 입력, 추가
27345    } else {
27346        $parent = $(this).parent();
27347        option_mode = $parent.data('option_mode'); //일반, 입력, 추가
27348    }
27349    
27350    if($parent.find('.prod-option-item.hide').length) {
27351        $parent.find('.prod-option-item.hide').closest('li').addClass('err').find('.edit-option-title input').focus();
27352        r = shoppingSetOption($parent.find('.prod-option-item.hide'));
27353        if(r == false) return r;
27354    }
27355
27356    var state = 'normal-product';
27357    $('.cl_product_state_check').each(function () {
27358        if ($(this).hasClass('active') === true) {
27359            state = $(this).attr('for');
27360        }
27361    });
27362    var status = true;
27363    var productNumber = $('#prod-no').val();
27364    
27365    // if (option_mode == "normal" && productNumber) {
27366    //     if($('.prod-option[data-option_mode="normal"] .prod-option-list>li').length <= 1) {
27367    //         $.ajax({
27368    //             url: '/shopping/download_list_check',
27369    //             type: 'post',
27370    //             dataType: 'json',
27371    //             data: {'product_number': productNumber},
27372    //             success: function (data) {
27373    //                 if (data.code == 'fail') {
27374    //                     alert(data.message);
27375    //                     status = false;
27376    //                     return false;
27377    //                 }
27378    //             }
27379    //         });
27380    //     }
27381    // }
27382    
27383    // if (status == false) return false;
27384    
27385    var tax = $('#tax').attr('data-total-tax'),
27386        check_quantity = $('.prod-detail-wrap .switch-quantity').prop('checked');
27387
27388    var item = '';
27389    if(option_mode == "text") {
27390        if($parent.find('li').length >= 6) {
27391            $('.prod-option[data-option_mode="text"] > .prod-option-add').addClass('disabled');
27392        }
27393        if($parent.find('li').length >= 7) {
27394            alert('입력형 옵션은 최대 7개까지 추가할 수 있습니다.');    
27395            return false;
27396        }
27397        item = '\
27398            <li>\
27399                <div class="prod-option-item hide">\
27400                    <span class="prod-option-title"></span>\
27401                    <span class="prod-option-require"></span>\
27402                </div>\
27403                <div class="prod-option-edit">\
27404                    <div class="form-wrap">\
27405                        <div class="form-group edit-option-title">\
27406                            <input type="text" maxlength="20" placeholder="안내문구 입력 (예:두께를 mm단위로 입력해주세요.)"/>\
27407                        </div>\
27408                        <div class="edit-option-delete"><svg viewBox="0 0 12 13" width="12" height="13"><path d="M12 2h-1H9V0H3.02v2H1 0v1h1v8c0 1.1 0.9 2 2 2h6c1.1 0 2-0.9 2-2V3h1V2zM4.02 1H8v1H4.02V1zM10 11c0 0.55-0.45 1-1 1H3c-0.55 0-1-0.45-1-1V3h1.02H9h1V11z"/><rect x="4" y="4" width="1" height="7"/><rect x="7" y="4" width="1" height="7"/></svg></div>\
27409                    </div>\
27410                </div>';
27411    } else {
27412        item = '\
27413            <li>\
27414                <div class="prod-option-item hide">\
27415                    <span class="prod-option-move cl-sort-handle">' + clSVG('move_handle', 20, 20) + '</span>\
27416                    <span class="prod-option-title"></span>\
27417                    <span class="prod-option-price"></span>\
27418                    <span class="prod-option-quantity"></span>\
27419                    <span class="prod-option-status"></span>\
27420                    <div class="edit-option-delete"><svg viewBox="0 0 12 13" width="12" height="13"><path d="M12 2h-1H9V0H3.02v2H1 0v1h1v8c0 1.1 0.9 2 2 2h6c1.1 0 2-0.9 2-2V3h1V2zM4.02 1H8v1H4.02V1zM10 11c0 0.55-0.45 1-1 1H3c-0.55 0-1-0.45-1-1V3h1.02H9h1V11z"/><rect x="4" y="4" width="1" height="7"/><rect x="7" y="4" width="1" height="7"/></svg></div>\
27421                </div>\
27422                <div class="prod-option-edit">\
27423                    <div class="form-wrap">\
27424                        <span class="prod-option-move cl-sort-handle">' + clSVG('move_handle', 20, 20) + '</span>\
27425                        <div class="form-group edit-option-title">\
27426                            <input type="text" maxlength="60" placeholder="옵션값"/>\
27427                        </div>\
27428                        <div class="form-group edit-option-price">\
27429                            <input type="text" class="option-price-number sign" placeholder="0" numberonly/>\
27430                        </div>\
27431                        <div class="form-group edit-option-quantity" ' + ((check_quantity) ? '' : 'style="display:none"') + '>\
27432                            <input type="text" class="option-price-quantity" maxlength="5" placeholder="0" numberonly/>\
27433                        </div>\
27434                        <div class="form-group edit-option-select">';
27435                        if (state == 'download-product' && $parent.attr('data-option_mode') == "normal") item += '<div class="option-price-status-str hand" data-val="O">품절</div>';
27436                        else item += '<div class="option-price-status-str hand" data-val="S">판매</div>';
27437                        item += '<ul class="option-price-status-select">\
27438                                <li data-val="S">판매</li>\
27439                                <li data-val="O">품절</li>\
27440                                <li data-val="H">숨김</li>\
27441                            </ul>\
27442                        </div>\
27443                        <div class="edit-option-delete"><svg viewBox="0 0 12 13" width="12" height="13"><path d="M12 2h-1H9V0H3.02v2H1 0v1h1v8c0 1.1 0.9 2 2 2h6c1.1 0 2-0.9 2-2V3h1V2zM4.02 1H8v1H4.02V1zM10 11c0 0.55-0.45 1-1 1H3c-0.55 0-1-0.45-1-1V3h1.02H9h1V11z"/><rect x="4" y="4" width="1" height="7"/><rect x="7" y="4" width="1" height="7"/></svg></div>\
27444                    </div>\
27445                </div>';
27446        if (state == 'download-product' && $parent.attr('data-option_mode') == "normal") {
27447            item += '\
27448                <div class="form-group product-status">\
27449                    <div class="product-state-box">\
27450                        <div class="product-upload">\
27451                            <div class="title">파일 업로드</div>\
27452                            <div class="download-contents">\
27453                                <span class="cl_icon_upload02" data-cnt="'+fileUpdateCnt+'">업로드</span>\
27454                                <div class="file-box-list" id="file-box-'+fileUpdateCnt+'"></div>\
27455                            </div>\
27456                        </div>\
27457                    </div>\
27458                </div>';
27459            fileUpdateCnt++;
27460        }
27461    }
27462    
27463    
27464        item += '</li>';
27465    var $item = $(item);
27466    
27467    $parent.find('.prod-option-list').append($item);
27468    $('.prod-option[data-option_mode="'+option_mode+'"] .prod-option-list>li:last-child').find('.edit-option-title input').focus();
27469
27470    $('.plus-price').removeClass('hide');
27471    // $('.plus-quantity').removeClass('hide');
27472    $('.plus-status').removeClass('hide');
27473
27474    // if(option_mode == "normal") {
27475    //     $('.plus-price').text('추가금액');
27476    //     $('.plus-quantity').text('수량');
27477    //     $('.plus-status').text('상태');
27478    // } else if(option_mode == "additional") {
27479    //     $('#plus-addt-price').text('금액');
27480    //     $('#plus-addt-quantity').text('수량');
27481    //     $('#plus-addt-status').text('상태');
27482    // } else if (option_mode == "text") {
27483    //     $('#check-require').text('필수여부');
27484    // }
27485    
27486    if($('.switch-quantity').is(":checked") == true) {
27487        if($('#normal-option').is(':checked') === true) {
27488            // $('#prod-quantity').attr('readonly','true').removeClass('hide').attr('placeholder','옵션에서 재고 관리');
27489            $('.quantity-label').addClass('on');
27490            $('.plus-quantity').removeClass('hide');
27491        } else if($('#normal-option').is(':checked') === false && $('#additional-option').is(':checked') === true) {
27492            $('.quantity-label').removeClass('on');
27493            $('#prod-quantity').removeAttr('readonly').removeClass('hide');
27494            $('.plus-quantity').removeClass('hide');
27495        } else {
27496            $('.quantity-label').removeClass('on');
27497            $('#prod-quantity').removeAttr('readonly').removeClass('hide');
27498            $('.plus-quantity').addClass('hide');
27499        }
27500    } else {
27501        $('.quantity-label').removeClass('on');
27502        $('.switch-quantity').parents('.form-wrap').addClass('disabled');
27503        $('#prod-quantity').addClass('hide');
27504        $('.prod-option-quantity, .prod-plus-quantity, .edit-option-quantity').hide();
27505        $('.plus-quantity').addClass('hide');
27506    }
27507
27508    return true;
27509}
27510
27511function limitProductOptionPriceInput($input) {
27512    var max = 1000000000,
27513        raw = $.trim($input.val()),
27514        sign = (raw.charAt(0) == '-') ? '-' : ((raw.charAt(0) == '+') ? '+' : ''),
27515        price = parseInt(removeCommas(raw), 10),
27516        limited = price;
27517
27518    if(raw == '' || raw == '-' || raw == '+') return;
27519    if(isNaN(price)) return;
27520    if(price > max) limited = max;
27521    if(price < -max) limited = -max;
27522    if(limited != price) {
27523        $input.val(((limited < 0) ? '-' : ((sign == '+') ? '+' : '')) + addCommas(Math.abs(limited).toString()));
27524    }
27525}
27526
27527var shoppingSetOption = function(optionItem) {
27528
27529    if($('.prod-option-item.hide').length) {
27530        var $o = (optionItem)? optionItem : $('.prod-option-item.hide');
27531        var ret = true;
27532
27533        $o.each(function(){
27534            var $t = $(this).parent().find('.prod-option-edit input');
27535            // console.log($t);
27536
27537            var $title = $t.closest('.form-wrap').find('.edit-option-title input'),
27538                $desc = $t.closest('.form-wrap').find('.edit-option-desc input'),
27539                $price = $t.closest('.form-wrap').find('.edit-option-price input'),
27540                $quantity = $t.closest('.form-wrap').find('.edit-option-quantity input'),
27541                $status = $t.closest('.form-wrap').find('.option-price-status-str'),
27542                $text_require = $t.closest('.form-wrap').find('.option-require-str');
27543        
27544            limitProductOptionPriceInput($price);
27545            var price = removeCommas($price.val()), quantity = removeCommas($quantity.val());
27546            if (!price) price = 0;
27547            if (!quantity) quantity = 0;
27548
27549            if(typeof quantity == 'string') {
27550                quantity = quantity.replace(/,/gi,'') ;
27551            }
27552
27553            quantity = Number(quantity);
27554
27555            price = parseInt(price);
27556            quantity = (quantity * 1);
27557            if(String(price) == "NaN") price = 0;
27558            var abs_price = Math.abs(price),
27559                str_price = abs_price.toString(),
27560                str_quantity = quantity.toString(); 
27561
27562             if(isNaN(price) === true) {
27563                $price.val(0);
27564                price = 0;
27565                $t.closest('li').find('.prod-option-price').attr('data-option-price', price);
27566            }
27567
27568            $t.closest('li').find('.prod-option-title').text($title.val());
27569            $t.closest('li').find('.prod-option-desc').text($desc.val());
27570            $t.closest('li').find('.prod-option-price').text(addCommas(str_price));
27571            $t.closest('li').find('.prod-option-quantity').text(addCommas(str_quantity));
27572            $t.closest('li').find('.prod-option-status').text($status.text());
27573
27574            if(price < 0) {
27575                $t.closest('li').find('.prod-option-price').addClass('minus');
27576            } else {
27577                $t.closest('li').find('.prod-option-price').removeClass('minus');
27578            }
27579            // if($text_require.find('input').is(':checked') == true) {
27580            //     var checkbox = "\
27581            //     <span>필수</span>\
27582            //     <svg class='active' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' width='16' height='16'>\
27583            //     <path d='M13 0H3C1.34 0 0 1.34 0 3v10c0 1.66 1.34 3 3 3h10c1.66 0 3-1.34 3-3V3C16 1.34 14.66 0 13 0zM13.03 6.03l-5.5 5.5C7.38 11.68 7.19 11.75 7 11.75s-0.38-0.07-0.53-0.22l-3.5-3.5c-0.29-0.29-0.29-0.77 0-1.06s0.77-0.29 1.06 0L7 9.94l4.97-4.97c0.29-0.29 0.77-0.29 1.06 0S13.32 5.74 13.03 6.03z'/>\
27584            //     </svg>";
27585            //     $t.parents('li').find('.prod-option-require').html(checkbox);
27586            // } else {
27587            //     var checkbox = "\
27588            //     <span>필수</span>\
27589            //     <svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' width='16' height='16'>\
27590            //     <path d='M13 0H3C1.3 0 0 1.3 0 3v10c0 1.7 1.3 3 3 3h10c1.7 0 3-1.3 3-3V3C16 1.3 14.7 0 13 0zM15 13c0 1.1-0.9 2-2 2H3c-1.1 0-2-0.9-2-2V3c0-1.1 0.9-2 2-2h10c1.1 0 2 0.9 2 2V13z'/>\
27591            //     </svg>";
27592            //     $t.parents('li').find('.prod-option-require').html(checkbox);
27593            // }
27594            var option_type = $t.closest('.prod-option').attr('data-option_mode');
27595
27596            if(product_options.advanced == 'false') {
27597                if($title.val() === undefined || $title.val().trim().length == 0 || (option_type == 'text' && $title.val().trim().length > 20)) {
27598                    $t.closest('li').addClass('err');
27599                    if($title.val().trim().length > 20) {
27600                        alert('옵션명은 20자까지 입력이 가능합니다.');
27601                    }
27602                    ret = false;
27603                    return false;
27604                }
27605            }
27606            if($quantity.val() == '') $t.closest('li').find('.prod-option-quantity').text('0');
27607            if($('.switch-quantity').is(':checked') == true && $t.closest('li').find('.prod-option-quantity').text() == '0') {
27608                $t.closest('li').find('.option-price-status-str').attr('data-val','O').text('품절');
27609                $t.closest('li').find('.prod-option-status').attr('data-val','O').text('품절');
27610            }
27611
27612            $t.closest('.prod-option-edit').addClass('hide');
27613            $t.closest('li').find('.prod-option-item').removeClass('hide');
27614            $t.closest('li').removeClass('err');
27615
27616            ret = true;
27617        });
27618        
27619        return ret;
27620    }
27621}
27622
27623var checkDuplicateOptionName = function(el) {
27624    var titles = $('.prod-option-title').map(function(idx, v) { 
27625            var str = $(v).text().trim();
27626            if(str.length > 0) return str;                        
27627        }).get();
27628    var input = el.val().trim();
27629    var cnt = titles.filter(function(el){
27630                return el == input;
27631            }).length;
27632    var flag = false;
27633
27634    if(input.length > 0 && cnt > 1) {
27635        el.parents('li').find('.prod-option-title').text('');
27636        el.val('');
27637        el.focus();
27638        flag = true;
27639        alert('옵션명 중복 오류입니다.'); 
27640    } else {
27641        el.parents('li').find('.prod-option-title').removeClass('now-input');
27642    }
27643
27644    return flag;
27645}
27646
27647var siteConfigOthersCheckModal = function(sid,check_id,check_uadmin,success_callback,cancel_callback) {
27648
27649    var config_url = (check_uadmin) ? '/_config' : '/config',
27650        check_data = {
27651            'id': check_id,
27652            'edit': check_uadmin,
27653            'step': 'check'
27654        };
27655
27656    $.post('/umember/login/others', {
27657        'sid': sid,
27658        'data': JSON.stringify(check_data)
27659    }, function(data) {
27660
27661        if(typeof data.error != 'undefined' && data.error) {
27662            $(this).showModalFlat('ERROR', data.error, true, false, '', 'close');
27663            return false;
27664        }
27665
27666        if(typeof success_callback == 'undefined' || !success_callback) {
27667            success_callback = function() { 
27668                setSiteLogs('config','enter','','dashboard');
27669                location.href = config_url;
27670            };
27671        }
27672
27673        if(!data.result) {
27674            success_callback();
27675        } else {
27676            var o_id = data.others_id,
27677                str = $.lang[LANG]['config.modal.others-login.3'] + o_id + $.lang[LANG]['config.modal.others-login.1'] + o_id + $.lang[LANG]['config.modal.others-login.2'],
27678                checkOtherLoginModal = $(this).showModalFlat($.lang[LANG]['config.information'], str, true, true, function() {
27679                    $.processON('Other Login Disconnecting...');
27680
27681                    var set_data = check_data;
27682                    set_data['step'] = 'set';
27683
27684                    $.ajax({
27685                        type: 'POST',
27686                        url: '/umember/login/others',
27687                        data: { sid: SID, data: JSON.stringify(set_data) },
27688                        dataType: 'json',
27689                        async: true,
27690                        success: function(data) {
27691                            setTimeout(function() {
27692                                $.processOFF();
27693                                success_callback();
27694                            }, 400);
27695                        }
27696                    });
27697                    
27698                }, 'cancel', 'ok', 'cl-p70 cl-cmmodal cl-s-btn w560 cl-p0 login-modal', '', '', '', cancel_callback);
27699        }
27700
27701    }, 'json');
27702}
27703
27704var getBackgroundImageUrls = function(backgroundValue) {
27705    var urls = [];
27706    var value = String(backgroundValue || '');
27707    var urlPattern = /url\(\s*(?:(["'])(.*?)\1|([^\s"')][^)]*?))\s*\)/gi;
27708    var match;
27709
27710    while((match = urlPattern.exec(value)) !== null) {
27711        var url = $.trim(typeof match[2] != 'undefined' ? match[2] : match[3]);
27712        if(url) urls.push(url);
27713    }
27714
27715    return urls;
27716};
27717
27718var normalizeBackgroundImageUrl = function(url) {
27719    return String(url || '').replace(/^(http)?(s)?(:)?\/\/i\.addblock\.net\//i,'//storage.googleapis.com/i.addblock.net/');
27720};
27721
27722var isCheckableBackgroundImageUrl = function(url) {
27723    var value = $.trim(String(url || ''));
27724    if(!value || /^(?:none|initial|inherit|unset|revert)$/i.test(value)) return false;
27725    if(/^data:image\//i.test(value) || /^blob:/i.test(value)) return true;
27726    if(/^(?:https?:)?\/\//i.test(value) || /^\//.test(value)) return true;
27727    if(/^[a-z][a-z0-9+.-]*:/i.test(value)) return false;
27728
27729    return /^(?:\.\.\/|\.\/|[A-Za-z0-9_-])[^\s]*$/i.test(value);
27730};
27731
27732var replaceBackgroundImageUrl = function(backgroundValue, targetUrl, replacement) {
27733    var target = normalizeBackgroundImageUrl(targetUrl);
27734    var urlPattern = /url\(\s*(?:(["'])(.*?)\1|([^\s"')][^)]*?))\s*\)/gi;
27735
27736    return String(backgroundValue || '').replace(urlPattern, function(match, quote, quotedUrl, unquotedUrl) {
27737        var currentUrl = $.trim(typeof quotedUrl != 'undefined' ? quotedUrl : unquotedUrl);
27738        if(normalizeBackgroundImageUrl(currentUrl) != target) return match;
27739        if(replacement == 'none') return 'none';
27740
27741        return 'url("' + String(replacement).replace(/\\/g, '\\\\').replace(/"/g, '\\"') + '")';
27742    });
27743};
27744
27745var checkBrokenBackgroundImages = function(backgroundValue, onError) {
27746    var checked = {};
27747
27748    $.each(getBackgroundImageUrls(backgroundValue), function(index, sourceUrl) {
27749        var imageUrl = normalizeBackgroundImageUrl(sourceUrl);
27750        if(!isCheckableBackgroundImageUrl(imageUrl) || checked[imageUrl]) return;
27751        checked[imageUrl] = true;
27752
27753        var testImage = new Image();
27754        testImage.onerror = function() {
27755            onError(sourceUrl, imageUrl);
27756            testImage.onload = null;
27757            testImage.onerror = null;
27758        };
27759        testImage.onload = function() {
27760            testImage.onload = null;
27761            testImage.onerror = null;
27762        };
27763        testImage.src = imageUrl;
27764    });
27765};
27766
27767var changeBrokenImages = function(el) {
27768    if($(el).length == 0) return;
27769    // if($(el).find('.hideBlockWrap').length > 0) return;
27770    var broken_icon = '//storage.googleapis.com/i.addblock.net/icon_broken_img.png',
27771        broken_image = '//storage.googleapis.com/i.addblock.net/img_broken.png',
27772        broken_popup = '//storage.googleapis.com/i.addblock.net/img_broken_fill_500.png';
27773
27774    var checkBlockConfig = $(el).is('#el-blockConfig'),
27775        checkSiteConfig = $(el).is('#el-siteConfig'),
27776        checkElement = $(el).is('.element'),
27777        checkMenu = $(el).is('header'),
27778        // broken_img =  (checkBlockConfig || checkMenu) ? '//storage.googleapis.com/i.addblock.net/icon_broken_img.png' : '//storage.googleapis.com/i.addblock.net/img_broken.png',
27779        broken_img =  (checkBlockConfig) ? broken_icon : broken_image,
27780        broken_bg = (checkBlockConfig) ? 'none' : 'url(' + broken_img + ')';
27781
27782    if(checkElement || checkMenu) {
27783        var el_bg = $(el).css('background-image');
27784        checkBrokenBackgroundImages(el_bg, function(sourceUrl, imageUrl) {
27785            console.log('block bg img error: '+imageUrl);
27786
27787            var currentBg = $(el).css('background-image');
27788            var replacement = (checkBlockConfig) ? 'none' : broken_img;
27789            $(el).css('background-image', replaceBackgroundImageUrl(currentBg, sourceUrl, replacement));
27790        });
27791    }
27792
27793    $(el).find('[data-attach="true"]:not(img), #preview-image').each(function() {
27794        var this_attach = $(this),
27795            attch_bg = this_attach.css('background-image'),
27796            this_el = this_attach.closest('.element').attr('data-el');
27797
27798        checkBrokenBackgroundImages(attch_bg, function(sourceUrl, imageUrl) {
27799                console.log('attach bg img error: '+imageUrl);
27800
27801                var currentBg = this_attach.css('background-image');
27802                var replacement = (checkBlockConfig) ? 'none' : broken_img;
27803                var replacedBg = replaceBackgroundImageUrl(currentBg, sourceUrl, replacement);
27804
27805                if(this_attach.is('[data-target]')) {
27806                    // img_broken background-image inline css reset
27807                    var attach_html = this_attach.outerHTML();
27808                    this_attach.replaceWith(attach_html.replace(/style\=\"(.+)?background\-image\:([^\;]+)\;\"(\=\"\")?/gi,''));
27809
27810                    var this_selector = '.' + $('.'+this_el).attr('data-name') + ' ' + this_attach.attr('data-target'),
27811                        this_css = $('#'+this_el+'css').html();
27812                    $('#'+this_el+'css').html( this_css + this_selector + ' { background-image: ' + replacedBg + '; }');
27813                } else {
27814                    this_attach.css('background-image',replacedBg);
27815                }
27816        });
27817    });
27818
27819    $(el).find('img').each(function() {
27820        var el_img = $(this);
27821        var this_img = el_img.attr('src');
27822        if(typeof this_img == 'undefined' || this_img == '') return;
27823
27824        if(this_img.match(/^\/\/i\.addblock\.net\//gi) !== null) {
27825            this_img = this_img.replace(/^\/\/i\.addblock\.net\//gi,'//storage.googleapis.com/i.addblock.net/');
27826            $(this).attr('src',this_img);
27827        }
27828
27829        $(this).error(function() {
27830            // console.log('img error: '+this_img);
27831            $(this).attr('data-orgimg',this_img);
27832
27833            if(checkSiteConfig) {
27834                if($(this).closest('.sc-banner-img-thumb').length > 0) {
27835                    var e_b_type = $(this).closest('.tab-panel').attr('data-type'),
27836                        e_b_id = $(this).closest('.panel-banner-item').attr('data-id'),
27837                        e_b_device = $(this).closest('.sc-banner-img').attr('data-device');
27838
27839                    $(this).unbind('error').attr('src', broken_icon);
27840                    if(e_b_device == 'p') $(this).closest('.panel-banner-item').find('.pt-thumb img').unbind('error').attr('src', broken_icon);
27841                    if(e_b_type == 'band') {
27842                        var e_b_root = (e_b_device == 'p') ? '--scbandBanner-img-pc' : '--scbandBanner-img-mobile';
27843                        document.querySelector('#el-siteConfig .sc-siteBanner .banner-box[data-id="'+e_b_id+'"][data-type="'+e_b_type+'"] .banner-img').style.setProperty(e_b_root, 'url('+broken_popup+')', null);
27844                    }
27845                }
27846            } else {
27847                $(this).unbind('error').attr('src', broken_img)
27848                    .removeAttr('data-storage')
27849                    .removeAttr('data-photo-id')
27850                    .removeAttr('data-img-val')
27851                    .removeAttr('data-width');
27852                if(checkBlockConfig) {
27853                    if($(this).closest('.attach-thumb').length > 0) $(this).closest('.attach-thumb').eq(0).css('background-image', broken_bg);
27854                } else {
27855                    if($(this).closest('.img-wrapper').find('.g-img').length > 0) $(this).closest('.img-wrapper').find('.g-img').css('background-image', broken_bg);
27856                }
27857            }
27858        });
27859
27860        if(checkBlockConfig) {
27861            this_img = replaceBrokenImages(this_img, 'icon');
27862            if(this_img.match(/^(http)?(s)?(:)?\/\/storage\.googleapis\.com\/i\.addblock\.net\/icon_broken_img\.png/gi) !== null) $(this).closest('.attach-thumb').eq(0).css('background-image', broken_bg);
27863        }
27864
27865        el_img.attr('src', this_img);
27866    });
27867
27868    if($(el).attr('data-type') == 'video' && $(el).attr('data-mode') == 'zoom') {
27869        $(el).find('.video-gallery-url').each(function(idx, v) {
27870            if($(v).attr('href').indexOf('youtu') > -1) {
27871                let poster = $(v).attr('data-poster');
27872                const testImg = new Image();
27873                testImg.onload = function () {
27874                    if (this.width <= 120 && this.height <= 90) {
27875                        const thumb = poster.replace('maxresdefault', '0');
27876                        $(v).attr('data-poster', thumb);
27877                        $(v).find('.ly-img').css('background-image', 'url(' + thumb + ')');
27878                    }
27879                };
27880                testImg.src = poster;
27881            }
27882        });
27883    }
27884}
27885
27886var replaceBrokenImages = function(path,return_type) {
27887    var check_broken_icon = /^(http)?(s)?(:)?\/\/storage\.googleapis\.com\/i\.addblock\.net\/icon_broken_img\.png/gi,
27888        check_broken_img = /^(http)?(s)?(:)?\/\/storage\.googleapis\.com\/i\.addblock\.net\/img_broken\.png/gi,
27889        v = path;
27890
27891    if(return_type == 'img') return v.replace(check_broken_icon, '//storage.googleapis.com/i.addblock.net/img_broken.png');
27892    else return v.replace(check_broken_img, '//storage.googleapis.com/i.addblock.net/icon_broken_img.png');
27893}
27894
27895var getServeImage = function(f,w,path) {
27896    if(f == undefined) return;
27897    var r = '';
27898    if(typeof w === 'number') w = String(w);
27899    if(f.indexOf('googleusercontent') > -1) {
27900        var magic_type = (typeof SETTINGS != 'undefined') ? SETTINGS.magic_type : property.SETTINGS.magic_type,
27901            check_magic_type = (typeof magic_type != 'undefined' && magic_type == 'webp') ? true : false;
27902            t =  (check_magic_type) ? '-rw' : '';
27903
27904        var n = f.indexOf('=');
27905        f = f.substring(0, n != -1 ? n : f.length);
27906        switch(w) {
27907            case "0"      : r = f + '=s0'+t;            break;
27908            case "30"     : r = f + '=w30'+t;           break;
27909            case "60"     : r = f + '=w60-h60-n'+t;     break;
27910            case "250"    : r = f + '=w250-h250-n'+t;   break;
27911            case "300"    : r = f + '=w300-h300-n'+t;   break;
27912            case "500"    : r = f + '=w500-h700-n'+t;   break; //5:7
27913            case "600"    : r = f + '=w600-h600-n'+t;   break; //1:1
27914            case "650"    : r = f + '=w650-h366-n'+t;   break; //16:9
27915            case "670"    : r = f + '=w670-h1005-n'+t;  break; //6:9
27916            case "700"    : r = f + '=w700-h500-n'+t;   break; //7:5
27917            case "800"    : r = f + '=w800'+t;          break;
27918
27919            case "540"    : r = f + '=w600-h480-n'+t;   break; //5:4
27920            case "430"    : r = f + '=w600-h450-n'+t;   break; //4:3
27921            case "320"    : r = f + '=w600-h400-n'+t;   break; //3:2
27922            case "169"    : r = f + '=w650-h366-n'+t;   break; //16:9
27923            case "450"    : r = f + '=w480-h600-n'+t;   break; //4:5
27924            case "340"    : r = f + '=w450-h600-n'+t;   break; //3:4
27925            case "230"    : r = f + '=w400-h600-n'+t;   break; //2:3
27926            case "916"    : r = f + '=w450-h800-n'+t;   break; //9:16
27927
27928            case "1920"   :
27929                $.ajax({
27930                    type: 'POST',
27931                    url: '/template/image',
27932                    data: { url : f, width : w },
27933                    dataType: 'json',                    
27934                    async: false,
27935                    success: function(data) {
27936                        if(typeof data.s800 != 'undefined') {
27937                            if(w == "800")
27938                                r = (Number(data.s800) > 2560) ? f + '=s0' : f + '=w800-h' + data.s800 + '-n';
27939                            if(w == "1920")
27940                                r = (Number(data.s1920) > 2560) ? f + '=s0' : f + '=w1920-h' + data.s1920 + '-n';
27941                            r+=t;
27942                        } else {
27943                            r = (check_magic_type) ? f+'=-rw' : f;
27944                        }
27945                    }
27946                });
27947                break;                           
27948            case "map-info"    : r = f + '=w640-h550-n'+t;   break;
27949            default       : r = (check_magic_type) ? f+'=-rw' : f;  break;
27950        }
27951    } else {
27952        if(f.indexOf('matcheslux.com') > -1 || f.indexOf('bullanseo.com') > -1 || f.indexOf('bullanseon.com') > -1 || f.indexOf('eccla.co.kr') > -1 || f.indexOf('bullanseo.cafe24.com') > -1) {
27953            r = f;
27954        } else {
27955            path = (path.slice(-1) == '/') ? path : path + '/';
27956            // r = (f.indexOf('http:') > -1) ? f : (w == "0" || w == "") ? path + f : path + w + '/' + f;
27957            if(f.indexOf('//') > -1) {
27958                if(w == "0" || w == "") {
27959                    file_name = f.split('/').pop();
27960                    r = path + file_name;
27961                }
27962            } else {
27963                r = (w == "0" || w == "") ? path + f : path + w + '/' + f;
27964            }
27965            // r = (f.indexOf('//') > -1) ? f : (w == "0" || w == "") ? path + f : path + w + '/' + f;
27966        }
27967    }
27968    return r;
27969}
27970
27971Date.prototype.format = function (f) {
27972    if (!this.valueOf()) return " ";
27973
27974    var weekName = ["일요일", "월요일", "화요일", "수요일", "목요일", "금요일", "토요일"];
27975    var d = this;
27976    
27977    return f.replace(/(yyyy|yy|MM|dd|E|hh|mm|ss|a\/p)/gi, function(da) {
27978        switch (da) {
27979            case "yyyy": return d.getFullYear();
27980            case "yy": return (d.getFullYear() % 1000).zf(2);
27981            case "MM": return (d.getMonth() + 1).zf(2);
27982            case "dd": return d.getDate().zf(2);
27983            case "E": return weekName[d.getDay()];
27984            case "HH": return d.getHours().zf(2);
27985            case "hh": return ((h = d.getHours() % 12) ? h : 12).zf(2);
27986            case "mm": return d.getMinutes().zf(2);
27987            case "ss": return d.getSeconds().zf(2);
27988            case "a/p": return d.getHours() < 12 ? "오전" : "오후";
27989            default: return da;
27990        }
27991    });
27992};
27993
27994String.prototype.string = function(len){var s = '', i = 0; while (i++ < len) { s += this; } return s;};
27995String.prototype.zf = function(len){return "0".string(len - this.length) + this;};
27996Number.prototype.zf = function(len){return this.toString().zf(len);};
27997
27998var galleryDeleteItem = function(seq,callback) {
27999    if(CANCEL) return true;
28000    var item_page = $('.gallery-items div[data-seq="' + seq + '"]').attr('data-page');
28001    $.ajax({
28002        url: '/template/element/type/get-projectPage-bookmarkBlock/seq/' + seq,
28003        data: {sid: SID, page: item_page},
28004        dataType: 'json',
28005        type: 'POST',
28006        async: true,
28007        cache: false,
28008        success: function (data) {
28009            checkError(data);
28010            if(typeof callback == 'function') {
28011                callback(data);
28012            }
28013        }
28014    }, 'json');                
28015}
28016
28017var glItemDelete = function(ids, page) {
28018    $.post('/template/gallery/delete', { sid: SID, s: ids, page: page }, function(data) {
28019        checkError(data);
28020    }, 'json');
28021}
28022function removeOptionModal(optionList, optionMode) {
28023    // console.log(optionList);
28024    var sid = (typeof SID == 'undefined') ? property.SID : SID;
28025    if(optionList.length > 0) {
28026        var modal = $(this).showModalFlat($.lang[LANG]['config.information'], '선택한 옵션을 삭제하시겠습니까?', true, true, function() {
28027            optionList.each(function(){
28028                var seq = $(this).find('.prod-option-title').attr('data-seq');
28029                
28030                if(typeof seq != "undefined" || seq) {
28031                    $.post('/template/products', { seq : seq, sid : sid, type : 'delete', mode: 'option' }, function(data) {
28032                        if(typeof data.error != "undefined" || data.error) {
28033                            alert(data.error);
28034                            return false;
28035                        }
28036
28037                        var liTotal = 0;
28038                        $('.prod-option-list > li').each(function () { liTotal++; });
28039                        if (liTotal < 2) $('.prod-option .plus-price').addClass('hide');
28040                    }, 'json');
28041                } else {
28042                    var liTotal = 0;
28043                    $('.prod-option-list > li').each(function () { liTotal++; });
28044                    if (liTotal < 2) $('.prod-str-price').text('');
28045                }
28046            });
28047
28048            optionList.remove();
28049            $('.prod-option[data-option_mode="'+optionMode+'"]').addClass('hide');
28050
28051            var cnt = $('.prod-option[data-option_mode="normal"] .prod-option-list > li').length;
28052            if (cnt <= 1) {
28053                var html = '<div class="download-contents">\
28054                                <span class="cl_icon_upload02" data-cnt="0">업로드</span>\
28055                                <div id="none-option-file"></div>\
28056                            </div>';
28057                fileUpdateCnt++;
28058
28059                $('#add-upload-check').prepend(html);
28060                if ($('#none-option-file').length > 0) {
28061                    $('.switch-product[value="off"]').prop('checked', true);
28062                    $('#status-append').fadeOut(0);
28063                    $('#sale-calendar').hide();
28064                }
28065            }
28066
28067            modal.modal('hide');
28068        }, 'cancel', 'ok', 'cl-p130 cl-cmmodal cl-s-btn w560 cl-p0', false, function(){
28069            $('#'+optionMode+'-option').prop('checked', true);
28070        }, '', function(){
28071            if(optionMode == 'normal') {
28072                if($('.prod-option[data-option_mode="normal"] .prod-option-list > li').length > 1) {
28073                    $('#'+optionMode+'-option').prop('checked', true);
28074                } 
28075            } else {
28076                if($('.prod-option[data-option_mode="'+optionMode+'"] .prod-option-list > li').length > 0) {
28077                    $('#'+optionMode+'-option').prop('checked', true);
28078                }
28079            }
28080        });
28081    } else {
28082        $('.prod-option[data-option_mode="'+optionMode+'"]').addClass('hide');
28083    }
28084}
28085
28086$(function () {
28087    $(document).on('change', '.review-checkbox-check', function () {
28088        if ($(this).is(':checked') === true) {
28089            $(this).closest('.form-wrap').removeClass('disabled');
28090            $('.photo-review-tab').removeClass('hide'); 
28091        } else {
28092            $(this).closest('.form-wrap').addClass('disabled');
28093            $('.photo-review-tab').addClass('hide');
28094            $('.photo-review-top-view').addClass('hide');
28095            $('.photo-review-tab #use-review-img-upload').prop('checked',false);
28096            $('.photo-review-tab #photo-review').prop('checked',false);
28097        }
28098    });
28099
28100    $(document).on('change', '#use-review-img-upload', function () {
28101        if ($(this).is(':checked') === true) {
28102            $('.photo-review-top-view').removeClass('hide');
28103        } else {
28104            $('.photo-review-top-view').addClass('hide');
28105            $('.photo-review-tab #photo-review').prop('checked',false);
28106        }
28107    });
28108
28109    $(document).on('change', '.qna-checkbox-check', function () {
28110        if ($(this).is(':checked') === true) {
28111            $(this).closest('.form-wrap').removeClass('disabled');
28112        } else {
28113            $(this).closest('.form-wrap').addClass('disabled');
28114        }
28115    });
28116
28117    $(document).on('change', '.option-state-box .status-checkbox', function (e) {
28118        if($(this).attr('id') == 'normal-option') {
28119            var li = $('.prod-option[data-option_mode="normal"] .prod-option-list > li').slice(1);
28120            if(product_options.advanced == 'true' && li.length == 0) {
28121                $(this).prop('checked',false);
28122                // alert('고급 설정이 적용되어 있어 입력형 옵션과 추가 옵션은 고급 설정창에서 설정이 가능합니다');
28123                var modal = $(this).showModalFlat('','고급 설정이 적용되어 있어 입력형 옵션과 추가 옵션은 고급 설정창에서 설정이 가능합니다',true,false,'','ok','','cl-cmmodal cl-s-btn w560 cl-p130 cl-t80 cl-modal cl-none-title cl-close-btn','','',function() {
28124                    $(document).on('keydown', function(e) {
28125                        if(e.keyCode == 27) modal.modal('hide');
28126                    });
28127                });
28128                return false;
28129            }
28130            if ($(this).is(':checked') === true) {
28131                if(li.length == 0) {
28132                    var r = addProductOption('normal');
28133                    if(r == false) {
28134                        $('#normal-option').prop('checked', false);
28135                        return false;
28136                    }
28137                }
28138                $('.prod-option-tab').removeClass('hide');
28139                $('.prod-option[data-option_mode="normal"]').removeClass('hide');
28140                $('.prod-option[data-option_mode="normal"] .plus-price').removeClass('hide');
28141                $('.prod-option[data-option_mode="normal"] .plus-status').removeClass('hide');
28142                switchDownload('on'); //다운로드 파일        
28143            } else {         
28144                switchDownload('off'); //다운로드 파일
28145                // removeOptionModal(li, 'normal');
28146                if(li.length == 1 && li.find('.prod-option-item .prod-option-title').text() == '') {
28147                    li.remove();
28148                }
28149                $('.prod-option[data-option_mode="normal"]').addClass('hide');
28150            }
28151        } else if($(this).attr('id') == 'text-option') {
28152            if($('#download-product').is(':checked') === true) { //다운로드 상품
28153                alert('다운로드 상품은 입력옵션을 지원하지 않습니다.');
28154                $(this).prop('checked', false);
28155                return false;
28156            }
28157            var li = $('.prod-option[data-option_mode="text"] .prod-option-list > li');
28158            if(product_options.advanced == 'true' && li.length == 0) {
28159                $(this).prop('checked',false);
28160                // alert('고급 설정이 적용되어 있어 입력형 옵션과 추가 옵션은 고급 설정창에서 설정이 가능합니다');
28161                var modal = $(this).showModalFlat('','고급 설정이 적용되어 있어 입력형 옵션과 추가 옵션은 고급 설정창에서 설정이 가능합니다',true,false,'','ok','','cl-cmmodal cl-s-btn w560 cl-p130 cl-t80 cl-modal cl-none-title cl-close-btn','','',function() {
28162                    $(document).on('keydown', function(e) {
28163                        if(e.keyCode == 27) modal.modal('hide');
28164                    });
28165                });
28166                return false;
28167            }
28168            if ($(this).is(':checked') === true) {   
28169                $('.prod-option-tab').removeClass('hide');
28170                $('.prod-option[data-option_mode="text"]').removeClass('hide');
28171
28172                if(li.length == 0) addProductOption('text');
28173                if(li.length >= 7) {
28174                    $('.prod-option[data-option_mode="text"] > .prod-option-add').addClass('disabled');
28175                } else {
28176                    $('.prod-option[data-option_mode="text"] > .prod-option-add').removeClass('disabled');
28177                }
28178            } else {
28179                // removeOptionModal(li, 'text');
28180                if(li.length == 1 && li.find('.prod-option-item .prod-option-title').text() == '') {
28181                    li.remove();
28182                }
28183                $('.prod-option[data-option_mode="text"]').addClass('hide');
28184            }
28185        } else if($(this).attr('id') == 'additional-option') {
28186            if($('#download-product').is(':checked') === true) { //다운로드 상품
28187                alert('다운로드 상품은 추가옵션을 지원하지 않습니다.');
28188                $(this).prop('checked', false);
28189                return false;
28190            }
28191            var li = $('.prod-option[data-option_mode="additional"] .prod-option-list > li');
28192            if(product_options.advanced == 'true' && li.length == 0) {
28193                $(this).prop('checked',false);
28194                // alert('고급 설정이 적용되어 있어 입력형 옵션과 추가 옵션은 고급 설정창에서 설정이 가능합니다.');
28195                var modal = $(this).showModalFlat('','고급 설정이 적용되어 있어 입력형 옵션과 추가 옵션은 고급 설정창에서 설정이 가능합니다',true,false,'','ok','','cl-cmmodal cl-s-btn w560 cl-p130 cl-t80 cl-modal cl-none-title cl-close-btn','','',function() {
28196                    $(document).on('keydown', function(e) {
28197                        if(e.keyCode == 27) modal.modal('hide');
28198                    });
28199                });
28200                return false;
28201            }
28202
28203            if ($(this).is(':checked') === true) {
28204                $('.prod-option-tab').removeClass('hide');
28205                $('.prod-option[data-option_mode="additional"]').removeClass('hide');
28206                $('.prod-option[data-option_mode="additional"] .plus-price').removeClass('hide');
28207                $('.prod-option[data-option_mode="additional"] .plus-status').removeClass('hide');
28208
28209                if(li.length == 0) addProductOption('additional');
28210            } else {
28211                // removeOptionModal(li, 'additional');
28212                if(li.length == 1 && li.find('.prod-option-item .prod-option-title').text() == '') {
28213                    li.remove();
28214                }
28215
28216                $('.prod-option[data-option_mode="additional"]').addClass('hide');
28217            }
28218        }
28219
28220        if($('.switch-quantity').is(":checked") == true) {
28221            if($('#normal-option').is(':checked') === true) {
28222                // $('#prod-quantity').attr('readonly','true').removeClass('hide').attr('placeholder','옵션에서 재고 관리');
28223                $('.quantity-label').addClass('on');
28224                $('.plus-quantity').removeClass('hide');
28225            } else if($('#normal-option').is(':checked') === false && $('#additional-option').is(':checked') === true) {
28226                $('.quantity-label').removeClass('on');
28227                $('#prod-quantity').removeAttr('readonly').removeClass('hide');
28228                $('.plus-quantity').removeClass('hide');
28229            } else {
28230                $('.quantity-label').removeClass('on');
28231                $('#prod-quantity').removeAttr('readonly').removeClass('hide');
28232                $('.plus-quantity').addClass('hide');
28233            }
28234
28235        //     $parent.find('.prod-option-quantity, .edit-option-quantity').show();
28236        //     $parent.find('.plus-quantity').removeClass('hide');
28237        } else {
28238            $('.quantity-label').removeClass('on');
28239            $('#prod-quantity').addClass('hide');
28240            $('.prod-option-quantity, .prod-plus-quantity, .edit-option-quantity').hide();
28241            $('.plus-quantity').addClass('hide');
28242        }
28243
28244        if($('.prod-option-tab .prod-option.hide').length == 3) { //탭 모두 비활성화일때
28245            $('.prod-option-tab').addClass('hide');
28246            if(product_options.advanced == 'true')
28247                $('.reset-wrap').addClass('hide');
28248            if($('.switch-quantity').is(":checked") == true) {
28249                $('.quantity-label').removeClass('on');
28250            }
28251        } else {
28252            if(product_options.advanced == 'true')
28253                $('.reset-wrap').removeClass('hide');
28254        }
28255    });
28256
28257    $(document).on('click','.btn-fblogin.btn-warning', function(e) {
28258        var facebook_disabled_str = '\
28259        <div class="text-left" style="padding: 20px 15px;"><br>\
28260        ' + $.lang[LANG]['config.modal.fblogin.error.1'] + '\
28261            <ol style="padding-inline-start: 15px; margin-top: 10px; line-height: 2;">\
28262            ' + $.lang[LANG]['config.modal.fblogin.error.2'] + '\
28263            </ol>\
28264        ' + $.lang[LANG]['config.modal.fblogin.error.3'] + '\
28265        </div>';
28266
28267        $(this).showModalFlat('INFORMATION',facebook_disabled_str,true,false,'','ok','','w555');
28268    });
28269
28270    //$(document).off('click', '#etc-start-date.etc_date');
28271    // $(document).on('click', '#etc-start-date-txt', function (e) {
28272    //     $('.cl_etc_date_time').each(function () {
28273    //         $(this).removeClass('active');
28274    //     });
28275
28276    //     if($('#etc-start-date-picker').css('display') == 'block') {
28277    //         $(this).removeClass('active');
28278    //         $('#etc-start-date-picker').hide();
28279    //     } else {
28280    //         $('.etc-date').removeClass('active');
28281    //         $(this).addClass('active');
28282    //         $('#etc-start-date-picker').show();
28283    //     }
28284    //     $('#etc-end-date-picker').hide();
28285    //     $('#etc-except-date-picker').hide();
28286            
28287    //     $('#select-calendar').val('etc-start-date');
28288    //     startPicker.generateDates();
28289    //     var i = 0;
28290    //     var width = 0;
28291    //     $('#etc-end-date-picker .Datepickk .d-table input + label').each(function () {
28292    //         if (i == 0) width = $(this).width();
28293    //         $(this).css('height', width+'px');
28294    //         i++;
28295    //     });
28296    //     var i = 0;
28297    //     var width = 0;
28298    //     $('#etc-start-date-picker .Datepickk .d-table input + label').each(function () {
28299    //         if (i == 0) width = $(this).width();
28300    //         $(this).css('height', width+'px');
28301    //         i++;
28302    //     });
28303    // });
28304
28305    // $(document).on('click', '#etc-end-date-txt', function () {
28306    //     $('.cl_etc_date_time').each(function () {
28307    //         $(this).removeClass('active');
28308    //     });
28309
28310    //     if($('#etc-end-date-picker').css('display') == 'block') {
28311    //         $(this).removeClass('active');
28312    //         $('#etc-end-date-picker').hide();
28313    //     } else {
28314    //         $('.etc-date').removeClass('active');
28315    //         $(this).addClass('active');
28316    //         $('#etc-end-date-picker').show();
28317    //     }
28318
28319    //     $('#etc-start-date-picker').hide();
28320    //     $('#etc-except-date-picker').hide();
28321
28322    //     $('#select-calendar').val('etc-end-date');
28323    //     endPicker.generateDates();
28324    //     var i = 0;
28325    //     var width = 0;
28326    //     $('#etc-end-date-picker .Datepickk .d-table input + label').each(function () {
28327    //         if (i == 0) width = $(this).width();
28328    //         $(this).css('height', width+'px');
28329    //         i++;
28330    //     });
28331    //     var i = 0;
28332    //     var width = 0;
28333    //     $('#etc-start-date-picker .Datepickk .d-table input + label').each(function () {
28334    //         if (i == 0) width = $(this).width();
28335    //         $(this).css('height', width+'px');
28336    //         i++;
28337    //     });
28338    // });
28339
28340    // $(document).on('click', '#etc-except-date', function () {
28341    //     $('.unselect-all').remove();
28342        
28343    //     if($('#etc-except-date-picker').css('display') == 'block') {
28344    //         $(this).removeClass('active');
28345    //         $('#etc-except-date-picker').hide();
28346    //     } else {
28347    //         $('.etc-date').removeClass('active');
28348    //         $(this).addClass('active');
28349    //         $('#etc-except-date-picker').show();
28350    //         $('#etc-except-date-picker').append('<div class="unselect-all"><svg viewBox="0 0 24 24" width="24" height="24"><path d="M12 5c-3.64 0-6.63 2.78-6.97 6.33L3.35 9.65l-0.71 0.71 2.85 2.85 2.85-2.85L7.65 9.65l-1.59 1.59C6.43 8.29 8.95 6 12 6c3.31 0 6 2.69 6 6s-2.69 6-6 6c-1.66 0-3.17-0.68-4.26-1.78l-0.71 0.71C8.3 18.21 10.06 19 12 19c3.87 0 7-3.13 7-7S15.87 5 12 5z"/></svg> 초기화</div>');
28351    //         displaySelectedDates();
28352    //     }
28353
28354    //     $('#etc-start-date-picker').hide();
28355    //     $('#etc-end-date-picker').hide();
28356
28357    //     setExceptPicker();
28358    //     // exceptPicker.generateDates(true);
28359    //     var i = 0;
28360    //     var width = 0;
28361    //     $('#etc-except-date-picker .Datepickk .d-table input + label').each(function () {
28362    //         if (i == 0) width = $(this).width();
28363    //         $(this).css('height', width+'px');
28364    //         i++;
28365    //     });
28366
28367
28368    // });
28369
28370    // $(document).on('click', '#etc-except-date-picker .unselect-all', function (e) {
28371    //     e.preventDefault();
28372    //     exceptPicker.unselectExceptAll();
28373    //     //exceptPicker.generateDates(true);
28374    //     setExceptPicker();
28375    //     $('#etc-except-date').val('-');
28376    //     $('.etc-except-date-status').text('');
28377    //     $(this).addClass('disabled');
28378    // });
28379
28380    
28381
28382    $(document).on('click', '.email-add-box:not(.disabled)', function(e){
28383
28384        if (!$(e.target).is('.email-box')) {
28385            $('#email-add-input').focus();
28386        }
28387    });
28388
28389    $(document).on('keydown', '.email-add-box:not(.disabled) #email-add-input', function (e) {
28390        var keyCode = e.keyCode || e.which;
28391        if (keyCode == 9 || keyCode == 13) {
28392            e.preventDefault();
28393            enterEmailBox($(this), 'add');
28394        }
28395    });
28396
28397    $(document).on('click', function(e) {
28398        if($('#email-add-input').length > 0 && !$(e.target).is('#email-add-input')) {
28399            e.stopPropagation();
28400            enterEmailBox($('#email-add-input'), 'add');
28401        }
28402    });
28403
28404    $(document).on('click', '.email-add-box:not(.disabled) .email-box-delt', function (e) {
28405        e.stopPropagation();
28406        enterEmailBox($(this), 'delete');
28407    });
28408
28409    $(document).on('click', '.email-add-box:not(.disabled) .email-box', function (e) {
28410
28411        e.stopPropagation();
28412
28413        var textWidth = $(this).find('.email-text').width();
28414        var emailTextInput = $(this).find('.email-text-input');
28415        var otherBox = $('.email-box').not(this); //선택한 박스 외 다른 박스
28416        var emailBox = enterEmailBox(otherBox.find('.email-text-input.active input'), 'modify');
28417        if (emailBox) {
28418            otherBox.find('.email-text').removeClass('hidden');
28419            otherBox.find('.email-text-input').addClass('hidden');
28420            otherBox.find('.email-text-input').removeClass('active');
28421        }
28422        if(emailTextInput.hasClass('hidden')) {
28423            $(this).find('.email-text').addClass('hidden');
28424            emailTextInput.removeClass('hidden');
28425            emailTextInput.addClass('active');
28426            emailTextInput.find('input').css('width', textWidth+'px');
28427            emailTextInput.find('input').focus();
28428        }
28429    });
28430
28431    $(document).on('keydown', '.email-box', function (e) {
28432        var keyCode = e.keyCode || e.which;
28433        if (keyCode == 9 || keyCode == 13) {
28434            var emailBox = enterEmailBox($('.email-text-input').not('.hidden').find('input'), 'modify');
28435
28436            if (emailBox) {
28437                $(this).find('.email-text').removeClass('hidden');
28438                $(this).find('.email-text-input').addClass('hidden');
28439            }
28440        }
28441    });
28442
28443    $(document).on('click', function (e) {
28444        if (!$(e.target).is('.email-box')) {
28445            e.stopPropagation();
28446            var emailBox = enterEmailBox($('.email-text-input.active input'), 'modify');
28447
28448            if (emailBox) {
28449                $(this).find('.email-text').removeClass('hidden');
28450                $(this).find('.email-text-input').addClass('hidden');
28451                $(this).find('.email-text-input').removeClass('active');
28452            }
28453        }
28454    });
28455    // if ($('#email-line-box').length > 0) {
28456    //     var name = $('#email-line-box').attr('name');
28457    //     var className = $('#email-line-box').attr('class');
28458    //     var value = $('#email-line-box').val();
28459
28460    //     var emailList = value.split(',');
28461
28462    //     var html = '\
28463    //         <input type="hidden" id="email-line-box" name="'+name+'" class="'+className+'" value="'+value+'">\
28464    //         <div class="email-add-box">\
28465    //             <input type="text" id="email-add-input">\
28466    //         </div>\
28467    //     ';
28468    //     $('#email-line-box').before(html);
28469
28470    //     var html = '';
28471    //     if (emailList.length >= 1) {
28472    //         if (emailList[0] != '') {
28473    //             for (var i=0;i<emailList.length;i++) {
28474    //                 html += '<div class="email-box">'+emailList[i]+'<span class="email-box-delt"><svg viewBox="0 0 8 8"><polygon points="8 0.71 7.29 0 4 3.29 0.71 0 0 0.71 3.29 4 0 7.29 0.71 8 4 4.71 7.29 8 8 7.29 4.71 4 "/></svg></span></div>'
28475    //             }
28476
28477    //             $('#email-add-input').before(html);
28478    //             var boxWidth = 0;
28479    //             $('.email-add-box .email-box').each(function () {
28480    //                 boxWidth += $(this).innerWidth() + 10;
28481    //             });
28482    //             var textWidth = $('#email-add-input').parent().innerWidth() - 20,
28483    //                 uni = 'px';
28484
28485    //             var totalWidth = textWidth - boxWidth;
28486
28487    //             if (totalWidth <= 40) {
28488    //                 totalWidth = 100;
28489    //                 uni = '%'
28490    //             }
28491
28492    //             $('#email-add-input').css('width', totalWidth+uni);
28493    //         }
28494    //     }
28495    //     $('#email-line-box').remove();
28496    // } L.20211008.
28497
28498    $(document).on('click', '.fitem-category', function (e) {
28499        if(typeof handleIconStorageCategoryClick == 'function') {
28500            handleIconStorageCategoryClick($(this));
28501            return;
28502        }
28503
28504        var quick_category = $(this).attr('data-category');
28505        $(this).addClass('active').siblings('.fitem-category').removeClass('active');
28506        getIconImage(quick_category);
28507    });
28508});
28509
28510function enterEmailBox (el, mode) {
28511    var regExp = /^[0-9a-zA-Z]([-_\.]?[0-9a-zA-Z])*@[0-9a-zA-Z]([-_\.]?[0-9a-zA-Z])*\.[a-zA-Z]{2,3}$/i;
28512    if(mode == 'add' || mode == 'modify') {
28513        var val = (typeof el.val() !== 'undefined')? el.val().trim() : '';
28514        if (val == '') return true;
28515        if(!regExp.test(val)) {
28516            // alert('이메일 형식이 올바르지 않습니다.');
28517            var modal = $(this).showModalFlat('','이메일 형식이 올바르지 않습니다.',true,false,function() {
28518                    modal.modal('hide');
28519                },'ok','','cl-cmmodal cl-s-btn w560 cl-p130 cl-t80 cl-modal cl-none-title cl-close-btn','','',function() {
28520                $(document).on('keydown', function(e) {
28521                    if(e.keyCode == 27) modal.modal('hide');
28522                });
28523            });
28524            el.val('');
28525            el.focus();
28526            return false;
28527        }
28528        var flag = true;
28529        $('.email-text').not('.hidden').each(function(idx, v) {
28530            if($(v).text() == val) {
28531                // alert('이미 등록된 이메일입니다.');
28532                var modal = $(this).showModalFlat('','이미 등록된 이메일입니다.',true,false,function() {
28533                    modal.modal('hide');
28534                },'ok','','cl-cmmodal cl-s-btn w560 cl-p130 cl-t80 cl-modal cl-none-title cl-close-btn','','',function() {
28535                    $(document).on('keydown', function(e) {
28536                        if(e.keyCode == 27) modal.modal('hide');
28537                    });
28538                });
28539                el.val('');
28540                el.focus();
28541                flag = false;
28542                return false;
28543            }
28544        });
28545
28546        if(flag === false) {
28547            return false;
28548        }
28549    }
28550
28551    if(mode == 'add') {
28552        var html = '<div class="email-box">\
28553        <div class="email-text">'+val+'</div>\
28554        <div class="email-text-input hidden"><input type="text" value="'+val+'"></div>\
28555        <span class="email-box-delt"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path d="M4.06 3 3 4.06 6.94 8 3 11.94 4.06 13 8 9.06 11.94 13 13 11.94 9.06 8 13 4.06 11.94 3 8 6.94z"/></svg></span>\
28556        </div>';
28557               
28558        if($('.email-box').length < 5) { //이메일 최대 5개까지
28559            el.before(html);
28560        }
28561        el.val('');
28562    } else if (mode == 'delete') {
28563        if($('.email-box').length <= 1) {
28564            alert('관리자 수신메일은 최소 1개 이상 등록되어 있어야 합니다.');
28565            return false;
28566        }
28567        el.parent().remove();
28568    } else if (mode == 'modify') {
28569        var emailBox = el.closest('.email-box').find('.email-text');
28570        emailBox.text(val);
28571    } else {
28572        return false;
28573    }
28574    
28575    var emailArr = new Array();
28576    $('.email-add-box .email-box .email-text').each(function () {
28577        emailArr.push($(this).text());
28578    });
28579    console.log(emailArr);
28580    $('#email-line-box').val(emailArr.join(','))
28581
28582    if($('.email-box').length >= 5) {
28583        $('#email-add-input').remove();
28584    } else {
28585        if($('#email-add-input').length == 0) {
28586            $('.email-add-box').append('<input type="text" id="email-add-input">');
28587        }
28588        if (mode != 'modify') {
28589            $('#email-add-input').focus();
28590        }
28591    }
28592
28593    return true;
28594}
28595
28596function enterGeneralBox (el, mode){
28597    var regExp = /^[0-9+]+$/;    
28598    if(mode == 'add' || mode == 'modify') {
28599
28600        var val = (typeof el.val() !== 'undefined')? el.val().trim() : '';//value 체크        
28601        val = val.replace(/ /g,""); 
28602        if (val == '') return true; //입력내용 비어있으면 종료
28603
28604    // console.log(val.replace('+',''));
28605    // console.log(val.replace('+','').length);
28606        if ( val.replace('+','').length < 10 || val.replace('+','').length > 15) {           
28607
28608                    siteNotice('kakao_number_length');
28609                    el.val('');
28610                    el.focus();
28611                    return false;            
28612        }
28613        if(!regExp.test(val)) {
28614                siteNotice('kakao_onlynumber');
28615                el.val('');
28616                el.focus();
28617                return false;
28618        }
28619        var flag = true;
28620        
28621        $('.generalnum-text').not('.hidden').each(function(idx, v) {
28622            
28623            if($(v).text().replace('+','') == val.replace('+','')) {
28624                // alert('이미 등록 된 이메일입니다.');
28625                siteNotice('kakao_dupnumber');
28626                el.val('');
28627                el.focus();
28628                flag = false;
28629                return false;
28630            }
28631        });
28632
28633        if(flag === false) {
28634            return false;
28635        }
28636    }
28637    if(mode == 'add') {
28638
28639        //0206 18:00 working..
28640        if(val.substring(0, 1) == '0'){
28641            var firststring_delete = val.substring(1);
28642            var sliceValue ='';        
28643            var text_array = new Array();
28644                firststring_delete = '+82'+firststring_delete;
28645                
28646                $('.generalnum-text').each(function(idx, v) {           
28647                    sliceValue = text_array.push($(v).text());
28648                });
28649        } else if(val.slice(0,2) =='82' || val.slice(0,3) =='+82'){
28650            if(val.slice(0,1) == '+') val = val.substring(1);
28651
28652            var firststring_delete = val.substring(2);
28653            var sliceValue =''; 
28654                firststring_delete = '0'+firststring_delete;
28655                   
28656            var text_array = new Array();
28657                $('.generalnum-text').each(function(idx, v) {           
28658                    sliceValue = text_array.push($(v).text());
28659                });            
28660        } else {
28661            var firststring_delete = val;
28662            var text_array = new Array();
28663
28664        } 
28665            if(text_array.includes(firststring_delete)){
28666                var modal = $(this).showModalFlat('',$.lang[LANG]['shopping.dashboard.kakaoNotice.dupnumber'],true,false,function() {
28667                    modal.modal('hide');
28668                },'ok','','cl-cmmodal cl-s-btn w560 cl-p130 cl-t80 cl-modal cl-none-title cl-close-btn','','',function() {
28669                    $(document).on('keydown', function(e) {
28670                        if(e.keyCode == 27) modal.modal('hide');
28671                    });
28672                });                
28673                el.val('');
28674                el.focus();                
28675                return false ;
28676            }
28677       
28678        //0206 18:00 working..
28679
28680        
28681        let val_chk = val.substring(0, 1);
28682        if(val_chk !== '0' && val_chk !=='+'){
28683            val = '+'+val;
28684        }           
28685        var html = '<div class="generalnum-box">\
28686        <div class="generalnum-text">'+val+'</div>\
28687        <div class="generalnum-text-input hidden"><input type="text" value="'+val+'"></div>\
28688        <span class="generalnum-box-delt"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path d="M4.06 3 3 4.06 6.94 8 3 11.94 4.06 13 8 9.06 11.94 13 13 11.94 9.06 8 13 4.06 11.94 3 8 6.94z"/></svg></span>\
28689        </div>';
28690               
28691        
28692       el.before(html);
28693           
28694        el.val('');
28695    } else if (mode == 'delete') {
28696
28697        // if($('.generalnum-box').length <= 1) {
28698        //   $(this).siblings(input);
28699        // }         
28700        el.parent().remove();
28701    } 
28702    else if (mode == 'modify') {
28703        // if(val.substring(0, 1) == '0'){
28704        //     var firststring_delete = val.substring(1);
28705        //     var sliceValue ='';        
28706        //     var text_array = new Array();
28707        //         firststring_delete = '+82'+firststring_delete;
28708        //         $('.generalnum-text').each(function(idx, v) {           
28709        //             sliceValue = text_array.push($(v).text());
28710        //         });
28711        // }
28712
28713        if(val.substring(0, 1) == '0'){
28714            var firststring_delete = val.substring(1);
28715            var sliceValue ='';        
28716            var text_array = new Array();
28717                firststring_delete = '+82'+firststring_delete;
28718                
28719                $('.generalnum-text').each(function(idx, v) {           
28720                    sliceValue = text_array.push($(v).text());
28721                });
28722        } else if(val.slice(0,2) =='82' || val.slice(0,3) =='+82'){     
28723          if(val.slice(0,1) == '+') val = val.substring(1);       
28724            var firststring_delete = val.substring(2);
28725            var sliceValue =''; 
28726                firststring_delete = '0'+firststring_delete;
28727                   
28728            var text_array = new Array();
28729                $('.generalnum-text').each(function(idx, v) {           
28730                    sliceValue = text_array.push($(v).text());
28731                });            
28732        } else {
28733            var firststring_delete = val;
28734            var text_array = new Array();
28735
28736        }         
28737            if(text_array.includes(firststring_delete)){
28738                var modal = $(this).showModalFlat('',$.lang[LANG]['shopping.dashboard.kakaoNotice.dupnumber'],true,false,function() {
28739                    modal.modal('hide');
28740                },'ok','','cl-cmmodal cl-s-btn w560 cl-p130 cl-t80 cl-modal cl-none-title cl-close-btn','','',function() {
28741                    $(document).on('keydown', function(e) {
28742                        if(e.keyCode == 27) modal.modal('hide');
28743                    });
28744                });                
28745                el.val('');
28746                el.focus();                
28747                return false ;
28748            }
28749       
28750
28751        
28752        let val_chk = val.substring(0, 1);
28753        if(val_chk !== '0' && val_chk !=='+'){
28754            val = '+'+val;
28755        }      
28756        var emailBox = el.closest('.generalnum-box').find('.generalnum-text');
28757        emailBox.text(val);
28758       
28759    } else {
28760        return false;
28761    }
28762
28763
28764 var emailArr = new Array();
28765    $('.generalnum-add-box .generalnum-box .generalnum-text').each(function () {
28766        emailArr.push($(this).text());
28767    });
28768    
28769    $('#generalnum-line-box').val(emailArr.join(','))
28770    $('#generalnum-add-input').remove();
28771
28772    (LANG =='ko') ? LangPlaceholderNumber = '번호를 입력해주세요.' : LangPlaceholderNumber = 'Please enter the Number.';
28773   
28774        if($('#generalnum-add-input').length == 0) {
28775            $('.generalnum-add-box').append('<input type="text" id="generalnum-add-input">');
28776            if ($('.generalnum-box').length == 0) {
28777                $('#generalnum-add-input').attr('placeholder',LangPlaceholderNumber)
28778            }
28779        }
28780        if (mode != 'modify') {
28781            $('#generalnum-add-input').focus();
28782        }
28783    
28784
28785    return true;    
28786}
28787
28788    $(document).on('click', function(e) {
28789        if($('#generalnum-add-input').length > 0 && !$(e.target).is('#generalnum-add-input')) {
28790            e.stopPropagation();
28791            enterGeneralBox($('#generalnum-add-input'), 'add');
28792           
28793        }
28794    });
28795
28796    $(document).on('keydown', '#generalnum-add-input', function (e) {
28797        var keyCode = e.keyCode || e.which;
28798        if (keyCode == 9 || keyCode == 13) {
28799            e.preventDefault();
28800            enterGeneralBox($(this), 'add');
28801        }
28802    });
28803
28804    $(document).on('click', '.generalnum-box', function (e) {
28805        e.stopPropagation();
28806        var textWidth = $(this).find('.generalnum-text').width();
28807        var emailTextInput = $(this).find('.generalnum-text-input');
28808        var otherBox = $('.generalnum-box').not(this); //선택한 박스 외 다른 박스
28809        var emailBox = enterGeneralBox(otherBox.find('.generalnum-text-input.active input'), 'modify');
28810        if (emailBox) {
28811            otherBox.find('.generalnum-text').removeClass('hidden');
28812            otherBox.find('.generalnum-text-input').addClass('hidden');
28813            otherBox.find('.generalnum-text-input').removeClass('active');
28814        }
28815        if(emailTextInput.hasClass('hidden')) {
28816            $(this).find('.generalnum-text').addClass('hidden');
28817            emailTextInput.removeClass('hidden');
28818            emailTextInput.addClass('active');
28819            emailTextInput.find('input').css('width', textWidth+'px');
28820            emailTextInput.find('input').focus();
28821        }
28822    });
28823
28824    $(document).on('click', '.generalnum-add-box', function(e){
28825        if (!$(e.target).is('.generalnum-box')) {
28826
28827            $('#generalnum-add-input').focus();
28828        }
28829    });
28830
28831   $(document).on('keydown', '.generalnum-box', function (e) {
28832        var keyCode = e.keyCode || e.which;
28833        if (keyCode == 9 || keyCode == 13) {
28834            $(this).find('.generalnum-text-input').removeClass('active');
28835            var emailBox = enterGeneralBox($('.generalnum-text-input').not('.hidden').find('input').not(this), 'modify');
28836
28837            if (emailBox) {
28838                $(this).find('.generalnum-text-input').addClass('hidden');
28839                $(this).find('.generalnum-text').removeClass('hidden');
28840
28841            }
28842        }
28843    });
28844
28845    $(document).on('click', function (e) {
28846        if (!$(e.target).is('.generalnum-box')) {
28847            e.stopPropagation();
28848            var emailBox = enterGeneralBox($('.generalnum-text-input.active input'), 'modify');
28849
28850
28851            if (emailBox) {
28852                $(this).find('.generalnum-text').removeClass('hidden');
28853                $(this).find('.generalnum-text-input').addClass('hidden');
28854                $(this).find('.generalnum-text-input').removeClass('active');
28855            }
28856        }
28857    });    
28858
28859    $(document).on('click', '.generalnum-box-delt', function (e) {
28860        e.stopPropagation();
28861        enterGeneralBox($(this), 'delete');
28862    });
28863
28864
28865function emailLineFunc () {
28866    var emailBox = enterEmailBox($('#email-add-input'), 'add');
28867    
28868    if ($('.email-box.none').length > 0) {
28869        alert('옳바르지 않은 이메일 주소가 포함되어있습니다.');
28870        return false;
28871    }
28872    
28873    if (emailBox === false) {
28874        $('#email-add-input').focus();
28875        return false;
28876    }
28877
28878    return true;
28879}
28880
28881function division (option, n) {
28882    var arr = option;
28883    var len = arr.length;
28884    var cnt = Math.floor(len / n) + (Math.floor(len % n) > 0 ? 1 : 0);
28885    var tmp = [];
28886
28887    for (var i=0;i<cnt;i++) {
28888        tmp.push(arr.splice(0, n));
28889    }
28890
28891    return tmp;
28892}
28893
28894function truncateReviewTitle (reviewArr) { //상품후기 제목 자르기
28895    $('.s-table-review .review-content>div').each(function(idx, item){
28896        var reviewContent = reviewArr[idx];
28897        
28898        if(reviewContent !== undefined) {
28899            $(this).html(reviewContent);
28900
28901            for(var i = reviewContent.length; i > 0; i--){
28902                if($(this).height() > 60) {
28903                    $(this).html(reviewContent.substr(0, i));
28904                    $(this).append('...');
28905                }
28906                else {
28907                    break;
28908                }
28909            }
28910        }
28911    });
28912}
28913
28914function nl2br (str, is_xhtml) {
28915    if (typeof str === 'undefined' || str === null) {
28916        return '';
28917    }
28918    var breakTag = (is_xhtml || typeof is_xhtml === 'undefined') ? '<br />' : '<br>';
28919    return (str + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1' + breakTag + '$2');
28920}
28921
28922function extra_charge_info($obj, status, free_flag, change_flag) {
28923    $(".order-cancel-content.extra-info").remove();
28924    var s = '\
28925    <div class="order-cancel-content extra-info">\
28926        <div class="cancel-info-box">\
28927            <p class="error">\
28928            ' + (free_flag ? '- 결제 당시 무료배송 조건을 충족하지 못해 배송료가 발생 할 수 있습니다.<br>' : '' ) + '\
28929            ' + (change_flag ? '- 주문 상품 ' + (status == 'C' ? '취소' : '반품') + ' 시 배송비 조건에 따라 배송비가 달라질 수 있습니다.<br>' : '') + '\
28930            - 자세한 사항은 판매자의 안내를 따라주세요.\
28931            </p>\
28932        </div>\
28933    </div>\
28934    ';
28935    if(free_flag || change_flag) {
28936        if($obj.find(".modal-comment.point-used-desc").length) {
28937            $obj.find(".modal-comment.point-used-desc").before(s);
28938        } else {
28939            $obj.append(s);
28940        }
28941    }
28942}
28943
28944function setCLEscrowFooter(sid,plantype,obj) {
28945    if(typeof sid == 'undefined') return false;
28946
28947    if( typeof plantype == 'undefined' || plantype != 'SM' || 
28948        typeof obj == 'undefined' || 
28949        typeof obj.onoff == 'undefined' || !obj.onoff || obj.onoff === false ||
28950        typeof obj.key == 'undefined' || !obj.key || obj.key == ''
28951    ) {
28952        $('.el-footer').find('.escrow-image-wrap-box').remove();
28953        return false;
28954    }
28955
28956    var escrow_img = (typeof obj.type != 'undefined' && obj.type) ? obj.type : 1,
28957        escrow_key = obj.key,
28958        checkCLEscrowFooter = ($('.el-footer').find('.escrow-image-wrap-box').length > 0) ? true : false,
28959        checkCLFooter = ($('.el-footer').find('.cl-footer-site-element').length > 0) ? true : false;
28960    
28961    var escrow_link = '';
28962    if(obj.pg_company == 'KCP') {
28963        escrow_img = '<img src="//storage.googleapis.com/i.addblock.net/shopping_mall/escrow_site/escrow_site0' + escrow_img + '.png" />';
28964        escrow_link = '//admin.kcp.co.kr/Modules/escrow/kcp_pop.jsp?site_cd=' + escrow_key;
28965    } else if(obj.pg_company == 'NICEPAY') {
28966        escrow_img = '<img src="//storage.googleapis.com/i.addblock.net/shopping_mall/escrow_setting/nicepay_escrow_setting0' + escrow_img + '.png" />';
28967        escrow_link = 'https://npg.nicepay.co.kr/issue/issueEscrow.do?Mid=' + escrow_key + '&CoNo=' + obj.b_number.replace(/-/g,'');
28968    }
28969        
28970    var clef_str = '\
28971            <div class="escrow-image-wrap">\
28972                <a href="' + escrow_link + '" target="_blank">\
28973                    ' + escrow_img + '\
28974                </a>\
28975            </div>\
28976    ';
28977
28978    if(checkCLEscrowFooter) {
28979        $('.el-footer').find('.escrow-image-wrap-box').html('<br>'+clef_str);
28980    } else if(checkCLFooter) {
28981        $('.el-footer').find('.escrow-image-wrap').remove();
28982        $('.el-footer').find('.cl-footer-site-element').last().append('<br><div class="escrow-image-wrap-box">'+clef_str+'</div>');
28983    } else {
28984        $('.el-footer').find('.container .row').last().append('<div class="col-xs-12 col-sm-12 col-md-12 clearfix clear escrow-image-wrap-box"><br>' + clef_str + '</div>');
28985    }
28986}
28987
28988
28989function setConfigLogs(action,v,obj,page) {
28990    $.post('/adm/clog/set', { action : action, v : v , obj : (typeof obj == 'object' && Object.keys(obj).length > 0) ? JSON.stringify(obj) : obj, page : page }, function(data) {
28991        if(typeof data.error != 'undefined' && data.error) {
28992            console.log(data.error);
28993            return false;
28994        }
28995    },'json');
28996}
28997
28998function setSiteLogs(action,v,obj,page,ref) {
28999    $.post('/slog/set', { action : action, v : v , obj : (typeof obj == 'object' && Object.keys(obj).length > 0) ? JSON.stringify(obj) : obj, page : page, ref : ref }, function(data) {
29000        if(typeof data.error != 'undefined' && data.error) {
29001            console.log(data.error);
29002            return false;
29003        }
29004    },'json');
29005}
29006
29007function getProductInfoList() {
29008    var input_empty = false,
29009        cate_null = false,
29010        idx = 0,
29011        prod_info_cate = $('.prod-select-title').text().trim(),
29012        $prod_info_lists = $('.prod-lists > div'),
29013        prod_info = {
29014            'title' : prod_info_cate,
29015            'content' : []
29016        };
29017        prod_null = new Array();
29018
29019    if(prod_info_cate=='선택하세요') {
29020        cate_null = true;
29021    }
29022
29023    $.each($prod_info_lists, function(i,v) {
29024        if($(this).hasClass('prod-info-list-save')) return true;
29025
29026        var info_list_title = $(this).find('label').text(),
29027            info_list_content = ($(this).find('.prod-input-value').length > 0) ? $(this).find('.prod-input-value').html().trim() : '';
29028        if(info_list_content.length > 0) info_list_content = info_list_content.replace(/&nbsp;/gi, '');
29029
29030        if(info_list_content.length==0) { 
29031            idx = i;
29032            input_empty = true;
29033            prod_null.push(idx);
29034        }
29035        var s = { 
29036            'title' : info_list_title,
29037            'content' : info_list_content
29038        }
29039        prod_info.content.push(s);
29040    });
29041    prod_info.input_empty = input_empty;
29042    prod_info.input_idx = idx;
29043    prod_info.cate_null = cate_null;
29044    return prod_info;
29045}
29046
29047function setOptionlist($data, func) {
29048    var check_quantity = $('.prod-detail-wrap .switch-quantity').prop('checked'),
29049        normal_options_count = 0;
29050
29051    $.each($data, function(idx,o) { //상품옵션 로드
29052        switch(o.option_status) {
29053            case "S" : str = '판매'; break;
29054            case "O" : str = '품절'; break;
29055            case "H" : str = '숨김'; break;
29056            default : str = '판매'; o.option_status = 'S'; break;
29057        }
29058
29059        if(typeof o.option_quantity == 'undefined' || o.option_quantity == null) o.option_quantity = 0;
29060        if(typeof o.option_price == 'undefined' || o.option_price == null) o.option_price = 0;
29061
29062        var s = "";
29063        if(typeof o.option_type !='undefined' && o.option_type.indexOf('T') > -1) {
29064            s = '\
29065            <li>\
29066                <div class="prod-option-item">\
29067                    <span class="prod-option-title" data-seq="' + o.seq + '">' + o.option_name + '</span>\
29068                    <span class="prod-option-require" data-val="' + o.option_type + '">';
29069                s += '</span>\
29070                </div>\
29071                <div class="prod-option-edit hide">\
29072                    <div class="form-wrap">\
29073                        <div class="form-group edit-option-title">\
29074                            <input type="text" maxlength="20" placeholder="안내문구 입력 (예:두께를 mm단위로 입력해주세요.)"/>\
29075                        </div>\
29076                        <div class="edit-option-delete" data-seq="' + o.seq + '"><svg viewBox="0 0 12 13" width="12" height="13"><path d="M12 2h-1H9V0H3.02v2H1 0v1h1v8c0 1.1 0.9 2 2 2h6c1.1 0 2-0.9 2-2V3h1V2zM4.02 1H8v1H4.02V1zM10 11c0 0.55-0.45 1-1 1H3c-0.55 0-1-0.45-1-1V3h1.02H9h1V11z"/><rect x="4" y="4" width="1" height="7"/><rect x="7" y="4" width="1" height="7"/></svg></div>\
29077                    </div>\
29078                </div>';
29079        } else {
29080            var option_price = Number(o.option_price),
29081                only_price = Math.abs(option_price),
29082                str_price = only_price.toString(),
29083                str_quantity = (o.option_quantity).toString(),
29084                minus = (option_price < 0)? 'minus':'',
29085                option_name = o.option_name;
29086
29087                if(o.option_mix3) {
29088                    option_name = '<label class="owidth ow1">' + o.option_mix2 + '</label><label class="owidth ow2">' + o.option_mix3 + '</label><label class="owidth ow3">' + option_name + '</label>';
29089                } else {
29090                    if(o.option_mix2) {
29091                        option_name = '<label class="owidth ow1">' + o.option_mix2 + '</label><label class="owidth ow2">' + option_name + '</label>';
29092                    } else if(o.option_group) {
29093                        option_name = '<label class="owidth ow1">' + o.option_group + '</label><label class="owidth ow2">' + option_name + '</label>';
29094                    }
29095                }
29096            s = '\
29097            <li>\
29098                <div class="prod-option-item">\
29099                    <span class="prod-option-move cl-sort-handle">' + clSVG('move_handle', 20, 20) + '</span>\
29100                    <span class="prod-option-title" data-seq="' + o.seq + '">' + option_name + '</span>\
29101                    <span class="prod-option-price '+minus+'" data-option-price="'+o.option_price+'">' + addCommas(str_price) + '</span>\
29102                    <span class="prod-option-quantity" ' + ((check_quantity) ? '' : 'style="display:none"') + '>' + addCommas(str_quantity) + '</span>\
29103                    <span class="prod-option-status" data-val="' + o.option_status + '">' + str + '</span>\
29104                    <div class="edit-option-delete" data-seq="' + o.seq + '"><svg viewBox="0 0 12 13" width="12" height="13"><path d="M12 2h-1H9V0H3.02v2H1 0v1h1v8c0 1.1 0.9 2 2 2h6c1.1 0 2-0.9 2-2V3h1V2zM4.02 1H8v1H4.02V1zM10 11c0 0.55-0.45 1-1 1H3c-0.55 0-1-0.45-1-1V3h1.02H9h1V11z"/><rect x="4" y="4" width="1" height="7"/><rect x="7" y="4" width="1" height="7"/></svg></div>\
29105                </div>\
29106                <div class="prod-option-edit hide">\
29107                    <div class="form-wrap">\
29108                        <span class="prod-option-move cl-sort-handle">' + clSVG('move_handle', 20, 20) + '</span>\
29109                        <div class="form-group edit-option-title">\
29110                            <input type="text" maxlength="60" placeholder="옵션값"/>\
29111                        </div>\
29112                        <div class="form-group edit-option-price">\
29113                            <input type="text" class="option-price-number sign" placeholder="0" numberOnly/>\
29114                        </div>\
29115                        <div class="form-group edit-option-quantity" ' + ((check_quantity) ? '' : 'style="display:none"') + '>\
29116                            <input type="text" class="option-price-quantity" maxlength="5" placeholder="0" numberonly/>\
29117                        </div>\
29118                        <div class="form-group edit-option-select">\
29119                            <div class="option-price-status-str hand" data-val="' + o.option_status + '">' + str + '</div>\
29120                            <ul class="option-price-status-select">\
29121                                <li data-val="S">판매</li>\
29122                                <li data-val="O">품절</li>\
29123                                <li data-val="H">숨김</li>\
29124                            </ul>\
29125                        </div>\
29126                        <div class="edit-option-delete" data-seq="' + o.seq + '"><svg viewBox="0 0 12 13" width="12" height="13"><path d="M12 2h-1H9V0H3.02v2H1 0v1h1v8c0 1.1 0.9 2 2 2h6c1.1 0 2-0.9 2-2V3h1V2zM4.02 1H8v1H4.02V1zM10 11c0 0.55-0.45 1-1 1H3c-0.55 0-1-0.45-1-1V3h1.02H9h1V11z"/><rect x="4" y="4" width="1" height="7"/><rect x="7" y="4" width="1" height="7"/></svg></div>\
29127                    </div>\
29128                </div>';
29129                // console.log('option_type:'+o.option_type);
29130            if (o.product_state && o.option_type!='A' && o.option_type!='T') {
29131                var p_s_data = JSON.parse(o.product_state);
29132
29133                if (p_s_data.file_name) {
29134                    if (fileUpdateCnt == 0) fileUpdateCnt++;
29135                    if (loadFile == 0) loadFile++;
29136                    s += '<div class="form-group product-status">\
29137                            <div class="product-state-box">\
29138                                <div class="product-upload">\
29139                                    <div class="title">파일 업로드</div>\
29140                                    <div class="download-contents">\
29141                                        <span class="cl_icon_upload02" data-cnt="'+fileUpdateCnt+'">업로드</span>\
29142                                        <div class="file-box-list" id="file-box-'+fileUpdateCnt+'">';
29143
29144                                            var serverName = p_s_data.file_url.split('/');
29145                                            s += '<div class="file-name file-name-'+loadFile+'">\
29146                                                    <span class="real-file-name">'+p_s_data.file_name+'</span>\
29147                                                    <span class="file-name-detail" title="'+p_s_data.file_name+'">'+p_s_data.file_str_name+'</span>\
29148                                                    <span class="file-size">'+p_s_data.file_size+'</span>\
29149                                                    <span class="cl-icon cl_icon_close" data-cnt="'+loadFile+'" data-pn="'+o.product_number+'" data-file="'+serverName[8]+'" data-seq="'+o.seq+'"></span>\
29150                                                    <span class="file-url">'+p_s_data.file_url+'</span>\
29151                                                </div>';
29152                                            loadFile++;
29153
29154                    s += '              </div>\
29155                                    </div>\
29156                                </div>\
29157                            </div>\
29158                        </div>';
29159                }
29160            }
29161            fileUpdateCnt++;
29162        }
29163        s += "</li>";
29164
29165        optionLength = Object.keys($data).length;
29166        if($data.length == 1 && o.option_name=='noneOption') {
29167            $('.prod-option[data-option_mode="normal"] .prod-option-list').append(s);
29168        } else {      
29169            if(o.option_type !== undefined && o.option_type.indexOf('T') > -1) {
29170                if($data.length > 0) {
29171                    $('.prod-option[data-option_mode="text"] .prod-option-list').append(s);
29172                    $('.option-state-box .newcheckbox').eq(1).find('#text-option').prop('checked',true);
29173                    $('.prod-option-tab').removeClass('hide');
29174                    $('.prod-option[data-option_mode="text"]').removeClass('hide');
29175                }
29176            } else if(o.option_type == 'A') {
29177                if($data.length > 0) {
29178                    $('.prod-option[data-option_mode="additional"] .prod-option-list').append(s);
29179                    $('.option-state-box .newcheckbox').eq(2).find('#additional-option').prop('checked',true);
29180                    $('.prod-option-tab').removeClass('hide');
29181                    $('.prod-option[data-option_mode="additional"]').removeClass('hide');
29182                    $('.prod-option[data-option_mode="additional"] .plus-price').removeClass('hide');
29183                    $('.prod-option[data-option_mode="additional"] .plus-status').removeClass('hide');
29184
29185                }
29186            } else {
29187                $('.prod-option[data-option_mode="normal"] .prod-option-list').append(s);
29188                normal_options_count++;
29189                if(normal_options_count > 1) {
29190                    $('.option-state-box .newcheckbox').eq(0).find('#normal-option').prop('checked',true);
29191                    $('.prod-option-tab').removeClass('hide');
29192                    $('.prod-option[data-option_mode="normal"]').removeClass('hide');
29193                    $('.prod-option[data-option_mode="normal"] .plus-price').removeClass('hide');
29194                    $('.prod-option[data-option_mode="normal"] .plus-status').removeClass('hide');
29195                }
29196            }
29197        }
29198
29199        if($('.prod-option[data-option_mode="normal"] .prod-option-list > li').length == 1) {
29200            $('.prod-option[data-option_mode="normal"]').addClass('hide');
29201            $('.option-state-box .newcheckbox').eq(0).find('#normal-option').prop('checked',fal
29201se);
29202        }
29203        if($('.prod-option[data-option_mode="text"] .prod-option-list > li').length == 0) {
29204            $('.prod-option[data-option_mode="text"]').addClass('hide');
29205            $('.option-state-box .newcheckbox').eq(1).find('#text-option').prop('checked',false);
29206        }
29207        if($('.prod-option[data-option_mode="additional"] .prod-option-list > li').length == 0) {
29208            $('.prod-option[data-option_mode="additional"]').addClass('hide');
29209            $('.option-state-box .newcheckbox').eq(2).find('#additional-option').prop('checked',false);
29210        }
29211        
29212        $('#product-state').find('input[type="file"]').attr('data-cnt', loadFile).click();
29213    }); 
29214    
29215    if(typeof func == 'function') {
29216        func();
29217    }
29218}
29219
29220var setAdvancedMode = function(r) {
29221    if(r == "true") { // 고급모드
29222        $('.option-type-title.tp2, .option-type-title.tp3').removeClass('hide');
29223        $('.option-type-title3.tp2, .option-type-title3.tp3').removeClass('hide');
29224        $('.options-config').addClass('active');
29225        $('.prod-option-list').sortable('disable');
29226        $('.edit-option-title input').prop('disabled', true);
29227        $('.prod-option-move').addClass('invisible');
29228        $('.edit-option-delete').addClass('invisible');
29229        $('.prod-option-add').addClass('hide');
29230        $('.reset-wrap').removeClass('hide');
29231        $('.option-type-title.tp1').removeClass('editable');
29232        $('.prod-option[data-option_mode="text"] > .text-option-info').removeClass('editable');
29233        $('.prod-option[data-option_mode="text"] > .option-head').removeClass('editable');
29234        $('.option-type-title3.tp1').removeClass('editable');
29235    } else {
29236        $('.option-type-title.tp2, .option-type-title.tp3').addClass('hide');
29237        $('.option-type-title3.tp2, .option-type-title3.tp3').addClass('hide');
29238        $('.options-config').removeClass('active');
29239        $('.prod-option-list').sortable('enable');
29240        $('.edit-option-title input').prop('disabled', false);
29241        $('.prod-option-move').removeClass('invisible');
29242        $('.edit-option-delete').removeClass('invisible');
29243        $('.prod-option-add').removeClass('hide');
29244        $('.reset-wrap').addClass('hide');
29245        $('.option-type-title.tp1').addClass('editable');
29246        $('.prod-option[data-option_mode="text"] > .text-option-info').addClass('editable');
29247        $('.prod-option[data-option_mode="text"] > .option-head').addClass('editable');
29248        $('.option-type-title3.tp1').addClass('editable');
29249    }
29250    if($('.prod-option-tab .prod-option.hide').length == 3) { //탭 모두 비활성화일때
29251        $('.reset-wrap').addClass('hide');
29252    }
29253
29254    switch(product_options.type) {
29255        case "1": 
29256            $('.option-head-str').text('단일형');
29257            $('.option-type-title.tp1').text('옵션명');
29258            $('.option-type-title.tp2').text('옵션값');
29259            $('.option-type-title.tp3').text('');
29260            break;
29261        case "2": 
29262            $('.option-head-str').text('2개 조합형');
29263            if(product_options['config1'][0] !== undefined)
29264                $('.option-type-title.tp1').text(product_options['config1'][0]['title']).removeClass('editable');
29265            if(product_options['config1'][0] !== undefined)
29266                $('.option-type-title.tp2').text(product_options['config1'][0]['value']);
29267            $('.option-type-title.tp3').text('');
29268            break;
29269        case "3": 
29270            $('.option-head-str').text('3개 조합형');
29271            if(product_options['config1'][0] !== undefined)
29272                $('.option-type-title.tp1').text(product_options['config1'][0]['title']).removeClass('editable');
29273            if(product_options['config1'][0] !== undefined)
29274                $('.option-type-title.tp2').text(product_options['config1'][0]['value']);
29275            if(product_options['config1'][0] !== undefined)
29276                $('.option-type-title.tp3').text(product_options['config1'][0]['value2']);
29277            break;
29278        default:
29279            $('.option-head-str').text('기본형');
29280            $('.option-type-title.tp1').text('옵션명');
29281            $('.option-type-title.tp2').text('옵션값');
29282            $('.option-type-title.tp3').text('');
29283            break;            
29284    }
29285}
29286var switchQuantity = function() {
29287    if($('.switch-quantity').is(':checked')) {
29288        $('.switch-quantity').parents('.form-wrap').removeClass('disabled');
29289        $('.prod-option-quantity, .prod-plus-quantity, .edit-option-quantity').show();
29290
29291        if($('#normal-option').is(':checked') === true) {
29292            // $('#prod-quantity').attr('readonly','true').removeClass('hide').attr('placeholder','옵션에서 재고 관리');
29293            $('.quantity-label').addClass('on');
29294            $('.plus-quantity').removeClass('hide');
29295        } else if($('#normal-option').is(':checked') === false && $('#additional-option').is(':checked') === true) {
29296            $('.quantity-label').removeClass('on');
29297            $('#prod-quantity').removeAttr('readonly').removeClass('hide');
29298            $('.plus-quantity').removeClass('hide');
29299        } else {
29300            $('.quantity-label').removeClass('on');
29301            $('#prod-quantity').removeAttr('readonly').removeClass('hide');
29302            $('.plus-quantity').addClass('hide');
29303        }
29304    } else {
29305        $('.quantity-label').removeClass('on');
29306        $('.switch-quantity').parents('.form-wrap').addClass('disabled');
29307        $('#prod-quantity').addClass('hide');
29308        $('.prod-option-quantity, .prod-plus-quantity, .edit-option-quantity').hide();
29309        $('.plus-quantity').addClass('hide');
29310    }
29311}        
29312
29313function getMapURL(map_url, return_type) {
29314    /*
29315        https://www.google.co.kr/maps/@37.4817147,127.0069527,14z
29316        https://www.google.co.kr/maps/place/%EB%82%B4%EB%B0%A9%EC%97%AD/@37.4817147,127.0069527,14z/data=!4m5!3m4!1s0x357ca1a63a309789:0xb47e374059d4245b!8m2!3d37.487707!4d126.993598
29317        <iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3163.016222643161!2d126.96939075969449!3d37.554681575448!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x357ca266e3947003%3A0xe7be97c172b7af6a!2z7ISc7Jq47Jet!5e0!3m2!1sko!2skr!4v1628745599351!5m2!1sko!2skr" width="600" height="450" style="border:0;" allowfullscreen="" loading="lazy"></iframe>
29318    
29319
29320        https://www.google.com/maps/place/%EC%9D%B4%EC%88%98%EC%97%AD/@37.4857251,126.9797283,17z/data=!4m9!1m2!2m1!1z7J207IiY7Jet!3m5!1s0x357ca1b3e26dcf3d:0xa16abe6619550e35!8m2!3d37.486491!4d126.981876!15sCgnsnbTsiJjsl62SAQtidXNfc3RhdGlvbg?hl=ko
29321        https://www.google.com/maps/search/%EC%9D%B4%EC%88%98%EC%97%AD/@37.4857251,126.9797283,17z/data=!3m1!4b1?hl=ko
29322    */
29323    
29324
29325    var checkGoogle = (map_url.match(/^(https|http)\:\/\/www\.google(\.co\.kr|\.com)\/maps\//g) !== null) ? true : false;
29326    if(checkGoogle) {
29327        var checkEmbed = (map_url.match(/^(https|http)\:\/\/www\.google(\.co\.kr|\.com)\/maps\/embed\?/g) !== null) ? true : false,
29328            checkPlace = (map_url.match(/^(https|http)\:\/\/www\.google(\.co\.kr|\.com)\/maps\/(place|search)/g) !== null) ? true : false;
29329        if(checkEmbed) {
29330            var map_src = map_url;
29331        } else {
29332            var map_arr = map_url.replace(/^(https|http)\:\/\/www\.google(\.co\.kr|\.com)\/maps\//g,'').split('/'),
29333                map_tmp = (checkPlace) ? map_arr[2].split(',') : map_arr[0].split(','),
29334                map_unit = (typeof map_tmp[2] != 'undefined' && map_tmp[2]) ? map_tmp[2].replace(/[0-9.]/g,'') : '',
29335                map_place = (checkPlace) ? map_arr[1] : '',
29336                map_xy = map_tmp[0].replace(/^@/,'') + ' ' + map_tmp[1],
29337                map_zoom = (map_unit == 'z') ? parseInt(map_tmp[2].replace('z','')) : 17,
29338                // 위성지도 map_miter = (map_unit == 'm') ? map_tmp[2].replace('m','') : '',
29339                map_query = (checkPlace) ? map_place : map_xy;
29340
29341
29342            if(map_unit == 'z') map_query += '&z='+map_zoom;
29343            // 위성지도  if(map_unit == 'm') map_query += '&t=k';
29344
29345            // 언어
29346            var check_lang = map_arr[map_arr.length-1];
29347            if(typeof check_lang != 'undefined' && check_lang) {
29348                var lang_arr = check_lang.split('?'),
29349                    lang_str = '';
29350                $.each(lang_arr, function(i,tmp) {
29351                    if(tmp.match(/^hl\=(ko|en|eu|ca|hr|cs|da|nl}fi|fr|de|gl|el|hi|id|it|ja|no|nn|pt|rm|ru|sr|sk|sl|es|sv|th|tr|uk|vi)/g) !== null) {
29352                        map_query += '&hl=' + tmp.replace(/^hl=/g,'');
29353                    }
29354                });
29355            }
29356            
29357            var map_src = '//www.google.com/maps?q=' + map_query + '&ll=' + map_xy.replace(/ /,',') + '&output=embed';
29358        }
29359
29360        var map_iframe = '\
29361            <iframe class="google-map" src="' + map_src + '" data-map="true" data-url="' + map_url + '" allowfullscreen="" loading="lazy"></iframe>\
29362        ';
29363        if(return_type == 'html') return map_iframe;
29364        else if(return_type == 'src') return map_src;
29365        // else if(return_type == 'obj') {
29366        //     return {
29367        //         'url' : map_url,
29368        //         'src' : map_src,
29369        //         'html' : map_iframe.trim(),
29370        //         'place' : (checkPlace) ? map_place : '',
29371        //         'xy' : (checkPlace) ? map_xy : '',
29372        //         'unit' : (checkPlace) ? map_unit : '',
29373        //         'zoom' : (checkPlace) ? map_zoom : '',
29374        //     };
29375        // }
29376    } else {
29377        var map_src = '//www.google.com/maps?q=서울특별시&z=10&output=embed',
29378            map_iframe = '\
29379            <iframe class="google-map disabled" src="' + map_src + '" data-map="true" data-url="' + map_src + '" allowfullscreen="" loading="lazy"></iframe>\
29380            <div class="map-undefined"><span>지도 URL을 다시 설정해주세요</span></div>\
29381        ';
29382
29383        if(return_type == 'html') return map_iframe;
29384        else if(return_type == 'src') return map_src;
29385    }
29386}
29387
29388var deliveryTemplateListModal = function(shopping_url, close_func) {
29389$.processON();
29390    var html = '';
29391
29392    html += '\
29393        <div class="setting-sub-content setting-delivery-template">\
29394            <div class="setting-sub-content-desc">여러 유형의 배송 조건을 설정하고, 상품 등록 시 미리 설정해둔 배송 조건을<br>간편하게 적용할 수 있습니다.</div>\
29395            <button type="button" class="btn-add-template btn btn-sm f-right"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10"><path d="M10 4H6V0H4v4H0v2h4v4h2V6h4z"/></svg>배송설정 추가</button>\
29396            <div class="delivery-template-area"></div>\
29397        </div>\
29398    '
29399
29400    var modal = $(this).showModalFlat($.lang[LANG]['shopping.delivery.template.title'],html,true,false, function() {
29401        modal.modal('hide');
29402    }, 'close','','cl-cmmodal cl-s-btn w680 cl-p70 cover delivery-template-modal', true, function() {
29403        if(typeof close_func == 'function') {
29404            close_func();
29405        }
29406    }, function() {
29407        
29408        var getDeliveryTemplateList = function() {
29409            $.ajax({
29410                url: shopping_url + '/getDeliveryTemplateList',
29411                type: 'post',
29412                dataType: 'json',
29413                data:{'sid' : SID},
29414                async: false,
29415                success:function(data) {
29416                    console.log(data);
29417                    var html = '';
29418                    if(data.length) {
29419                        $(data).each(function(idx) {
29420                            var row = this;
29421
29422                            html += '<div class="template-row-box" data-seq="' + row.seq + '">';
29423                            html += '<div class="template-row-title-box">';
29424                            html += '<div class="template-row-title">' + row.name + '</div>';
29425
29426                            if(LUX) {
29427                                if(idx > 0) {
29428                                    html += '<div class="template-row-buttons">\
29429                                                <span class="btn-edit-template"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 12 12" width="12" height="12"><path d="m11.56.57-.13-.13C11.14.15 10.76 0 10.37 0c-.38 0-.77.15-1.06.44L.75 9 0 12l3-.75 8.56-8.56c.59-.59.59-1.54 0-2.12zm-9.07 9.78-1.11.28.28-1.11 6.58-6.58.84.84-6.59 6.57zm8.36-8.37L9.77 3.06l-.83-.83 1.08-1.08a.487.487 0 0 1 .7 0l.13.13c.2.19.2.51 0 .7z"></path></svg></span>\
29430                                                <span class="btn-copy-template"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 12 13" width="12" height="13"><path d="M10.5 0h-6C3.67 0 3 .67 3 1.5V2H1.5C.67 2 0 2.67 0 3.5v8c0 .83.67 1.5 1.5 1.5h6c.83 0 1.5-.67 1.5-1.5V11h1.5c.83 0 1.5-.67 1.5-1.5v-8c0-.83-.67-1.5-1.5-1.5zM8 11.5c0 .28-.22.5-.5.5h-6c-.28 0-.5-.22-.5-.5v-8c0-.28.22-.5.5-.5H3v6.5c0 .83.67 1.5 1.5 1.5H8v.5zm3-2c0 .28-.22.5-.5.5h-6c-.28 0-.5-.22-.5-.5v-8c0-.28.22-.5.5-.5h6c.28 0 .5.22.5.5v8z"></path></svg></span>\
29431                                    ';
29432                                    if(idx > 1) {
29433                                        html += '\
29434                                                    <span class="btn-delete-template"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 12 13" width="12" height="13"><path d="M11 2H9V0H3.02v2H1 0v1h1v8c0 1.1 0.9 2 2 2h6c1.1 0 2-0.9 2-2V3h1V2H11zM4.02 1H8v1H4.02V1zM10 11c0 0.55-0.45 1-1 1H3c-0.55 0-1-0.45-1-1V3h1.02H9h1V11z"></path><rect x="4" y="4" width="1" height="7"></rect><rect x="7" y="4" width="1" height="7"></rect></svg></span>\
29435                                        ';
29436                                    }
29437                                    html += '\
29438                                            </div>';
29439                                }
29440                            } else {
29441                                html += '<div class="template-row-buttons">\
29442                                            <span class="btn-edit-template"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 12 12" width="12" height="12"><path d="m11.56.57-.13-.13C11.14.15 10.76 0 10.37 0c-.38 0-.77.15-1.06.44L.75 9 0 12l3-.75 8.56-8.56c.59-.59.59-1.54 0-2.12zm-9.07 9.78-1.11.28.28-1.11 6.58-6.58.84.84-6.59 6.57zm8.36-8.37L9.77 3.06l-.83-.83 1.08-1.08a.487.487 0 0 1 .7 0l.13.13c.2.19.2.51 0 .7z"></path></svg></span>\
29443                                            <span class="btn-copy-template"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 12 13" width="12" height="13"><path d="M10.5 0h-6C3.67 0 3 .67 3 1.5V2H1.5C.67 2 0 2.67 0 3.5v8c0 .83.67 1.5 1.5 1.5h6c.83 0 1.5-.67 1.5-1.5V11h1.5c.83 0 1.5-.67 1.5-1.5v-8c0-.83-.67-1.5-1.5-1.5zM8 11.5c0 .28-.22.5-.5.5h-6c-.28 0-.5-.22-.5-.5v-8c0-.28.22-.5.5-.5H3v6.5c0 .83.67 1.5 1.5 1.5H8v.5zm3-2c0 .28-.22.5-.5.5h-6c-.28 0-.5-.22-.5-.5v-8c0-.28.22-.5.5-.5h6c.28 0 .5.22.5.5v8z"></path></svg></span>\
29444                                ';
29445                                if(idx > 0) {
29446                                    html += '\
29447                                                <span class="btn-delete-template"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 12 13" width="12" height="13"><path d="M11 2H9V0H3.02v2H1 0v1h1v8c0 1.1 0.9 2 2 2h6c1.1 0 2-0.9 2-2V3h1V2H11zM4.02 1H8v1H4.02V1zM10 11c0 0.55-0.45 1-1 1H3c-0.55 0-1-0.45-1-1V3h1.02H9h1V11z"></path><rect x="4" y="4" width="1" height="7"></rect><rect x="7" y="4" width="1" height="7"></rect></svg></span>\
29448                                    ';
29449                                }
29450                                html += '\
29451                                        </div>';
29452                            }
29453                            html += '</div>';
29454
29455                            html += '<div class="template-row-content">';
29456                            html += (row.mix_yn == 'Y' ? '묶음배송' : '개별배송') + ' / ';
29457
29458                            var delivery_type_arr = row.delivery_type.split(',');
29459                            var delivery_type_str = '';
29460                            $(delivery_type_arr).each(function(k,v) {
29461                                if(delivery_type_str) delivery_type_str += ', ';
29462                                delivery_type_str += $.lang[LANG]['shopping.delivery.template.delivery_type.' + v.toLowerCase()];
29463                            });
29464
29465
29466                            if(delivery_type_str) html += delivery_type_str + ' / ';
29467                            if(delivery_type_arr.indexOf('DELIVERY') > -1) 
29468                                html += $.lang[LANG]['shopping.delivery.' + row.delivery_company.toLowerCase()] + ' / ';
29469                            html += $.lang[LANG]['shopping.delivery.template.price_type.' + row.price_type.toLowerCase()]; 
29470
29471                            if(row.price_type == 'FIX') {
29472                                html += '(' + number_format(row.delivery_fee) + '원)';
29473                            } else if(row.price_type == 'QUANTITY' || row.price_type == 'WEIGHT') {
29474                                var price_type_detail = row.price_type_detail ? JSON.parse(row.price_type_detail) : {};
29475                                
29476                                if(price_type_detail.method == 'DIFFERENTIAL') {
29477                                    var detail = '';
29478                                    var popup_content = '';
29479                                    if(price_type_detail.detail) {
29480                                        $.each(price_type_detail.detail, function(k, v) {
29481                                            var value = Object.keys(v);
29482                                            var price = Object.values(v);
29483
29484                                            if(row.price_type == 'QUANTITY') {
29485                                                if(k < 2) {
29486                                                    if(detail) detail += ', ';
29487                                                    detail += value + '개 이상(' + number_format(price) + '원)';
29488                                                }
29489                                                popup_content += value + '개 이상 ' + number_format(price) + '원' + '<br>';
29490                                            } else if(row.price_type == 'WEIGHT') {
29491                                                if(k < 2) {
29492                                                    if(detail) detail += ', ';
29493                                                    detail += value + 'Kg 이상(' + number_format(price) + '원)';
29494                                                }
29495                                                popup_content += value + 'Kg 이상 ' + number_format(price) + '원' + '<br>';
29496                                            }
29497                                        });
29498
29499                                        if(price_type_detail.detail.length > 2) {
29500                                            popup_content = $.lang[LANG]['shopping.delivery.template.price_type.' + row.price_type.toLowerCase()] + '<br>' + popup_content;
29501                                            if(!LUX) popup_content += '<br>※ 추가 상품은 배송비 조건에 반영되지 않습니다.';
29502                                            detail += '<span class="cm-popover-info" data-toggle="popover" tabindex="0" data-trigger="hover" data-html="true" data-placement="bottom" data-content="' + popup_content + '"> 더보기 </span>';
29503                                        }
29504                                    }
29505                                    if(detail) {
29506                                        detail = '(차등 / ' + detail + ')';
29507                                        html += detail;
29508                                    }
29509                                } else if(price_type_detail.method == 'REPEAT') {
29510                                    var detail = '';
29511                                    var value = Object.keys(price_type_detail.detail);
29512                                    var price = Object.values(price_type_detail.detail);
29513
29514                                    if(row.price_type == 'QUANTITY') {
29515                                        detail += value + '개 구매시마다 ' + number_format(price) + '원 반복 부과';
29516                                    } else if(row.price_type == 'WEIGHT') {
29517                                        detail += value + 'Kg마다 ' + number_format(price) + '원 반복 부과';
29518                                    }
29519
29520                                    if(detail) {
29521                                        detail = '(반복 / ' + detail + ')';
29522                                        html += detail;
29523                                    }
29524                                }
29525                            }
29526
29527                            if(row.additional_yn == 'Y') {
29528                                html += ' / 도서산간 지역 추가 배송비 (제주 ' + number_format(row.additional_jeju_price) + '원, 제주 외 도서산간 ' + number_format(row.additional_land_price) + '원';
29529                            }
29530
29531                            html += ' / ' + $.lang[LANG]['shopping.delivery.template.pay_type.' + row.pay_type.toLowerCase()];
29532
29533                            if(row.free_condition_yn == 'Y') {
29534                                html += ' / ' + number_format(row.free_condition) + '원 이상 무료 배송';
29535                            }
29536
29537                            if(row.make_to_order_yn == 'Y') {
29538                                html += ' / 주문 확인 후 ' + row.due_date + '일 후 배송 예정';
29539                            }
29540
29541                            if(row.install_fee_yn == 'Y') {
29542                                html += ' / 별도 설치비 있음';
29543                            }
29544
29545                            html += '</div>';
29546                            html += '</div>';
29547                        });
29548                    } else {
29549                        html += '<div>배송 템플릿이 없습니다.</div>';
29550                    }
29551                    html += '</div>';
29552                    $('.delivery-template-area').html(html);
29553                    $('.delivery-template-area').find('[data-toggle="popover"]').popover();
29554                }, complete: function() {
29555                    $.processOFF();
29556                }
29557            });
29558        }
29559
29560        getDeliveryTemplateList();
29561
29562        $('.btn-add-template').on('click', function() {
29563            deliveryTemplateEditModal(shopping_url, '', getDeliveryTemplateList);
29564        });
29565
29566        modal.on('click', '.btn-edit-template', function() {
29567            var seq = $(this).closest('.template-row-box').data('seq');
29568            deliveryTemplateEditModal(shopping_url, seq, getDeliveryTemplateList);
29569        });
29570
29571        modal.on('click', '.btn-copy-template', function() {
29572            var seq = $(this).closest('.template-row-box').data('seq');
29573            var copy_modal = $(this).showModalFlat('배송설정 복제', '선택한 배송설정을 복제하시겠습니까?', true, true, function() {
29574                    $.processON();
29575                    setTimeout(function() {
29576                        $.ajax({
29577                            url: shopping_url + '/copyDeliveryTemplate',
29578                            type:'post',
29579                            dataType:'json',
29580                            async: false,
29581                            data:{'sid' : SID, 'seq' : seq},
29582                            success:function(data) {
29583                                getDeliveryTemplateList();
29584                            }, complete: function() {
29585                                $.processOFF();
29586                            }
29587                        });
29588                    });
29589                    
29590                copy_modal.modal('hide');
29591            }, 'cancel', 'ok', 'cl-cmmodal cl-s-btn w560 cl-p130');
29592            var backdrop_z_index = Number(copy_modal.css('zIndex'));
29593            backdrop_z_index+=2;
29594            copy_modal.css('zIndex', backdrop_z_index + 1);
29595            copy_modal.parent().next('.modal-backdrop').css('zIndex', backdrop_z_index);
29596        });
29597
29598        modal.on('click', '.btn-delete-template', function() {
29599            var seq = $(this).closest('.template-row-box').data('seq');
29600            var delete_modal = $(this).showModalFlat('배송설정 삭제', '선택한 배송설정이 적용되었던 상품들은 기본 배송설정으로 변경됩니다.<br><br>선택한 배송설정을 삭제하시겠습니까?', true, true, function() {
29601                    $.processON();
29602                    setTimeout(function() {
29603                        $.ajax({
29604                            url: shopping_url + '/deleteDeliveryTemplate',
29605                            type:'post',
29606                            dataType:'json',
29607                            async: false,
29608                            data: {
29609                                'sid' : SID,
29610                                'seq' : seq
29611                            },
29612                            success:function(data) {
29613                                getDeliveryTemplateList();
29614                            },
29615                            complete: function() {
29616                                $.processOFF();
29617                            }
29618                        });
29619                    });
29620                delete_modal.modal('hide');
29621            }, 'cancel', 'ok', 'cl-cmmodal cl-s-btn w560 cl-p130',true);
29622                
29623            var backdrop_z_index = Number(delete_modal.css('zIndex'));
29624            backdrop_z_index+=2;
29625            delete_modal.css('zIndex', backdrop_z_index + 1);
29626            delete_modal.parent().next('.modal-backdrop').css('zIndex', backdrop_z_index);
29627        }); 
29628    }, function() {
29629        // if(typeof close_func == 'function') {
29630        //     close_func();
29631        // }
29632    });
29633}
29634
29635var deliveryTemplateEditModal = function(shopping_url, template_seq, callback_func) {
29636
29637    var seq = template_seq ? template_seq : '';
29638
29639    var opts = {
29640        'seq' : '',
29641        'name':'',
29642        'mix_yn' : 'Y',
29643        'delivery_type' : 'DELIVERY',
29644        'price_type' : 'FIX',
29645        'delivery_fee' : 2500,
29646        'additional_yn' : 'N',
29647        'pay_type' : 'PREPAY',
29648        'free_condition_yn' : 'N',
29649        'make_to_order_yn' : 'N',
29650        'install_fee_yn' : 'N',
29651        'additional_jeju_price' : 0,
29652        'additional_land_price' : 0,
29653        'due_date' : '',
29654        'free_condition' : 0,
29655        'delivery_company' : 'pt',
29656        'price_type_detail' : {}
29657    };
29658
29659    if(seq) {
29660        $.ajax({
29661            url:shopping_url + '/getDeliveryTemplate',
29662            type:'post',
29663            dataType:'json',
29664            async: false,
29665            data:{
29666                'seq' : seq,
29667                'sid' : SID,
29668            },
29669            success:function(data) {
29670                $.extend(opts, data);
29671            }
29672        });
29673    }
29674
29675    opts.delivery_type = opts.delivery_type.split(',');
29676    if(opts.price_type == 'QUANTITY' || opts.price_type == 'WEIGHT') {
29677        opts.price_type_detail = opts.price_type_detail ? JSON.parse(opts.price_type_detail) : {};
29678        
29679        if(!opts.price_type_detail.detail) {
29680            opts.price_type_detail.detail = {};
29681        }
29682
29683        if(opts.price_type_detail.method && opts.price_type_detail.method == 'REPEAT') {
29684            if(opts.price_type == 'QUANTITY') {
29685                opts.quantity_repeat_value = Object.keys(opts.price_type_detail.detail)[0];
29686                opts.quantity_repeat_price = Object.values(opts.price_type_detail.detail)[0];
29687            } else if(opts.price_type == 'WEIGHT') {
29688                opts.weight_repeat_value = Object.keys(opts.price_type_detail.detail)[0];
29689                opts.weight_repeat_price = Object.values(opts.price_type_detail.detail)[0];
29690            }
29691        } else {
29692            opts.price_type_detail.method = 'DIFFERENTIAL';
29693        }
29694    }
29695
29696    if(opts.delivery_company == '') opts.delivery_company = 'pt';
29697
29698    var tracking_delivery_company_arr = ['cj','pt','hj','lg','lt','post'];
29699
29700    var delivery_company_arr = [
29701        'etc',
29702        'cj',
29703        'pt',
29704        'hj',
29705        'lg',
29706        'lt',
29707        'post',
29708        'koryo',
29709        'wevill',
29710        'daesin',
29711        'ilyang',
29712        'kdexp',
29713        'chunil',
29714        'cv',
29715        'cu',
29716        'hdexp',
29717        'dhl',
29718        'dhlglobalmail',
29719        'dhlde',
29720        'fedex',
29721        'gsmnton',
29722        'warpex',
29723        'ems',
29724        'ace',
29725        'qxpress',
29726        'aciexpress',
29727        'lineexp',
29728        'pantos',
29729        'smartlogis',
29730        'hlcglobal',
29731        'ups',
29732        'korexg',
29733        'tnt',
29734        'swgexp',
29735        'daewoon',
29736        'usps',
29737        'iparcel',
29738        'kunyoung',
29739        'hpl',
29740        'gnetwork',
29741        'slx',
29742        'daelim',
29743        'honam',
29744        'gsiexpress',
29745        'eunha',
29746        'homeinno',
29747        'hybrid',
29748        'airway',
29749        'woorihb',
29750        'yjsworld',
29751        'yjs',
29752        'crlx',
29753        'homepick',
29754        'cwayexpress',
29755        'anytrack',
29756        'bridge',
29757        'gpslogix',
29758        'esther',
29759        'lotos',
29760        'ufreight',
29761        'ik',
29762        'lslogis',
29763        'sebang',
29764        'nonghyup',
29765        'yongma',
29766        'europarcel',
29767        'kgsl',
29768        'sunghun',
29769        'forever',
29770        'airboy',
29771        'ecmsexpress',
29772        'efs',
29773        'handex',
29774        'kglnet',
29775        'twofastexpress',
29776        'gos',
29777        'gspostbox',
29778        'adcair',
29779        'donggang',
29780        'kin',
29781        'hanwoori',
29782        'lglogistics',
29783        'generalpost',
29784        'ezusa',
29785        'handalum',
29786        'howser',
29787        'dpd',
29788        'gop',
29789        'wizwa',
29790        'selc',
29791        'sfex',
29792        'wihtyou',
29793        'roadsunexpress',
29794        'dongjin',
29795        'ilshin',
29796        'ky',
29797        'tpmlogis',
29798        'zeniel',
29799        'fresh',
29800        'jlogist',
29801        'chainlogis',
29802        'hivecity',
29803        'hanssem',
29804        'todaypickup',
29805        'qrun',
29806        'nogok',
29807        'spasys1',
29808        'freshmates',
29809        'etomars',
29810        'shipnergy',
29811        'geniego',
29812        'dodoflex',
29813        'ltl',
29814        'vendorpia',
29815        'coship',
29816        'gdakorea',
29817        'lge',
29818        'teamfresh',
29819        'yunda',
29820        'alltakorea',
29821        'lottechilsung',
29822        'valex',
29823        'bababa',
29824        'ch1',
29825        'apex',
29826        'homeplus',
29827        'gsfresh',
29828        'hanaromart',
29829        'choroc',
29830        'vroong',
29831        'dcommerce',
29832        'aboutpet',
29833        '1004home',
29834        'gtslogis',
29835        'sbgls',
29836        'ssg',
29837        'kokusai',
29838        'goodtoluck',
29839        'ekdp',
29840        'woongji',
29841        'xinpatek',
29842        'herewego',
29843        'panasia',
29844        'pingpong',
29845        'cargoplease',
29846		'kjt', // 케이제이티
29847		'rush', // 오늘회러쉬
29848		'ntlps', // 엔티엘피스
29849		'actcore', // 에이씨티앤코아
29850		'logisvalley', // 로지스밸리
29851		'drabbit', // 딜리래빗
29852		'naeun', // 나은물류
29853		'logispartner', // UFO 로지스
29854		'ndexkorea', // NDEX KOREA
29855    ];
29856
29857        // console.log(new_delivery_company_arr)
29858    var tmp_delivery_company_arr = {}, new_delivery_company_arr = {};
29859    var delivery_company_options = '';
29860    $(delivery_company_arr).each(function(k, v) {
29861        tmp_delivery_company_arr[$.lang[LANG]['shopping.delivery.' + v]] = v;
29862    });
29863
29864    $(Object.keys(tmp_delivery_company_arr).sort()).each(function(k, v) {
29865        new_delivery_company_arr[v] = tmp_delivery_company_arr[v];
29866    });
29867
29868    delivery_company_options = '';
29869    $.each(new_delivery_company_arr, function(k, v) {
29870        var data_content = '';
29871        if(tracking_delivery_company_arr.indexOf(v) > -1) {
29872            data_content = '<span class="tracking-delivery-icon"></span>';
29873        }
29874        delivery_company_options += '<option value="' + v + '" ' + (opts.delivery_company == v ? ' selected ' : '') + (data_content ? ' data-content=\'' + k + data_content + '\'' : '') + '>' + k + '</option>';
29875    });
29876
29877    var html = '\
29878        <div class="delivery-template-layer">\
29879            <form id="deliveryTemplateForm">\
29880                <div class="item-row">\
29881                    <div class="">' + $.lang[LANG]['shopping.delivery.template.name'] + '</div>\
29882                    <div class=""><input type="hidden" name="sid" value="' + SID + '" /><input type="text" name="name" class="form-control" value="' + opts.name + '" maxlength="50" autocomplete="off" /><input type="hidden" name="seq" value="' + opts.seq + '" /></div>\
29883                </div>\
29884                <div class="item-row">\
29885                    <div class="">' + $.lang[LANG]['shopping.delivery.template.mix_yn'] + '<svg class="cm-popover-info" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 13" width="13" height="13" tabindex="0" data-trigger="hover" data-toggle="popover" fill="#4789e7" data-html="true" data-placement="top" data-content="<ul><li class=\'item\'>묶음 배송 : 여러 상품을 같이 구매할 경우, 동일한 배송설정이 적용되어 있다면 구매자에게 배송비가 한 번만 부과됩니다.</li><li class=\'item\'>개별 배송 : 여러 상품을 구매하더라도, 상품 별로 설정한 배송비가 부과됩니다.</li></ul>" data-original-title="" title=""><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"></path><path d="M6.66 3.01C5.61 3.01 4.58 3.5 4.5 4.8c0 0.06-0.01 0.12 0 0.2h1.02c0-0.07 0.01-0.15 0.02-0.23 0.08-0.62 0.52-0.76 1.08-0.76 0.63 0 1.02 0.37 1.02 0.95 -0.01 0.48-0.3 0.87-0.76 1.34C6.21 6.97 6.02 7.37 6 8h0.99C7 7.66 7.04 7.37 7.67 6.75 8.17 6.27 8.7 5.68 8.7 4.87 8.7 3.85 7.89 3.01 6.66 3.01z"></path><rect x="6" y="9" width="1" height="1"></rect></svg></div>\
29886                    <div class="mix-yn-row"><label><input type="radio" name="mix_yn" value="Y" ' + (opts.mix_yn == 'Y' ? ' checked ' : '') + ' /><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 18 18" width="18" height="18"><path d="M9 0a9 9 0 1 0 .001 18.001A9 9 0 0 0 9 0zm0 17c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"/></svg><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 18 18" width="18" height="18"><path d="M9 0a9 9 0 1 0 .001 18.001A9 9 0 0 0 9 0zm0 17c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"/><circle cx="9" cy="9" r="6"/></svg>
29886' + $.lang[LANG]['shopping.delivery.template.mix_yn.y'] + '</label> <label><input type="radio" name="mix_yn" value="N" ' + (opts.mix_yn == 'N' ? ' checked ' : '') + ' /><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 18 18" width="18" height="18"><path d="M9 0a9 9 0 1 0 .001 18.001A9 9 0 0 0 9 0zm0 17c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"/></svg><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 18 18" width="18" height="18"><path d="M9 0a9 9 0 1 0 .001 18.001A9 9 0 0 0 9 0zm0 17c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"/><circle cx="9" cy="9" r="6"/></svg>' + $.lang[LANG]['shopping.delivery.template.mix_yn.n'] + '</label></div>\
29887                </div>\
29888                <div class="item-row">\
29889                    <div class="">' + $.lang[LANG]['shopping.delivery.template.delivery_type'] + '<svg class="cm-popover-info" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 13" width="13" height="13" tabindex="0" data-trigger="hover" data-toggle="popover" fill="#4789e7" data-html="true" data-placement="top" data-content="<ul><li class=\'title\'>상품을 배송하는 수단을 선택합니다.</li><li class=\'item\'>택배 : 택배사를 이용하여 상품을 발송합니다.</li><li class=\'item\'>직접배송(화물배달) : 판매자가 직접 배송을 하거나 화물로 발송합니다.</li><li class=\'item\'>퀵서비스 : 퀵서비스를 이용하여 상품을 발송합니다. 배송비는 별도 안내로 설정되고 결제 방식은 착불만 지원합니다.<div class=\'desc\'>* 퀵서비스 가능 여부 및 배송비에 대해 상세페이지에 내용을 입력하거나 구매자와 협의해 주세요.</div></li><li class=\'item\'>방문수령 : 구매자가 판매자에게 방문하여 직접 상품을 받아 갑니다. 배송비는 무료 배송으로 설정되고 결제방식은 지원하지 않습니다.</li></ul>" data-original-title="" title=""><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"></path><path d="M6.66 3.01C5.61 3.01 4.58 3.5 4.5 4.8c0 0.06-0.01 0.12 0 0.2h1.02c0-0.07 0.01-0.15 0.02-0.23 0.08-0.62 0.52-0.76 1.08-0.76 0.63 0 1.02 0.37 1.02 0.95 -0.01 0.48-0.3 0.87-0.76 1.34C6.21 6.97 6.02 7.37 6 8h0.99C7 7.66 7.04 7.37 7.67 6.75 8.17 6.27 8.7 5.68 8.7 4.87 8.7 3.85 7.89 3.01 6.66 3.01z"></path><rect x="6" y="9" width="1" height="1"></rect></svg></div>\
29890                    <div class="delivery-type-row"><label class="btn-delivery-type"><input type="radio" name="delivery_type[]" value="DELIVERY" ' + (opts.delivery_type.indexOf('DELIVERY') > -1 ? ' checked ' : '') + ' /><div>' + $.lang[LANG]['shopping.delivery.template.delivery_type.delivery'] + '</div></label> <label class="btn-delivery-type"><input type="radio" name="delivery_type[]" value="DIRECT" ' + (opts.delivery_type.indexOf('DIRECT') > -1 ? ' checked ' : '') + ' /><div>' + $.lang[LANG]['shopping.delivery.template.delivery_type.direct'] + '</div></label> <label><input type="checkbox" name="delivery_type[]" value="QUICK" ' + (opts.delivery_type.indexOf('QUICK') > -1 ? ' checked ' : '') + ' /><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path d="M13 0H3C1.3 0 0 1.3 0 3v10c0 1.7 1.3 3 3 3h10c1.7 0 3-1.3 3-3V3C16 1.3 14.7 0 13 0zM15 13c0 1.1-0.9 2-2 2H3c-1.1 0-2-0.9-2-2V3c0-1.1 0.9-2 2-2h10c1.1 0 2 0.9 2 2V13z"></path></svg><svg class="active" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path d="M13 0H3C1.34 0 0 1.34 0 3v10c0 1.66 1.34 3 3 3h10c1.66 0 3-1.34 3-3V3C16 1.34 14.66 0 13 0zM13.03 6.03l-5.5 5.5C7.38 11.68 7.19 11.75 7 11.75s-0.38-0.07-0.53-0.22l-3.5-3.5c-0.29-0.29-0.29-0.77 0-1.06s0.77-0.29 1.06 0L7 9.94l4.97-4.97c0.29-0.29 0.77-0.29 1.06 0S13.32 5.74 13.03 6.03z"></path></svg>' + $.lang[LANG]['shopping.delivery.template.delivery_type.quick'] + '</label> <label><input type="checkbox" name="delivery_type[]" value="VISIT" ' + (opts.delivery_type.indexOf('VISIT') > -1 ? ' checked ' : '') + ' /><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path d="M13 0H3C1.3 0 0 1.3 0 3v10c0 1.7 1.3 3 3 3h10c1.7 0 3-1.3 3-3V3C16 1.3 14.7 0 13 0zM15 13c0 1.1-0.9 2-2 2H3c-1.1 0-2-0.9-2-2V3c0-1.1 0.9-2 2-2h10c1.1 0 2 0.9 2 2V13z"></path></svg><svg class="active" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path d="M13 0H3C1.34 0 0 1.34 0 3v10c0 1.66 1.34 3 3 3h10c1.66 0 3-1.34 3-3V3C16 1.34 14.66 0 13 0zM13.03 6.03l-5.5 5.5C7.38 11.68 7.19 11.75 7 11.75s-0.38-0.07-0.53-0.22l-3.5-3.5c-0.29-0.29-0.29-0.77 0-1.06s0.77-0.29 1.06 0L7 9.94l4.97-4.97c0.29-0.29 0.77-0.29 1.06 0S13.32 5.74 13.03 6.03z"></path></svg>
29890' + $.lang[LANG]['shopping.delivery.template.delivery_type.visit'] + '</label>\
29891                        <div class="delivery-company-row" style="' + (opts.delivery_type.indexOf('DELIVERY') > -1 ? '' : ' display: none; ') + '">\
29892                            <div class="row-sub-title">' + $.lang[LANG]['shopping.delivery.template.delivery_company'] + '</div>\
29893                            <select name="delivery_company" class="form-control">\
29894                                ' + delivery_company_options + '\
29895                            </select>\
29896                        </div>\
29897                    </div>\
29898                </div>\
29899                <div class="item-row">\
29900                    <div class="">' + $.lang[LANG]['shopping.delivery.template.price_type'] + '<svg class="cm-popover-info" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 13" width="13" height="13" tabindex="0" data-trigger="hover" data-toggle="popover" fill="#4789e7" data-html="true" data-placement="top" data-content="<ul><li class=\'title\'>배송비 계산 방법을 선택합니다.</li><li class=\'item\'>고정 배송비(기본설정) : 설정한 배송비로 부과합니다. (네이버 페이 결제 가능)</li><li class=\'item\'>수량별 배송비 : 수량에 따라서 배송비를 차등/반복 옵션으로 부과합니다.<div class=\'desc\'>* 네이버 페이 결제 가능 (단, 수량별 배송비 차등 항목이 4개 이상인 경우 네이버 페이 결제 불가능)</div></li><li class=\'item\'>무게별 배송비 : 무게에 따라서 배송비를 차등/반복 옵션으로 부과합니다. (네이버 페이 결제 불가능)</li><li class=\'item\'>무료 배송 : 배송비가 무료입니다. (네이버 페이 결제 가능)</li><li class=\'item\'>별도 안내 : 결제 시 배송비가 부과하지 않고 판매자와 별도로 협의하여 배송비를 별도로 측정 및 계산합니다. (네이버 페이 결제 가능)</li></ul>" data-original-title="" title=""><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"></path><path d="M6.66 3.01C5.61 3.01 4.58 3.5 4.5 4.8c0 0.06-0.01 0.12 0 0.2h1.02c0-0.07 0.01-0.15 0.02-0.23 0.08-0.62 0.52-0.76 1.08-0.76 0.63 0 1.02 0.37 1.02 0.95 -0.01 0.48-0.3 0.87-0.76 1.34C6.21 6.97 6.02 7.37 6 8h0.99C7 7.66 7.04 7.37 7.67 6.75 8.17 6.27 8.7 5.68 8.7 4.87 8.7 3.85 7.89 3.01 6.66 3.01z"></path><rect x="6" y="9" width="1" height="1"></rect></svg></div>\
29901                    <div class=""><select name="price_type" class="form-control"><option value="FIX" ' + (opts.price_type == 'FIX' ? ' selected ' : '') + '>' + $.lang[LANG]['shopping.delivery.template.price_type.fix'] + '</option><option value="FREE_CONDITION" ' + (opts.price_type == 'FREE_CONDITION' ? ' selected ' : '') + '>' + $.lang[LANG]['shopping.delivery.template.price_type.free_condition'] + '</option><option value="QUANTITY" ' + (opts.price_type == 'QUANTITY' ? ' selected ' : '') + '>' + $.lang[LANG]['shopping.delivery.template.price_type.quantity'] + '</option><option value="WEIGHT" ' + (opts.price_type == 'WEIGHT' ? ' selected ' : '') + '>' + $.lang[LANG]['shopping.delivery.template.price_type.weight'] + '</option><option value="FREE" ' + (opts.price_type == 'FREE' ? ' selected ' : '') + '>' + $.lang[LANG]['shopping.delivery.template.price_type.free'] + '</option><option value="ETC" ' + (opts.price_type == 'ETC' ? ' selected ' : '') + '>' + $.lang[LANG]['shopping.delivery.template.price_type.etc'] + '</option></select>\
29902                        <div class="fix-row free-condition-row m15t" style="' + (opts.price_type == 'FIX' || opts.price_type == 'FREE_CONDITION' ? '' : ' display: none; ') + '">\
29903                            <div class="row-sub-title">기본 배송비</div>\
29904                            <div class="m5t"><input type="text" name="delivery_fee" class="form-control" value="' + (opts.delivery_fee ? number_format(opts.delivery_fee) : 0) + '" numberonly maxlength="13" />원</div>\
29905                        </div>\
29906                        <div class="free-condition-row m15t" style="' + (opts.price_type == 'FREE_CONDITION' ? '' : ' display: none; ') + '">\
29907                            <div class="row-sub-title">무료 배송 조건</div>\
29908                            <div class="m5t">\
29909                                <input type="text" name="free_condition" class="form-control" value="' + (number_format(opts.free_condition)) + '" numberonly maxlength="13" />원 이상 구매 시 무료 배송\
29910                            </div>\
29911                            <div class="row-sub-title m10t"><svg class="cm-popover-info m5r" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 13" width="13" height="13" tabindex="0"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12.13c-3.11 0-5.63-2.53-5.63-5.63S3.39 0.87 6.5 0.87s5.63 2.53 5.63 5.63S9.61 12.13 6.5 12.13z"></path><path d="M7.44 9.58c-0.1-0.02-0.18-0.05-0.25-0.1C7.12 9.44 7.07 9.37 7.03 9.28 6.98 9.19 6.96 9.07 6.96 8.92V5h-1.7v0.4h0.03c0.11 0 0.21 0.01 0.3 0.02 0.09 0.02 0.18 0.05 0.25 0.09 0.07 0.05 0.13 0.11 0.17 0.2 0.04 0.09 0.06 0.2 0.06 0.34v2.91c0 0.14-0.02 0.25-0.06 0.34C5.97 9.39 5.91 9.45 5.84 9.5 5.77 9.54 5.68 9.57 5.59 9.58 5.49 9.6 5.39 9.6 5.29 9.6H5.16v0.4h2.71V9.6H7.75C7.64 9.6 7.54 9.6 7.44 9.58z"></path><rect x="6" y="3" width="1" height="1"></rect></svg>배송비를 제외한 상품 주문금액 합계가 조건 금액 이상인 경우 무료 배송으로 적용됩니다.</div>\
29912                        </div>\
29913                        <div class="price-type-detail-method-row quantity-row weight-row" style="' + (opts.price_type == 'QUANTITY' || opts.price_type == 'WEIGHT' ? '' : ' display: none;') + '">\
29914                            <label><input type="radio" id="price_type_detail_method_D" name="price_type_detail_method" value="DIFFERENTIAL" ' + (opts.price_type_detail.method == 'DIFFERENTIAL' ? ' checked ' : '') + ' /><div>차등</div></label>\
29915                            <label><input type="radio" id="price_type_detail_method_R" name="price_type_detail_method" value="REPEAT" ' + (opts.price_type_detail.method == 'REPEAT' ? ' checked ' : '') + ' /><div>반복</div></label>\
29916                        </div>\
29917                        <div class="quantity-row" style="' + (opts.price_type == 'QUANTITY' ? '' : ' display: none; ') + '">\
29918                        <div class="quantity-differential" style="' + (opts.price_type_detail.method == 'DIFFERENTIAL' ? '' : ' display: none;') + '">\
29919                            <table>\
29920                                <colgroup><col width="45%" /><col width="40%" /><col width="20%" /></colgroup>\
29921                        ';
29922
29923                        if(opts.price_type == 'QUANTITY' && opts.price_type_detail.method == 'DIFFERENTIAL' && opts.price_type_detail.detail.length) {
29924                            $.each(opts.price_type_detail.detail, function(k, v) {
29925                                var value = Object.keys(v);
29926                                var price = Object.values(v);
29927                                if(k == 0) value = 1;
29928                                html += '<tr><td><input type="text" class="form-control" name="quantity_differential_value[]" value="' + (number_format(value)) + '" ' + (k == 0 ? ' readonly ' : '') + ' numberonly maxlength="13" /> 개 이상</td><td><input type="text" class="form-control" name="quantity_differential_price[]" value="' + number_format(price) + '" numberonly maxlength="13" />원</td><td>' + (k > 0 ? '<span class="btn-delete-condition-row"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 12 13" width="12" height="13"><path d="M11 2H9V0H3.02v2H1 0v1h1v8c0 1.1 0.9 2 2 2h6c1.1 0 2-0.9 2-2V3h1V2H11zM4.02 1H8v1H4.02V1zM10 11c0 0.55-0.45 1-1 1H3c-0.55 0-1-0.45-1-1V3h1.02H9h1V11z"/><rect x="4" y="4" width="1" height="7"/><rect x="7" y="4" width="1" height="7"/></svg></span>' : '') + '</td></tr>';
29929                            });
29930                        } else {
29931                            html += '<tr><td><input type="text" class="form-control" name="quantity_differential_value[]" value="1" readonly numberonly maxlength="13" /> 개 이상</td><td><input type="text" class="form-control" name="quantity_differential_price[]" numberonly maxlength="13" />원</td><td></td></tr>';
29932                        }
29933
29934                        html += '\
29935                                </table>\
29936                                <div><button type="button" class="btn btn-quantity-diff">+ 조건 추가</button></div>\
29937                            </div>\
29938                            <div class="quantity-repeat" style="' + (opts.price_type_detail.method == 'REPEAT' ? '' : ' display: none;') + '">\
29939                                <div class="row-sub-title">기본 배송비</div>\
29940                                <div class="m5t"><input type="text" class="form-control m5r" name="quantity_repeat_price" value="' + (opts.quantity_repeat_price ? opts.quantity_repeat_price : 0) + '" numberonly maxlength="13" />원</div>\
29941                                <div class="m10t"><input type="text" class="form-control m5r" name="quantity_repeat_value" value="' + (opts.quantity_repeat_value ? opts.quantity_repeat_value : 0) + '" numberonly maxlength="13" />개마다 기본 배송비 반복 부과</div>\
29942                            </div>\
29943                        </div>\
29944                        <div class="weight-row" style="' + (opts.price_type == 'WEIGHT' ? '' : ' display: none;') + '">\
29945                        <div class="weight-differential" style="' + (opts.price_type_detail.method == 'DIFFERENTIAL' ? '' : ' display: none;') + '">\
29946                            <table>\
29947                                <colgroup><col width="45%" /><col width="40%" /><col width="20%" /></colgroup>\
29948                        ';
29949
29950                        if(opts.price_type == 'WEIGHT' && opts.price_type_detail.method == 'DIFFERENTIAL' && opts.price_type_detail.detail.length) {
29951                            $(opts.price_type_detail.detail).each(function(k, v) {
29952                                var value = Object.keys(v);
29953                                var price = Object.values(v);
29954                                if(k == 0) value = 0;
29955                                html += '<tr><td><input type="text" class="form-control isFloat" name="weight_differential_value[]" value="' + (number_format(value)) + '" ' + (k == 0 ? ' readonly ' : '') + ' numberonly maxlength="13" /> Kg 이상</td><td><input type="text" class="form-control" name="weight_differential_price[]" value="' + (number_format(price)) + '" numberonly maxlength="13" />원</td><td>' + (k > 0 ? '<span class="btn-delete-condition-row"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 12 13" width="12" height="13">
29955<path d="M11 2H9V0H3.02v2H1 0v1h1v8c0 1.1 0.9 2 2 2h6c1.1 0 2-0.9 2-2V3h1V2H11zM4.02 1H8v1H4.02V1zM10 11c0 0.55-0.45 1-1 1H3c-0.55 0-1-0.45-1-1V3h1.02H9h1V11z"/><rect x="4" y="4" width="1" height="7"/><rect x="7" y="4" width="1" height="7"/></svg></span>' : '') + '</td></tr>';
29956                            });
29957                        } else {
29958                            html += '<tr><td><input type="text" class="form-control isFloat" name="weight_differential_value[]" value="0" readonly numberonly maxlength="13" /> Kg 이상</td><td><input type="text" class="form-control" name="weight_differential_price[]" numberonly maxlength="13" />원</td><td></td></tr>';
29959                        }
29960                        html += '\
29961                                </table>\
29962                                <div><button type="button" class="btn btn-weight-diff">+ 조건 추가</button></div>\
29963                            </div>\
29964                            <div class="weight-repeat" style="' + (opts.price_type_detail.method == 'REPEAT' ? '' : ' display: none; ') + '">\
29965                                <div>기본 배송비</div>\
29966                                <div class="m5t"><input type="text" class="form-control" name="weight_repeat_price" value="' + (opts.weight_repeat_price ? opts.weight_repeat_price : 0) + '" numberonly maxlength="13" />원</div>\
29967                                <div class="m10t"><input type="text" class="form-control isFloat" name="weight_repeat_value" value="' + (opts.weight_repeat_value ? opts.weight_repeat_value : 0) + '" numberonly maxlength="13" />Kg마다 기본 배송비 반복 부과</div>\
29968                            </div>\
29969                        </div>\
29970                        ';
29971                        if(!LUX) {
29972                            html += '\
29973                        <div class="quantity-row weight-row" style="' + (opts.price_type == 'QUANTITY' || opts.price_type == 'WEIGHT' ? '' : ' display: none;') + '">\
29974                            <div class="row-sub-title m10t"><svg class="cm-popover-info" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 13" width="13" height="13" tabindex="0"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12.13c-3.11 0-5.63-2.53-5.63-5.63S3.39 0.87 6.5 0.87s5.63 2.53 5.63 5.63S9.61 12.13 6.5 12.13z"></path><path d="M7.44 9.58c-0.1-0.02-0.18-0.05-0.25-0.1C7.12 9.44 7.07 9.37 7.03 9.28 6.98 9.19 6.96 9.07 6.96 8.92V5h-1.7v0.4h0.03c0.11 0 0.21 0.01 0.3 0.02 0.09 0.02 0.18 0.05 0.25 0.09 0.07 0.05 0.13 0.11 0.17 0.2 0.04 0.09 0.06 0.2 0.06 0.34v2.91c0 0.14-0.02 0.25-0.06 0.34C5.97 9.39 5.91 9.45 5.84 9.5 5.77 9.54 5.68 9.57 5.59 9.58 5.49 9.6 5.39 9.6 5.29 9.6H5.16v0.4h2.71V9.6H7.75C7.64 9.6 7.54 9.6 7.44 9.58z"></path><rect x="6" y="3" width="1" height="1"></rect></svg> 추가 상품은 배송비 조건에 반영되지 않습니다. </div>\
29975                        </div>\
29976                            ';
29977                        }
29978                        html += '\
29979                    </div>\
29980                </div>\
29981                <div class="item-row">\
29982                    <div class="">' + $.lang[LANG]['shopping.delivery.template.additional_yn'] + '<svg class="cm-popover-info" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 13" width="13" height="13" tabindex="0" data-trigger="hover" data-toggle="popover" fill="#4789e7" data-html="true" data-placement="top" data-content="주소지가 제주 및 도서산간 지역이면 기본 배송비에 제주/제주 외 도서산간 지역 배송비가 추가로 부과됩니다." data-original-title="" title=""><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"></path><path d="M6.66 3.01C5.61 3.01 4.58 3.5 4.5 4.8c0 0.06-0.01 0.12 0 0.2h1.02c0-0.07 0.01-0.15 0.02-0.23 0.08-0.62 0.52-0.76 1.08-0.76 0.63 0 1.02 0.37 1.02 0.95 -0.01 0.48-0.3 0.87-0.76 1.34C6.21 6.97 6.02 7.37 6 8h0.99C7 7.66 7.04 7.37 7.67 6.75 8.17 6.27 8.7 5.68 8.7 4.87 8.7 3.85 7.89 3.01 6.66 3.01z"></path><rect x="6" y="9" width="1" height="1"></rect></svg></div>\
29983                    <div class="additional-yn-row"><label><input type="radio" name="additional_yn" value="N" ' + (opts.additional_yn == 'N' ? ' checked ' : '') + ' /><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 18 18" width="18" height="18"><path d="M9 0a9 9 0 1 0 .001 18.001A9 9 0 0 0 9 0zm0 17c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"/></svg><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 18 18" width="18" height="18"><path d="M9 0a9 9 0 1 0 .001 18.001A9 9 0 0 0 9 0zm0 17c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"/><circle cx="9" cy="9" r="6"/></svg>
29983' + $.lang[LANG]['shopping.delivery.template.additional_yn.n'] + '</label> <label><input type="radio" name="additional_yn" value="Y" ' + (opts.additional_yn == 'Y' ? ' checked ' : '') + ' /><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 18 18" width="18" height="18"><path d="M9 0a9 9 0 1 0 .001 18.001A9 9 0 0 0 9 0zm0 17c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"/></svg><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 18 18" width="18" height="18"><path d="M9 0a9 9 0 1 0 .001 18.001A9 9 0 0 0 9 0zm0 17c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"/><circle cx="9" cy="9" r="6"/></svg>' + $.lang[LANG]['shopping.delivery.template.additional_yn.y'] + '</label>\
29984                        <div class="additional-row m15t" style="' + (opts.additional_yn == 'Y' ? '' : ' display: none; ') + '">\
29985                            <div class="row-sub-title">제주</div>\
29986                            <div class="m5t"><input type="text" name="additional_jeju_price" class="form-control m5r" value="' + number_format(opts.additional_jeju_price) + '" numberonly maxlength="13" />원</div>\
29987                            <div class="row-sub-title m15t">제주 외 도서산간</div>\
29988                            <div class="m5t"><input type="text" name="additional_land_price" class="form-control m5r" value="' + number_format(opts.additional_land_price) + '" numberonly maxlength="13" />원</div>\
29989                        </div>\
29990                    </div>\
29991                </div>\
29992                <div class="item-row">\
29993                    <div class="">' + $.lang[LANG]['shopping.delivery.template.pay_type'] + '<svg class="cm-popover-info" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 13" width="13" height="13" tabindex="0" data-trigger="hover" data-toggle="popover" fill="#4789e7" data-html="true" data-placement="top" data-content="<ul><li class=\'title\'>배송비 결제 방식을 선택할 수 있습니다.</li><li class=\'item\'>선결제 : 상품 결제 시 배송비를 같이 결제합니다.</li><li class=\'item\'>착불 : 상품 결제 시 배송비가 포함되지 않고 구매자가 상품을 받을 때 배송비를 따로 결제합니다.</li><li class=\'item\'>선결제 또는 착불 : 구매자가 선결제 또는 착불로 결제할지 선택할 수 있습니다.</li></ul>" data-original-title="" title=""><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"></path><path d="M6.66 3.01C5.61 3.01 4.58 3.5 4.5 4.8c0 0.06-0.01 0.12 0 0.2h1.02c0-0.07 0.01-0.15 0.02-0.23 0.08-0.62 0.52-0.76 1.08-0.76 0.63 0 1.02 0.37 1.02 0.95 -0.01 0.48-0.3 0.87-0.76 1.34C6.21 6.97 6.02 7.37 6 8h0.99C7 7.66 7.04 7.37 7.67 6.75 8.17 6.27 8.7 5.68 8.7 4.87 8.7 3.85 7.89 3.01 6.66 3.01z"></path><rect x="6" y="9" width="1" height="1"></rect></svg></div>\
29994                    <div class="pay-type-row"><label><input type="radio" name="pay_type" value="PREPAY" ' + (opts.pay_type == 'PREPAY' ? ' checked ' : '') + ' /><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 18 18" width="18" height="18"><path d="M9 0a9 9 0 1 0 .001 18.001A9 9 0 0 0 9 0zm0 17c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"/></svg><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 18 18" width="18" height="18"><path d="M9 0a9 9 0 1 0 .001 18.001A9 9 0 0 0 9 0zm0 17c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"/><circle cx="9" cy="9" r="6"/></svg>' + $.lang[LANG]['shopping.delivery.template.pay_type.prepay'] + '</label> <label><input type="radio" name="pay_type" value="DELIVERED" ' + (opts.pay_type == 'DELIVERED' ? ' checked ' : '') + ' /><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 18 18" width="18" height="18"><path d="M9 0a9 9 0 1 0 .001 18.001A9 9 0 0 0 9 0zm0 17c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"/></svg><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 18 18" width="18" height="18"><path d="M9 0a9 9 0 1 0 .001 18.001A9 9 0 0 0 9 0zm0 17c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"/><circle cx="9" cy="9" r="6"/></svg>
29994' + $.lang[LANG]['shopping.delivery.template.pay_type.delivered'] + '</label> <label><input type="radio" name="pay_type" value="BOTH" ' + (opts.pay_type == 'BOTH' ? ' checked ' : '') + ' /><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 18 18" width="18" height="18"><path d="M9 0a9 9 0 1 0 .001 18.001A9 9 0 0 0 9 0zm0 17c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"/></svg><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 18 18" width="18" height="18"><path d="M9 0a9 9 0 1 0 .001 18.001A9 9 0 0 0 9 0zm0 17c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"/><circle cx="9" cy="9" r="6"/></svg>' + $.lang[LANG]['shopping.delivery.template.pay_type.both'] + '</label></div>\
29995                </div>\
29996                <div class="item-row">\
29997                    <div class="">' + $.lang[LANG]['shopping.delivery.template.make_to_order_yn'] + '<svg class="cm-popover-info" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 13" width="13" height="13" tabindex="0" data-trigger="hover" data-toggle="popover" fill="#4789e7" data-html="true" data-placement="top" data-content="판매 상품이 주문 접수 후 제작에 들어간다면, 구매자에게 상품 제작 후 배송되는 기간을 알려줄 수 있습니다." data-original-title="" title=""><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"></path><path d="M6.66 3.01C5.61 3.01 4.58 3.5 4.5 4.8c0 0.06-0.01 0.12 0 0.2h1.02c0-0.07 0.01-0.15 0.02-0.23 0.08-0.62 0.52-0.76 1.08-0.76 0.63 0 1.02 0.37 1.02 0.95 -0.01 0.48-0.3 0.87-0.76 1.34C6.21 6.97 6.02 7.37 6 8h0.99C7 7.66 7.04 7.37 7.67 6.75 8.17 6.27 8.7 5.68 8.7 4.87 8.7 3.85 7.89 3.01 6.66 3.01z"></path><rect x="6" y="9" width="1" height="1"></rect></svg></div>\
29998                    <div class="make-to-order-yn-row"><label><input type="radio" name="make_to_order_yn" value="N" ' + (opts.make_to_order_yn == 'N' ? ' checked ' : '') + ' /><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 18 18" width="18" height="18"><path d="M9 0a9 9 0 1 0 .001 18.001A9 9 0 0 0 9 0zm0 17c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"/></svg><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 18 18" width="18" height="18"><path d="M9 0a9 9 0 1 0 .001 18.001A9 9 0 0 0 9 0zm0 17c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"/><circle cx="9" cy="9" r="6"/></svg>' + $.lang[LANG]['shopping.delivery.template.make_to_order_yn.n'] + '</label> <label><input type="radio" name="make_to_order_yn" value="Y" ' + (opts.make_to_order_yn == 'Y' ? ' checked ' : '') + ' /><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 18 18" width="18" height="18"><path d="M9 0a9 9 0 1 0 .001 18.001A9 9 0 0 0 9 0zm0 17c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"/></svg><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 18 18" width="18" height="18"><path d="M9 0a9 9 0 1 0 .001 18.001A9 9 0 0 0 9 0zm0 17c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"/><circle cx="9" cy="9" r="6"/></svg>' + $.lang[LANG]['shopping.delivery.template.make_to_order_yn.y'] + '</label>\
29999                        <div class="make-to-order-row" style="' + (opts.make_to_order_yn == 'Y' ? '' : ' display : none; ') + '">\
30000                            <div class="row-sub-title m15t">발송 예정일</div>\
30001                            <div class="m5t">\
30002                                <select name="due_date" class="form-control">\
30003                                    <option value="">선택</option>\
30004                    ';
30005
30006                    for(var i=2; i<=14; i++) {
30007                        html += '<option value="' + i + '" ' + (opts.due_date == i ? ' selected ' : '') + '>' + i + '</option>';
30008                    }
30009
30010                    html += '   </select> 일 이내 발송 예정\
30011                            </div>\
30012                            <div class="row-sub-title m10t"><svg class="cm-popover-info" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 13" width="13" height="13" tabindex="0"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12.13c-3.11 0-5.63-2.53-5.63-5.63S3.39 0.87 6.5 0.87s5.63 2.53 5.63 5.63S9.61 12.13 6.5 12.13z"></path><path d="M7.44 9.58c-0.1-0.02-0.18-0.05-0.25-0.1C7.12 9.44 7.07 9.37 7.03 9.28 6.98 9.19 6.96 9.07 6.9
300126 8.92V5h-1.7v0.4h0.03c0.11 0 0.21 0.01 0.3 0.02 0.09 0.02 0.18 0.05 0.25 0.09 0.07 0.05 0.13 0.11 0.17 0.2 0.04 0.09 0.06 0.2 0.06 0.34v2.91c0 0.14-0.02 0.25-0.06 0.34C5.97 9.39 5.91 9.45 5.84 9.5 5.77 9.54 5.68 9.57 5.59 9.58 5.49 9.6 5.39 9.6 5.29 9.6H5.16v0.4h2.71V9.6H7.75C7.64 9.6 7.54 9.6 7.44 9.58z"></path><rect x="6" y="3" width="1" height="1"></rect></svg>주말/공휴일을 제외한 영업일 기준으로 입력</div>\
30013                        </div>\
30014                    </div>\
30015                </div>\
30016                <div class="item-row">\
30017                    <div class="">' + $.lang[LANG]['shopping.delivery.template.install_fee_yn'] + '<svg class="cm-popover-info" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 13" width="13" height="13" tabindex="0" data-trigger="hover" data-toggle="popover" fill="#4789e7" data-html="true" data-placement="top" data-content="<ul><li class=\'title\'>상품 배송 외에 별도 설치비가 발생된다면, 사용자에게 별도 설치비가 발생한다고 안내할 수 있습니다.</li><li class=\'item\'>별도 설치비에 관한 자세한 내용은 상세 페이지에 별도로 표기해 주세요.</li><li class=\'item\'>별도 설치비 설정 시 네이버 쇼핑에도 반영됩니다.</li></ul>" data-original-title="" title=""><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"></path><path d="M6.66 3.01C5.61 3.01 4.58 3.5 4.5 4.8c0 0.06-0.01 0.12 0 0.2h1.02c0-0.07 0.01-0.15 0.02-0.23 0.08-0.62 0.52-0.76 1.08-0.76 0.63 0 1.02 0.37 1.02 0.95 -0.01 0.48-0.3 0.87-0.76 1.34C6.21 6.97 6.02 7.37 6 8h0.99C7 7.66 7.04 7.37 7.67 6.75 8.17 6.27 8.7 5.68 8.7 4.87 8.7 3.85 7.89 3.01 6.66 3.01z"></path><rect x="6" y="9" width="1" height="1"></rect></svg></div>\
30018                    <div class="install-fee-yn-row"><label><input type="radio" name="install_fee_yn" value="N" ' + (opts.install_fee_yn == 'N' ? ' checked ' : '') + ' /><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 18 18" width="18" height="18"><path d="M9 0a9 9 0 1 0 .001 18.001A9 9 0 0 0 9 0zm0 17c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"/></svg><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 18 18" width="18" height="18"><path d="M9 0a9 9 0 1 0 .001 18.001A9 9 0 0 0 9 0zm0 17c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"/><circle cx="9" cy="9" r="6"/></svg>' + $.lang[LANG]['shopping.delivery.template.install_fee_yn.n'] + '</label> <label><input type="radio" name="install_fee_yn" value="Y" ' + (opts.install_fee_yn == 'Y' ? ' checked ' : '') + ' /><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 18 18" width="18" height="18"><path d="M9 0a9 9 0 1 0 .001 18.001A9 9 0 0 0 9 0zm0 17c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"/></svg><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 18 18" width="18" height="18"><path d="M9 0a9 9 0 1 0 .001 18.001A9 9 0 0 0 9 0zm0 17c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"/><circle cx="9" cy="9" r="6"/></svg>' + $.lang[LANG]['shopping.delivery.template.install_fee_yn.y'] + '</label></div>\
30019                </div>\
30020            </form>\
30021        </div>\
30022    ';
30023
30024    var modal = $(this).showModalFlat($.lang[LANG]['shopping.delivery.template.title.' + (seq != '' ? 'm' : 'n')],html,true,true, function() {
30025        modal.find('.error').remove();
30026        modal.find('.error-box').removeClass('error-box');
30027
30028        var result = true;
30029
30030        if($.trim(modal.find('input[name="name"]').val()) == '') {
30031            modal.find('input[name="name"]').after('<div class="error name-error m5t"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>템플릿 이름을 입력해 주세요.</div>');
30032            modal.find('input[name="name"]').addClass('error-box').focus();
30033            result = false;
30034        } 
30035
30036        if(checkEmojis(modal.find('input[name="name"]').val())) {
30037            modal.find('input[name="name"]').after('<div class="error name-error m5t"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>이모지는 사용할 수 없습니다.</div>');
30038            modal.find('input[name="name"]').addClass('error-box').focus();
30039            result = false;
30040        }
30041
30042        $.ajax({
30043            url: shopping_url + '/deliveryTemplateNameCheck',
30044            type: 'post',
30045            dataType: 'json',
30046            async: false,
30047            data: {
30048                'sid' : SID,
30049                'seq' : modal.find('input[name="seq"]').val(),
30050                'name' : $.trim(modal.find('input[name="name"]').val())
30051            },
30052            success:function(data) {
30053                if(data.result != 'N') {
30054                    modal.find('input[name="name"]').after('<div class="error name-error m5t"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>이미 사용 중인 이름입니다.</div>');
30055                    modal.find('input[name="name"]').focus();
30056                    result = false;
30057                }
30058            }
30059        });
30060
30061        if((modal.find('select[name="price_type"]').val() == 'FIX' || modal.find('select[name="price_type"]').val() == 'FREE_CONDITION') && (!modal.find('input[name="delivery_fee"]').val() || modal.find('input[name="delivery_fee"]').val() < 10)) {
30062            modal.find('input[name="delivery_fee"]').parent().after('<div class="error m5t"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>배송비를 10원 이상 입력해 주세요.</div>');
30063            modal.find('input[name="delivery_fee"]').addClass('error-box').focus();
30064            result = false;
30065        } 
30066
30067        if(modal.find('select[name="price_type"]').val() == 'FREE_CONDITION') {
30068            if(!modal.find('input[name="free_condition"]').val() || modal.find('input[name="free_condition"]').val() < 10) {
30069                modal.find('input[name="free_condition"]').parent().after('<div class="error m5t"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>무료 배송 조건 금액을 10원 이상 입력해 주세요.</div>');
30070                modal.find('input[name="free_condition"]').addClass('error-box').focus();;
30071                result = false;
30072            }
30073        } else if(modal.find('select[name="price_type"] option:selected').val() == 'QUANTITY') { // 수량별
30074            if(modal.find('input[name="price_type_detail_method"]:checked').val() == 'DIFFERENTIAL') { // 차등 부과
30075                modal.find('input[name="quantity_differential_value[]"]:not([readonly]), input[name="quantity_differential_price[]"]').each(function() {
30076                    if($(this).attr('name') == 'quantity_differential_value[]') {   
30077                        if($.trim($(this).val()) == '' || $(this).val() == 0) {
30078                            $(this).closest('tr').after('<tr class="error m5t"><td colspan="2"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>수량을 입력해 주세요. </td></tr>');
30079                            result = false;
30080                            $(this).addClass('error-box');
30081                        } else {
30082                            var val = $(this).val();
30083                            var cur_elem = this;
30084                            var dup_elem = modal.find('input[name="quantity_differential_value[]"]').filter(function() { return cur_elem != this && $(this).val() == val;});
30085                            if(dup_elem.length) {
30086                                dup_elem.addClass('error-box');
30087                                result = false;
30088                                $(dup_elem).closest('tr').after('<tr class="error dup-value m5t"><td colspan="2"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>동일한 값이 존재합니다.</td></tr>');
30089                            }
30090                        }
30091                    } 
30092
30093                    if($(this).attr('name') == 'quantity_differential_price[]') {
30094                        if($.trim($(this).val()) == '' || $.trim($(this).val()) < 10) {
30095                            if(!$(this).closest('tr').next('tr.error').length)
30096                                $(this).closest('tr').after('<tr class="error m5t"><td colspan="2"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>배송비를 10원 이상 입력해 주세요.</td></tr>')
30097                            $(this).addClass('error-box');
30098                            result = false;
30099                        }
30100                    }
30101                });
30102            } else if(modal.find('input[name="price_type_detail_method"]:checked').val() == 'REPEAT') {
30103                if(modal.find('input[name="quantity_repeat_value"]').val() == 0 || modal.find('input[name="quantity_repeat_value"]').val() == '') { // 반복 부과
30104                    modal.find('.quantity-repeat').append('<div class="error m5t"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>수량을 입력해 주세요.</div>');
30105                    modal.find('input[name="quantity_repeat_value"]').addClass('error-box');
30106                    modal.find('input[name="quantity_repeat_value"]').focus();
30107                    result = false;
30108                } 
30109
30110                if(!modal.find('input[name="quantity_repeat_price"]').val() || modal.find('input[name="quantity_repeat_price"]').val() < 10) {
30111                    modal.find('input[name="quantity_repeat_price"]').parent().after('<div class="error m5t"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>배송비를 10원 이상 입력해 주세요.</div>');
30112                    modal.find('input[name="quantity_repeat_price"]').addClass('error-box');
30113                    modal.find('input[name="quantity_repeat_price"]').focus();
30114                    result = false;
30115                }
30116            }
30117        } else if(modal.find('select[name="price_type"] option:selected').val() == 'WEIGHT') { // 무게별
30118            if(modal.find('input[name="price_type_detail_method"]:checked').val() == 'DIFFERENTIAL') { // 차등 부과
30119                
30120                modal.find('input[name="weight_differential_value[]"], input[name="weight_differential_price[]"]').not('[readonly]').each(function() {
30121                    if($(this).attr('name') == 'weight_differential_value[]') {
30122                        if($.trim($(this).val()) == '' || $.trim($(this).val()) == 0) {
30123                            result = false;
30124                            $(this).addClass('error-box');
30125                            $(this).focus();
30126                            $(this).closest('tr').after('<tr class="error m5t"><td colspan="2"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>무게를 0 이상 입력해 주세요. </td></tr>');
30127                            
30128                        } else {
30129                            var val = $(this).val();
30130                            var cur_elem = this;
30131                            var dup_elem = modal.find('input[name="weight_differential_value[]"]').filter(function() { return cur_elem != this && $(this).val() == val;});
30132                            if(dup_elem.length) {
30133                                dup_elem.addClass('error-box');
30134                                dup_elem.eq(0).focus();
30135                                result = false;
30136                                $(dup_elem).closest('tr').after('<tr class="error dup-value m5t"><td colspan="2"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>동일한 값이 존재합니다.</td></tr>');
30137                                
30138                            }
30139                        }
30140                    }
30141                    
30142                    if($(this).attr('name') == 'weight_differential_price[]') {
30143                        if(!$(this).val() || $(this).val() < 10) {
30144                            if(!$(this).closest('tr').next('tr.error').length)
30145                                $(this).closest('tr').after('<tr class="error m5t"><td colspan="2"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>배송비를 10원 이상 입력해 주세요.</td></tr>')
30146                            $(this).addClass('error-box');
30147                            $(this).focus();
30148                            result = false;
30149                        }
30150                    }
30151                });
30152            } else if(modal.find('input[name="price_type_detail_method"]:checked').val() == 'REPEAT') { // 반복 부과
30153                if(modal.find('input[name="weight_repeat_value"]').val() == 0 || modal.find('input[name="weight_repeat_value"]').val() == '') {
30154                    modal.find('.weight-repeat').append('<div class="error m5t"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>무게를 0 이상 입력해 주세요.</div>');
30155                    modal.find('input[name="weight_repeat_value"]').addClass('error-box');
30156                    modal.find('input[name="weight_repeat_value"]').focus();
30157                    result = false;
30158                }
30159
30160                if(!modal.find('input[name="weight_repeat_price"]').val() || modal.find('input[name="weight_repeat_price"]').val() < 10) {
30161                    modal.find('input[name="weight_repeat_price"]').parent().after('<div class="error m5t"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>배송비를 10원 이상 입력해 주세요.</div>');
30162                    modal.find('input[name="weight_repeat_price"]').addClass('error-box');
30163                    modal.find('input[name="weight_repeat_price"]').focus();
30164                    result = false;
30165                }
30166            }
30167        }
30168
30169        if(modal.find('input[name="additional_yn"]:checked').val() == 'Y') {
30170            modal.find('input[name="additional_jeju_price"]').parent().next('.error').remove();
30171            if($.trim(modal.find('input[name="additional_jeju_price"]').val()) == '' || $.trim(modal.find('input[name="additional_jeju_price"]').val()) < 10) {
30172                modal.find('input[name="additional_jeju_price"]').parent().after('<div class="error m5t"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>배송비를 10원 이상 입력해 주세요.</div>');
30173                modal.find('input[name="additional_jeju_price"]').addClass('error-box');
30174                result = false;
30175            }
30176
30177            modal.find('input[name="additional_land_price"]').parent().next('.error').remove();
30178            if($.trim(modal.find('input[name="additional_land_price"]').val()) == '' || $.trim(modal.find('input[name="additional_jeju_price"]').val()) < 10) {
30179                modal.find('input[name="additional_land_price"]').parent().after('<div class="error m5t"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>배송비를 10원 이상 입력해 주세요.</div>');
30180                modal.find('input[name="additional_land_price"]').addClass('error-box');
30181                result = false;
30182            }
30183        }
30184
30185        if(modal.find('input[name="make_to_order_yn"]:checked').val() == 'Y' && modal.find('select[name="due_date"]').val() == '') {
30186            modal.find('select[name="due_date"]').parent().parent().append('<div class="error due-date-error m5t"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>발송 예정일을 선택해 주세요.</div>');
30187            modal.find('.make-to-order-row button').addClass('error-box');
30188            result = false;
30189        }
30190
30191        if(!result) return false;
30192
30193        $.processON();
30194        setTimeout(function() {
30195            $.ajax({
30196                url: shopping_url + '/insertDeliveryTemplate',
30197                type:'post',
30198                dataType:'json',
30199                async:false,
30200                data: $('#deliveryTemplateForm').serialize(),
30201                success:function(data) {
30202
30203                },
30204                complete: function() {
30205                    $.processOFF();
30206                    if(typeof callback_func == 'function') callback_func();
30207                }
30208            });
30209        });
30210        
30211        modal.modal('hide');
30212    }, 'cancel','save','cl-cmmodal cover delivery-template-modal cl-s-btn w620 cl-p80', true, '', function() {
30213        modal.find('#deliveryTemplateForm input[name="name"]').on('blur', function() {
30214            modal.find('.name-error').remove();
30215            $(this).removeClass('error-box');
30216
30217            if($.trim($(this).val()) == '') {
30218                $(this).addClass('error-box');
30219                modal.find('input[name="name"]').after('<div class="error name-error m5t"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>템플릿 이름을 입력해 주세요.</div>');
30220                return;  
30221            } 
30222
30223            if(checkEmojis($(this).val())) {
30224                $(this).addClass('error-box');
30225                modal.find('input[name="name"]').after('<div class="error name-error m5t"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>이모지는 사용할 수 없습니다.</div>');
30226                return false;
30227            }
30228
30229            $.ajax({
30230                url: shopping_url + '/deliveryTemplateNameCheck',
30231                type: 'post',
30232                dataType: 'json',
30233                data: {
30234                    'sid' : SID,
30235                    'seq' : modal.find('input[name="seq"]').val(),
30236                    'name' : $.trim($(this).val())
30237                },
30238                success:function(data) {
30239                    if(data.result != 'N') {
30240                        $(this).addClass('error-box');
30241                        modal.find('input[name="name"]').after('<div class="error name-error m5t"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>이미 사용 중인 이름입니다.</div>');
30242                    } else {
30243                        modal.find('.name-error').remove();
30244                        modal.find('#deliveryTemplateForm input[name="name"]').removeClass('error-box');
30245                    }
30246                }
30247            });
30248        }).on('input', function() {
30249            var regexp = /^[ㄱ-ㅎㅏ-ㅣ가-힣a-zA-Z0-9\(\)\[\]\_\- ]+$/;
30250            if(!regexp.test($.trim($(this).val()))) {
30251                $(this).val($.trim($(this).val()).replace(/[^ㄱ-ㅎㅏ-ㅣ가-힣a-zA-Z0-9\(\)\[\]\_\- ]/gi, ''));
30252            }
30253        });
30254
30255        modal.find('input[name="mix_yn"]').on('change', function() {
30256            if($('input[name="mix_yn"]:checked').val() == 'Y') {
30257                modal.find('.mix-price-type-row').show();
30258            } else {
30259                modal.find('.mix-price-type-row').hide();
30260            }
30261        });
30262
30263        modal.find('select[name="price_type"]').on('change', function() {
30264            if($(this).find('option:selected').val() == 'QUANTITY') {
30265                modal.find('input[name="price_type_detail_method"]:first').prop('checked', true).change();
30266                modal.find('.weight-row').hide();
30267                modal.find('.fix-row').hide();
30268                modal.find('.free-condition-row').hide();
30269                modal.find('.quantity-row').show();
30270            } else if($(this).find('option:selected').val() == 'WEIGHT') {
30271                modal.find('input[name="price_type_detail_method"]:first').prop('checked', true).change();
30272                modal.find('.quantity-row').hide();
30273                modal.find('.fix-row').hide();
30274                modal.find('.free-condition-row').hide();
30275                modal.find('.weight-row').show();
30276            } else if($(this).find('option:selected').val() == 'FIX') {
30277                modal.find('.quantity-row').hide();
30278                modal.find('.weight-row').hide();
30279                modal.find('.free-condition-row').hide();
30280                modal.find('.fix-row').show();
30281            } else if($(this).find('option:selected').val() == 'FREE_CONDITION') {
30282                modal.find('.quantity-row').hide();
30283                modal.find('.weight-row').hide();
30284                modal.find('.fix-row').hide();
30285                modal.find('.free-condition-row').show();
30286            } else {
30287                modal.find('.fix-row').hide();
30288                modal.find('.quantity-row').hide();
30289                modal.find('.weight-row').hide();
30290                modal.find('.free-condition-row').hide();
30291            }
30292        });
30293
30294        modal.find('.btn-quantity-diff').on('click', function() {
30295            var html = '<tr><td><input type="text" class="form-control" name="quantity_differential_value[]" numberonly /> 개 이상</td><td><input type="text" class="form-control" name="quantity_differential_price[]" numberonly /> 원</td><td>
30295<span class="btn-delete-condition-row"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 12 13" width="12" height="13"><path d="M11 2H9V0H3.02v2H1 0v1h1v8c0 1.1 0.9 2 2 2h6c1.1 0 2-0.9 2-2V3h1V2H11zM4.02 1H8v1H4.02V1zM10 11c0 0.55-0.45 1-1 1H3c-0.55 0-1-0.45-1-1V3h1.02H9h1V11z"/><rect x="4" y="4" width="1" height="7"/><rect x="7" y="4" width="1" height="7"/></svg></span></td></tr>';
30296            modal.find('.quantity-differential table').append(html);
30297        });
30298
30299        modal.find('.btn-weight-diff').on('click', function() {
30300            var html = '<tr><td><input type="text" class="form-control isFloat" name="weight_differential_value[]" numberonly> Kg 이상</td><td><input type="text" class="form-control" name="weight_differential_price[]" numberonly /> 원</td><td><span class="btn-delete-condition-row"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 12 13" width="12" height="13"><path d="M11 2H9V0H3.02v2H1 0v1h1v8c0 1.1 0.9 2 2 2h6c1.1 0 2-0.9 2-2V3h1V2H11zM4.02 1H8v1H4.02V1zM10 11c0 0.55-0.45 1-1 1H3c-0.55 0-1-0.45-1-1V3h1.02H9h1V11z"/><rect x="4" y="4" width="1" height="7"/><rect x="7" y="4" width="1" height="7"/></svg></span></td></tr>';
30301            modal.find('.weight-differential table').append(html);
30302        });
30303
30304        modal.find('input[name="delivery_type[]"]').on('change', function() {
30305            if(modal.find('input[name="delivery_type[]"][value="DELIVERY"]:checked').length) {
30306                modal.find('.delivery-company-row').show();
30307            } else {
30308                modal.find('.delivery-company-row').hide();
30309            }
30310
30311            modal.find('select[name="price_type"]').prop('disabled', false);
30312
30313            // modal.find('input[name="additional_yn"]').prop('disabled', false);
30314            modal.find('.additional-yn-row').removeClass('disabled-area');
30315            
30316            // modal.find('input[name="pay_type"]').prop('disabled', false);
30317            modal.find('.pay-type-row').removeClass('disabled-area');
30318
30319            if(modal.find('input[name="delivery_type[]"]:checked').length == 1 && modal.find('input[name="delivery_type[]"]:checked').val() == 'VISIT') {
30320                modal.find('select[name="price_type"]').val('FREE').change().prop('disabled', true);
30321                modal.find('input[name="delivery_fee"]').val(0);
30322                modal.find('input[name="additional_yn"][value="N"]').prop('checked', true).change();
30323                // modal.find('input[name="additional_yn"]').prop('disabled', true);
30324                modal.find('.additional-yn-row').addClass('disabled-area');
30325                modal.find('input[name="pay_type"][value="PREPAY"]').prop('checked', true).change();
30326                // modal.find('input[name="pay_type"]').prop('disabled', true);
30327                modal.find('.pay-type-row').addClass('disabled-area');
30328            } else if(modal.find('input[name="delivery_type[]"]:checked').length == 1 && modal.find('input[name="delivery_type[]"]:checked').val() == 'QUICK') {
30329                modal.find('select[name="price_type"]').val('ETC').change().prop('disabled', true);
30330                modal.find('input[name="additional_yn"][value="N"]').prop('checked', true).change();
30331                // modal.find('input[name="additional_yn"]').prop('disabled', true);
30332                modal.find('.additional-yn-row').addClass('disabled-area');
30333                modal.find('input[name="pay_type"][value="DELIVERED"]').prop('checked', true).change();
30334                modal.find('input[name="pay_type"]').prop('disabled', true);
30335                modal.find('.pay-type-row').addClass('disabled-area');
30336            } else if(modal.find('input[name="delivery_type[]"][value="DELIVERY"]:checked').length == 0 && modal.find('input[name="delivery_type[]"][value="DIRECT"]:checked').length == 0) {
30337                modal.find('select[name="price_type"]').val('ETC').prop('disabled', true).change();
30338                modal.find('input[name="additional_yn"][value="N"]').prop('checked', true).change()
30339                // modal.find('input[name="additional_yn"]').prop('disabled', true);
30340                modal.find('.additional-yn-row').removeClass('disabled-area');
30341                modal.find('input[name="pay_type"][value="DELIVERED"]').prop('checked', true).change();
30342                // modal.find('input[name="pay_type"]').prop('disabled', true);
30343                modal.find('.pay-type-row').addClass('disabled-area');
30344            }
30345            modal.find('select[name="price_type"]').selectpicker('refresh');
30346        });
30347
30348        modal.on('input', 'input[numberonly]', function(){
30349            var max_num = 1000000000; //10억
30350            if(Number($(this).val().replace(/,/g, '')) > max_num) {
30351                $(this).val(number_format(max_num));
30352            }
30353        });
30354
30355        modal.on('input', 'input[name="weight_repeat_value"], input[name="weight_differential_value[]"]', function(){
30356            var max_num = 100;
30357
30358            var val = $(this).val().replace(/,/g, '');
30359            if(val.indexOf('.') > -1 && val.indexOf('.') < val.length-4) {
30360                val = Number((Math.floor(Number(val) * 1000) / 1000).toFixed(3));
30361            }
30362
30363            if(Number(val) > max_num) {
30364                val = max_num;
30365            }
30366            $(this).val(number_format(val));
30367        });
30368
30369        modal.find('input[name="price_type_detail_method"]').on('change', function() {
30370            if(modal.find('select[name="price_type"] option:selected').val() == 'QUANTITY') {
30371                if(modal.find('input[name="price_type_detail_method"]:checked').val() == 'DIFFERENTIAL') {
30372                    $('.quantity-differential').show();
30373                    $('.quantity-repeat').hide();
30374                } else if(modal.find('input[name="price_type_detail_method"]:checked').val() == 'REPEAT') {
30375                    $('.quantity-repeat').show();
30376                    $('.quantity-differential').hide();
30377                }
30378            } else if(modal.find('select[name="price_type"] option:selected').val() == 'WEIGHT') {
30379                if(modal.find('input[name="price_type_detail_method"]:checked').val() == 'DIFFERENTIAL') {
30380                    $('.weight-differential').show();
30381                    $('.weight-repeat').hide();
30382                } else if(modal.find('input[name="price_type_detail_method"]:checked').val() == 'REPEAT') {
30383                    $('.weight-repeat').show();
30384                    $('.weight-differential').hide();
30385                }
30386            }
30387        });
30388
30389        modal.find('input[name="delivery_fee"]').on('blur', function() {
30390            $(this).removeClass('error-box');
30391            $(this).parent().next('.error').remove();            
30392            if($.trim($(this).val()) == '' || $(this).val() < 10) {
30393                $(this).addClass('error-box');
30394                modal.find('input[name="delivery_fee"]').parent().after('<div class="error m5t"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 13" width="13" height="13">
30394<path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>배송비를 10원 이상 입력해 주세요.</div>');
30395            }
30396        });
30397
30398        modal.find('input[name="additional_yn"]').on('change', function() {
30399            if(modal.find('input[name="additional_yn"]:checked').val() == 'Y') {
30400                modal.find('.additional-row').show();
30401            } else {
30402                modal.find('.additional-row').hide();
30403            }
30404        });
30405
30406        modal.find('input[name="free_condition_yn"]').on('change', function() {
30407            if(modal.find('input[name="free_condition_yn"]:checked').val() == 'Y') {
30408                modal.find('.free-condition-row').show();
30409            } else {
30410                modal.find('.free-condition-row').hide();
30411            }
30412        });
30413
30414        modal.find('input[name="free_condition"]').on('blur', function() {
30415            $(this).removeClass('error-box');
30416            $(this).parent().next('.error').remove();
30417            if($.trim($(this).val()) == '' || $(this).val() < 10) {
30418                $(this).addClass('error-box');
30419                $(this).parent().after('<div class="error m5t"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>무료 배송 조건 금액을 10원 이상 입력해 주세요.</div>');
30420            }
30421        });
30422
30423        modal.find('input[name="make_to_order_yn"]').on('change', function() {
30424            if(modal.find('input[name="make_to_order_yn"]:checked').val() == 'Y') {
30425                modal.find('.make-to-order-row').show();
30426            } else {
30427                modal.find('.make-to-order-row').hide();
30428            }
30429        });
30430
30431        modal.on('blur', 'input[name="quantity_repeat_price"], input[name="weight_repeat_price"], input[name="additional_jeju_price"], input[name="additional_land_price"]', function() {
30432            $(this).removeClass('error-box');
30433            $(this).parent().next('.error').remove();
30434            if($.trim($(this).val()) == '' || $.trim($(this).val()) < 10) {
30435                $(this).parent().after('<div class="error m5t"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>배송비를 10원 이상 입력해 주세요.</div>');
30436                $(this).addClass('error-box');
30437            }
30438        })
30439
30440        modal.on('blur', 'input[name="quantity_repeat_value"]', function() {
30441            $(this).removeClass('error-box');
30442            $(this).parent().next('.error').remove();
30443            if($.trim($(this).val()) == '' || $.trim($(this).val()) == 0) {
30444                $(this).parent().after('<div class="error m5t"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>수량을 입력해 주세요.</div>');
30445                $(this).addClass('error-box');
30446            }
30447        });
30448
30449        modal.on('blur', 'input[name="weight_repeat_value"]', function() {
30450            $(this).removeClass('error-box');
30451            $(this).parent().next('.error').remove();
30452            if($.trim($(this).val()) == '' || $.trim($(this).val()) == 0) {
30453                $(this).parent().after('<div class="error m5t"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 13" width="13" height="13">
30453<path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>무게를 0 이상 입력해 주세요.</div>');
30454                $(this).addClass('error-box');
30455            }
30456        });
30457
30458        modal.on('blur', 'input[name="quantity_differential_value[]"]', function() {
30459            $(this).removeClass('error-box');
30460            $(this).closest('tr').next('tr.error').remove();
30461            if($.trim($(this).val()) == '' || $(this).val() == 0) {
30462                $(this).closest('tr').after('<tr class="error m5t"><td colspan="2"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>수량을 입력해 주세요.</td></tr>')
30463                $(this).addClass('error-box');
30464                return false;
30465            }
30466            modal.find('input[name="quantity_differential_value[]"]').removeClass('error-box');
30467            modal.find('.error.dup-value').remove();
30468            modal.find('input[name="quantity_differential_value[]"]').each(function() {
30469                var val = $(this).val();
30470                var cur_elem = this;
30471                var dup_elem = modal.find('input[name="quantity_differential_value[]"]').filter(function() { return cur_elem != this && $(this).val() == val;});
30472                if(dup_elem.length) {
30473                    dup_elem.addClass('error-box');
30474                    $(dup_elem).closest('tr').after('<tr class="error dup-value m5t"><td colspan="2"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>동일한 값이 존재합니다.</td></tr>');
30475                    return false;
30476                }
30477            });
30478        });
30479
30480        modal.on('blur', 'input[name="weight_differential_value[]"]', function() {
30481            $(this).removeClass('error-box');
30482            $(this).closest('tr').next('tr.error').remove();
30483            if(!$('input[name="weight_differential_value[]"]').is('[readonly]') && ($.trim($(this).val()) == '' || $(this).val() == 0)) {
30484                $(this).closest('tr').after('<tr class="error m5t"><td colspan="2"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>무게를 0 이상 입력해 주세요.</td></tr>')
30485                $(this).addClass('error-box');
30486                return false;
30487            }
30488            modal.find('input[name="weight_differential_value[]"]').removeClass('error-box');
30489            modal.find('.error.dup-value').remove();
30490            modal.find('input[name="weight_differential_value[]"]').each(function() {
30491                var val = $(this).val();
30492                var cur_elem = this;
30493                var dup_elem = modal.find('input[name="weight_differential_value[]"]').filter(function() { return cur_elem != this && $(this).val() == val;});
30494                if(dup_elem.length) {
30495                    dup_elem.addClass('error-box');
30496                    $(dup_elem).closest('tr').after('<tr class="error dup-value m5t"><td colspan="2"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>동일한 값이 존재합니다.</td></tr>');
30497                    return false;
30498                }
30499            });
30500        });
30501
30502        modal.on('blur', 'input[name="quantity_differential_price[]"], input[name="weight_differential_price[]"]', function() {
30503            $(this).removeClass('error-box');
30504            $(this).closest('tr').next('tr.error').remove();
30505            if($.trim($(this).val()) == '' || $(this).val() < 10) {
30506                $(this).closest('tr').after('<tr class="error m5t"><td colspan="2"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>배송비를 10원 이상 입력해 주세요.</td></tr>')
30507                $(this).addClass('error-box');
30508            }
30509        });
30510
30511        modal.on('change', 'select[name="due_date"]', function() {
30512            modal.find('select[name="due_date"]').parent().parent().find('.due-date-error').remove();
30513            modal.find('.make-to-order-row button').removeClass('error-box');
30514            if($(this).val() == '') {
30515                modal.find('select[name="due_date"]').parent().parent().append('<div class="error due-date-error m5t"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>
30515발송 예정일을 선택해 주세요.</div>');
30516                modal.find('.make-to-order-row button').addClass('error-box');
30517            }
30518        });
30519
30520        modal.on('click', '.btn-delete-condition-row', function() {
30521            var btn = this;
30522            var modal = $(this).showModalFlat('배송비 조건 구간 삭제', '선택한 배송비 조건 구간을 삭제하시겠습니까?', true, true, function() {
30523                $(btn).closest('tr').remove();
30524                modal.modal('hide');
30525            }, 'cancel', 'ok', 'cl-cmmodal cl-s-btn w560 cl-p130');
30526            var backdrop_z_index = Number(modal.css('zIndex'));
30527            modal.css('zIndex', backdrop_z_index + 1);
30528            modal.parent().next('.modal-backdrop').css('zIndex', backdrop_z_index);
30529        }); 
30530
30531        modal.find('[data-toggle="popover"]').popover();
30532
30533        modal.find('select').selectpicker();
30534
30535        modal.find('.delivery-company-row').find('.tracking-delivery-icon').replaceWith('<svg data-toggle="popover" data-content="배송 추적 가능" data-trigger="hover" data-placement="top" data-html="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path d="m11.6 17.72-.98.61v-5.37l5.2-3.25v.76c.39-.08.79-.13 1.2-.13V8.62c0-.01-.01-.02-.01-.03 0-.06-.02-.12-.04-.17a.625.625 0 0 0-.23-.3l-6.4-4a.614.614 0 0 0-.64 0l-6.4 4c-.11.07-.18.18-.23.3-.02.05-.03.11-.04.17 0 .01-.01.02-.01.03v6.8c0 .21.11.4.28.51l6.4 4a.62.62 0 0 0 .64 0l1.75-1.1c-.2-.34-.36-.71-.49-1.11zM10.02 5.33l2.11 1.32-5.28 3.3-2.1-1.32 5.27-3.3zm-.6 13.01-5.2-3.25V9.72l5.2 3.25v5.37zm.6-6.41-2.04-1.27 5.28-3.3 2.04 1.27-5.28 3.3z"/><path d="m22.85 21-2.61-2.61c.49-.66.79-1.48.79-2.36 0-2.21-1.79-4-4-4s-4 1.79-4 4 1.79 4 4 4c.89 0 1.7-.3 2.36-.79L22 21.85c.12.12.27.18.42.18s.31-.06.42-.18a.6.6 0 0 0 .01-.85zm-8.63-4.98c0-1.54 1.26-2.8 2.8-2.8s2.8 1.26 2.8 2.8c0 .77-.31 1.46-.81 1.97 0 0-.01 0-.01.01s0 .01-.01.01a2.799 2.799 0 0 1-4.77-1.99z"/></svg>');
30536        modal.find('.delivery-company-row').find('[data-toggle="popover"]').popover();
30537        modal.find('select[name="delivery_company"]').on('shown.bs.select changed.bs.select', function(select_event, dropdown_event) {
30538            modal.find('.delivery-company-row').find('.tracking-delivery-icon').replaceWith('<svg data-toggle="popover" data-content="배송 추적 가능" data-trigger="hover" data-placement="top" data-html="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path d="m11.6 17.72-.98.61v-5.37l5.2-3.25v.76c.39-.08.79-.13 1.2-.13V8.62c0-.01-.01-.02-.01-.03 0-.06-.02-.12-.04-.17a.625.625 0 0 0-.23-.3l-6.4-4a.614.614 0 0 0-.64 0l-6.4 4c-.11.07-.18.18-.23.3-.02.05-.03.11-.04.17 0 .01-.01.02-.01.03v6.8c0 .21.11.4.28.51l6.4 4a.62.62 0 0 0 .64 0l1.75-1.1c-.2-.34-.36-.71-.49-1.11zM10.02 5.33l2.11 1.32-5.28 3.3-2.1-1.32 5.27-3.3zm-.6 13.01-5.2-3.25V9.72l5.2 3.25v5.37zm.6-6.41-2.04-1.27 5.28-3.3 2.04 1.27-5.28 3.3z"/><path d="m22.85 21-2.61-2.61c.49-.66.79-1.48.79-2.36 0-2.21-1.79-4-4-4s-4 1.79-4 4 1.79 4 4 4c.89 0 1.7-.3 2.36-.79L22 21.85c.12.12.27.18.42.18s.31-.06.42-.18a.6.6 0 0 0 .01-.85zm-8.63-4.98c0-1.54 1.26-2.8 2.8-2.8s2.8 1.26 2.8 2.8c0 .77-.31 1.46-.81 1.97 0 0-.01 0-.01.01s0 .01-.01.01a2.799 2.799 0 0 1-4.77-1.99z"/></svg>');
30539            modal.find('.delivery-company-row').find('[data-toggle="popover"]').popover();
30540            // if(select_event.type == 'shown') {
30541            //     var select = select_event.target;
30542            //     var dropdown = dropdown_event.target;
30543            //     var selected_text = $(select).find('option:selected').text();
30544            //     // console.log(dropdown);
30545            //     var target = $(dropdown).find('li').filter(function() { return $(this).find('span.text').text() == selected_text});
30546            //     var pos = $(target).offset().top;
30547            //     $(dropdown).find('.inner').scrollTop($(dropdown).find('.inner').scrollTop() + pos);
30548            // }
30549        });
30550
30551    });
30552}
30553
30554function convertDateString(input) {
30555    const regex = /(\d{4})년 (\d{2})월 (\d{2})일 (오전|오후) (\d{2}):(\d{2})/;
30556    const match = input.match(regex);
30557    if (!match) return "";
30558
30559    let [_, year, month, day, period, hour, minute] = match;
30560    return `${year}-${month}-${day} ${hour}:${minute}`;
30561}
30562
30563// var calendarDateTimePicker = function(id, type, se, fulltime) {
30564//     console.log('id: ' + id +', type: ' + type + ', se: ' + se + ', fulltime: ' + fulltime);
30565//     // if(typeof id === undefined || !id) {
30566//     //     return false;
30567//     // }
30568//     var sid = (typeof property != 'undefined') ? property.SID : SID;
30569//     var blocklang = LANG;
30570//     var field_setting = {};
30571//     var etcDateState = 'N';
30572
30573//     //기본값
30574//     $default_term = {
30575//         'select_terms' : 'N',
30576//         'start_date' : '',
30577//         'end_date' : '',
30578//         'date_week' : 'A',
30579//         'days' : 'sun|mon|tue|wed|thu|fri|sat',
30580//     };
30581//     $default_excludeDate = {'date' : ''};
30582//     $default_time = {
30583//         'interval' : '30',
30584//         'am' : '0000|0030|0100|0130|0200|0230|0300|0330|0400|0430|0500|0530|0600|0630|0700|0730|0800|0830|0900|0930|1000|1030|1100|1130',
30585//         'pm' : '1200|1230|1300|1330|1400|1430|1500|1530|1600|1630|1700|1730|1800|1830|1900|1930|2000|2030|2100|2130|2200|2230|2300|2330'
30586//     };
30587//     $default_color = {'highlight' : '4789e7'};
30588
30589//     field_setting = {
30590//         'term' : $default_term,
30591//         'excludeDate' : $default_excludeDate,
30592//         'time' : $default_time,
30593//         'color' : $default_color,
30594//     };
30595
30596//     var term = (field_setting.term)? field_setting.term:{};
30597//     var excludeDate = (field_setting.excludeDate)? field_setting.excludeDate:{};
30598//     var time = (type != 'date' && field_setting.time)? field_setting.time:{};
30599//     var color = (field_setting.color)? field_setting.color:{};
30600
30601//     var startDate = (term.start_date !== undefined)? term.start_date:'';
30602//     var endDate = (term.end_date !== undefined)? term.end_date:'';
30603//     var dateWeek = (term.date_week !== undefined)? term.date_week:'';
30604//     var days = (term.days !== undefined)? term.days.split('|'):[];
30605//     var daysObj = {
30606//         'sun': 0,
30607//         'mon': 1,
30608//         'tue': 2,
30609//         'wed': 3,
30610//         'thu': 4,
30611//         'fri': 5,
30612//         'sat': 6,
30613//     }
30614
30615//     //excludeDate
30616//     var exceptDate = (excludeDate.date !== undefined)? excludeDate.date.split(','):[];
30617
30618//     //time
30619//     var interval = (time.interval!==undefined)? time.interval:'30';
30620//     var am = (time.am!==undefined && time.am)? time.am.split('|'):[];
30621//     var pm = (time.pm!==undefined && time.pm)? time.pm.split('|'):[];
30622    
30623//     var disabled = null;
30624//     if(term.select_terms == 'Y') {
30625//         if(dateWeek == 'W') {
30626//             disabled = [0, 6];
30627//         } else if(dateWeek == 'K') {
30628//             disabled = [1, 2, 3, 4, 5];
30629//         }
30630//         if(days.length > 0) {
30631//             disabled = [0, 1, 2, 3, 4, 5, 6];
30632//             $.each(days, function(i, v){
30633//                 enableIdx = disabled.indexOf(daysObj[v]);
30634//                 if(enableIdx > -1) {
30635//                     disabled.splice(enableIdx, 1);
30636//                 }
30637//             });
30638//         }
30639//     }
30640//     var modal_title = (!fulltime) ? $.lang[blocklang]['config.form.date2.select'] : $.lang[blocklang]['config.form.date.select'];
30641//     var modal_str = '\
30642//         <div class="term-calendar-box form-calendar-box" data-type="'+type+'">\
30643//             <input type="hidden" id="select-calendar" value="term-datepicker">\
30644//             <input type="hidden" id="etc-start-date-txt" value="'+startDate+'">\
30645//             <input type="hidden" id="etc-end-date-txt" value="'+endDate+'">\
30646//             <input type="hidden" id="etc-date-week" value="'+dateWeek+'">\
30647//             <input type="hidden" id="etc-except-date" value="'+exceptDate+'">\
30648//             <input type="hidden" id="select-date-ymd">\
30649//             <div id="form-date2-datepicker-'+id+'"></div>\
30650//         </div>';
30651//     if(!fulltime) {
30652//         modal_str+='\
30653//             <div class="setting-row">\
30654//                 <div class="setting-label am">'+$.lang[blocklang]['config.form.date2.time.am']+'</div>\
30655//                 <div class="display-flex time-interval" data-time="am"></div>\
30656//             </div>\
30657//             <div class="setting-row">\
30658//                 <div class="setting-label pm">'+$.lang[blocklang]['config.form.date2.time.pm']+'</div>\
30659//                 <div class="display-flex time-interval" data-time="pm"></div>\
30660//             </div>';
30661//     }
30662    
30663//     if($('#etc-status').val() == 'P') {
30664//         modal_str+='\
30665//         <div class="term-setting hide" data-blocklang="'+blocklang+'">\
30666//             <span class="start-date"></span> ~ <span class="end-date"></span><span class="time"></span>\
30667//         </div>';
30668//     } else {
30669//         modal_str+='\
30670//         <div class="term-setting hide" data-blocklang="'+blocklang+'"></div>';
30671//     }
30672    
30673
30674//     var modal_class = 'modal-dialog cl-cmmodal cl-s-btn form-date2 cl-close-btn cover';
30675//     var etcText = '';
30676//     var dateTimeModal = $(this).showModalFlat(modal_title, modal_str, true, true, function () { //confirm
30677//         var datePick = $('.term-setting').text();
30678//         if(!fulltime) {
30679//             if(datePick == '') {
30680//                 alert('날짜와 시간을 선택해 주세요');
30681//                 return false;
30682//             } else {
30683//                 $('.userEL'+id).find('.calendar-modal-body .modal-field.'+se+' input').val(convertDateString(datePick));
30684//             }
30685//         } else {
30686//             var d = $('#select-date-ymd').val();
30687//             if(d == '') {
30688//                 alert('날짜를 선택해 주세요');
30689//                 return false;
30690//             }
30691//             var dp = d.replaceAll('.', '-');
30692//             $('.userEL'+id).find('.calendar-modal-body .modal-field.'+se+' input').val(dp);
30693//         }
30694
30695//         var $body = $('.userEL'+id).find('.calendar-modal-body');
30696//         var sVal = $body.find('.modal-field.sdate input').val() || '';
30697//         var eVal = $body.find('.modal-field.edate input').val() || '';
30698//         var pass = 'N';
30699
30700//         var rx = /^\d{4}-\d{2}-\d{2}( \d{2}:\d{2})?$/;
30701
30702//         var sOk = rx.test(sVal), eOk = rx.test(eVal);
30703//         if (sOk && eOk) {
30704//             var sStr = (sVal.length === 10) ? (sVal + ' 00:00') : sVal;
30705//             var eStr = (eVal.length === 10) ? (eVal + ' 00:00') : eVal;
30706//             var sDate = new Date(sStr.replace(' ', 'T'));
30707//             var eDate = new Date(eStr.replace(' ', 'T'));
30708
30709//             if (isFinite(sDate) && isFinite(eDate) && sDate <= eDate) {
30710//                 pass = 'Y';
30711//         }
30712//         }
30713
30714//         $body.find('.pass').val(pass).trigger('change');
30715
30716//         dateTimeModal.modal('hide');
30717//     },$.lang[blocklang]['config.cancel'],$.lang[blocklang]['config.ok'], modal_class, true, '', function() { //show
30718//         var currentYear = new Date().getFullYear();
30719//         var termPicker = new Datepickk({
30720//             container: document.querySelector('#form-date2-datepicker-'+id),
30721//             inline:true,
30722//             today:true,
30723//             range: ((type == 'etc-product-date' || type == 'etc-product-datetime') && $('#etc-status').val() == 'P')? true : false,
30724//             disabledDays: disabled,
30725//             lang: blocklang,
30726//             minDate: new Date(1900, 0, 1),
30727//             maxDate: new Date(currentYear + 15, 11, 31),
30728//         });
30729
30730//         if(type.indexOf('etc-product-date') > -1) {
30731//             startDate = $('#etc-min-date').val();
30732//             endDate = $('#etc-max-date').val();
30733//         }
30734
30735//         if(exceptDate) {
30736//             var disabledDateArr = new Array();
30737//             $.each(exceptDate, function(idx, item){
30738//                 item = item.replace(/\./g,'/'); //date for firefox
30739//                 disabledDateArr.push(new Date(item));
30740//             });
30741//             termPicker.disabledDates = disabledDateArr;
30742//         }
30743        
30744//         if(startDate && endDate) {
30745//             var checkStartDate = startDate.split('.');
30746//             var checkEndDate = endDate.split('.');
30747//             termPicker.minDate = new Date(checkStartDate[0], (checkStartDate[1] * 1) - 1, checkStartDate[2]);
30748//             termPicker.maxDate = new Date(checkEndDate[0], (checkEndDate[1] * 1) - 1, checkEndDate[2]);
30749//         }
30750
30751//         $(document).off('click', '.d-year, .d-month');
30752//         $(document).on('click', '.d-year, .d-month', function(){
30753//             $('.d-month-year-picker').toggleClass('d-show');
30754//             scrollToCurrentYearMonth();
30755//         });
30756
30757//         $('#datetime-style-'+id).remove();
30758//         var highlight = '#'+color.highlight;
30759//         var h_rgba = hexToRgba(highlight);
30760//         var rgba_str = h_rgba.r+','+h_rgba.g+','+h_rgba.b;
30761//         var style = '\
30762//             <style id="datetime-style-'+id+'">\
30763//                 .form-date2 .Datepickk .d-table input:not(:disabled):not(:checked) + label:hover:before{border: 1px solid '+highlight+'; background-color: transparent;}\
30764//                 .form-date2 .Datepickk .d-table input:not(:disabled) + label:hover:before{border: 1px solid '+highlight+'; background-color: transparent;}\
30765//                 .form-date2 .Datepickk .d-table input:checked + label:before, .form-date2 .Datepickk .d-table input:checked + label:hover:before {background-color: '+highlight+'; border: 1px solid '+highlight+';}\
30766//                 .form-date2 .time-interval input:checked + label {color: '+highlight+'; border: 1px solid '+highlight+';}\
30767//                 .form-date2 .time-interval label{background-color: rgba('+rgba_str+', 0.05); border: 1px solid rgba('+rgba_str+', 0.1);}\
30768//                 .form-date2 .term-setting{background-color: rgba('+rgba_str+', 0.05);}\
30769//             </style>\
30770//             ';
30771//         $('.cl-cmmodal.form-date2').append(style);
30772        
30773//         dateTimeModal.find('.time-interval').each(function(i, v){
30774//             var mna = $(v).data('time');
30775//             var times = '';
30776
30777//             if(mna === 'am') {
30778//                 for(let t = 0; t <= 11; t++) {
30779//                     let hstr = t.toString().padStart(2, '0');
30780//                     times += '\
30781//                         <input type="checkbox" id="'+mna+'-'+t+'-00" class="o-time hide" name="'+mna+'" value="'+mna+' '+hstr+':00" data-setting_time="'+hstr+'00">\
30782//                         <label for="'+mna+'-'+t+'-00" class="o-time">'+hstr+':00</label>\
30783//                         <input type="checkbox" id="'+mna+'-'+t+'-30" class="ten-time half-time hide" name="'+mna+'" value="'+mna+' '+hstr+':30" data-setting_time="'+hstr+'30">\
30784//                         <label for="'+mna+'-'+t+'-30" class="ten-time half-time">'+hstr+':30</label>\
30785//                     ';
30786//                 }
30787//             }
30788
30789//             if(mna === 'pm') {
30790//                 for(let t = 12; t <= 23; t++) {
30791//                     let hstr = t.toString();
30792//                     times += '\
30793//                         <input type="checkbox" id="'+mna+'-'+t+'-00" class="o-time hide" name="'+mna+'" value="'+mna+' '+hstr+':00" data-setting_time="'+hstr+'00">\
30794//                         <label for="'+mna+'-'+t+'-00" class="o-time">'+hstr+':00</label>\
30795//                         <input type="checkbox" id="'+mna+'-'+t+'-30" class="ten-time half-time hide" name="'+mna+'" value="'+mna+' '+hstr+':30" data-setting_time="'+hstr+'30">\
30796//                         <label for="'+mna+'-'+t+'-30" class="ten-time half-time">'+hstr+':30</label>\
30797//                     ';
30798//                 }
30799//             }
30800
30801//             $(v).html(times);
30802//         });
30803        
30804//         dateTimeModal.find('.time-interval input').prop('disabled', true);
30805        
30806//         if(am.length > 0) {
30807//             $.each(am, function(i, v){
30808//                 dateTimeModal.find('.time-interval[data-time="am"] input[data-setting_time="'+v+'"]').prop('disabled', false);
30809//             });
30810//         }
30811
30812//         if(pm.length > 0) {
30813//             $.each(pm, function(i, v){
30814//                 dateTimeModal.find('.time-interval[data-time="pm"] input[data-setting_time="'+v+'"]').prop('disabled', false);
30815//             });
30816//         }
30817        
30818//         dateTimeModal.find('.time-interval label:not(.o-time)').addClass('hide');
30819        
30820//         switch (interval) {
30821//             case '10':
30822//                 dateTimeModal.find('.time-interval label').removeClass('hide');
30823//                 break;
30824//             case '20':
30825//                 dateTimeModal.find('.time-interval label.twt-time').removeClass('hide');
30826//                 break;
30827//             case '30':
30828//                 dateTimeModal.find('.time-interval label.half-time').removeClass('hide');
30829//                 break;
30830//         }
30831
30832//         let $enableTimes = dateTimeModal.find('.time-interval[data-time] input:not(:disabled) + label').not('.hide');
30833//         let $enableTimesAM = dateTimeModal.find('.time-interval[data-time="am"] input:not(:disabled) + label').not('.hide');
30834//         let $enableTimesPM = dateTimeModal.find('.time-interval[data-time="pm"] input:not(:disabled) + label').not('.hide');
30835
30836//         $enableTimes.first().prevAll('label').addClass('hide');
30837//         $enableTimes.last().nextAll('label').addClass('hide');
30838
30839//         if($enableTimesAM.length == 0) {
30840//             $('.setting-label.am').addClass('hide');
30841//             $('.time-interval[data-time="am"]').addClass('hide');
30842//         }
30843//         if($enableTimesPM.length == 0) {
30844//             $('.setting-label.pm').addClass('hide');
30845//             $('.time-interval[data-time="pm"]').addClass('hide');
30846//         }
30847
30848//         dateTimeModal.find('.time-interval input').on('change', function(){
30849//             $('.time-interval input').prop('checked', false);
30850//             $(this).prop('checked', true);
30851            
30852//             if(type == 'etc-product-datetime') {
30853//                 if($('#etc-status').val() == 'P') {
30854//                     if(!$('#etc-start-date-txt').val() || !$('#etc-end-date-txt').val()) return false;
30855//                 } else {
30856//                     if(!$('#etc-start-date-txt').val()) return false;
30857//                 }
30858//             }
30859
30860//             getDateTimeStr(blocklang);
30861//         });
30862
30863//         if(type.indexOf('etc-product-date') > -1 && $('#etc-start-date-option').val()) { //etc product
30864//             if($('#etc-status').val() == 'P') { //기간
30865//                 document.querySelector('#etc-start-date-txt').value = document.querySelector('#etc-start-date-option').value;
30866//                 document.querySelector('#etc-end-date-txt').value = document.querySelector('#etc-end-date').value;
30867//                 document.querySelector('#select-date-ymd').value = document.querySelector('#etc-start-date-option').value + '|' + document.querySelector('#etc-end-date').value
30868//                 termPicker.startDate = $('#etc-start-date-option').val();
30869//                 termPicker.endDate = $('#etc-end-date').val();
30870//             } else {
30871//                 document.querySelector('#etc-start-date-txt').value = document.querySelector('#etc-start-date-option').value;
30872//                 document.querySelector('#select-date-ymd').value = document.querySelector('#etc-start-date-option').value;
30873//                 var sDate = $('#etc-start-date-option').val();
30874//                 var sDateObj = new Date(sDate);
30875//                 termPicker.selectDate(sDateObj);
30876//             }
30877
30878//             if($('#etc-time').val()) {
30879//                 var sTime = $('#etc-time').val();
30880//                 $('.time-interval input[value="'+sTime+'"]').prop('checked', true);
30881//             }
30882            
30883//             setTimeout(function(){
30884//                 getDateTimeStr('ko')
30885//             }, 500);
30886//         }
30887//     });
30888// }
30889
30890var formDateTimePicker = function(id, type) {
30891    if(typeof id === undefined || !id) {
30892        return false;
30893    }
30894    var sid = (typeof property != 'undefined') ? property.SID : SID;
30895    var blocklang = ($('[form-seq="'+id+'"]').closest('.element').attr('data-blocklang'))? $('[form-seq="'+id+'"]').closest('.element').attr('data-blocklang'):LANG;
30896    var field_setting = {};
30897    var etcDateState = 'N';
30898
30899    if(type == 'etc-product-date' || type == 'etc-product-datetime') {
30900        blocklang = LANG;
30901        etcDateState = $('#etc-state').val();
30902        field_setting.term = JSON.parse($('#etc-term-setting').val());
30903        field_setting.excludeDate = {'date': $('#etc-exclude-date').val()};
30904        if(type == 'etc-product-datetime') field_setting.time = JSON.parse($('#etc-time-setting').val());
30905    } else {
30906        $.ajax({
30907            url: '/template/forms/field_config',
30908            dataType: 'json',
30909            type: 'POST',
30910            data:  { sid: sid, id : id },
30911            async: false,
30912            cache: false,
30913            success: function(data) {
30914                checkError(data);
30915                field_setting = data;
30916            }
30917        });
30918    }
30919
30920    var term = (field_setting.term)? field_setting.term:{};
30921    var excludeDate = (field_setting.excludeDate)? field_setting.excludeDate:{};
30922    var time = (type != 'date' && field_setting.time)? field_setting.time:{};
30923    var color = (field_setting.color)? field_setting.color:{};
30924
30925    var startDate = (term.start_date !== undefined)? term.start_date:'';
30926    var endDate = (term.end_date !== undefined)? term.end_date:'';
30927    var dateWeek = (term.date_week !== undefined)? term.date_week:'';
30928    var days = (term.days !== undefined)? term.days.split('|'):[];
30929    var daysObj = {
30930        'sun': 0,
30931        'mon': 1,
30932        'tue': 2,
30933        'wed': 3,
30934        'thu': 4,
30935        'fri': 5,
30936        'sat': 6,
30937    }
30938
30939    //excludeDate
30940    var exceptDate = (excludeDate.date !== undefined)? excludeDate.date.split(','):[];
30941
30942    //time
30943    if(type == 'date2' || type == 'etc-product-datetime') {
30944        var interval = (time.interval!==undefined)? time.interval:'30';
30945        var am = (time.am!==undefined && time.am)? time.am.split('|'):[];
30946        var pm = (time.pm!==undefined && time.pm)? time.pm.split('|'):[];
30947    }
30948    
30949    var disabled = null;
30950    if(term.select_terms == 'Y') {
30951        if(dateWeek == 'W') {
30952            disabled = [0, 6];
30953        } else if(dateWeek == 'K') {
30954            disabled = [1, 2, 3, 4, 5];
30955        }
30956        if(days.length > 0) {
30957            disabled = [0, 1, 2, 3, 4, 5, 6];
30958            $.each(days, function(i, v){
30959                enableIdx = disabled.indexOf(daysObj[v]);
30960                if(enableIdx > -1) {
30961                    disabled.splice(enableIdx, 1);
30962                }
30963            });
30964        }
30965    }
30966    var modal_title = (type == 'date2' || type == 'etc-product-datetime')? $.lang[blocklang]['config.form.date2.select'] : $.lang[blocklang]['config.form.date.select'];
30967    var modal_str = '\
30968        <div class="term-calendar-box form-calendar-box" data-type="'+type+'">\
30969            <input type="hidden" id="select-calendar" value="term-datepicker">\
30970            <input type="hidden" id="etc-start-date-txt" value="'+startDate+'">\
30971            <input type="hidden" id="etc-end-date-txt" value="'+endDate+'">\
30972            <input type="hidden" id="etc-date-week" value="'+dateWeek+'">\
30973            <input type="hidden" id="etc-except-date" value="'+exceptDate+'">\
30974            <input type="hidden" id="select-date-ymd">\
30975            <div id="form-date2-datepicker-'+id+'"></div>\
30976        </div>';
30977    if(type == 'etc-product-date' || type == 'etc-product-datetime') {
30978        modal_str = '\
30979        <div class="term-calendar-box form-calendar-box" data-type="'+type+'">\
30980            <input type="hidden" id="select-calendar" value="term-datepicker">\
30981            <input type="hidden" id="etc-start-date-txt" value="">\
30982            <input type="hidden" id="etc-end-date-txt" value="">\
30983            <input type="hidden" id="etc-date-week" value="'+dateWeek+'">\
30984            <input type="hidden" id="etc-except-date" value="'+exceptDate+'">\
30985            <input type="hidden" id="select-date-ymd">\
30986            <div id="form-date2-datepicker-'+id+'"></div>\
30987        </div>';
30988    }
30989    if(type == 'date2' || type == 'etc-product-datetime') {
30990        modal_str+='\
30991        <div class="setting-row">\
30992            <div class="setting-label am">'+$.lang[blocklang]['config.form.date2.time.am']+'</div>\
30993            <div class="display-flex time-interval" data-time="am"></div>\
30994        </div>\
30995        <div class="setting-row">\
30996            <div class="setting-label pm">'+$.lang[blocklang]['config.form.date2.time.pm']+'</div>\
30997            <div class="display-flex time-interval" data-time="pm"></div>\
30998        </div>';
30999    
31000    }
31001    if($('#etc-status').val() == 'P') {
31002        modal_str+='\
31003        <div class="term-setting hide" data-blocklang="'+blocklang+'">\
31004            <span class="start-date"></span> ~ <span class="end-date"></span><span class="time"></span>\
31005        </div>';
31006    } else {
31007        modal_str+='\
31008        <div class="term-setting hide" data-blocklang="'+blocklang+'"></div>';
31009    }
31010    
31011
31012    var modal_class = 'modal-dialog cl-cmmodal cl-s-btn form-date2 
31012cl-close-btn cover';
31013    if(type == 'etc-product-date' || type == 'etc-product-datetime') modal_class = 'modal-dialog cl-cmmodal cl-s-btn form-date2 etc-product-date cl-close-btn cover';
31014    var etcText = '';
31015    var dateTimeModal = $(this).showModalFlat(modal_title, modal_str, true, true, function () { //confirm
31016        //input value
31017        var $formDateYmd = $('[form-seq="'+id+'"] .date-ymd');
31018        var isFranchiseBar = ($formDateYmd.closest('[data-type="contact"][data-type2="franchise bar"]').length > 0);
31019        $formDateYmd.attr('data-select_date', $('#select-date-ymd').val());
31020        var dateVal = ($('#select-date-ymd').val() && $('.term-setting').text())? true : false;
31021        switch(type) {
31022            case 'date2':
31023                if(dateVal) {
31024                    $formDateYmd.attr('data-select_time', $('.time-interval input:checked').attr('id'));
31025                    $formDateYmd.val($('.term-setting').text());
31026                    if(isFranchiseBar) {
31027                        $formDateYmd.removeAttr('style');
31028                    } else {
31029                        $formDateYmd.css('width', '240px');
31030                    }
31031                } else {
31032                    alert($.lang[blocklang]['config.form.date2.notSelected']);
31033                    return false;
31034                }
31035                break;
31036            case 'etc-product-date':
31037                if(dateVal) {
31038                    if($('#etc-status').val() == 'P') {
31039                        var selectedDate = $('#select-date-ymd').val().split('|');
31040
31041                        $('.option-body #etc-start-date-option').val(selectedDate[0]);
31042                        $('.modal-cart-option-change #etc-start-date-option').val(selectedDate[0]);
31043                        $('input[name="change_option_start_date"]').val(selectedDate[0]);
31044
31045                        $('.option-body #etc-end-date').val(selectedDate[1]);
31046                        $('.modal-cart-option-change #etc-end-date').val(selectedDate[1]);
31047                        $('input[name="change_option_end_date"]').val(selectedDate[1]);
31048
31049                        etcText = selectedDate[0] + ' - ' + selectedDate[1];
31050                    } else {
31051                        var selectedDate = $('#select-date-ymd').val();
31052                        $('.option-body #etc-start-date-option').val(selectedDate);
31053                        $('.modal-cart-option-change #etc-start-date-option').val(selectedDate);
31054                        $('input[name="change_option_start_date"]').val(selectedDate);
31055                        etcText = selectedDate;
31056                    }
31057
31058                    $('#etc-date-text').text(etcText);
31059                    console.log(etcText);
31060                } else {
31061                    alert('날짜를 선택해 주세요.');
31062                    return false;
31063                }
31064                break;
31065            case 'etc-product-datetime':
31066                if(!dateTimeModal.find('.time-interval input:checked').val() || !dateVal) {
31067                    alert('날짜와 시간을 선택해 주세요.');
31068                    return false;
31069                }
31070                if(dateVal) {
31071                    $('.option-body #etc-time').val($('.time-interval input:checked').val());
31072                    $('.modal-cart-option-change #etc-time').val($('.time-interval input:checked').val());
31073                    if($('#etc-status').val() == 'P') {
31074                        var selectedDate = $('#select-date-ymd').val().split('|');
31075
31076                        $('.option-body #etc-start-date-option').val(selectedDate[0]);
31077                        $('.modal-cart-option-change #etc-start-date-option').val(selectedDate[0]);
31078                        $('input[name="change_option_start_date"]').val(selectedDate[0]);
31079
31080                        $('.option-body #etc-end-date').val(selectedDate[1]);
31081                        $('.modal-cart-option-change #etc-end-date').val(selectedDate[1]);
31082                        $('input[name="change_option_end_date"]').val(selectedDate[1]);
31083
31084                        etcText = selectedDate[0] + ' - ' + selectedDate[1];
31085                    } else {
31086                        var selectedDate = $('#select-date-ymd').val();
31087                        $('.option-body #etc-start-date-option').val(selectedDate);
31088                        $('.modal-cart-option-change #etc-start-date-option').val(selectedDate);
31089                        $('input[name="change_option_start_date"]').val(selectedDate);
31090                        etcText = selectedDate;
31091                    }
31092
31093                    if($('#etc-time').val()) {
31094                        var etcTime = $('#etc-time').val().split(' ');
31095                        if(etcTime[0] == 'am') {
31096                            etcText += (' 오전 ' + etcTime[1]);
31097                        } else {
31098                            etcText += (' 오후 ' + etcTime[1]);
31099                        }
31100                    }
31101
31102                    $('#etc-date-text').text(etcText);
31103                }
31104                break;
31105            default:
31106                if(dateVal) {
31107                    $formDateYmd.val($('.term-setting').text());
31108                } else {
31109                    alert($.lang[blocklang]['config.form.date.notSelected']);
31110                    return false;
31111                }
31112                break;
31113        }
31114        
31115        if(type == 'etc-product-date' || type == 'etc-product-datetime') {
31116            if ($('.cl-s-normal-option-selector').length <= 0) {
31117                var quantity = $('#product-quantity').val();
31118                var price = $('#product_c_price').val();
31119                var option = document.createElement('div');
31120                console.log(etcText + '||0||' + quantity);
31121                $(option).attr('data-val', etcText + '||0||' + quantity);
31122                productOptionPick(option, price, 'etc_none_option');
31123            }
31124        }
31125        
31126        //old
31127        if($('[form-seq="'+id+'"] .date-yyyy').length > 0) {
31128            var selectedDate = $('#select-date-ymd').val();
31129            var dateArr = selectedDate.split('.');
31130            $('[form-seq="'+id+'"] .date-yyyy').val(dateArr[0]);
31131            $('[form-seq="'+id+'"] .date-mm').val(dateArr[1]);
31132            $('[form-seq="'+id+'"] .date-dd').val(dateArr[2]);
31133
31134            if($('[form-seq="'+id+'"] .date-hh').length > 0) {
31135                var checkedTime = $('.time-interval input:checked').val();
31136                var timeArr = checkedTime.replace(/am |pm /g, '').split(':');
31137                var hh = timeArr[0];
31138                var ii = timeArr[1];
31139
31140                if(checkedTime.indexOf('pm') > -1) {
31141                    hh = (timeArr[0] == '12')? timeArr[0] : Number(timeArr[0])+12;
31142                }
31143
31144                $('[form-seq="'+id+'"] .date-hh').val(hh);
31145                $('[form-seq="'+id+'"] .date-ii').val(ii);
31146            }
31147        } 
31148        dateTimeModal.modal('hide');
31149    },$.lang[blocklang]['config.cancel'],$.lang[blocklang]['config.ok'], modal_class, true, '', function() { //show
31150        var currentYear = new Date().getFullYear();
31151        var termPicker = new Datepickk({
31152            container: document.querySelector('#form-date2-datepicker-'+id),
31153            inline:true,
31154            today:true,
31155            range: ((type == 'etc-product-date' || type == 'etc-product-datetime') && $('#etc-status').val() == 'P')? true : false,
31156            disabledDays: disabled,
31157            lang: blocklang,
31158            minDate: new Date(1900, 0, 1),
31159            maxDate: new Date(currentYear + 15, 11, 31),
31160        });
31161
31162        if(type.indexOf('etc-product-date') > -1) {
31163            startDate = $('#etc-min-date').val();
31164            endDate = $('#etc-max-date').val();
31165        }
31166
31167        if(exceptDate) {
31168            var disabledDateArr = new Array();
31169            $.each(exceptDate, function(idx, item){
31170                item = item.replace(/\./g,'/'); //date for firefox
31171                disabledDateArr.push(new Date(item));
31172            });
31173            termPicker.disabledDates = disabledDateArr;
31174        }
31175        
31176        if(startDate && endDate) {
31177            var checkStartDate = startDate.split('.');
31178            var checkEndDate = endDate.split('.');
31179            termPicker.minDate = new Date(checkStartDate[0], (checkStartDate[1] * 1) - 1, checkStartDate[2]);
31180            termPicker.maxDate = new Date(checkEndDate[0], (checkEndDate[1] * 1) - 1, checkEndDate[2]);
31181        }
31182
31183        $(document).off('click', '.d-year, .d-month');
31184        $(document).on('click', '.d-year, .d-month', function(){
31185            $('.d-month-year-picker').toggleClass('d-show');
31186            scrollToCurrentYearMonth();
31187        });
31188
31189        if((type=='date'||type=='date2') && color) {
31190            $('#datetime-style-'+id).remove();
31191            var highlight = '#'+color.highlight;
31192            var h_rgba = hexToRgba(highlight);
31193            var rgba_str = h_rgba.r+','+h_rgba.g+','+h_rgba.b;
31194            var style = '\
31195                <style id="datetime-style-'+id+'">\
31196                    .form-date2 .Datepickk .d-table input:not(:disabled):not(:checked) + label:hover:before{border: 1px solid '+highlight+'; background-color: transparent;}\
31197                    .form-date2 .Datepickk .d-table input:not(:disabled) + label:hover:before{border: 1px solid '+highlight+'; background-color: transparent;}\
31198                    .form-date2 .Datepickk .d-table input:checked + label:before, .form-date2 .Datepickk .d-table input:checked + label:hover:before {background-color: '+highlight+'; border: 1px solid '+highlight+';}\
31199                    .form-date2 .time-interval input:checked + label {color: '+highlight+'; border: 1px solid '+highlight+';}\
31200                    .form-date2 .time-interval label{background-color: rgba('+rgba_
31200str+', 0.05); border: 1px solid rgba('+rgba_str+', 0.1);}\
31201                    .form-date2 .term-setting{background-color: rgba('+rgba_str+', 0.05);}\
31202                </style>\
31203             ';
31204            $('.cl-cmmodal.form-date2').append(style);
31205        }
31206        if(type == 'date2' || type == 'etc-product-datetime') {
31207            dateTimeModal.find('.time-interval').each(function(i, v){
31208                var mna = $(v).data('time');
31209                var times = '\
31210                    <input type="checkbox" id="'+mna+'-12-00" class="o-time hide" name="'+mna+'" value="'+mna+' 12:00" data-setting_time="1200">\
31211                    <label for="'+mna+'-12-00" class="o-time">12:00</label>\
31212                    <input type="checkbox" id="'+mna+'-12-10" class="ten-time hide" name="'+mna+'" value="'+mna+' 12:10" data-setting_time="1210">\
31213                    <label for="'+mna+'-12-10" class="ten-time">12:10</label>\
31214                    <input type="checkbox" id="'+mna+'-12-20" class="ten-time twt-time hide" name="'+mna+'" value="'+mna+' 12:20" data-setting_time="1220">\
31215                    <label for="'+mna+'-12-20" class="ten-time twt-time">12:20</label>\
31216                    <input type="checkbox" id="'+mna+'-12-30" class="ten-time half-time hide" name="'+mna+'" value="'+mna+' 12:30" data-setting_time="1230">\
31217                    <label for="'+mna+'-12-30" class="ten-time half-time">12:30</label>\
31218                    <input type="checkbox" id="'+mna+'-12-40" class="ten-time twt-time hide" name="'+mna+'" value="'+mna+' 12:40" data-setting_time="1240">\
31219                    <label for="'+mna+'-12-40" class="ten-time twt-time">12:40</label>\
31220                    <input type="checkbox" id="'+mna+'-12-50" class="ten-time hide" name="'+mna+'" value="'+mna+' 12:50" data-setting_time="1250">\
31221                    <label for="'+mna+'-12-50" class="ten-time">12:50</label>\
31222                    \
31223                    ';
31224                    for(let t = 1; t <= 11; t++) {
31225                        let hstr = t.toString().padStart(2, '0');
31226                        times += '\
31227                            <input type="checkbox" id="'+mna+'-'+t+'-00" class="o-time hide" name="'+mna+'" value="'+mna+' '+hstr+':00" data-setting_time="'+hstr+'00">\
31228                            <label for="'+mna+'-'+t+'-00" class="o-time">'+t+':00</label>\
31229                            <input type="checkbox" id="'+mna+'-'+t+'-10" class="ten-time hide" name="'+mna+'" value="'+mna+' '+hstr+':10" data-setting_time="'+hstr+'10">\
31230                            <label for="'+mna+'-'+t+'-10" class="ten-time">'+t+':10</label>\
31231                            <input type="checkbox" id="'+mna+'-'+t+'-20" class="ten-time twt-time hide" name="'+mna+'" value="'+mna+' '+hstr+':20" data-setting_time="'+hstr+'20">\
31232                            <label for="'+mna+'-'+t+'-20" class="ten-time twt-time">'+t+':20</label>\
31233                            <input type="checkbox" id="'+mna+'-'+t+'-30" class="ten-time half-time hide" name="'+mna+'" value="'+mna+' '+hstr+':30" data-setting_time="'+hstr+'30">\
31234                            <label for="'+mna+'-'+t+'-30" class="ten-time half-time">'+t+':30</label>\
31235                            <input type="checkbox" id="'+mna+'-'+t+'-40" class="ten-time twt-time hide" name="'+mna+'" value="'+mna+' '+hstr+':40" data-setting_time="'+hstr+'40">\
31236                            <label for="'+mna+'-'+t+'-40" class="ten-time twt-time">'+t+':40</label>\
31237                            <input type="checkbox" id="'+mna+'-'+t+'-50" class="ten-time hide" name="'+mna+'" value="'+mna+' '+hstr+':50" data-setting_time="'+hstr+'50">\
31238                            <label for="'+mna+'-'+t+'-50" class="ten-time">'+t+':50</label>\
31239                        ';
31240                    }
31241                    // times += '\
31242                    // <input type="checkbox" id="'+mna+'-1-00" class="hide" name="'+mna+'" value="'+mna+' 01:00" data-setting_time="0100">\
31243                    // <label for="'+mna+'-1-00">1:00</label>\
31244                    // <input type="checkbox" id="'+mna+'-1-30" class="half-time hide" name="'+mna+'" value="'+mna+' 01:30" data-setting_time="0130">\
31245                    // <label for="'+mna+'-1-30" class="half-time">1:30</label>\
31246                    // \
31247                    // <input type="checkbox" id="'+mna+'-2-00" class="hide" name="'+mna+'" value="'+mna+' 02:00" data-setting_time="0200">\
31248                    // <label for="'+mna+'-2-00">2:00</label>\
31249                    // <input type="checkbox" id="'+mna+'-2-30" class="half-time hide" name="'+mna+'" value="'+mna+' 02:30" data-setting_time="0230">\
31250                    // <label for="'+mna+'-2-30" class="half-time">2:30</label>\
31251                    // \
31252                    // <input type="checkbox" id="'+mna+'-3-00" class="hide" name="'+mna+'" value="'+mna+' 03:00" data-setting_time="0300">\
31253                    // <label for="'+mna+'-3-00">3:00</label>\
31254                    // <input type="checkbox" id="'+mna+'-3-30" class="half-time hide" name="'+mna+'" value="'+mna+' 03:30" data-setting_time="0330">\
31255                    // <label for="'+mna+'-3-30" class="half-time">3:30</label>\
31256                    // \
31257                    // <input type="checkbox" id="'+mna+'-4-00" class="hide" name="'+mna+'" value="'+mna+' 04:00" data-setting_time="0400">\
31258                    // <label for="'+mna+'-4-00">4:00</label>\
31259                    // <input type="checkbox" id="'+mna+'-4-30" class="half-time hide" name="'+mna+'" value="'+mna+' 04:30" data-setting_time="0430">\
31260                    // <label for="'+mna+'-4-30" class="half-time">4:30</label>\
31261                    // \
31262                    // <input type="checkbox" id="'+mna+'-5-00" class="hide" name="'+mna+'" value="'+mna+' 05:00" data-setting_time="0500">\
31263                    // <label for="'+mna+'-5-00">5:00</label>\
31264                    // <input type="checkbox" id="'+mna+'-5-30" class="half-time hide" name="'+mna+'" value="'+mna+' 05:30" data-setting_time="0530">\
31265                    // <label for="'+mna+'-5-30" class="half-time">5:30</label>\
31266                    // \
31267                    // <input type="checkbox" id="'+mna+'-6-00" class="hide" name="'+mna+'" value="'+mna+' 06:00" data-setting_time="0600">\
31268                    // <label for="'+mna+'-6-00">6:00</label>\
31269                    // <input type="checkbox" id="'+mna+'-6-30" class="half-time hide" name="'+mna+'" value="'+mna+' 06:30" data-setting_time="0630">\
31270                    // <label for="'+mna+'-6-30" class="half-time">6:30</label>\
31271                    // \
31272                    // <input type="checkbox" id="'+mna+'-7-00" class="hide" name="'+mna+'" value="'+mna+' 07:00" data-setting_time="0700">\
31273                    // <label for="'+mna+'-7-00">7:00</label>\
31274                    // <input type="checkbox" id="'+mna+'-7-30" class="half-time hide" name="'+mna+'" value="'+mna+' 07:30" data-setting_time="0730">\
31275                    // <label for="'+mna+'-7-30" class="half-time">7:30</label>\
31276                    // \
31277                    // <input type="checkbox" id="'+mna+'-8-00" class="hide" name="'+mna+'" value="'+mna+' 08:00" data-setting_time="0800">\
31278                    // <label for="'+mna+'-8-00">8:00</label>\
31279                    // <input type="checkbox" id="'+mna+'-8-30" class="half-time hide" name="'+mna+'" value="'+mna+' 08:30" data-setting_time="0830">\
31280                    // <label for="'+mna+'-8-30" class="half-time">8:30</label>\
31281                    // \
31282                    // <input type="checkbox" id="'+mna+'-9-00" class="hide" name="'+mna+'" value="'+mna+' 09:00" data-setting_time="0900">\
31283                    // <label for="'+mna+'-9-00">9:00</label>\
31284                    // <input type="checkbox" id="'+mna+'-9-30" class="half-time hide" name="'+mna+'" value="'+mna+' 09:30" data-setting_time="0930">\
31285                    // <label for="'+mna+'-9-30" class="half-time">9:30</label>\
31286                    // \
31287                    // <input type="checkbox" id="'+mna+'-10-00" class="hide" name="'+mna+'" value="'+mna+' 10:00" data-setting_time="1000">\
31288                    // <label for="'+mna+'-10-00">10:00</label>\
31289                    // <input type="checkbox" id="'+mna+'-10-30" class="half-time hide" name="'+mna+'" value="'+mna+' 10:30" data-setting_time="1030">\
31290                    // <label for="'+mna+'-10-30" class="half-time">10:30</label>\
31291                    // \
31292                    // <input type="checkbox" id="'+mna+'-11-00" class="hide" name="'+mna+'" value="'+mna+' 11:00" data-setting_time="1100">\
31293                    // <label for="'+mna+'-11-00">11:00</label>\
31294                    // <input type="checkbox" id="'+mna+'-11-30" class="half-time hide" name="'+mna+'" value="'+mna+' 11:30" data-setting_time="1130">\
31295                    // <label for="'+mna+'-11-30" class="half-time">11:30</label>\
31296                    // ';
31297                $(v).html(times);
31298            }); //end each
31299            
31300            dateTimeModal.find('.time-interval input').prop('disabled', true);
31301            
31302            if(am.length > 0) {
31303                $.each(am, function(i, v){
31304                    dateTimeModal.find('.time-interval[data-time="am"] input[data-setting_time="'+v+'"]').prop('disabled', false);
31305                });
31306            }
31307
31308            if(pm.length > 0) {
31309                $.each(pm, function(i, v){
31310                    dateTimeModal.find('.time-interval[data-time="pm"] input[data-setting_time="'+v+'"]').prop('disabled', false);
31311                });
31312            }
31313            
31314            dateTimeModal.find('.time-interval label:not(.o-time)').addClass('hide');
31315            console.log('interval', interval);
31316            switch (interval) {
31317                case '10':
31318                    dateTimeModal.find('.time-interval label').removeClass('hide');
31319                    break;
31320                case '20':
31321                    dateTimeModal.find('.time-interval label.twt-time').removeClass('hide');
31322                    break;
31323                case '30':
31324                    dateTimeModal.find('.time-interval label.half-time').removeClass('hide');
31325                    break;
31326            }
31327
31328            let $enableTimes = dateTimeModal.find('.time-interval[data-time] input:not(:disabled) + label').not('.hide');
31329            let $enableTimesAM = dateTimeModal.find('.time-interval[data-time="am"] input:not(:disabled) + label').not('.hide');
31330            let $enableTimesPM = dateTimeModal.find('.time-interval[data-time="pm"] input:not(:disabled) + label').not('.hide');
31331
31332            $enableTimes.first().prevAll('label').addClass('hide');
31333            $enableTimes.last().nextAll('label').addClass('hide');
31334
31335            if($enableTimesAM.length == 0) {
31336                $('.setting-label.am').addClass('hide');
31337                $('.time-interval[data-time="am"]').addClass('hide');
31338            }
31339            if($enableTimesPM.length == 0) {
31340                $('.setting-label.pm').addClass('hide');
31341                $('.time-interval[data-time="pm"]').addClass('hide');
31342            }
31343
31344            // var num = 1;
31345            // var length = 0;
31346            // dateTimeModal.find('.time-interval label').not('.hide').each(function(i, v){
31347            //     $(v).prev('input').addClass('row-'+num);
31348            //     if($(v).prev('input').prop('disabled')) {
31349            //         length++;
31350            //     }
31351
31352            //     if((i+1)%4 == 0) {
31353            //         if(length == 4) $('input.row-'+num+' + label').addClass('hide');
31354            //         length = 0;
31355            //         num ++;
31356            //     }
31357            // });
31358
31359            dateTimeModal.find('.time-interval input').on('change', function(){
31360                $('.time-interval input').prop('checked', false);
31361                $(this).prop('checked', true);
31362                
31363                if(type == 'etc-product-datetime') {
31364                    if($('#etc-status').val() == 'P') {
31365                        if(!$('#etc-start-date-txt').val() || !$('#etc-end-date-txt').val()) return false;
31366                    } else {
31367                        if(!$('#etc-start-date-txt').val()) return false;
31368                    }
31369                }
31370
31371                getDateTimeStr(blocklang);
31372            });
31373        } //date2
31374
31375        if($('[form-seq="'+id+'"] .date-ymd').val()) { //form
31376            var sDate = $('[form-seq="'+id+'"] .date-ymd').attr('data-select_date');
31377            var sDateObj = new Date(sDate);
31378            termPicker.currentDate  = sDateObj;
31379            termPicker.selectDate(sDateObj);
31380            $('#select-date-ymd').val(sDate);
31381            
31382            if(type == 'date2') {
31383                var sTime = $('[form-seq="'+id+'"] .date-ymd').attr('data-select_time');
31384                $('#'+sTime).prop('checked', true);
31385            }
31386            getDateTimeStr(blocklang);
31387        }
31388
31389        if(type.indexOf('etc-product-date') > -1 && $('#etc-start-date-option').val()) { //etc product
31390            if($('#etc-status').val() == 'P') { //기간
31391                document.querySelector('#etc-start-date-txt').value = document.querySelector('#etc-start-date-option').value;
31392                document.querySelector('#etc-end-date-txt').value = document.querySelector('#etc-end-date').value;
31393                document.querySelector('#select-date-ymd').value = document.querySelector('#etc-start-date-option').value + '|' + document.querySelector('#etc-end-date').value
31394                termPicker.startDate = $('#etc-start-date-option').val();
31395                termPicker.endDate = $('#etc-end-date').val();
31396            } else {
31397                document.querySelector('#etc-start-date-txt').value = document.querySelector('#etc-start-date-option').value;
31398                document.querySelector('#select-date-ymd').value = document.querySelector('#etc-start-date-option').value;
31399                var sDate = $('#etc-start-date-option').val();
31400                var sDateObj = new Date(sDate);
31401                termPicker.selectDate(sDateObj);
31402            }
31403
31404            if($('#etc-time').val()) {
31405                var sTime = $('#etc-time').val();
31406                $('.time-interval input[value="'+sTime+'"]').prop('checked', true);
31407            }
31408            
31409            setTimeout(function(){
31410                getDateTimeStr('ko')
31411            }, 500);
31412        }
31413    });
31414}
31415
31416function getDateTimeStr(blocklang, w, c) {
31417    // console.log(c)
31418    if(typeof w == 'undefined') w = '';
31419    if(typeof c == 'undefined') c = '';
31420    var lang = (blocklang)? blocklang:LANG
31421    var selectedDate = $('#select-date-ymd').val();
31422    var checkSelectedDate = selectedDate.split('.');
31423    var inputType = ($('.setting-datetime-input').length > 0)? $('.setting-datetime-input').attr('data-type') : $('.form-calendar-box').attr('data-type');
31424    var selectedTime = $('.time-interval input:checked');
31425
31426    switch (inputType) {
31427        case 'date2':
31428            if(selectedDate && selectedTime.length > 0) {
31429                $('.term-setting').removeClass('hide');
31430                var selectedTimeTxt = ' '+$.lang[lang]['config.form.date2.time.'+selectedTime.attr('name')]+' '+selectedTime.next('label').text();            
31431                if(lang == 'ko') {
31432                    $('.term-setting').text(checkSelectedDate[0]+'년 '+checkSelectedDate[1]+'월 '+checkSelectedDate[2]+'일'+selectedTimeTxt);
31433                } else {
31434                    $('.term-setting').text(checkSelectedDate[1]+'/'+checkSelectedDate[2]+'/'+checkSelectedDate[0]+selectedTimeTxt);
31435                }
31436            }
31437            break;
31438        case 'etc-product-date':
31439        case 'etc-product-datetime':
31440            lang = 'ko';
31441            blocklang = 'ko';
31442            
31443            var selectedTimeTxt = '';
31444            selectedDate = $('#etc-start-date-txt').val();
31445            checkSelectedDate = selectedDate.split('.');
31446
31447            var startDate = $('#etc-start-date-txt').val();
31448            var endDate = $('#etc-end-date-txt').val();
31449            if(selectedDate) {
31450                $('.term-setting').removeClass('hide');
31451                if($('#etc-status').val() == 'P') { //기간
31452                    var checkStartDate = startDate.split('.');
31453                    var checkEndDate = endDate.split('.');
31454                    if (selectedTime.length > 0) selectedTimeTxt = '<br>'+$.lang[lang]['config.form.date2.time.'+selectedTime.attr('name')]+' '+selectedTime.next('label').text();            
31455                    if(blocklang == 'ko') {
31456                        $('.term-setting .start-date').html(checkStartDate[0]+'년 '+checkStartDate[1]+'월 '+checkStartDate[2]+' 일');
31457                        $('.term-setting .end-date').html(checkEndDate[0]+'년 '+checkEndDate[1]+'월 '+checkEndDate[2]+' 일'+selectedTimeTxt);
31458                    } else {
31459                        $('.term-setting .start-date').html(checkStartDate[1]+'/'+checkStartDate[2]+'/'+checkStartDate[0]);
31460                        $('.term-setting .end-date').html(checkEndDate[1]+'/'+checkEndDate[2]+'/'+checkEndDate[0]+selectedTimeTxt);
31461                    }
31462                } else {
31463                    if (selectedTime.length > 0) selectedTimeTxt = ' '+$.lang[lang]['config.form.date2.time.'+selectedTime.attr('name')]+' '+selectedTime.next('label').text();            
31464                    if(lang == 'ko') {
31465                        $('.term-setting').html(checkSelectedDate[0]+'년 '+checkSelectedDate[1]+'월 '+checkSelectedDate[2]+'일'+selectedTimeTxt);
31466                    } else {
31467                        $('.term-setting').html(checkSelectedDate[1]+'/'+checkSelectedDate[2]+'/'+checkSelectedDate[0]+selectedTimeTxt);
31468                    }
31469                }
31470            }
31471            break;
31472        case 'saleStartDateTime':
31473            if(c == '') {
31474                lang = 'ko';
31475                blocklang = 'ko';
31476            } else {
31477                lang = c;
31478                blocklang = c;
31479            }
31480            // console.log('w', w);
31481            var selectedTimeTxt = '';
31482            checkSelectedDate = selectedDate.split('.');
31483
31484            if(selectedDate) {
31485                if(lang == 'ko') {
31486                    $('.sale-calendar-box .start-date').html(checkSelectedDate[0]+'년 '+checkSelectedDate[1]+'월 '+checkSelectedDate[2]+'일');
31487                } else {
31488                    $('.sale-calendar-box .start-date').html(checkSelectedDate[1]+'/'+checkSelectedDate[2]+'/'+checkSelectedDate[0]);
31489                }
31490                
31491                var saleStartDateTime = $('#sale-start-datetime').val();
31492                
31493                if (w == 'calendar') {
31494                    $('.setting-sale-date .setting-datetime-input').slideUp(400, function(){
31495                        $('.setting-sale-date').removeClass('open');
31496                    });
31497
31498                    $('.setting-sale-time .setting-datetime-input').slideDown(400, function(){
31499                        $('.setting-sale-time').addClass('open');
31500                    });
31501                } else {
31502                    if(!w && saleStartDateTime) {
31503                        $('.setting-sale-date').removeClass('open');
31504                        $('.setting-sale-date .setting-datetime-input').css('display', 'none');
31505                        
31506                        $('.setting-sale-time').removeClass('open');
31507                        $('.setting-sale-time .setting-datetime-input').css('display', 'none');
31508                    }
31509                }
31510            }
31511
31512            if (selectedTime.length > 0) {
31513                var timeArr = selectedTime.next('label').text().split(':');
31514                if(c == 'en') selectedTimeTxt = $.lang[c]['config.form.date2.time.'+selectedTime.closest('.time-interval').attr('data-time')]+' '+timeArr[0]+' : '+timeArr[1];
31515                else selectedTimeTxt = $.lang[lang]['config.form.date2.time.'+selectedTime.closest('.time-interval').attr('data-time')]+' '+timeArr[0]+'시 '+timeArr[1]+'분';
31516                $('.sale-calendar-box .start-time').html(selectedTimeTxt);
31517                
31518                if (w == 'time') {
31519                    $('.setting-sale-time .setting-datetime-input').slideUp(400, function(){
31520                        $('.setting-sale-time').removeClass('open');
31521                    });
31522                }
31523            }
31524            break;
31525        case 'saleEndDateTime':
31526            if(c == '') {
31527                lang = 'ko';
31528                blocklang = 'ko';
31529            } else {
31530                lang = c;
31531                blocklang = c;
31532            }
31533
31534            var selectedTimeTxt = '';
31535            checkSelectedDate = selectedDate.split('.');
31536
31537            if(selectedDate) {
31538                if(lang == 'ko') {
31539                    $('.sale-calendar-box .end-date').html(checkSelectedDate[0]+'년 '+checkSelectedDate[1]+'월 '+checkSelectedDate[2]+'일');
31540                } else {
31541                    $('.sale-calendar-box .end-date').html(checkSelectedDate[1]+'/'+checkSelectedDate[2]+'/'+checkSelectedDate[0]);
31542                }
31543
31544                var saleStartDateTime = $('#sale-start-datetime').val();
31545                var saleEndDateTime = $('#sale-end-datetime').val();
31546
31547                var startDate = saleStartDateTime.split(' ')[0];
31548                var startTime = saleStartDateTime.split(' ')[1];
31549
31550                if (w == 'calendar') {
31551                    $('.setting-sale-date .setting-datetime-input').slideUp(400, function(){
31552                        $('.setting-sale-date').removeClass('open');
31553                    });
31554
31555                    $('.setting-sale-time .setting-datetime-input').slideDown(400, function(){
31556                        $('.setting-sale-time').addClass('open');
31557                    });
31558                } else {
31559                    if(!w && saleStartDateTime) {
31560                        $('.setting-sale-date').removeClass('open');
31561                        $('.setting-sale-date .setting-datetime-input').css('display', 'none');
31562                        
31563                        $('.setting-sale-time').removeClass('open');
31564                        $('.setting-sale-time .setting-datetime-input').css('display', 'none');
31565                    }
31566                }
31567
31568                $('.time-interval input').prop('disabled', false);
31569                if(saleStartDateTime && startDate == selectedDate.replace(/\./g,'-')) {
31570                    var hour = parseInt(startTime.split(':')[0]);
31571                    var minute = parseInt(startTime.split(':')[1]);
31572                    var mna = (hour >= 12)? 'pm' : 'am';
31573
31574                    if(hour >= 12) {
31575                        if (hour > 12) hour -= 12;
31576                    } else if (hour == 0) hour += 12
31577
31578                    var formattedStartTime = hour.toString().padStart(2, '0') + minute.toString().padStart(2, '0');
31579                    $('.time-interval[data-time="' + mna + '"] input[value="' + formattedStartTime + '"]').prop('disabled', true);
31580                    if(mna == 'pm') {
31581                        $('.time-interval[data-time="am"] input').prop('disabled', true);
31582                        $('.time-interval[data-time="pm"] input[value="' + formattedStartTime + '"]').prevAll('input').prop('disabled', true);
31583                    } else {
31584                        $('.time-interval[data-time="am"] input[value="' + formattedStartTime + '"]').prevAll('input').prop('disabled', true);
31585                    }
31586                    if($('.time-interval input:checked').is(':disabled')) {
31587                        $('.time-interval input:checked').prop('checked', false);
31588                        $('.sale-calendar-box .end-time').html('');
31589                        selectedTime = '';
31590                    }
31591                }
31592            }
31593
31594            if (selectedTime.length > 0) {
31595                var timeArr = selectedTime.next('label').text().split(':');
31596                if(c == 'en') selectedTimeTxt = $.lang[c]['config.form.date2.time.'+selectedTime.closest('.time-interval').attr('data-time')]+' '+timeArr[0]+' : '+timeArr[1];
31597                else selectedTimeTxt = $.lang[lang]['config.form.date2.time.'+selectedTime.closest('.time-interval').attr('data-time')]+' '+timeArr[0]+'시 '+timeArr[1]+'분';
31598                $('.sale-calendar-box .end-time').html(selectedTimeTxt);
31599
31600                if (w == 'time') {
31601                    $('.setting-sale-time .setting-datetime-input').slideUp(400, function(){
31602                        $('.setting-sale-time').removeClass('open');
31603                    });
31604                }
31605            }
31606            break;
31607        default:
31608            if(selectedDate) {
31609                $('.term-setting').removeClass('hide');
31610                if(lang == 'ko') {
31611                    $('.term-setting').text(checkSelectedDate[0]+'년 '+checkSelectedDate[1]+'월 '+checkSelectedDate[2]+'일');
31612                } else {
31613                    $('.term-setting').text(checkSelectedDate[1]+'/'+checkSelectedDate[2]+'/'+checkSelectedDate[0]);
31614                }
31615            }
31616            break;
31617    }
31618    // if(selectedDate && startTime.length > 0 && endTime.length > 0) {
31619    //     var startTimeTxt = (startTime.attr('name') == 'am') ? '오전 '+startTime.next('label').text():'오후 '+startTime.next('label').text();
31620    //     var endTimeTxt = (endTime.attr('name') == 'am') ? '오전 '+endTime.next('label').text() :'오후 '+endTime.next('label').text();
31621
31622    //     var s = startTime.val();
31623    //     var e = endTime.val();
31624    //     var sHour = (startTime.attr('name') == 'pm')? Number(s.substr(0, 2))+12 : Number(s.substr(0, 2));
31625    //     var sMinute = Number(s.substr(2));
31626    //     var eHour = (endTime.attr('name') == 'pm')? Number(e.substr(0, 2))+12 : Number(e.substr(0, 2));
31627    //     var eMinute = Number(e.substr(2));
31628        
31629    //     if(sHour == 24) sHour = 12;
31630    //     else if(sHour == 12) sHour = 0;
31631    //     if(eHour == 24) eHour = 12;
31632    //     else if(eHour == 12) eHour = 0;
31633
31634    //     var startDateTime = new Date(checkSelectedDate[0], checkSelectedDate[1], checkSelectedDate[2], sHour, sMinute);
31635    //     var endDateTime = new Date(checkSelectedDate[0], checkSelectedDate[1], checkSelectedDate[2], eHour, eMinute);
31636    //     var elapsedMSec = endDateTime.getTime()-startDateTime.getTime();
31637    //     var elapsedHour = elapsedMSec/1000/60/60;
31638    //     console.log(sHour, sMinute, startDateTime, endDateTime, elapsedMSec, elapsedHour);
31639    //     var totalTimesTxt = (elapsedMSec%3600000 == 0)? ' ('+elapsedHour+'시간)' : ' ('+Math.floor(elapsedHour)+'시간 30분)';
31640    //     $('.term-setting').removeClass('hide');
31641    //     $('.term-setting').text(checkSelectedDate[0]+'년 '+checkSelectedDate[1]+'월 '+checkSelectedDate[2]+' 일 '+startTimeTxt+' ~ '+ endTimeTxt + totalTimesTxt);
31642    // }
31643}
31644
31645// function calendarDateTimeStr(blocklang, w) {
31646//     if(typeof w == 'undefined') w = '';
31647//     var lang = (blocklang)? blocklang:LANG
31648//     var selectedDate = $('#select-date-ymd').val();
31649//     var checkSelectedDate = selectedDate.split('.');
31650//     var inputType = ($('.setting-datetime-input').length > 0)? $('.setting-datetime-input').attr('data-type') : $('.form-calendar-box').attr('data-type');
31651//     var selectedTime = $('.time-interval input:checked');
31652
31653//     switch (inputType) {
31654//         case 'date2':
31655//             if(selectedDate && selectedTime.length > 0) {
31656//                 $('.term-setting').removeClass('hide');
31657//                 var selectedTimeTxt = ' '+$.lang[lang]['config.form.date2.time.'+selectedTime.attr('name')]+' '+selectedTime.next('label').text();            
31658//                 if(lang == 'ko') {
31659//                     $('.term-setting').text(checkSelectedDate[0]+'년 '+checkSelectedDate[1]+'월 '+checkSelectedDate[2]+'일'+selectedTimeTxt);
31660//                 } else {
31661//                     $('.term-setting').text(checkSelectedDate[1]+'/'+checkSelectedDate[2]+'/'+checkSelectedDate[0]+selectedTimeTxt);
31662//                 }
31663//             }
31664//             break;
31665//         case 'etc-product-date':
31666//         case 'etc-product-datetime':
31667//             lang = 'ko';
31668//             blocklang = 'ko';
31669            
31670//             var selectedTimeTxt = '';
31671//             selectedDate = $('#etc-start-date-txt').val();
31672//             checkSelectedDate = selectedDate.split('.');
31673
31674//             var startDate = $('#etc-start-date-txt').val();
31675//             var endDate = $('#etc-end-date-txt').val();
31676//             if(selectedDate) {
31677//                 $('.term-setting').removeClass('hide');
31678//                 if($('#etc-status').val() == 'P') { //기간
31679//                     var checkStartDate = startDate.split('.');
31680//                     var checkEndDate = endDate.split('.');
31681//                     if (selectedTime.length > 0) selectedTimeTxt = '<br>'+$.lang[lang]['config.form.date2.time.'+selectedTime.attr('name')]+' '+selectedTime.next('label').text();            
31682//                     if(blocklang == 'ko') {
31683//                         $('.term-setting .start-date').html(checkStartDate[0]+'년 '+checkStartDate[1]+'월 '+checkStartDate[2]+' 일');
31684//                         $('.term-setting .end-date').html(checkEndDate[0]+'년 '+checkEndDate[1]+'월 '+checkEndDate[2]+' 일'+selectedTimeTxt);
31685//                     } else {
31686//                         $('.term-setting .start-date').html(checkStartDate[1]+'/'+checkStartDate[2]+'/'+checkStartDate[0]);
31687//                         $('.term-setting .end-date').html(checkEndDate[1]+'/'+checkEndDate[2]+'/'+checkEndDate[0]+selectedTimeTxt);
31688//                     }
31689//                 } else {
31690//                     if (selectedTime.length > 0) selectedTimeTxt = ' '+$.lang[lang]['config.form.date2.time.'+selectedTime.attr('name')]+' '+selectedTime.next('label').text();            
31691//                     if(lang == 'ko') {
31692//                         $('.term-setting').html(checkSelectedDate[0]+'년 '+checkSelectedDate[1]+'월 '+checkSelectedDate[2]+'일'+selectedTimeTxt);
31693//                     } else {
31694//                         $('.term-setting').html(checkSelectedDate[1]+'/'+checkSelectedDate[2]+'/'+checkSelectedDate[0]+selectedTimeTxt);
31695//                     }
31696//                 }
31697//             }
31698//             break;
31699//         case 'saleStartDateTime':
31700//             lang = 'ko';
31701//             blocklang = 'ko';
31702//             console.log('w', w);
31703//             var selectedTimeTxt = '';
31704//             checkSelectedDate = selectedDate.split('.');
31705
31706//             if(selectedDate) {
31707//                 if(lang == 'ko') {
31708//                     $('.sale-calendar-box .start-date').html(checkSelectedDate[0]+'년 '+checkSelectedDate[1]+'월 '+checkSelectedDate[2]+'일');
31709//                 } else {
31710//                     $('.sale-calendar-box .start-date').html(checkSelectedDate[1]+'/'+checkSelectedDate[2]+'/'+checkSelectedDate[0]);
31711//                 }
31712                
31713//                 var saleStartDateTime = $('#sale-start-datetime').val();
31714                
31715//                 if (w == 'calendar') {
31716//                     $('.setting-sale-date .setting-datetime-input').slideUp(400, function(){
31717//                         $('.setting-sale-date').removeClass('open');
31718//                     });
31719
31720//                     $('.setting-sale-time .setting-datetime-input').slideDown(400, function(){
31721//                         $('.setting-sale-time').addClass('open');
31722//                     });
31723//                 } else {
31724//                     if(!w && saleStartDateTime) {
31725//                         $('.setting-sale-date').removeClass('open');
31726//                         $('.setting-sale-date .setting-datetime-input').css('display', 'none');
31727                        
31728//                         $('.setting-sale-time').removeClass('open');
31729//                         $('.setting-sale-time .setting-datetime-input').css('display', 'none');
31730//                     }
31731//                 }
31732//             }
31733
31734//             if (selectedTime.length > 0) {
31735//                 var timeArr = selectedTime.next('label').text().split(':');
31736//                 selectedTimeTxt = $.lang[lang]['config.form.date2.time.'+selectedTime.closest('.time-interval').attr('data-time')]+' '+timeArr[0]+'시 '+timeArr[1]+'분';
31737//                 $('.sale-calendar-box .start-time').html(selectedTimeTxt);
31738                
31739//                 if (w == 'time') {
31740//                     $('.setting-sale-time .setting-datetime-input').slideUp(400, function(){
31741//                         $('.setting-sale-time').removeClass('open');
31742//                     });
31743//                 }
31744//             }
31745//             break;
31746//         case 'saleEndDateTime':
31747//             lang = 'ko';
31748//             blocklang = 'ko';
31749
31750//             var selectedTimeTxt = '';
31751//             checkSelectedDate = selectedDate.split('.');
31752
31753//             if(selectedDate) {
31754//                 if(lang == 'ko') {
31755//                     $('.sale-calendar-box .end-date').html(checkSelectedDate[0]+'년 '+checkSelectedDate[1]+'월 '+checkSelectedDate[2]+'일');
31756//                 } else {
31757//                     $('.sale-calendar-box .end-date').html(checkSelectedDate[1]+'/'+checkSelectedDate[2]+'/'+checkSelectedDate[0]);
31758//                 }
31759
31760//                 var saleStartDateTime = $('.'+selectEL).find('.calendar-modal-container .sdate .start').val();
31761//                 var saleEndDateTime = $('.'+selectEL).find('.calendar-modal-container .edate .end').val();
31762
31763//                 var selectedDate = ($('#select-date-ymd').val() || '').trim();
31764//                 var checkSelectedDate = selectedDate ? selectedDate.split('.') : [];
31765
31766//                 if (w == 'calendar') {
31767//                     $('.setting-sale-date .setting-datetime-input').slideUp(400, function(){
31768//                         $('.setting-sale-date').removeClass('open');
31769//                     });
31770
31771//                     $('.setting-sale-time .setting-datetime-input').slideDown(400, function(){
31772//                         $('.setting-sale-time').addClass('open');
31773//                     });
31774//                 } else {
31775//                     if(!w && saleStartDateTime) {
31776//                         $('.setting-sale-date').removeClass('open');
31777//                         $('.setting-sale-date .setting-datetime-input').css('display', 'none');
31778                        
31779//                         $('.setting-sale-time').removeClass('open');
31780//                         $('.setting-sale-time .setting-datetime-input').css('display', 'none');
31781//                     }
31782//                 }
31783
31784//                 $('.time-interval input').prop('disabled', false);
31785//                 if(saleStartDateTime && startDate == selectedDate.replace(/\./g,'-')) {
31786//                     var hour = parseInt(startTime.split(':')[0]);
31787//                     var minute = parseInt(startTime.split(':')[1]);
31788//                     var mna = (hour >= 12)? 'pm' : 'am';
31789
31790//                     if(hour >= 12) {
31791//                         if (hour > 12) hour -= 12;
31792//                     } else if (hour == 0) hour += 12
31793
31794//                     var formattedStartTime = hour.toString().padStart(2, '0') + minute.toString().padStart(2, '0');
31795//                     $('.time-interval[data-time="' + mna + '"] input[value="' + formattedStartTime + '"]').prop('disabled', true);
31796//                     if(mna == 'pm') {
31797//                         $('.time-interval[data-time="am"] input').prop('disabled', true);
31798//                         $('.time-interval[data-time="pm"] input[value="' + formattedStartTime + '"]').prevAll('input').prop('disabled', true);
31799//                     } else {
31800//                         $('.time-interval[data-time="am"] input[value="' + formattedStartTime + '"]').prevAll('input').prop('disabled', true);
31801//                     }
31802//                     if($('.time-interval input:checked').is(':disabled')) {
31803//                         $('.time-interval input:checked').prop('checked', false);
31804//                         $('.sale-calendar-box .end-time').html('');
31805//                         selectedTime = '';
31806//                     }
31807//                 }
31808//             }
31809
31810//             if (selectedTime.length > 0) {
31811//                 var timeArr = selectedTime.next('label').text().split(':');
31812//                 selectedTimeTxt = $.lang[lang]['config.form.date2.time.'+selectedTime.closest('.time-interval').attr('data-time')]+' '+timeArr[0]+'시 '+timeArr[1]+'분';
31813//                 $('.sale-calendar-box .end-time').html(selectedTimeTxt);
31814
31815//                 if (w == 'time') {
31816//                     $('.setting-sale-time .setting-datetime-input').slideUp(400, function(){
31817//                         $('.setting-sale-time').removeClass('open');
31818//                     });
31819//                 }
31820//             }
31821//             break;
31822//         default:
31823//             if(selectedDate) {
31824//                 $('.term-setting').removeClass('hide');
31825//                 if(lang == 'ko') {
31826//                     $('.term-setting').text(checkSelectedDate[0]+'년 '+checkSelectedDate[1]+'월 '+checkSelectedDate[2]+'일');
31827//                 } else {
31828//                     $('.term-setting').text(checkSelectedDate[1]+'/'+checkSelectedDate[2]+'/'+checkSelectedDate[0]);
31829//                 }
31830//             }
31831//             break;
31832//     }
31833// }
31834
31835function scrollToCurrentYearMonth() {
31836    $('.year-picker').scrollTop(0);
31837    $('.month-picker').scrollTop(0);
31838    var offsetYear = $('.year-picker .current').position().top - 30;
31839    var offsetMonth = $('.month-picker .current').position().top - 30;
31840    $('.year-picker').scrollTop(offsetYear);
31841    $('.month-picker').scrollTop(offsetMonth);
31842}
31843
31844function calInputWidth(inputObj) {
31845    let inputTxt = inputObj.val().replace(/[\u3131-\u318E\uAC00-\uD7A3]/g, '');
31846    let Num = Number(removeCommas(inputTxt));
31847
31848    let $tempSpan = $('<span>').css({
31849        'font-size': inputObj.css('font-size'),
31850        'font-family': inputObj.css('font-family'),
31851        'visibility': 'hidden',
31852        'white-space': 'pre'
31853    }).text(inputTxt);
31854    
31855    $('body').append($tempSpan);
31856    
31857    let inputWidth = Math.floor($tempSpan.width()) + 5;
31858    if(inputWidth < 13 || Num == 0) inputWidth = 13;
31859    inputObj.width(inputWidth);
31860    $tempSpan.remove();
31861}
31862
31863function calDiscount(inputObj) {
31864    var orgPrice = Number(removeCommas($('#prod-sale').text())),
31865        discountRate = inputObj.val(),
31866        discountUnit = $('#prod-discount-unit').attr('data-value'),
31867        price = 0;
31868
31869    discountRate = Number(discountRate.replace(/[^0-9]/g, ''));
31870    if($('.form-group.discount-append').hasClass('discount-multi')) {
31871        switch(discountUnit) {
31872            case 'W':
31873                inputObj.val(number_format(discountRate));
31874                break;
31875            case 'P':
31876                if(discountRate >= 100) {
31877                    discountRate = 100;
31878                }
31879                inputObj.val(discountRate);
31880                
31881                break;
31882        }
31883    } else {
31884        switch(discountUnit) {
31885            case 'W':
31886                price = orgPrice - discountRate;
31887                if(price < 0) {
31888                    price = 0;
31889                    inputObj.val(number_format(orgPrice));
31890                } else {
31891                    inputObj.val(number_format(discountRate));
31892                }
31893                break;
31894            case 'P':
31895                if(discountRate >= 100) {
31896                    price = 0;
31897                    discountRate = 100;
31898                } else {
31899                    var discountPrice = orgPrice * (discountRate / 100);
31900                    price = Math.round(orgPrice - discountPrice);
31901                    // if($('#price-cut-btn').is(':checked')) price = Math.floor(price / 10) * 10;
31902                }
31903                
31904                // if (price % 10 == 0 || price == 0) $('#price-cut-btn').addClass('disabled');
31905                // else $('#price-cut-btn').removeClass('disabled');
31906                inputObj.val(discountRate);
31907                
31908                break;
31909        } //end switch
31910        console.log('price', price);
31911
31912        $('#prod-price').val(number_format(price));
31913        calInputWidth($('#prod-price'));
31914    }
31915    
31916}
31917
31918$(document).on('click', '.element[data-type="review"]  a[data-review]', function(e){
31919    e.preventDefault();
31920    if ($(this).closest('.element').hasClass('review-sample-block')) return false;
31921
31922    if (PAGE_MODE != 'c') {
31923        var seq = $(this).attr('data-review');
31924        $.shoppingmall.viewReviewModal(property.SID, seq);
31925    }
31926});
31927
31928
31929var configDateTime = function(el) {
31930    var field_type = $(el).attr('data-type');
31931    var id = (field_type.indexOf('etc-product-date') > -1) ? $('#prod-no').val() : $(el).closest('.form-sort-item').attr('data-id');
31932    var func = $(el).attr('data-setting');
31933    var field_setting = {};
31934    // console.log('field_type', field_type, el);
31935
31936    if (field_type.indexOf('etc-product-date') > -1) {
31937        field_setting.term = ($('#etc-term').val()) ? JSON.parse($('#etc-term').val()) : {};
31938        field_setting.excludeDate = { 'date': $('#etc-exclude-date').val() };
31939        field_setting.time = ($('#etc-time').val()) ? JSON.parse($('#etc-time').val()) : {};
31940    } else if (field_type.indexOf('sale-product-datetime') > -1) {
31941        field_setting.term = ($('#etc-term').val()) ? JSON.parse($('#etc-term').val()) : {};
31942    } else {
31943        $.ajax({
31944            url: '/template/forms/field_config',
31945            dataType: 'json',
31946            type: 'POST',
31947            data: { sid: SID, id: id },
31948            async: false,
31949            cache: false,
31950            success: function(data) {
31951                checkError(data);
31952                field_setting = data;
31953            }
31954        });
31955    }
31956    // console.log(field_setting);
31957
31958    var term = (field_setting.term) ? field_setting.term : {};
31959    var excludeDate = (field_setting.excludeDate) ? field_setting.excludeDate : {};
31960    var time = (field_setting.time) ? field_setting.time : {};
31961
31962    //term
31963    var startDate = (term.start_date !== undefined && term.start_date != '') ? term.start_date : '';
31964    var endDate = (term.end_date !== undefined && term.end_date != '') ? term.end_date : '';
31965    var dateWeek = (term.date_week !== undefined && term.date_week != '') ? term.date_week : 'A';
31966    var days = (term.days !== undefined && term.days != '') ? term.days.split('|') : [];
31967    var daysObj = {
31968        'sun': 0,
31969        'mon': 1,
31970        'tue': 2,
31971        'wed': 3,
31972        'thu': 4,
31973        'fri': 5,
31974        'sat': 6,
31975    }
31976
31977    //excludeDate
31978    var exceptDate = (excludeDate.date !== undefined) ? excludeDate.date : '';
31979
31980    //time
31981    var interval = (time.interval !== undefined) ? time.interval : '30';
31982    var am = (time.am !== undefined) ? time.am.split('|') : [];
31983    var pm = (time.pm !== undefined) ? time.pm.split('|') : [];
31984    var timeCnt = am.length + pm.length;
31985    // var disabled = null;
31986
31987    // var allTimeChecked = '';
31988    // if (interval == '10' && timeCnt == 144) allTimeChecked = 'checked';
31989    // if (interval == '20' && timeCnt == 72) allTimeChecked = 'checked';
31990    // if (interval == '30' && timeCnt == 48) allTimeChecked = 'checked';
31991    // if (interval == '60' && timeCnt == 24) allTimeChecked = 'checked';
31992
31993    var language = (LANG != 'ko') ? 'en' : 'ko';
31994    var blocklang = ($('[form-seq="' + id + '"]').closest('.element').attr('data-blocklang')) ? $('[form-seq="' + id + '"]').closest('.element').attr('data-blocklang') : LANG;
31995
31996    var modal_title = '';
31997    var modal_str = '';
31998    var modal_class = 'modal-dialog cl-cmmodal cl-s-btn setting-form-option-date2 cl-close-btn cover';
31999    switch (func) {
32000        case 'term':
32001            modal_title = $.lang[LANG]['config.form.date.title'];
32002            modal_str = '\
32003                <input type="hidden" id="etc-date-week" value="' + dateWeek + '">\
32004                <div class="display-flex align-items-center setting-row">\
32005                    <div class="setting-label">' + $.lang[LANG]['config.form.date.dateWeek.label'] + '</div>\
32006                    <div class="btn-group btn-group-justified week">\
32007                        <label class="btn checked">' + $.lang[LANG]['config.form.date.dateWeek.entire'] + '<input type="radio" name="week" value="A" checked></label>\
32008                        <label class="btn">' + $.lang[LANG]['config.form.date.dateWeek.weekday'] + '<input type="radio" name="week" value="W"></label>\
32009                        <label class="btn">' + $.lang[LANG]['config.form.date.dateWeek.weekend'] + '<input type="radio" name="week" value="K"></label>\
32010                    </div>\
32011                </div>\
32012                <div class="display-flex align-items-center setting-row">\
32013                    <div class="setting-label">' + $.lang[LANG]['config.form.date.day.label'] + '</div>\
32014                    <div class="btn-group btn-group-justified day">\
32015                        <label class="btn checked">' + $.lang[LANG]['config.form.date.day.sun'] + '<input type="checkbox" name="day" value="sun" checked></label>\
32016                        <label class="btn checked">' + $.lang[LANG]['config.form.date.day.mon'] + '<input type="checkbox" name="day" value="mon" checked></label>\
32017                        <label class="btn checked">' + $.lang[LANG]['config.form.date.day.tue'] + '<input type="checkbox" name="day" value="tue" checked></label>\
32018                        <label class="btn checked">' + $.lang[LANG]['config.form.date.day.wed'] + '<input type="checkbox" name="day" value="wed" checked></label>\
32019                        <label class="btn checked">' + $.lang[LANG]['config.form.date.day.thu'] + '<input type="checkbox" name="day" value="thu" checked></label>\
32020                        <label class="btn checked">' + $.lang[LANG]['config.form.date.day.fri'] + '<input type="checkbox" name="day" value="fri" checked></label>\
32021                        <label class="btn checked">' + $.lang[LANG]['config.form.date.day.sat'] + '<input type="checkbox" name="day" value="sat" checked></label>\
32022                    </div>\
32023                </div>\
32024                <div class="term-calendar-box">\
32025                    <input type="hidden" id="select-calendar" value="term-datepicker">\
32026                    <input type="hidden" id="etc-start-date-prev" value="' + startDate + '">\
32027                    <input type="hidden" id="etc-end-date-prev" value="' + endDate + '">\
32028                    <input type="hidden" id="etc-start-date-txt" value="' + startDate + '">\
32029                    <input type="hidden" id="etc-end-date-txt" value="' + endDate + '">\
32030                    <input type="hidden" id="select-except-date">\
32031                    <div id="term-datepicker"></div>\
32032                </div>\
32033                <div class="term-setting hide" data-blocklang="' + blocklang + '">\
32034                    <span class="start-date"></span> ~ <span class="end-date"></span>\
32035                </div>\
32036            ';
32037            break;
32038        case 'saleStartDateTime':
32039        case 'saleEndDateTime':
32040            modal_class = 'modal-dialog cl-cmmodal cl-s-btn setting-form-option-date2 setting-product-sale-datetime cl-close-btn cover';
32041            var timeClass = 'start-time';
32042            if(func == 'saleStartDateTime') {
32043                modal_title = '시작 날짜/시간 선택';
32044                modal_str = '\
32045                <div class="term-calendar-box sale-calendar-box setting-sale-date">\
32046                    <div class="setting-label display-flex align-items-center space-between">\
32047                        <div class="display-flex align-items-center">\
32048                            <span>날짜 선택</span>\
32049                            <span class="start-date datetime-txt" data-blocklang="' + blocklang + '"></span>\
32050                        </div>\
32051                        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path d="M8 12.5a.47.47 0 0 1-.35-.15l-7.5-7.5c-.2-.2-.2-.51 0-.71.2-.2.51-.2.71 0L8 11.29l7.15-7.15c.2-.2.51-.2.71 0 .2.2.2.51 0 .71l-7.5 7.5c-.1.1-.23.15-.36.15z"></path></svg>\
32052                    </div>\
32053                    <div class="setting-datetime-input" data-type="' + func + '">\
32054                        <input type="hidden" id="select-calendar" value="term-datepicker">\
32055                        <input type="hidden" id="select-date-ymd" value="">\
32056                        <input type="hidden" id="etc-start-date-prev" value="">\
32057                        <input type="hidden" id="etc-start-date-txt" value="">\
32058                        <div id="sale-datepicker"></div>\
32059                    </div>\
32060                </div>\
32061                ';
32062            } else {
32063                modal_title = '종료 날짜/시간 선택';
32064                modal_str = '\
32065                <div class="term-calendar-box sale-calendar-box setting-sale-date">\
32066                    <div class="setting-label display-flex align-items-center space-between">\
32067                        <div class="display-flex align-items-center">\
32068                            <span>날짜 선택</span>\
32069                            <span class="end-date datetime-txt" data-blocklang="' + blocklang + '"></span>\
32070                        </div>\
32071                        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path d="M8 12.5a.47.47 0 0 1-.35-.15l-7.5-7.5c-.2-.2-.2-.51 0-.71.2-.2.51-.2.71 0L8 11.29l7.15-7.15c.2-.2.51-.2.71 0 .2.2.2.51 0 .71l-7.5 7.5c-.1.1-.23.15-.36.15z"></path></svg>\
32072                    </div>\
32073                    <div class="setting-datetime-input" data-type="' + func + '">\
32074                        <input type="hidden" id="select-calendar" value="term-datepicker">\
32075                        <input type="hidden" id="select-date-ymd" value="">\
32076                        <input type="hidden" id="etc-start-date-prev" value="">\
32077                        <input type="hidden" id="etc-start-date-txt" value="">\
32078                        <input type="hidden" id="etc-end-date-prev" value="">\
32079                        <input type="hidden" id="etc-end-date-txt" value="">\
32080                        <div id="sale-datepicker"></div>\
32081                    </div>\
32082                </div>\
32083                ';
32084                timeClass = 'end-time';
32085            }
32086            
32087            modal_str += '\
32088                <div class="term-calendar-box sale-calendar-box setting-sale-time">\
32089                    <div class="setting-label display-flex align-items-center space-between">\
32090                        <div class="display-flex align-items-center">\
32091                            <span>시간 선택</span>\
32092                            <span class="'+timeClass+' datetime-txt" data-blocklang="' + blocklang + '"></span>\
32093                        </div>\
32094                        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">
32094<path d="M8 12.5a.47.47 0 0 1-.35-.15l-7.5-7.5c-.2-.2-.2-.51 0-.71.2-.2.51-.2.71 0L8 11.29l7.15-7.15c.2-.2.51-.2.71 0 .2.2.2.51 0 .71l-7.5 7.5c-.1.1-.23.15-.36.15z"></path></svg>\
32095                    </div>\
32096                    <div class="setting-datetime-input" data-type="' + func + '" style="display:none;">\
32097                        <div class="display-flex align-items-center setting-row">\
32098                            <div class="setting-label">' + $.lang[LANG]['config.form.date2.time.interval.label'] + '</div>\
32099                            <div class="newcheckbox hand">\
32100                                <label>\
32101                                    <div class="newcheckboxSvgRadio">\
32102                                        <input type="radio" class="cl-common-form-radio-hide" name="time_interval" value="30" checked>\
32103                                        <svg viewBox="0 0 18 18" width="18" height="18">\
32104                                            <path d="M9 0C4.03 0 0 4.03 0 9c0 4.97 4.03 9 9 9s9-4.03 9-9C18 4.03 13.97 0 9 0zM9 17c-4.41 0-8-3.59-8-8 0-4.41 3.59-8 8-8s8 3.59 8 8C17 13.41 13.41 17 9 17z"></path>\
32105                                        </svg>\
32106                                        <svg class="active" viewBox="0 0 18 18" width="18" height="18">\
32107                                            <path d="M9 0C4.03 0 0 4.03 0 9c0 4.97 4.03 9 9 9s9-4.03 9-9C18 4.03 13.97 0 9 0zM9 17c-4.41 0-8-3.59-8-8 0-4.41 3.59-8 8-8s8 3.59 8 8C17 13.41 13.41 17 9 17z"></path>\
32108                                            <circle cx="9" cy="9" r="6"></circle>\
32109                                        </svg>\
32110                                    </div>\
32111                                    <span>' + $.lang[LANG]['config.form.date2.time.interval.30'] + '</span>\
32112                                </label>\
32113                            </div>\
32114                            <div class="newcheckbox hand">\
32115                                <label>\
32116                                    <div class="newcheckboxSvgRadio">\
32117                                        <input type="radio" class="cl-common-form-radio-hide" name="time_interval" value="60">\
32118                                        <svg viewBox="0 0 18 18" width="18" height="18">\
32119                                            <path d="M9 0C4.03 0 0 4.03 0 9c0 4.97 4.03 9 9 9s9-4.03 9-9C18 4.03 13.97 0 9 0zM9 17c-4.41 0-8-3.59-8-8 0-4.41 3.59-8 8-8s8 3.59 8 8C17 13.41 13.41 17 9 17z"></path>\
32120                                        </svg>\
32121                                        <svg class="active" viewBox="0 0 18 18" width="18" height="18">\
32122                                            <path d="M9 0C4.03 0 0 4.03 0 9c0 4.97 4.03 9 9 9s9-4.03 9-9C18 4.03 13.97 0 9 0zM9 17c-4.41 0-8-3.59-8-8 0-4.41 3.59-8 8-8s8 3.59 8 8C17 13.41 13.41 17 9 17z"></path>\
32123                                            <circle cx="9" cy="9" r="6"></circle>\
32124                                        </svg>\
32125                                    </div>\
32126                                    <span>' + $.lang[LANG]['config.form.date2.time.interval.60'] + '</span>\
32127                                </label>\
32128                            </div>\
32129                        </div>\
32130                        <div class="setting-row am">\
32131                            <div class="setting-label">' + $.lang[LANG]['config.form.date2.time.am'] + '</div>\
32132                            <div class="display-flex time-interval" data-time="am"></div>\
32133                        </div>\
32134                        <div class="setting-row">\
32135                            <div class="setting-label">' + $.lang[LANG]['config.form.date2.time.pm'] + '</div>\
32136                            <div class="display-flex time-interval" data-time="pm"></div>\
32137                        </div>\
32138                    </div>\
32139                </div>\
32140            ';
32141            break;
32142        case 'excludeDate':
32143            modal_title = $.lang[LANG]['config.form.date.excludeDate'];
32144            modal_str = '\
32145            <div class="except-calendar-box">\
32146                <div class="unselect-all hand"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path d="m15.29 7-1.32 1.32c.01-.11.03-.21.03-.32 0-3.31-2.69-6-6-6-1.66 0-3.16.67-4.24 1.76l.71.71C5.37 3.56 6.62 3 8 3c2.76 0 5 2.24 5 5 0 .09-.02.18-.03.27L11.71 7l-.71.71 2.5 2.5 2.5-2.5-.71-.71z"/><path d="M8 13c-2.76 0-5-2.24-5-5 0-.09.02-.18.03-.27L4.29 9 5 8.29l-2.5-2.5L0 8.29.71 9l1.32-1.32C2.02 7.79 2 7.89 2 8c0 3.31 2.69 6 6 6 1.66 0 3.16-.67 4.24-1.76l-.71-.71C10.63 12.44 9.38 13 8 13z"/></svg> ' + $.lang[LANG]['config.form.date.excludeDate.clear'] + '</div>\
32147                <input type="hidden" id="select-calendar" value="etc-except-date-picker">\
32148                <input type="hidden" class="etc-date" id="etc-except-date" value="">\
32149                <input type="hidden" id="etc-start-date-txt" value="' + startDate + '">\
32150                <input type="hidden" id="etc-end-date-txt" value="' + endDate + '">\
32151                <input type="hidden" id="etc-date-week" value="' + dateWeek + '">\
32152                <input type="hidden" id="select-except-date" value="' + exceptDate + '">\
32153                <input type="hidden" id="term-days" value="' + term.days + '">\
32154                <div id="etc-except-date-picker"></div>\
32155            </div>\
32156            <div class="term-setting hide" data-blocklang="' + blocklang + '">\
32157                <span class="start-date"></span> ~ <span class="end-date"></span>\
32158            </div>\
32159            ';
32160            break;
32161        case 'time':
32162            modal_title = $.lang[LANG]['config.form.date2.time'];
32163            modal_class += ' setting-times';
32164            modal_str = '\
32165            <div class="guide-wrap">\
32166                <div class="display-flex align-items-center setting-row">\
32167                    <div class="setting-label">' + $.lang[LANG]['config.form.date2.time.interval.label'] + '</div>\
32168                    <div class="newcheckbox hand">\
32169                        <label>\
32170                            <div class="newcheckboxSvgRadio">\
32171                                <input type="radio" class="cl-common-form-radio-hide" name="time_interval" value="60">\
32172                                <svg viewBox="0 0 18 18" width="18" height="18">\
32173                                    <path d="M9 0C4.03 0 0 4.03 0 9c0 4.97 4.03 9 9 9s9-4.03 9-9C18 4.03 13.97 0 9 0zM9 17c-4.41 0-8-3.59-8-8 0-4.41 3.59-8 8-8s8 3.59 8 8C17 13.41 13.41 17 9 17z"></path>\
32174                                </svg>\
32175                                <svg class="active" viewBox="0 0 18 18" width="18" height="18">\
32176                                    <path d="M9 0C4.03 0 0 4.03 0 9c0 4.97 4.03 9 9 9s9-4.03 9-9C18 4.03 13.97 0 9 0zM9 17c-4.41 0-8-3.59-8-8 0-4.41 3.59-8 8-8s8 3.59 8 8C17 13.41 13.41 17 9 17z"></path>\
32177                                    <circle cx="9" cy="9" r="6"></circle>\
32178                                </svg>\
32179                            </div>\
32180                            <span>' + $.lang[LANG]['config.form.date2.time.interval.60'] + '</span>\
32181                        </label>\
32182                    </div>\
32183                    <div class="newcheckbox hand">\
32184                        <label>\
32185                            <div class="newcheckboxSvgRadio">\
32186                                <input type="radio" class="cl-common-form-radio-hide" name="time_interval" value="30" checked>\
32187                                <svg viewBox="0 0 18 18" width="18" height="18">\
32188                                    <path d="M9 0C4.03 0 0 4.03 0 9c0 4.97 4.03 9 9 9s9-4.03 9-9C18 4.03 13.97 0 9 0zM9 17c-4.41 0-8-3.59-8-8 0-4.41 3.59-8 8-8s8 3.59 8 8C17 13.41 13.41 17 9 17z"></path>\
32189                                </svg>\
32190                                <svg class="active" viewBox="0 0 18 18" width="18" height="18">\
32191                                    <path d="M9 0C4.03 0 0 4.03 0 9c0 4.97 4.03 9 9 9s9-4.03 9-9C18 4.03 13.97 0 9 0zM9 17c-4.41 0-8-3.59-8-8 0-4.41 3.59-8 8-8s8 3.59 8 8C17 13.41 13.41 17 9 17z"></path>\
32192                                    <circle cx="9" cy="9" r="6"></circle>\
32193                                </svg>\
32194                            </div>\
32195                            <span>' + $.lang[LANG]['config.form.date2.time.interval.30'] + '</span>\
32196                        </label>\
32197                    </div>\
32198                    <div class="newcheckbox hand">\
32199                        <label>\
32200                            <div class="newcheckboxSvgRadio">\
32201                                <input type="radio" class="cl-common-form-radio-hide" name="time_interval" value="20">\
32202                                <svg viewBox="0 0 18 18" width="18" height="18">\
32203                                    <path d="M9 0C4.03 0 0 4.03 0 9c0 4.97 4.03 9 9 9s9-4.03 9-9C18 4.03 13.97 0 9 0zM9 17c-4.41 0-8-3.59-8-8 0-4.41 3.59-8 8-8s8 3.59 8 8C17 13.41 13.41 17 9 17z"></path>\
32204                                </svg>\
32205                                <svg class="active" viewBox="0 0 18 18" width="18" height="18">\
32206                                    <path d="M9 0C4.03 0 0 4.03 0 9c0 4.97 4.03 9 9 9s9-4.03 9-9C18 4.03 13.97 0 9 0zM9 17c-4.41 0-8-3.59-8-8 0-4.41 3.59-8 8-8s8 3.59 8 8C17 13.41 13.41 17 9 17z"></path>\
32207                                    <circle cx="9" cy="9" r="6"></circle>\
32208                                </svg>\
32209                            </div>\
32210                            <span>' + $.lang[LANG]['config.form.date2.time.interval.20'] + '</span>\
32211                        </label>\
32212                    </div>\
32213                    <div class="newcheckbox hand">\
32214                        <label>\
32215                            <div class="newcheckboxSvgRadio">\
32216                                <input type="radio" class="cl-common-form-radio-hide" name="time_interval" value="10">\
32217                                <svg viewBox="0 0 18 18" width="18" height="18">\
32218                                    <path d="M9 0C4.03 0 0 4.03 0 9c0 4.97 4.03 9 9 9s9-4.03 9-9C18 4.03 13.97 0 9 0zM9 17c-4.41 0-8-3.59-8-8 
322180-4.41 3.59-8 8-8s8 3.59 8 8C17 13.41 13.41 17 9 17z"></path>\
32219                                </svg>\
32220                                <svg class="active" viewBox="0 0 18 18" width="18" height="18">\
32221                                    <path d="M9 0C4.03 0 0 4.03 0 9c0 4.97 4.03 9 9 9s9-4.03 9-9C18 4.03 13.97 0 9 0zM9 17c-4.41 0-8-3.59-8-8 0-4.41 3.59-8 8-8s8 3.59 8 8C17 13.41 13.41 17 9 17z"></path>\
32222                                    <circle cx="9" cy="9" r="6"></circle>\
32223                                </svg>\
32224                            </div>\
32225                            <span>' + $.lang[LANG]['config.form.date2.time.interval.10'] + '</span>\
32226                        </label>\
32227                    </div>\
32228                </div>\
32229                <div class="setting-row am">\
32230                    <label for="all-time-select" class="all-time display-flex align-items-center">\
32231                        <div class="newcheckbox hand">\
32232                            <input id="all-time-select" class="hide" type="checkbox">\
32233                            <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\
32234                                <path d="M13 0H3C1.3 0 0 1.3 0 3v10c0 1.7 1.3 3 3 3h10c1.7 0 3-1.3 3-3V3C16 1.3 14.7 0 13 0zM15 13c0 1.1-0.9 2-2 2H3c-1.1 0-2-0.9-2-2V3c0-1.1 0.9-2 2-2h10c1.1 0 2 0.9 2 2V13z"/>\
32235                            </svg>\
32236                            <svg class="active" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">\
32237                                <path d="M13 0H3C1.34 0 0 1.34 0 3v10c0 1.66 1.34 3 3 3h10c1.66 0 3-1.34 3-3V3C16 1.34 14.66 0 13 0zM13.03 6.03l-5.5 5.5C7.38 11.68 7.19 11.75 7 11.75s-0.38-0.07-0.53-0.22l-3.5-3.5c-0.29-0.29-0.29-0.77 0-1.06s0.77-0.29 1.06 0L7 9.94l4.97-4.97c0.29-0.29 0.77-0.29 1.06 0S13.32 5.74 13.03 6.03z"/>\
32238                            </svg>\
32239                        </div>\
32240                        <span>' + $.lang[LANG]['config.form.date2.time.selectAll'] + '</span>\
32241                    </label>\
32242                    <div class="setting-label">' + $.lang[LANG]['config.form.date2.time.am'] + '</div>\
32243                    <div class="display-flex time-interval" data-time="am"></div>\
32244                </div>\
32245                <div class="setting-row">\
32246                    <div class="setting-label">' + $.lang[LANG]['config.form.date2.time.pm'] + '</div>\
32247                    <div class="display-flex time-interval" data-time="pm"></div>\
32248                </div>\
32249            </div>\
32250            ';
32251            break;
32252    }
32253
32254    var settingModal = $(el).showModalFlat(modal_title, modal_str, true, true, function() { //confirm
32255        var postData = {};
32256        switch (func) {
32257            case 'term':
32258                if (!$('#etc-start-date-txt').val() || !$('#etc-end-date-txt').val()) {
32259                    alert('날짜 기간을 선택해주세요.');
32260                    return false;
32261                }
32262                var days = new Array();
32263                $('input[name="day"]:checked').each(function(i, v) {
32264                    days.push($(v).val());
32265                });
32266                postData = {
32267                    'term': {
32268                        'select_terms': 'Y',
32269                        'date_week': $('#etc-date-week').val(),
32270                        'start_date': $('#etc-start-date-txt').val(),
32271                        'end_date': $('#etc-end-date-txt').val(),
32272                        'days': (days.length > 0) ? days.join('|') : ''
32273                    }
32274                };
32275
32276                startDate = $('#etc-start-date-txt').val();
32277                endDate = $('#etc-end-date-txt').val();
32278
32279                if (field_type.indexOf('etc-product-date') > -1 && startDate && endDate) { //etc product
32280                    $('#etc-week').val($('#etc-date-week').val());
32281                    $('#etc-start-date').val(startDate);
32282                    $('#etc-end-date').val(endDate);
32283                    $('#etc-term').val(JSON.stringify(postData.term));
32284                    $('.term-setting .setting-text .content').text(startDate + ' ~ ' + endDate);
32285                }
32286
32287                break;
32288            case 'saleStartDateTime':
32289            case 'saleEndDateTime':
32290                var selectedDate = $('#select-date-ymd').val();
32291
32292                if (!selectedDate || $('.time-interval input:checked').length == 0) {
32293                    alert('날짜와 시간을 선택해주세요.');
32294                    return false;
32295                }
32296
32297                if (!selectedDate || $('.time-interval input:checked').length == 0) {
32298                    alert('날짜와 시간을 선택해주세요.');
32299                    return false;
32300                }
32301
32302                var mna = $('.time-interval input:checked').parent().attr('data-time');
32303                var selectedTime = convertTime24(mna, $('.time-interval input:checked').val());
32304                var saleDateTime = selectedDate + '. ' + convertTime12(selectedTime);
32305                var saleDateTimeVal = selectedDate.replace(/\./g, '-') + ' ' + selectedTime + ':00';
32306                console.log(selectedTime);
32307                if(func == 'saleStartDateTime') {
32308                    var startDateTime = new Date(saleDateTimeVal);
32309                    var currentDateTime = new Date();
32310
32311                    if($('#sale-end-datetime').val()) {
32312                        var endDateTime = new Date($('#sale-end-datetime').val());
32313                        if(endDateTime <= startDateTime) {
32314                            startDateTime.setHours(startDateTime.getHours() + 1);
32315                            console.log(startDateTime);
32316                            var endDateTimeVal = convertDateObjToStr(startDateTime);
32317                            var endDateTime = endDateTimeVal.split(' ');
32318
32319                            $('#sale-end-datetime').val(endDateTimeVal);
32320                            $('.sale-setting .setting-text .content-end').text(endDateTime[0] + '. ' + convertTime12(endDateTime[1]));
32321                        }
32322                    }
32323                    
32324                    $('.sale-setting .setting-text .content-start').text(saleDateTime);
32325                    $('#sale-start-datetime').val(saleDateTimeVal);
32326                } else {
32327                    var endDateTime = new Date(saleDateTimeVal);
32328
32329                    if($('#sale-start-datetime').val()) {
32330                        var startDateTime = new Date($('#sale-start-datetime').val());
32331                        if(startDateTime >
32331= endDateTime) {
32332                            alert('판매 시작 시간보다 나중 시간을 선택해 주세요.');
32333                            return false;
32334                        }
32335                    }
32336
32337                    $('.sale-setting .setting-text .content-end').text(saleDateTime);
32338                    $('#sale-end-datetime').val(saleDateTimeVal);
32339                }
32340
32341                break;
32342            case 'excludeDate':
32343                postData = {
32344                    'excludeDate': {
32345                        'date': $('#select-except-date').val(),
32346                    }
32347                };
32348
32349                if (field_type.indexOf('etc-product-date') > -1) { //etc product
32350                    if ($('#select-except-date').val()) {
32351                        $('#etc-exclude-date').val($('#select-except-date').val());
32352                        $('.exclude-setting .setting-text .content').text($('#select-except-date').val());
32353                        $('.exclude-setting .setting-text').attr('data-toggle', 'tooltip');
32354                        $('.exclude-setting .setting-text').attr('data-original-title', "<div class='except-date-tooltip'>" + $('#select-except-date').val() + "</div>");
32355                    } else {
32356                        $('#etc-exclude-date').val('');
32357                        $('.exclude-setting .setting-text .content').text('');
32358                        $('.exclude-setting .setting-text').removeAttr('data-toggle');
32359                        $('.exclude-setting .setting-text').removeAttr('data-original-title');
32360                    }
32361                }
32362                break;
32363            case 'time':
32364                if ($('.time-interval input:checked').length == 0) {
32365                    alert($.lang[LANG]['config.form.date2.time.excludeAll']);
32366                    return false;
32367                }
32368
32369                var interval = $('input[name="time_interval"]:checked').val();
32370                var am = new Array();
32371                var pm = new Array();
32372                $('input[name="am"]:checked').each(function(i, v) {
32373                    // if ($(v).next('label').hasClass('hide')) {
32374                    //     return true;
32375                    // }
32376                    am.push($(v).val());
32377                });
32378                $('input[name="pm"]:checked').each(function(i, v) {
32379                    // if ($(v).next('label').hasClass('hide')) {
32380                    //     return true;
32381                    // }
32382                    pm.push($(v).val());
32383                });
32384                postData = {
32385                    'time': {
32386                        'interval': interval,
32387                        'am': (am.length > 0) ? am.join('|') : '',
32388                        'pm': (pm.length > 0) ? pm.join('|') : '',
32389                    }
32390                };
32391
32392                if (field_type.indexOf('etc-product-date') > -1) {
32393                    $('#etc-time').val(JSON.stringify(postData.time));
32394                }
32395                break;
32396        }
32397        // console.log(id, postData);
32398        // console.log('field_type', field_type);
32399        if (field_type.indexOf('etc-product-date') == -1 && field_type.indexOf('sale-product-datetime') == -1) { //form date
32400            var settings = {
32401                'type': 'val',
32402                'value': JSON.stringify(postData),
32403            }
32404
32405            if (itemsAjax) itemsAjax.abort();
32406            itemsAjax = $.ajax({
32407                url: "/template/forms/items",
32408                async: true,
32409                type: "post",
32410                dataType: "json",
32411                data: {
32412                    sid: SID,
32413                    id: id,
32414                    field: field_type,
32415                    val_type: func,
32416                    settings: settings
32417                },
32418                success: function(data) {
32419                    checkError(data);
32420                    initDateTimeConf(SID, id, field_type);
32421                }
32422            });
32423        }
32424
32425
32426        // saveFormElement();
32427        settingModal.modal('hide');
32428    }, 'cancel', 'ok', modal_class, true, function() { //close
32429        if (func == 'term' && (!$('#etc-start-date-txt').val() || !$('#etc-end-date-txt').val())) {
32430            if (!$('#etc-start-date-prev').val() && !$('#etc-end-date-prev').val()) {
32431                $('input[name="select_terms-' + id + '"][value="N"]').prop('checked', true);
32432                $('.form-sort-item[data-id="' + id + '"] .setting-date2[data-setting="term"]').addClass('disabled');
32433            }
32434        }
32435        settingModal.modal('hide');
32436    }, function() { //show
32437        if (field_type.indexOf('etc-product-date') > -1) {
32438            startDate = $('#etc-start-date').val();
32439            endDate = $('#etc-end-date').val();
32440            lang = 'ko';
32441            $('#etc-start-date-txt').val(startDate);
32442            $('#etc-end-date-txt').val(endDate);
32443        }
32444
32445        if (startDate && endDate) {
32446            var checkStartDate = startDate.split('.');
32447            var checkEndDate = endDate.split('.');
32448
32449            $('.term-setting').removeClass('hide');
32450            if (blocklang == 'ko') {
32451                $('.term-setting .start-date').text(checkStartDate[0] + '년 ' + checkStartDate[1] + '월 ' + checkStartDate[2] + ' 일');
32452                $('.term-setting .end-date').text(checkEndDate[0] + '년 ' + checkEndDate[1] + '월 ' + checkEndDate[2] + ' 일');
32453            } else {
32454                $('.term-setting .start-date').text(checkStartDate[1] + '/' + checkStartDate[2] + '/' + checkStartDate[0]);
32455                $('.term-setting .end-date').text(checkEndDate[1] + '/' + checkEndDate[2] + '/' + checkEndDate[0]);
32456            }
32457        }
32458        // console.log(language);
32459        $('#term-datepicker').html('');
32460        var currentYear = new Date().getFullYear();
32461        switch (func) {
32462            case 'term':
32463                var termPicker = new Datepickk({
32464                    container: document.querySelector('#term-datepicker'),
32465                    inline: true,
32466                    range: true,
32467                    exp: false,
32468                    lang: language,
32469                    startDate: (startDate.replace(/\./g, '/')) ? new Date(startDate.replace(/\./g, '/')) : new Date(),
32470                    minDate: new Date(1900, 0, 1),
32471                    maxDate: new Date(currentYear + 15, 11, 31),
32472                });
32473
32474                if (dateWeek) {
32475                    $('.btn-group.week label').removeClass('checked');
32476                    $('input[value="' + dateWeek + '"]').prop('checked', true);
32477                    $('input[value="' + dateWeek + '"]').closest('label').addClass('checked');
32478                    disabled = (days.length > 0) ? getDisabledDays(days) : [];
32479                    termPicker.disabledDays = (disabled.length > 0) ? disabled : null;
32480                }
32481
32482                if (startDate && endDate) {
32483                    $('input[name="day"]').prop('checked', false);
32484                    $('input[name="day"]').closest('label').removeClass('checked');
32485                    termPicker.setSelectedDates(startDate, 'start');
32486                    termPicker.setSelectedDates(endDate, 'end');
32487                }
32488
32489                if (days) {
32490                    $.each(days, function(i, v) {
32491                        $('input[value="' + v + '"]').prop('checked', true);
32492                        $('input[value="' + v + '"]').closest('label').addClass('checked');
32493                    });
32494                }
32495                $('input[name="week"]').on('change', function() {
32496                    var value = $(this).val();
32497                    $('#etc-date-week').val(value);
32498                    $('.btn-group.week label').removeClass('checked');
32499                    if ($(this).is(':checked')) $(this).closest('label').addClass('checked');
32500                    termPicker.disabledDays = null;
32501                    $('#etc-start-date-txt').val('');
32502                    $('#etc-end-date-txt').val('');
32503                    if (field_type.indexOf('etc-product-date') == -1) $('.term-setting').addClass('hide');
32504                    switch (value) {
32505                        case 'A':
32506                            $('input[name="day"]').prop('checked', true);
32507                            $('input[name="day"]').closest('label').addClass('checked');
32508                            termPicker.disabledDays = null;
32509                            break;
32510                        case 'W':
32511                            $('input[name="day"][value="sat"], input[name="day"][value="sun"]').prop('checked', false)
32512                            $('input[name="day"][value="sat"], input[name="day"][value="sun"]').closest('label').removeClass('checked');
32513                            $('input[name="day"]').not('[value="sat"],[value="sun"]').prop('checked', true);
32514                            $('input[name="day"]').not('[value="sat"],[value="sun"]').closest('label').addClass('checked');
32515                            termPicker.disabledDays = [0, 6];
32516                            break;
32517                        case 'K':
32518                            $('input[name="day"][value="sat"], input[name="day"][value="sun"]').prop('checked', true);
32519                            $('input[name="day"][value="sat"], input[name="day"][value="sun"]').closest('label').addClass('checked');
32520                            $('input[name="day"]').not('[value="sat"],[value="sun"]').prop('checked', false);
32521                            $('input[name="day"]').not('[value="sat"],[value="sun"]').closest('label').removeClass('checked');
32522                            termPicker.disabledDays = [1, 2, 3, 4, 5];
32523                            break;
32524                    }
32525
32526                    termPicker.setSelectedDates($('#etc-start-date-txt').val(), 'start');
32527                    termPicker.setSelectedDates($('#etc-end-date-txt').val(), 'end');
32528                });
32529
32530                $('input[name="day"]').on('change', function() {
32531                    if ($(this).is(':checked')) $(this).closest('label').addClass('checked');
32532                    else $(this).closest('label').removeClass('checked');
32533
32534                    if ($('input[name="day"]:checked').length == 0) {
32535                        alert($.lang[LANG]['config.form.date.day.excludeAll']);
32536                        $(this).prop('checked', true);
32537                        $(this).closest('label').addClass('checked');
32538                        return false;
32539                    }
32540
32541                    termPicker.disabledDays = null;
32542                    disabled = getDisabledDays();
32543
32544                    termPicker.disabledDays = disabled;
32545                    termPicker.setSelectedDates($('#etc-start-date-txt').val(), 'start');
32546                    termPicker.setSelectedDates($('#etc-end-date-txt').val(), 'end');
32547                });
32548                break;
32549            case 'excludeDate':
32550                var disabled = null;
32551                if (dateWeek == 'W') {
32552                    disabled = [0, 6];
32553                } else if (dateWeek == 'K') {
32554                    disabled = [1, 2, 3, 4, 5];
32555                }
32556                if (days.length > 0) {
32557                    disabled = [0, 1, 2, 3, 4, 5, 6];
32558                    $.each(days, function(i, v) {
32559                        enableIdx = disabled.indexOf(daysObj[v]);
32560                        if (enableIdx > -1) {
32561                            disabled.splice(enableIdx, 1);
32562                        }
32563                    });
32564                }
32565
32566                var exceptPicker = new Datepickk({
32567                    container: document.querySelector('#etc-except-date-picker'),
32568                    inline: true,
32569                    exp: true,
32570                    disabledDays: disabled,
32571                    lang: language,
32572                    minDate: new Date(1900, 0, 1),
32573                    maxDate: new Date(currentYear + 15, 11, 31),
32574                });
32575
32576                exceptPicker.disabledDays = (disabled.length > 0) ? disabled : null;
32577
32578                if (startDate && endDate) {
32579                    var checkStartDate = startDate.split('.');
32580                    var checkEndDate = endDate.split('.');
32581
32582                    exceptPicker.minDate = new Date(Number(checkStartDate[0]), Number(checkStartDate[1]) - 1, Number(checkStartDate[2]));
32583                    exceptPicker.maxDate = new Date(Number(checkEndDate[0]), Number(checkEndDate[1]) - 1, Number(checkEndDate[2]));
32584                }
32585
32586                displaySelectedDates();
32587
32588                $('.unselect-all').on('click', function() {
32589                    $('#select-except-date').val('');
32590                    $('#etc-except-date-picker input').prop('checked', false);
32591                    $('#etc-except-date-picker input').removeClass('active');
32592                });
32593
32594                break;
32595            case 'saleStartDateTime':
32596            case 'saleEndDateTime':
32597                var saleStartDateTime = $('#sale-start-datetime').val();
32598                var saleEndDateTime = $('#sale-end-datetime').val();
32599                startDate = saleStartDateTime.split(' ')[0];
32600                endDate = saleEndDateTime.split(' ')[0];
32601                var startTime = saleStartDateTime.split(' ')[1];
32602                var endTime = saleEndDateTime.split(' ')[1];
32603
32604                var currentDateTime = new Date();
32605                currentDateTime.setDate(currentDateTime.getDate() - 1);
32606                // console.log('currentDateTime', currentDateTime, new Date());
32607
32608                var datepickkObj = {
32609                    container: document.querySelector('#sale-datepicker'),
32610                    inline: true,
32611                    range: false,
32612                    exp: false,
32613                    lang: language,
32614                    startDate: (startDate)? startDate : currentDateTime,
32615                    minDate: currentDateTime,
32616                    maxDate: new Date(currentYear + 15, 11, 31),
32617                };
32618                
32619                if(func == 'saleStartDateTime') {
32620                    if(saleStartDateTime) {
32621                        $('#select-date-ymd').val(startDate.replace(/-/g, '.'));
32622                    } else {
32623                        $('.setting-sale-date').addClass('open');
32624                    }
32625                }
32626                console.log('currentDateTime', currentDateTime);
32627                if(func == 'saleEndDateTime') {
32628                    var datepickk_startDate = currentDateTime;
32629
32630                    if(saleStartDateTime) {
32631                        datepickk_startDate = (new Date() > new Date(saleStartDateTime))? new Date() : new Date(saleStartDateTime.replace(/-/g, '/'));
32632                        console.log('datepickk_startDate', datepickk_startDate);
32633                        datepickk_startDate.setDate(datepickk_startDate.getDate() - 1);
32634                    }
32635                    if(saleEndDateTime) {
32636                        $('#select-date-ymd').val(endDate.replace(/-/g, '.'));
32637                        if(new Date() > new Date(saleEndDateTime)) {
32638                            datepickk_startDate = new Date();
32639                            datepickk_startDate.setDate(datepickk_startDate.getDate() - 1);
32640                        }
32641                    } else {
32642                        $('.setting-sale-date').addClass('open');
32643                    }
32644
32645                    datepickkObj = {
32646                        container: document.querySelector('#sale-datepicker'),
32647                        inline: true,
32648                        range: false,
32649                        exp: false,
32650                        lang: language,
32651                        startDate: (endDate)? endDate : datepickk_startDate,
32652                        minDate: datepickk_startDate,
32653                        maxDate: new Date(currentYear + 15, 11, 31),
32654                    };
32655                }
32656                var termPicker = new Datepickk(datepickkObj);
32657                displaySelectedDates();
32658                
32659                $('.time-interval').each(function(i, v) {
32660                    var mna = $(v).data('time');
32661                    var times = '\
32662                        <input type="radio" id="' + mna + '-12-00" class="hide" name="sale_time" value="1200">\
32663                        <label for="' + mna + '-12-00">12:00</label>\
32664                        <input type="radio" id="' + mna + '-12-30" class="half-time hide" name="sale_time" value="1230">\
32665                        <label for="' + mna + '-12-30" class="half-time">12:30</label>\
32666                        \
32667                        <input type="radio" id="' + mna + '-1-00" class="hide" name="sale_time" value="
326670100">\
32668                        <label for="' + mna + '-1-00">1:00</label>\
32669                        <input type="radio" id="' + mna + '-1-30" class="half-time hide" name="sale_time" value="0130">\
32670                        <label for="' + mna + '-1-30" class="half-time">1:30</label>\
32671                        \
32672                        <input type="radio" id="' + mna + '-2-00" class="hide" name="sale_time" value="0200">\
32673                        <label for="' + mna + '-2-00">2:00</label>\
32674                        <input type="radio" id="' + mna + '-2-30" class="half-time hide" name="sale_time" value="0230">\
32675                        <label for="' + mna + '-2-30" class="half-time">2:30</label>\
32676                        \
32677                        <input type="radio" id="' + mna + '-3-00" class="hide" name="sale_time" value="0300">\
32678                        <label for="' + mna + '-3-00">3:00</label>\
32679                        <input type="radio" id="' + mna + '-3-30" class="half-time hide" name="sale_time" value="0330">\
32680                        <label for="' + mna + '-3-30" class="half-time">3:30</label>\
32681                        \
32682                        <input type="radio" id="' + mna + '-4-00" class="hide" name="sale_time" value="
326820400">\
32683                        <label for="' + mna + '-4-00">4:00</label>\
32684                        <input type="radio" id="' + mna + '-4-30" class="half-time hide" name="sale_time" value="0430">\
32685                        <label for="' + mna + '-4-30" class="half-time">4:30</label>\
32686                        \
32687                        <input type="radio" id="' + mna + '-5-00" class="hide" name="sale_time" value="0500">\
32688                        <label for="' + mna + '-5-00">5:00</label>\
32689                        <input type="radio" id="' + mna + '-5-30" class="half-time hide" name="sale_time" value="0530">\
32690                        <label for="' + mna + '-5-30" class="half-time">5:30</label>\
32691                        \
32692                        <input type="radio" id="' + mna + '-6-00" class="hide" name="sale_time" value="0600">\
32693                        <label for="' + mna + '-6-00">6:00</label>\
32694                        <input type="radio" id="' + mna + '-6-30" class="half-time hide" name="sale_time" value="0630">\
32695                        <label for="' + mna + '-6-30" class="half-time">6:30</label>\
32696                        \
32697                        <input type="radio" id="' + mna + '-7-00" class="hide" name="sale_time" value="
326970700">\
32698                        <label for="' + mna + '-7-00">7:00</label>\
32699                        <input type="radio" id="' + mna + '-7-30" class="half-time hide" name="sale_time" value="0730">\
32700                        <label for="' + mna + '-7-30" class="half-time">7:30</label>\
32701                        \
32702                        <input type="radio" id="' + mna + '-8-00" class="hide" name="sale_time" value="0800">\
32703                        <label for="' + mna + '-8-00">8:00</label>\
32704                        <input type="radio" id="' + mna + '-8-30" class="half-time hide" name="sale_time" value="0830">\
32705                        <label for="' + mna + '-8-30" class="half-time">8:30</label>\
32706                        \
32707                        <input type="radio" id="' + mna + '-9-00" class="hide" name="sale_time" value="0900">\
32708                        <label for="' + mna + '-9-00">9:00</label>\
32709                        <input type="radio" id="' + mna + '-9-30" class="half-time hide" name="sale_time" value="0930">\
32710                        <label for="' + mna + '-9-30" class="half-time">9:30</label>\
32711                        \
32712                        <input type="radio" id="' + mna + '-10-00" class="hide" name="sale_time" value="1000">\
32713                        <label for="' + mna + '-10-00">10:00</label>\
32714                        <input type="radio" id="' + mna + '-10-30" class="half-time hide" name="sale_time" value="1030">\
32715                        <label for="' + mna + '-10-30" class="half-time">10:30</label>\
32716                        \
32717                        <input type="radio" id="' + mna + '-11-00" class="hide" name="sale_time" value="1100">\
32718                        <label for="' + mna + '-11-00">11:00</label>\
32719                        <input type="radio" id="' + mna + '-11-30" class="half-time hide" name="sale_time" value="1130">\
32720                        <label for="' + mna + '-11-30" class="half-time">11:30</label>\
32721                        ';
32722                    $(v).html(times);
32723                }); //end each
32724
32725                $('input[name="time_interval"][value="' + interval + '"]').prop('checked', true);
32726
32727                if(func == 'saleStartDateTime' && saleStartDateTime) {
32728                    var hour = parseInt(startTime.split(':')[0]);
32729                    var minute = parseInt(startTime.split(':')[1]);
32730                    var mna = 'am';
32731                    if(hour >= 12) {
32732                        if (hour > 12) hour -= 12;
32733                        mna = 'pm';   
32734                    } else if (hour == 0) hour += 12
32735                    var formattedTime = hour.toString().padStart(2, '0') + minute.toString().padStart(2, '0');
32736                    $('.time-interval[data-time="' + mna + '"] input[value="' + formattedTime + '"]').prop('checked', true);
32737                    getDateTimeStr(language);
32738                }
32739 
32740                if(func == 'saleEndDateTime') {
32741                    if(saleStartDateTime && startDate == endDate) {
32742                        var hour = parseInt(startTime.split(':')[0]);
32743                        var minute = parseInt(startTime.split(':')[1]);
32744                        var mna = (hour >= 12)? 'pm' : 'am';
32745
32746                        if(hour >= 12) {
32747                            if (hour > 12) hour -= 12;
32748                        } else if (hour == 0) hour += 12
32749
32750                        var formattedStartTime = hour.toString().padStart(2, '0') + minute.toString().padStart(2, '0');
32751                        $('.time-interval[data-time="' + mna + '"] input[value="' + formattedStartTime + '"]').prop('disabled', true);
32752                        if(mna == 'pm') {
32753                            $('.time-interval[data-time="am"] input').prop('disabled', true);
32754                            $('.time-interval[data-time="pm"] input[value="' + formattedStartTime + '"]').prevAll('input').prop('disabled', true);
32755                        } else {
32756                            $('.time-interval[data-time="am"] input[value="' + formattedStartTime + '"]').prevAll('input').prop('disabled', true);
32757                        }
32758                    }
32759                    if(saleEndDateTime) {
32760                        var hour = parseInt(endTime.split(':')[0]);
32761                        var minute = parseInt(endTime.split(':')[1]);
32762                        var mna = 'am';
32763                        if(hour >= 12) {
32764                            if (hour > 12) hour -= 12;
32765                            mna = 'pm';   
32766                        } else if (hour == 0) hour += 12
32767                        var formattedTime = hour.toString().padStart(2, '0') + minute.toString().padStart(2, '0');
32768                        $('.time-interval[data-time="' + mna + '"] input[value="' + formattedTime + '"]').prop('checked', true);
32769                        getDateTimeStr(language);
32770                    }
32771                }
32772
32773                var time_interval = $('input[name="time_interval"]:checked').val();
32774
32775                switch (time_interval) {
32776                    case 10:
32777                        dateTimeModal.find('.time-interval label.ten-time').removeClass('hide');
32778                        break;
32779                    case 20:
32780                        dateTimeModal.find('.time-interval label.twt-time').removeClass('hide');
32781                        break;
32782                    case 30:
32783                        dateTimeModal.find('.time-interval label.half-time').removeClass('hide');
32784                        break;
32785                    case 60:
32786                        dateTimeModal.find('.time-interval label').removeClass('hide');
32787                        break;
32788                }
32789
32790                $('input[name="time_interval"]').on('change', function() {
32791                    if ($(this).val() == 60) {
32792                        $('.time-interval label.half-time').addClass('hide');
32793                        if ($('#all-time-select').is(':checked')) {
32794                            $('.time-interval input.o-time').prop('checked', true);
32795                        }
32796                    } else { //30
32797                        $('.time-interval label.half-time').removeClass('hide');
32798                        if ($('#all-time-select').is(':checked')) {
32799                            $('.time-interval input').prop('checked', true);
32800                        }
32801                    }
32802                });
32803
32804                $('.time-interval input').on('change', function(){
32805                    getDateTimeStr(language, 'time');
32806                });
32807
32808                $('.sale-calendar-box .setting-label').on('click', function(){
32809                    var $saleCalendarBox = $(this).closest('.sale-calendar-box');
32810
32811                    if($saleCalendarBox.hasClass('open')) {
32812                        $('.sale-calendar-box .setting-datetime-input').slideUp(400, function(){
32813                            $('.sale-calendar-box').removeClass('open');
32814                        });
32815                    } else{
32816                        $('.sale-calendar-box .setting-datetime-input').slideUp(400, function(){
32817                            $('.sale-calendar-box').removeClass('open');
32818                        });
32819
32820                        $saleCalendarBox.find('.setting-datetime-input').slideDown(400, function(){
32821                            $saleCalendarBox.addClass('open');
32822                        });
32823                    }
32824                });
32825
32826                break;
32827            case 'time':
32828                $('.time-interval').each(function(i, v) {
32829                    var mna = $(v).data('time');
32830                    var times = '\
32831                    <input type="checkbox" id="'+mna+'-12-00" class="o-time hide" name="'+mna+'" value="1200">\
32832                    <label for="'+mna+'-12-00" class="o-time">12:00</label>\
32833                    \
32834                    <input type="checkbox" id="'+mna+'-12-10" class="ten-time hide" name="'+mna+'" value="1210">\
32835                    <label for="'+mna+'-12-10" class="ten-time">12:10</label>\
32836                    \
32837                    <input type="checkbox" id="'+mna+'-12-20" class="ten-time twt-time hide" name="'+mna+'" value="1220">\
32838                    <label for="'+mna+'-12-20" class="ten-time twt-time">12:20</label>\
32839                    \
32840                    <input type="checkbox" id="'+mna+'-12-30" class="ten-time half-time hide" name="'+mna+'" value="1230">\
32841                    <label for="'+mna+'-12-30" class="ten-time half-time">12:30</label>\
32842                    \
32843                    <input type="checkbox" id="'+mna+'-12-40" class="ten-time twt-time hide" name="'+mna+'" value="1240">\
32844                    <label for="'+mna+'-12-40" class="ten-time twt-time">12:40</label>\
32845                    \
32846                    <input type="checkbox" id="'+mna+'-12-50" class="ten-time hide" name="'+mna+'" value="1250">\
32847                    <label for="'+mna+'-12-50" class="ten-time">12:50</label>\
32848                    ';
32849
32850                    for(let t = 1; t <= 11; t++) {
32851                        let hstr = t.toString().padStart(2, '0');
32852                        times += '\
32853                            <input type="checkbox" id="'+mna+'-'+t+'-00" class="o-time hide" name="'+mna+'" value="'+hstr+'00">\
32854                            <label for="'+mna+'-'+t+'-00" class="o-time">'+t+':00</label>\
32855                            \
32856                            <input type="checkbox" id="'+mna+'-'+t+'-10" class="ten-time hide" name="'+mna+'" value="'+hstr+'10">\
32857                            <label for="'+mna+'-'+t+'-10" class="ten-time">'+t+':10</label>\
32858                            \
32859                            <input type="checkbox" id="'+mna+'-'+t+'-20" class="ten-time twt-time hide" name="'+mna+'" value="'+hstr+'20">\
32860                            <label for="'+mna+'-'+t+'-20" class="ten-time twt-time">'+t+':20</label>\
32861                            \
32862                            <input type="checkbox" id="'+mna+'-'+t+'-30" class="ten-time half-time hide" name="'+mna+'" value="'+hstr+'30">\
32863                            <label for="'+mna+'-'+t+'-30" class="ten-time half-time">'+t+':30</label>\
32864                            \
32865                            <input type="checkbox" id="'+mna+'-'+t+'-40" class="ten-time twt-time hide" name="'+mna+'" value="'+hstr+'40">\
32866                            <label for="'+mna+'-'+t+'-40" class="ten-time twt-time">'+t+':40</label>\
32867                            \
32868                            <input type="checkbox" id="'+mna+'-'+t+'-50" class="ten-time hide" name="'+mna+'" value="'+hstr+'50">\
32869                            <label for="'+mna+'-'+t+'-50" class="ten-time">'+t+':50</label>\
32870                        ';
32871                    }
32872                    // var times = '\
32873                    //     <input type="checkbox" id="' + mna + '-12-00" class="hide" name="' + mna + '" value="1200">\
32874                    //     <label for="' + mna + '-12-00">12:00</label>\
32875                    //     <input type="checkbox" id="' + mna + '-12-30" class="half-time hide" name="' + mna + '" value="1230">\
32876                    //     <label for="' + mna + '-12-30" class="half-time">12:30</label>\
32877                    //     \
32878                    //     <input type="checkbox" id="' + mna + '-1-00" class="hide" name="' + mna + '" value="
328780100">\
32879                    //     <label for="' + mna + '-1-00">1:00</label>\
32880                    //     <input type="checkbox" id="' + mna + '-1-30" class="half-time hide" name="' + mna + '" value="0130">\
32881                    //     <label for="' + mna + '-1-30" class="half-time">1:30</label>\
32882                    //     \
32883                    //     <input type="checkbox" id="' + mna + '-2-00" class="hide" name="' + mna + '" value="0200">\
32884                    //     <label for="' + mna + '-2-00">2:00</label>\
32885                    //     <input type="checkbox" id="' + mna + '-2-30" class="half-time hide" name="' + mna + '" value="0230">\
32886                    //     <label for="' + mna + '-2-30" class="half-time">2:30</label>\
32887                    //     \
32888                    //     <input type="checkbox" id="' + mna + '-3-00" class="hide" name="' + mna + '" value="0300">\
32889                    //     <label for="' + mna + '-3-00">3:00</label>\
32890                    //     <input type="checkbox" id="' + mna + '-3-30" class="half-time hide" name="' + mna + '" value="0330">\
32891                    //     <label for="' + mna + '-3-30" class="half-time">3:30</label>\
32892                    //     \
32893                    //     <input type="checkbox" id="' + mna + '-4-00" class="hide" name="' + mna + '" value="0400">\
32894                    //     <label for="' + mna + '-4-00">4:00</label>\
32895                    //     <input type="checkbox" id="' + mna + '-4-30" class="half-time hide" name="' + mna + '" value="0430">\
32896                    //     <label for="' + mna + '-4-30" class="half-time">4:30</label>\
32897                    //     \
32898                    //     <input type="checkbox" id="' + mna + '-5-00" class="hide" name="' + mna + '" value="0500">\
32899                    //     <label for="' + mna + '-5-00">5:00</label>\
32900                    //     <input type="checkbox" id="' + mna + '-5-30" class="half-time hide" name="' + mna + '" value="0530">\
32901                    //     <label for="' + mna + '-5-30" class="half-time">5:30</label>\
32902                    //     \
32903                    //     <input type="checkbox" id="' + mna + '-6-00" class="hide" name="' + mna + '" value="0600">\
32904                    //     <label for="' + mna + '-6-00">6:00</label>\
32905                    //     <input type="checkbox" id="' + mna + '-6-30" class="half-time hide" name="' + mna + '" value="0630">\
32906                    //     <label for="' + mna + '-6-30" class="half-time">6:30</label>\
32907                    //     \
32908                    //     <input type="checkbox" id="' + mna + '-7-00" class="hide" name="' + mna + '" value="0700">\
32909                    //     <label for="' + mna + '-7-00">7:00</label>\
32910                    //     <input type="checkbox" id="' + mna + '-7-30" class="half-time hide" name="' + mna + '" value="0730">\
32911                    //     <label for="' + mna + '-7-30" class="half-time">7:30</label>\
32912                    //     \
32913                    //     <input type="checkbox" id="' + mna + '-8-00" class="hide" name="' + mna + '" value="0800">\
32914                    //     <label for="' + mna + '-8-00">8:00</label>\
32915                    //     <input type="checkbox" id="' + mna + '-8-30" class="half-time hide" name="' + mna + '" value="0830">\
32916                    //     <label for="' + mna + '-8-30" class="half-time">8:30</label>\
32917                    //     \
32918                    //     <input type="checkbox" id="' + mna + '-9-00" class="hide" name="' + mna + '" value="0900">\
32919                    //     <label for="' + mna + '-9-00">9:00</label>\
32920                    //     <input type="checkbox" id="' + mna + '-9-30" class="half-time hide" name="' + mna + '" value="0930">\
32921                    //     <label for="' + mna + '-9-30" class="half-time">9:30</label>\
32922                    //     \
32923                    //     <input type="checkbox" id="' + mna + '-10-00" class="hide" name="' + mna + '" value="1000">\
32924                    //     <label for="' + mna + '-10-00">10:00</label>\
32925                    //     <input type="checkbox" id="' + mna + '-10-30" class="half-time hide" name="' + mna + '" value="1030">\
32926                    //     <label for="' + mna + '-10-30" class="half-time">10:30</label>\
32927                    //     \
32928                    //     <input type="checkbox" id="' + mna + '-11-00" class="hide" name="' + mna + '" value="1100">\
32929                    //     <label for="' + mna + '-11-00">11:00</label>\
32930                    //     <input type="checkbox" id="' + mna + '-11-30" class="half-time hide" name="' + mna + '" value="1130">\
32931                    //     <label for="' + mna + '-11-30" class="half-time">11:30</label>\
32932                    //     ';
32933                    $(v).html(times);
32934                }); //end each
32935
32936                $('input[name="time_interval"][value="' + interval + '"]').prop('checked', true);
32937                if (am) {
32938                    $.each(am, function(i, v) {
32939                        $('.time-interval[data-time="am"] input[value="' + v + '"]').prop('checked', true);
32940                        $('.time-interval[data-time="am"] input[value="' + v + '"] + label').addClass('ui-selected');
32941                    });
32942                }
32943                if (pm) {
32944                    $.each(pm, function(i, v) {
32945                        $('.time-interval[data-time="pm"] input[value="' + v + '"]').prop('checked', true);
32946                        $('.time-interval[data-time="pm"] input[value="' + v + '"] + label').addClass('ui-selected');
32947                    });
32948                }
32949
32950                var time_interval = $('input[name="time_interval"]:checked').val();
32951                // if (time_interval == 60) {
32952                //     $('.time-interval label.half-time').addClass('hide');
32953                // } else { //30
32954                //     $('.time-interval label.half-time').removeClass('hide');
32955                // }
32956                // console.log('time_interval', time_interval);
32957                $('.time-interval label:not(.o-time)').addClass('hide');
32958                switch (time_interval) {
32959                    case '10':
32960                        $('.time-interval label').removeClass('hide');
32961                        break;
32962                    case '20':
32963                        $('.time-interval label.twt-time').removeClass('hide');
32964                        break;
32965                    case '30':
32966                        $('.time-interval label.half-time').removeClass('hide');
32967                        break;
32968                }
32969
32970                $('input[name="time_interval"]').on('change', function() {
32971                    let time_interval = $(this).val();
32972                    // if ($(this).val() == 60) {
32973                    //     $('.time-interval label.half-time').addClass('hide');
32974                    //     if ($('#all-time-select').is(':checked')) {
32975                    //         $('.time-interval input:not(.half-time)').prop('checked', true);
32976                    //     }
32977                    // } else { //30
32978                    //     $('.time-interval label.half-time').removeClass('hide');
32979                    //     if ($('#all-time-select').is(':checked')) {
32980                    //         $('.time-interval input').prop('checked', true);
32981                    //     }
32982                    // }
32983                    $('.time-interval label:not(.o-time)').addClass('hide');
32984
32985                    switch (time_interval) {
32986                        case '10':
32987                            $('.time-interval label').removeClass('hide');
32988                            if ($('#all-time-select').is(':checked')) {
32989                                $('.time-interval input').prop('checked', true);
32990                                $('.time-interval input + label').addClass('ui-selected');
32991                            }
32992                            break;
32993                        case '20':
32994                            $('.time-interval label.twt-time').removeClass('hide');
32995                            if ($('#all-time-select').is(':checked')) {
32996                                $('.time-interval input.twt-time').prop('checked', true);
32997                                $('.time-interval input.twt-time + label').addClass('ui-selected');
32998
32999                            }
33000                            break;
33001                        case '30':
33002                            $('.time-interval label.half-time').removeClass('hide');
33003                            if ($('#all-time-select').is(':checked')) {
33004                                $('.time-interval input.half-time').prop('checked', true);
33005                            }
33006                            break;
33007                        case '60':
33008                            if ($('#all-time-select').is(':checked')) {
33009                                $('.time-interval input.o-time').prop('checked', true);
33010                            }
33011                            break;
33012                    }
33013                });
33014
33015                isSelectedAllTimes();
33016
33017                $('#all-time-select').change(function() {
33018                    var time_interval = $('input[name="time_interval"]:checked').val();
33019                    if ($(this).is(':checked')) {
33020                        $('.time-interval label').prev('input').prop('checked', true);
33021                        $('.time-interval label').addClass('ui-selected');
33022                    } else {
33023                        $('.time-interval input').prop('checked', false);
33024                        $('.time-interval label').removeClass('ui-selected');
33025                    }
33026                });
33027
33028                $('.time-interval[data-time] input[type=checkbox]').on('change', function(){
33029                    timeSelect($(this).next('label'), 'click');
33030                    isSelectedAllTimes();
33031                });
33032
33033                $('.setting-form-option-date2').closest('.modal').mousedown(function(e) {
33034                    e.metaKey = true; // Mac에서는 Command 키, Windows에서는 Ctrl 키 역할
33035                }).selectableScroll({
33036                    filter: 'label',
33037                    cancel: 'input[type=radio], .newcheckbox label, #all-time-select, label.all-time, button',
33038                    delay: 100,
33039                    selected: function(e, ui) {
33040                        timeSelect(ui.selected);
33041                    },
33042                    stop: function(e, ui) {
33043                        $('.time-interval[data-time] label').each(function(idx, v) {
33044                            if($(v).hasClass('.all-time')) return true;
33045                            let chk = $("#" + $(v).attr("for"));
33046                            // console.log('chk', chk);
33047                            if(chk.is(':checked')) {
33048                                $(v).addClass('ui-selected');
33049                            } else {
33050                                $(v).removeClass('ui-selected');
33051                            }
33052                        });
33053                    
33054                        isSelectedAllTimes();
33055                    },
33056                });
33057                break;
33058        }
33059
33060        $(document).off('click', '.d-year, .d-month');
33061        $(document).on('click', '.d-year, .d-month', function() {
33062            $('.d-month-year-picker').toggleClass('d-show');
33063            scrollToCurrentYearMonth();
33064        });
33065
33066        function timeSelect(label, action) {
33067            if(typeof action == 'undefined') action = '';
33068            // console.log(label);
33069            let interval = $('input[name=time_interval]:checked').val();
33070            let chk = $("#" + $(label).attr('for'));
33071            let t = chk.prevAll('input.ten-time');
33072            // console.log('chk', chk);
33073            if(action == 'click') {
33074                if(chk.is(':checked')) {
33075                    label.addClass('ui-selected'); // 체크박스 선택
33076                } else {
33077                    label.removeClass('ui-selected'); // 체크박스 선택
33078                }
33079            } else {
33080                if(chk.is(':checked')) {
33081                    chk.prop("checked", false); // 체크박스 선택
33082                } else {
33083                    chk.prop("checked", true); // 체크박스 선택
33084                }
33085            }
33086            
33087            switch (interval) {
33088                case '20':
33089                    if(chk.is(':checked') && $(t[0]).prevAll('input.o-time, input.twt-time').first().is(':checked')) {
33090                        $(t[0]).prop('checked', true);
33091                        if(action == 'click') $(t[0]).next('label').addClass('ui-selected');
33092                    } else {
33093                        $(t[0]).prop('checked', false);
33094                        if(action == 'click') $(t[0]).next('label').removeClass('ui-selected');
33095                    }
33096                    break;
33097                case '30':
33098                    if(chk.is(':checked') && $(t[0]).prevAll('input.o-time, input.half-time').first().is(':checked')) {
33099                        $(t[0]).prop('checked', true);
33100                        $(t[1]).prop('checked', true);
33101                        if(action == 'click') {
33102                            $(t[0]).next('label').addClass('ui-selected');
33103                            $(t[1]).next('label').addClass('ui-selected');
33104                        }
33105                    } else {
33106                        $(t[0]).prop('checked', false);
33107                        $(t[1]).prop('checked', false);
33108                        if(action == 'click') {
33109                            $(t[0]).next('label').removeClass('ui-selected');
33110                            $(t[1]).next('label').removeClass('ui-selected');
33111                        }                        
33112                    }
33113
33114                    break;
33115                case '60':
33116                    if(chk.is(':checked') && $(t[0]).prevAll('input.o-time').first().is(':checked')) {
33117                        $(t[0]).prop('checked', true);
33118                        $(t[1]).prop('checked', true);
33119                        $(t[2]).prop('checked', true);
33120                        $(t[3]).prop('checked', true);
33121                        $(t[4]).prop('checked', true);
33122                        if(action == 'click') {
33123                            $(t[0]).next('label').addClass('ui-selected');
33124                            $(t[1]).next('label').addClass('ui-selected');
33125                            $(t[2]).next('label').addClass('ui-selected');
33126                            $(t[3]).next('label').addClass('ui-selected');
33127                            $(t[4]).next('label').addClass('ui-selected');
33128                        }                        
33129                    } else {
33130                        $(t[0]).prop('checked', false);
33131                        $(t[1]).prop('checked', false);
33132                        $(t[2]).prop('checked', false);
33133                        $(t[3]).prop('checked', false);
33134                        $(t[4]).prop('checked', false);
33135                        if(action == 'click') {
33136                            $(t[0]).next('label').removeClass('ui-selected');
33137                            $(t[1]).next('label').removeClass('ui-selected');
33138                            $(t[2]).next('label').removeClass('ui-selected');
33139                            $(t[3]).next('label').removeClass('ui-selected');
33140                            $(t[4]).next('label').removeClass('ui-selected');
33141                        }                                                
33142                    }
33143                    
33144                    break;
33145            }
33146        }
33147
33148        function isSelectedAllTimes() {
33149            let interval = $('input[name=time_interval]:checked').val();
33150            let am = $('.time-interval[data-time="am"] label:not(.hide)').prev('input[type="checkbox"]:checked');
33151            let pm = $('.time-interval[data-time="pm"] label:not(.hide)').prev('input[type="checkbox"]:checked');
33152            let timeCnt = am.length + pm.length;
33153            // console.log('timeCnt', timeCnt);
33154            let allTimeChecked = '';
33155            if (interval == '10' && timeCnt == 144) allTimeChecked = 'checked';
33156            if (interval == '20' && timeCnt == 72) allTimeChecked = 'checked';
33157            if (interval == '30' && timeCnt == 48) allTimeChecked = 'checked';
33158            if (interval == '60' && timeCnt == 24) allTimeChecked = 'checked';
33159
33160            if(allTimeChecked) {
33161                $('#all-time-select').prop('checked', true);
33162            } else {
33163                $('#all-time-select').prop('checked', false);
33164            }
33165        }
33166    }, function() { //hide
33167        if (func == 'term' && (!$('#etc-start-date-txt').val() || !$('#etc-end-date-txt').val())) {
33168            if (!$('#etc-start-date-prev').val() && !$('#etc-end-date-prev').val()) {
33169                $('input[name="select_terms-' + id + '"][value="N"]').prop('checked', true);
33170                $('.form-sort-item[data-id="' + id + '"] .setting-date2[data-setting="term"]').addClass('disabled');
33171            }
33172        }
33173        settingModal.modal('hide');
33174    });
33175}
33176
33177var calendarDateTime = function(el, id, type, se, fulltime, locale) {
33178    var field_type = 'sale-product-datetime';
33179    var func = (se == 'sdate') ? 'saleStartDateTime' : 'saleEndDateTime';
33180
33181    var sid = (typeof property != 'undefined') ? property.SID : SID;
33182    var blocklang = locale;
33183    var field_setting = {};
33184    var etcDateState = 'N';
33185    var $scopeCtx = (typeof selectEL !== 'undefined') ? $('.' + el) : $('.calendar-modal-container');
33186    var isAllDay = $scopeCtx.find('input.all-day').is(':checked');
33187
33188    //기본값
33189    $default_term = {
33190        'select_terms' : 'N',
33191        'start_date' : '',
33192        'end_date' : '',
33193        'date_week' : 'A',
33194        'days' : 'sun|mon|tue|wed|thu|fri|sat',
33195    };
33196    $default_excludeDate = {'date' : ''};
33197    $default_time = {
33198        'interval' : '30',
33199        'am' : '0000|0030|0100|0130|0200|0230|0300|0330|0400|0430|0500|0530|0600|0630|0700|0730|0800|0830|0900|0930|1000|1030|1100|1130',
33200        'pm' : '1200|1230|1300|1330|1400|1430|1500|1530|1600|1630|1700|1730|1800|1830|1900|1930|2000|2030|2100|2130|2200|2230|2300|2330'
33201    };
33202    $default_color = {'highlight' : '4789e7'};
33203
33204    field_setting = {
33205        'term' : $default_term,
33206        'excludeDate' : $default_excludeDate,
33207        'time' : $default_time,
33208        'color' : $default_color,
33209    };
33210
33211    var term = (field_setting.term)? field_setting.term:{};
33212    var excludeDate = (field_setting.excludeDate)? field_setting.excludeDate:{};
33213    var time = (type != 'date' && field_setting.time)? field_setting.time:{};
33214    var color = (field_setting.color)? field_setting.color:{};
33215
33216    var startDate = (term.start_date !== undefined)? term.start_date:''; 
33217    var endDate = (term.end_date !== undefined)? term.end_date:'';
33218    var dateWeek = (term.date_week !== undefined)? term.date_week:'';
33219    var days = (term.days !== undefined)? term.days.split('|'):[];
33220    var daysObj = {
33221        'sun': 0, 'mon': 1, 'tue': 2, 'wed': 3, 'thu': 4, 'fri': 5, 'sat': 6,
33222    }
33223
33224    var exceptDate = (excludeDate.date !== undefined) ? excludeDate.date : '';
33225
33226    var interval = (time.interval !== undefined) ? time.interval : '30';
33227    var am = (time.am !== undefined) ? time.am.split('|') : [];
33228    var pm = (time.pm !== undefined) ? time.pm.split('|') : [];
33229    var timeCnt = am.length + pm.length;
33230    var language = (locale != 'ko') ? 'en' : 'ko';
33231    var blocklang = ($('[form-seq="' + id + '"]').closest('.element').attr('data-blocklang')) ? $('[form-seq="' + id + '"]').closest('.element').attr('data-blocklang') : locale;
33232
33233    var modal_title = '';
33234    var modal_str = '';
33235    var modal_class = 'modal-dialog cl-cmmodal cl-s-btn setting-form-option-date2 cl-close-btn cover';
33236    
33237    modal_class = 'modal-dialog cl-cmmodal cl-s-btn setting-form-option-date2 setting-product-sale-datetime cl-close-btn cover';
33238    var timeClass = 'start-time';
33239    if(func == 'saleStartDateTime') {
33240        // modal_title = '시작 날짜/시간 선택';
33241        modal_title = $.lang[locale]['config.calendar.sdate'];
33242        modal_str = '\
33243        <div class="term-calendar-box sale-calendar-box setting-sale-date">\
33244            <div class="setting-label display-flex align-items-center space-between">\
33245                <div class="display-flex align-items-center">\
33246                    <span>'+ $.lang[locale]['config.calendar.date'] +'</span>\
33247                    <span class="start-date datetime-txt" data-blocklang="' + blocklang + '"></span>\
33248                </div>\
33249                <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path d="M8 12.5a.47.47 0 0 1-.35-.15l-7.5-7.5c-.2-.2-.2-.51 0-.71.2-.2.51-.2.71 0L8 11.29l7.15-7.15c.2-.2.51-.2.71 0 .2.2.2.51 0 .71l-7.5 7.5c-.1.1-.23.15-.36.15z"></path></svg>\
33250            </div>\
33251            <div class="setting-datetime-input" data-type="' + func + '">\
33252                <input type="hidden" id="select-calendar" value="term-datepicker">\
33253                <input type="hidden" id="select-date-ymd" value="">\
33254                <input type="hidden" id="etc-start-date-prev" value="">\
33255                <input type="hidden" id="etc-start-date-txt" value="">\
33256                <input type="hidden" id="clang" value="'+ locale +'">\
33257                <div id="sale-datepicker"></div>\
33258            </div>\
33259        </div>\
33260        ';
33261    } else {
33262        // modal_title = '종료 날짜/시간 선택';
33263        modal_title = $.lang[locale]['config.calendar.edate'];
33264        modal_str = '\
33265        <div class="term-calendar-box sale-calendar-box setting-sale-date">\
33266            <div class="setting-label display-flex align-items-center space-between">\
33267                <div class="display-flex align-items-center">\
33268                    <span>'+ $.lang[locale]['config.calendar.date'] +'</span>\
33269                    <span class="end-date datetime-txt" data-blocklang="' + blocklang + '"></span>\
33270                </div>\
33271                <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path d="M8 12.5a.47.47 0 0 1-.35-.15l-7.5-7.5c-.2-.2-.2-.51 0-.71.2-.2.51-.2.71 0L8 11.29l7.15-7.15c.2-.2.51-.2.71 0 .2.2.2.51 0 .71l-7.5 7.5c-.1.1-.23.15-.36.15z"></path></svg>\
33272            </div>\
33273            <div class="setting-datetime-input" data-type="' + func + '">\
33274                <input type="hidden" id="select-calendar" value="term-datepicker">\
33275                <input type="hidden" id="select-date-ymd" value="">\
33276                <input type="hidden" id="etc-start-date-prev" value="">\
33277                <input type="hidden" id="etc-start-date-txt" value="">\
33278                <input type="hidden" id="etc-end-date-prev" value="">\
33279                <input type="hidden" id="etc-end-date-txt" value="">\
33280                <input type="hidden" id="clang" value="'+ locale +'">\
33281                <div id="sale-datepicker"></div>\
33282            </div>\
33283        </div>\
33284        ';
33285        timeClass = 'end-time';
33286    }
33287    
33288    modal_str += '\
33289        <div class="term-calendar-box sale-calendar-box setting-sale-time">\
33290            <div class="setting-label display-flex align-items-center space-between">\
33291                <div class="display-flex align-items-center">\
33292                    <span>'+ $.lang[locale]['config.calendar.time'] +'</span>\
33293                    <span class="'+timeClass+' datetime-txt" data-blocklang="' + blocklang + '"></span>\
33294                </div>\
33295                <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path d="M8 12.5a.47.47 0 0 1-.35-.15l-7.5-7.5c-.2-.2-.2-.51 0-.71.2-.2.51-.2.71 0L8 11.29l7.15-7.15c.2-.2.51-.2.71 0 .2.2.2.51 0 .71l-7.5 7.5c-.1.1-.23.15-.36.15z"></path></svg>\
33296            </div>\
33297            <div class="setting-datetime-input" data-type="' + func + '" style="display:none;">\
33298                <div class="display-flex align-items-center setting-row">\
33299                    <div class="setting-label">' + $.lang[locale]['config.form.date2.time.interval.label'] + '</div>\
33300                    <div class="newcheckbox hand">\
33301                        <label>\
33302                            <div class="newcheckboxSvgRadio">\
33303                                <input type="radio" class="cl-common-form-radio-hide" name="time_interval" value="30" checked>\
33304                                <svg viewBox="0 0 18 18" width="18" height="18">\
33305                                    <path d="M9 0C4.03 0 0 4.03 0 9c0 4.97 4.03 9 9 9s9-4.03 9-9C18 4.03 13.97 0 9 0zM9 17c-4.41 0-8-3.59-8-8 
333050-4.41 3.59-8 8-8s8 3.59 8 8C17 13.41 13.41 17 9 17z"></path>\
33306                                </svg>\
33307                                <svg class="active" viewBox="0 0 18 18" width="18" height="18">\
33308                                    <path d="M9 0C4.03 0 0 4.03 0 9c0 4.97 4.03 9 9 9s9-4.03 9-9C18 4.03 13.97 0 9 0zM9 17c-4.41 0-8-3.59-8-8 0-4.41 3.59-8 8-8s8 3.59 8 8C17 13.41 13.41 17 9 17z"></path>\
33309                                    <circle cx="9" cy="9" r="6"></circle>\
33310                                </svg>\
33311                            </div>\
33312                            <span>' + $.lang[locale]['config.form.date2.time.interval.30'] + '</span>\
33313                        </label>\
33314                    </div>\
33315                    <div class="newcheckbox hand">\
33316                        <label>\
33317                            <div class="newcheckboxSvgRadio">\
33318                                <input type="radio" class="cl-common-form-radio-hide" name="time_interval" value="60">\
33319                                <svg viewBox="0 0 18 18" width="18" height="18">\
33320                                    <path d="M9 0C4.03 0 0 4.03 0 9c0 4.97 4.03 9 9 9s9-4.03 9-9C18 4.03 13.97 0 9 0zM9 17c-4.41 0-8-3.59-8-8 0-4.41 3.59-8 8-8s8 3.59 8 8C17 13.41 13.41 17 9 17z"></path>\
33321                                </svg>\
33322                                <svg class="active" viewBox="0 0 18 18" width="18" height="18">\
33323                                    <path d="M9 0C4.03 0 0 4.03 0 9c0 4.97 4.03 9 9 9s9-4.03 9-9C18 4.03 13.97 0 9 0zM9 17c-4.41 0-8-3.59-8-8 0-4.41 3.59-8 8-8s8 3.59 8 8C17 13.41 13.41 17 9 17z"></path>\
33324                                    <circle cx="9" cy="9" r="6"></circle>\
33325                                </svg>\
33326                            </div>\
33327                            <span>' + $.lang[locale]['config.form.date2.time.interval.60'] + '</span>\
33328                        </label>\
33329                    </div>\
33330                </div>\
33331                <div class="setting-row am">\
33332                    <div class="setting-label">' + $.lang[locale]['config.form.date2.time.am'] + '</div>\
33333                    <div class="display-flex time-interval" data-time="am"></div>\
33334                </div>\
33335                <div class="setting-row">\
33336                    <div class="setting-label">' + $.lang[locale]['config.form.date2.time.pm'] + '</div>\
33337                    <div class="display-flex time-interval" data-time="pm"></div>\
33338                </div>\
33339            </div>\
33340        </div>\
33341    ';
33342
33343    var settingModal = $(el).showModalFlat(modal_title, modal_str, true, true, function() { //confirm
33344        function splitHHmm(hmRaw) {
33345            var hm = String(hmRaw).replace(/[^0-9]/g, '').padStart(4, '0'); 
33346            return { hh: hm.slice(0, 2), mm: hm.slice(2, 4) };
33347        }
33348        switch (func) {
33349            case 'saleStartDateTime': {
33350                const selectedDate = $('#select-date-ymd').val();
33351                const $timeChecked = $('.time-interval input:checked');
33352                if (!selectedDate || (!isAllDay && $timeChecked.length === 0)) {
33353                    alert($.lang[locale]['config.calendar.enter-date']);
33354                    return false;
33355                }
33356
33357                let hh = '00', mm = '00';
33358                if (!isAllDay) {
33359                    const mna   = $timeChecked.closest('.time-interval').data('time');
33360                    const hmRaw = convertTime24(mna, $timeChecked.val());
33361                    ({ hh, mm } = splitHHmm(hmRaw)); 
33362                }
33363
33364                const dateDash        = selectedDate.replace(/\./g, '-');
33365                const saleDateTimeVal = `${dateDash} ${hh}:${mm}:00`;
33366                const saleDateTimeUI  = `${dateDash} ${hh}:${mm}`;
33367
33368                $('.sale-setting .setting-text .content-start').text(isAllDay ? selectedDate : (selectedDate + '. ' + convertTime12(hh + mm)));
33369                $('#sale-start-datetime').val(saleDateTimeVal);
33370
33371                (function setStartInput(){
33372                    const $scope = (typeof selectEL !== 'undefined') ? $('.' + el) : $('.calendar-modal-container');
33373                    const saleDateUI = isAllDay ? dateDash : `${dateDash} ${hh}:${mm}`;
33374                    $scope.find('.sdate .start').val(saleDateUI);
33375                })();
33376
33377                (function fixEndAfterStart() {
33378                    function parseLocal(str) {
33379                        if (!str) return null;
33380                        var p = str.trim().split(' ');
33381                        if (p.length < 2) return null;
33382                        var d = p[0].split('-').map(Number);
33383                        var t = p[1].split(':').map(Number);
33384                        return new Date(d[0], (d[1]||1)-1, d[2]||1, t[0]||0, t[1]||0, 0, 0);
33385                    }
33386                    function pad2(n){ return String(n).padStart(2,'0'); }
33387
33388                    const $scope    = (typeof selectEL !== 'undefined') ? $('.' + el) : $('.calendar-modal-container');
33389                    const endInput  = ($scope.find('.edate .end').val() || '').trim();
33390                    const endHidden = ($('#sale-end-datetime').val() || '').trim();
33391                    const endStr    = endInput || endHidden;
33392
33393                    const startDT = parseLocal(saleDateTimeVal);
33394                    const endDT   = parseLocal(endStr);
33395
33396                    if (!endDT || startDT >= endDT) {
33397                        let fixed = new Date(startDT.getTime());
33398                        if (isAllDay) {
33399                            fixed.setHours(23, 59, 0, 0);
33400                        } else {
33401                            fixed.setHours(fixed.getHours() + 1);
33402                        }
33403
33404                        const y = fixed.getFullYear();
33405                        const m = pad2(fixed.getMonth() + 1);
33406                        const d = pad2(fixed.getDate());
33407                        const H = pad2(fixed.getHours());
33408                        const M = pad2(fixed.getMinutes());
33409
33410                        $('#sale-end-datetime').val(`${y}-${m}-${d} ${H}:${M}:00`);
33411
33412                        if (isAllDay) {
33413                            $('.sale-setting .setting-text .content-end').text(`${y}-${m}-${d}`);
33414                        } else {
33415                            $('.sale-setting .setting-text .content-end').text(`${y}-${m}-${d}. ` + convertTime12(H + M));
33416                        }
33417
33418                        $scope.find('.edate .end').val(isAllDay ? `${y}-${m}-${d}` : `${y}-${m}-${d} ${H}:${M}`);
33419                    }
33420                })();
33421
33422                break;
33423            }
33424
33425            case 'saleEndDateTime': {
33426                const selectedDate = $('#select-date-ymd').val();
33427                const $timeChecked = $('.time-interval input:checked');
33428
33429                if (!selectedDate || (!isAllDay && $timeChecked.length === 0)) {
33430                    alert($.lang[locale]['config.calendar.enter-date']);
33431                    return false;
33432                }
33433
33434                let hh = '23', mm = '59';
33435                if (!isAllDay) {
33436                    const mna   = $timeChecked.closest('.time-interval').data('time');
33437                    const hmRaw = convertTime24(mna, $timeChecked.val());
33438                    ({ hh, mm } = splitHHmm(hmRaw));
33439                }
33440
33441                const dateDash        = selectedDate.replace(/\./g, '-');
33442                const saleDateTimeVal = `${dateDash} ${hh}:${mm}:00`;
33443                const saleDateTimeUI  = `${dateDash} ${hh}:${mm}`;
33444
33445                const startHidden = $('#sale-start-datetime').val();
33446                if (startHidden) {
33447                    const startDT = new Date(startHidden.replace(/-/g,'/'));
33448                    const endDT   = new Date(saleDateTimeVal.replace(/-/g,'/'));
33449                    if (startDT >= endDT) {
33450                        alert('시작 시간보다 나중 날짜' + (isAllDay ? '' : '/시간') + '을 선택해 주세요.');
33451                        return false;
33452                    }
33453                }
33454
33455                if (isAllDay) {
33456                    $('.sale-setting .setting-text .content-end').text(selectedDate);
33457                } else {
33458                    $('.sale-setting .setting-text .content-end').text(selectedDate + '. ' + convertTime12(hh + mm));
33459                }
33460                $('#sale-end-datetime').val(saleDateTimeVal);
33461
33462                (function setEndInput(){
33463                    const $scope = (typeof selectEL !== 'undefined') ? $('.' + el) : $('.calendar-modal-container');
33464                    const saleDateUI = isAllDay ? dateDash : `${dateDash} ${hh}:${mm}`;
33465                    $scope.find('.edate .end').val(saleDateUI);
33466                })();
33467                break;
33468            }
33469        }
33470
33471        // saveFormElement();
33472        settingModal.modal('hide');
33473    }, $.lang[locale]['config.cancel'], $.lang[locale]['config.ok'], modal_class, true, function() { //close
33474        
33475        settingModal.modal('hide');
33476    }, function() { //show
33477
33478        if (startDate && endDate) {
33479            var checkStartDate = startDate.split('.');
33480            var checkEndDate = endDate.split('.');
33481
33482            $('.term-setting').removeClass('hide');
33483            if (locale == 'ko') {
33484                $('.term-setting .start-date').text(checkStartDate[0] + '년 ' + checkStartDate[1] + '월 ' + checkStartDate[2] + ' 일');
33485                $('.term-setting .end-date').text(checkEndDate[0] + '년 ' + checkEndDate[1] + '월 ' + checkEndDate[2] + ' 일');
33486            } else {
33487                $('.term-setting .start-date').text(checkStartDate[1] + '/' + checkStartDate[2] + '/' + checkStartDate[0]);
33488                $('.term-setting .end-date').text(checkEndDate[1] + '/' + checkEndDate[2] + '/' + checkEndDate[0]);
33489            }
33490        }
33491
33492        $('#term-datepicker').html('');
33493        var currentYear = new Date().getFullYear();
33494        switch (func) {
33495            case 'saleStartDateTime':
33496            case 'saleEndDateTime': {
33497                var saleStartDateTime =
33498                    ($('.' + el).find('.calendar-modal-container .sdate .start').val() || '').trim() ||
33499                    ($('#sale-start-datetime').val() || '').trim();
33500                var saleEndDateTime =
33501                    ($('.' + el).find('.calendar-modal-container .edate .end').val() || '').trim() ||
33502                    ($('#sale-end-datetime').val() || '').trim();
33503
33504                function splitDateTime(str) {
33505                    if (!str) return { date: '', time: '' };
33506                    var date = str.slice(0, 10);
33507                    var time = (str.length >= 16) ? str.slice(11, 16) : '';
33508                    return { date: date, time: time };
33509                }
33510                var s = splitDateTime(saleStartDateTime);
33511                var e = splitDateTime(saleEndDateTime);
33512                var selStartDate = s.date;
33513                var selEndDate   = e.date;
33514                var selStartTime = s.time;
33515                var selEndTime   = e.time;
33516
33517                function toDateOnly(ymd) {
33518                    if (!ymd) return null;
33519                    var y = +ymd.slice(0, 4), m = +ymd.slice(5, 7) - 1, d = +ymd.slice(8, 10);
33520                    return new Date(y, m, d, 0, 0, 0, 0);
33521                }
33522                var selStartDateOnly = toDateOnly(selStartDate);
33523                var selEndDateOnly   = toDateOnly(selEndDate);
33524
33525                const MIN_DATE = new Date(1900, 0, 1);
33526                const MAX_DATE = new Date(currentYear + 15, 11, 31);
33527
33528                var datepickkObj = {
33529                    container: document.querySelector('#sale-datepicker'),
33530                    inline: true,
33531                    range: false,
33532                    exp: false,
33533                    lang: language,
33534                    startDate: new Date(),
33535                    minDate: MIN_DATE,
33536                    maxDate: MAX_DATE
33537                };
33538
33539                if (func == 'saleStartDateTime') {
33540                    $('.time-interval input').prop('disabled', false).removeAttr('disabled');
33541                    datepickkObj.minDate   = MIN_DATE;
33542                    datepickkObj.maxDate   = MAX_DATE;
33543                    if (selStartDateOnly) datepickkObj.startDate = selStartDateOnly;
33544
33545                    if (selStartDate) $('#select-date-ymd').val(selStartDate.replace(/-/g, '.'));
33546                    // else $('.setting-sale-date').addClass('open');
33547                    $('.setting-sale-date').addClass('open');
33548
33549                } else { // saleEndDateTime
33550                    datepickkObj.minDate   = selStartDateOnly || MIN_DATE;
33551                    datepickkObj.startDate = selEndDateOnly || selStartDateOnly || new Date();
33552
33553                    if (selEndDate) {
33554                        $('#select-date-ymd').val(selEndDate.replace(/-/g, '.'));
33555                    } else if (selStartDate) {
33556                        $('#select-date-ymd').val(selStartDate.replace(/-/g, '.'));
33557                    } else {
33558                        var today = new Date();
33559                        var y = today.getFullYear(), m = String(today.getMonth()+1).padStart(2,'0'), d = String(today.getDate()).padStart(2,'0');
33560                        $('#select-date-ymd').val(`${y}.${m}.${d}`);
33561                        // $('.setting-sale-date').addClass('open');
33562                    }
33563                    $('.setting-sale-date').addClass('open');
33564                }
33565
33566                var termPicker = new Datepickk(datepickkObj);
33567
33568                if (isAllDay) {
33569                    $('.setting-sale-time').hide();
33570                } else {
33571                    $('.setting-sale-time').show();
33572                }
33573                if (func === 'saleEndDateTime' && !isAllDay) {
33574                    const $endScope = $('.sale-calendar-box.setting-sale-date .setting-datetime-input[data-type="saleEndDateTime"]').closest('.modal-dialog');
33575
33576                    function minutesFromInput($input) {
33577                        var v = String($input.val() || '').padStart(4,'0');
33578                        var h = parseInt(v.slice(0,2), 10);
33579                        var m = parseInt(v.slice(2,4), 10);
33580                        var period = $input.closest('.time-interval').data('time');
33581                        if (period === 'am') {
33582                            if (h === 12) h = 0;
33583                        } else {
33584                            if (h !== 12) h += 12;
33585                        }
33586                        return (h * 60) + m;
33587                    }
33588
33589                    function minutesFromStart(str) {
33590                        if (!str) return null;
33591                        var hh = parseInt(str.slice(11,13), 10);
33592                        var mm = parseInt(str.slice(14,16), 10);
33593                        if (isNaN(hh) || isNaN(mm)) return null;
33594                        return hh*60 + mm;
33595                    }
33596
33597                    function refreshEndTimeDisables() {
33598                        const $inputs = $endScope.find('.time-interval input');
33599
33600                        $inputs.prop('disabled', false).removeAttr('disabled');
33601
33602                        const selectedDot = ($('#select-date-ymd').val() || '').trim();
33603                        const $scope = (typeof selectEL !== 'undefined') ? $('.' + el) : $('.calendar-modal-container');
33604                        const startInput  = ($scope.find('.sdate .start').val() || '').trim();
33605                        const startHidden = ($('#sale-start-datetime').val() || '').trim();
33606                        const startStr    = startInput || startHidden;
33607
33608                        if (!selectedDot || !startStr) return;
33609
33610                        const endYmd   = selectedDot.replace(/\./g, '-').slice(0, 10);
33611                        const startYmd = startStr.slice(0, 10);
33612                        if (endYmd !== startYmd) return;
33613
33614                        const startMin = minutesFromStart(startStr);
33615                        if (startMin == null) return;
33616
33617                        $inputs.each(function(){
33618                            const $it = $(this);
33619                            const m = minutesFromInput($it);
33620                            if (m < startMin) $it.prop('disabled', true).attr('disabled','disabled');
33621                        });
33622
33623                        const $checked = $endScope.find('.time-interval input:checked');
33624                        if ($checked.length && $checked.is(':disabled')) {
33625                            $checked.prop('checked', false);
33626                            $('.sale-calendar-box .end-time').html('');
33627                        }
33628                    }
33629
33630                    window.__refreshEndTimeDisables = refreshEndTimeDisables;
33631
33632                    if (termPicker && typeof termPicker.onSelect !== 'undefined') {
33633                        const prev = termPicker.onSelect;
33634                        termPicker.onSelect = function(date){
33635                            if (typeof prev === 'function') prev.call(this, date);
33636                            if (date instanceof Date && !isNaN(date.getTime())) {
33637                                const y = date.getFullYear(), m = String(date.getMonth()+1).padStart(2,'0'), d = String(date.getDate()).padStart(2,'0');
33638                                $('#select-date-ymd').val(`${y}.${m}.${d}`);
33639                            }
33640                            refreshEndTimeDisables();
33641                        };
33642                    } else {
33643                        $('#sale-datepicker').off('click.updateEndTime')
33644                          .on('click.updateEndTime', '.d-day', function(){ setTimeout(refreshEndTimeDisables, 0); });
33645                    }
33646                }
33647
33648                if (typeof displaySelectedDates === 'function') displaySelectedDates();
33649
33650                $('.time-interval').each(function(i, v) {
33651                    var mna = $(v).data('time');
33652                    var times = '\
33653                        <input type="radio" id="' + mna + '-12-00" class="hide" name="sale_time" value="1200">\
33654                        <label for="' + mna + '-12-00">12:00</label>\
33655                        <input type="radio" id="' + mna + '-12-30" class="half-time hide" name="sale_time" value="1230">\
33656                        <label for="' + mna + '-12-30" class="half-time">12:30</label>\
33657                        \
33658                        <input type="radio" id="' + mna + '-1-00" class="hide" name="sale_time" value="
336580100">\
33659                        <label for="' + mna + '-1-00">1:00</label>\
33660                        <input type="radio" id="' + mna + '-1-30" class="half-time hide" name="sale_time" value="0130">\
33661                        <label for="' + mna + '-1-30" class="half-time">1:30</label>\
33662                        \
33663                        <input type="radio" id="' + mna + '-2-00" class="hide" name="sale_time" value="0200">\
33664                        <label for="' + mna + '-2-00">2:00</label>\
33665                        <input type="radio" id="' + mna + '-2-30" class="half-time hide" name="sale_time" value="0230">\
33666                        <label for="' + mna + '-2-30" class="half-time">2:30</label>\
33667                        \
33668                        <input type="radio" id="' + mna + '-3-00" class="hide" name="sale_time" value="0300">\
33669                        <label for="' + mna + '-3-00">3:00</label>\
33670                        <input type="radio" id="' + mna + '-3-30" class="half-time hide" name="sale_time" value="0330">\
33671                        <label for="' + mna + '-3-30" class="half-time">3:30</label>\
33672                        \
33673                        <input type="radio" id="' + mna + '-4-00" class="hide" name="sale_time" value="
336730400">\
33674                        <label for="' + mna + '-4-00">4:00</label>\
33675                        <input type="radio" id="' + mna + '-4-30" class="half-time hide" name="sale_time" value="0430">\
33676                        <label for="' + mna + '-4-30" class="half-time">4:30</label>\
33677                        \
33678                        <input type="radio" id="' + mna + '-5-00" class="hide" name="sale_time" value="0500">\
33679                        <label for="' + mna + '-5-00">5:00</label>\
33680                        <input type="radio" id="' + mna + '-5-30" class="half-time hide" name="sale_time" value="0530">\
33681                        <label for="' + mna + '-5-30" class="half-time">5:30</label>\
33682                        \
33683                        <input type="radio" id="' + mna + '-6-00" class="hide" name="sale_time" value="0600">\
33684                        <label for="' + mna + '-6-00">6:00</label>\
33685                        <input type="radio" id="' + mna + '-6-30" class="half-time hide" name="sale_time" value="0630">\
33686                        <label for="' + mna + '-6-30" class="half-time">6:30</label>\
33687                        \
33688                        <input type="radio" id="' + mna + '-7-00" class="hide" name="sale_time" value="
336880700">\
33689                        <label for="' + mna + '-7-00">7:00</label>\
33690                        <input type="radio" id="' + mna + '-7-30" class="half-time hide" name="sale_time" value="0730">\
33691                        <label for="' + mna + '-7-30" class="half-time">7:30</label>\
33692                        \
33693                        <input type="radio" id="' + mna + '-8-00" class="hide" name="sale_time" value="0800">\
33694                        <label for="' + mna + '-8-00">8:00</label>\
33695                        <input type="radio" id="' + mna + '-8-30" class="half-time hide" name="sale_time" value="0830">\
33696                        <label for="' + mna + '-8-30" class="half-time">8:30</label>\
33697                        \
33698                        <input type="radio" id="' + mna + '-9-00" class="hide" name="sale_time" value="0900">\
33699                        <label for="' + mna + '-9-00">9:00</label>\
33700                        <input type="radio" id="' + mna + '-9-30" class="half-time hide" name="sale_time" value="0930">\
33701                        <label for="' + mna + '-9-30" class="half-time">9:30</label>\
33702                        \
33703                        <input type="radio" id="' + mna + '-10-00" class="hide" name="sale_time" value="1000">\
33704                        <label for="' + mna + '-10-00">10:00</label>\
33705                        <input type="radio" id="' + mna + '-10-30" class="half-time hide" name="sale_time" value="1030">\
33706                        <label for="' + mna + '-10-30" class="half-time">10:30</label>\
33707                        \
33708                        <input type="radio" id="' + mna + '-11-00" class="hide" name="sale_time" value="1100">\
33709                        <label for="' + mna + '-11-00">11:00</label>\
33710                        <input type="radio" id="' + mna + '-11-30" class="half-time hide" name="sale_time" value="1130">\
33711                        <label for="' + mna + '-11-30" class="half-time">11:30</label>\
33712                    ';
33713                    $(v).html(times);
33714                });
33715
33716                if (func === 'saleEndDateTime' && typeof window.__refreshEndTimeDisables === 'function') {
33717                    window.__refreshEndTimeDisables();
33718                }
33719
33720                $('input[name="time_interval"][value="' + interval + '"]').prop('checked', true);
33721
33722                if (func == 'saleStartDateTime' && selStartDate && selStartTime) {
33723                    var hour = parseInt(selStartTime.split(':')[0], 10);
33724                    var minute = parseInt(selStartTime.split(':')[1], 10);
33725                    var mna = 'am';
33726                    if (hour >= 12) { if (hour > 12) hour -= 12; mna = 'pm'; }
33727                    else if (hour === 0) { hour = 12; }
33728                    var formattedTime = String(hour).padStart(2, '0') + String(minute).padStart(2, '0');
33729                    $('.time-interval[data-time="' + mna + '"] input[value="' + formattedTime + '"]').prop('checked', true);
33730                    if (typeof getDateTimeStr === 'function') getDateTimeStr(language, '', locale);
33731                }
33732
33733                var time_interval = $('input[name="time_interval"]:checked').val();
33734                if (typeof dateTimeModal !== 'undefined' && dateTimeModal && dateTimeModal.find) {
33735                    switch (time_interval) {
33736                        case 10: dateTimeModal.find('.time-interval label.ten-time').removeClass('hide'); break;
33737                        case 20: dateTimeModal.find('.time-interval label.twt-time').removeClass('hide'); break;
33738                        case 30: dateTimeModal.find('.time-interval label.half-time').removeClass('hide'); break;
33739                        case 60: dateTimeModal.find('.time-interval label').removeClass('hide'); break;
33740                    }
33741                }
33742
33743                $('input[name="time_interval"]').on('change', function() {
33744                    if ($(this).val() == 60) {
33745                        $('.time-interval label.half-time').addClass('hide');
33746                        if ($('#all-time-select').is(':checked')) {
33747                            $('.time-interval input.o-time').prop('checked', true);
33748                        }
33749                    } else {
33750                        $('.time-interval label.half-time').removeClass('hide');
33751                        if ($('#all-time-select').is(':checked')) {
33752                            $('.time-interval input').prop('checked', true);
33753                        }
33754                    }
33755                    if (func === 'saleEndDateTime' && typeof window.__refreshEndTimeDisables === 'function') {
33756                        setTimeout(window.__refreshEndTimeDisables, 0);
33757                    }
33758                });
33759
33760                $('.time-interval input').on('change', function(){
33761                    if (typeof getDateTimeStr === 'function') getDateTimeStr(language, 'time', locale);
33762                    if (func === 'saleEndDateTime' && typeof window.__refreshEndTimeDisables === 'function') {
33763                        setTimeout(window.__refreshEndTimeDisables, 0);
33764                    }
33765                });
33766
33767                $('.sale-calendar-box .setting-label').on('click', function(){
33768                    var $saleCalendarBox = $(this).closest('.sale-calendar-box');
33769                    if($saleCalendarBox.hasClass('open')) {
33770                        $('.sale-calendar-box .setting-datetime-input').slideUp(400, function(){
33771                            $('.sale-calendar-box').removeClass('open');
33772                        });
33773                    } else{
33774                        $('.sale-calendar-box .setting-datetime-input').slideUp(400, function(){
33775                            $('.sale-calendar-box').removeClass('open');
33776                        });
33777                        $saleCalendarBox.find('.setting-datetime-input').slideDown(400, function(){
33778                            $saleCalendarBox.addClass('open');
33779                        });
33780                    }
33781                });
33782
33783                break;
33784            }
33785        }
33786
33787        $(document).off('click', '.d-year, .d-month');
33788        $(document).on('click', '.d-year, .d-month', function() {
33789            $('.d-month-year-picker').toggleClass('d-show');
33790            scrollToCurrentYearMonth();
33791        });
33792
33793        function timeSelect(label, action) {
33794            if(typeof action == 'undefined') action = '';
33795            let interval = $('input[name=time_interval]:checked').val();
33796            let chk = $("#" + $(label).attr('for'));
33797            let t = chk.prevAll('input.ten-time');
33798
33799            if(action == 'click') {
33800                if(chk.is(':checked')) {
33801                    label.addClass('ui-selected');
33802                } else {
33803                    label.removeClass('ui-selected');
33804                }
33805            } else {
33806                if(chk.is(':checked')) {
33807                    chk.prop("checked", false);
33808                } else {
33809                    chk.prop("checked", true);
33810                }
33811            }
33812            
33813            switch (interval) {
33814                case '20':
33815                    if(chk.is(':checked') && $(t[0]).prevAll('input.o-time, input.twt-time').first().is(':checked')) {
33816                        $(t[0]).prop('checked', true);
33817                        if(action == 'click') $(t[0]).next('label').addClass('ui-selected');
33818                    } else {
33819                        $(t[0]).prop('checked', false);
33820                        if(action == 'click') $(t[0]).next('label').removeClass('ui-selected');
33821                    }
33822                    break;
33823                case '30':
33824                    if(chk.is(':checked') && $(t[0]).prevAll('input.o-time, input.half-time').first().is(':checked')) {
33825                        $(t[0]).prop('checked', true);
33826                        $(t[1]).prop('checked', true);
33827                        if(action == 'click') {
33828                            $(t[0]).next('label').addClass('ui-selected');
33829                            $(t[1]).next('label').addClass('ui-selected');
33830                        }
33831                    } else {
33832                        $(t[0]).prop('checked', false);
33833                        $(t[1]).prop('checked', false);
33834                        if(action == 'click') {
33835                            $(t[0]).next('label').removeClass('ui-selected');
33836                            $(t[1]).next('label').removeClass('ui-selected');
33837                        }                        
33838                    }
33839
33840                    break;
33841                case '60':
33842                    if(chk.is(':checked') && $(t[0]).prevAll('input.o-time').first().is(':checked')) {
33843                        $(t[0]).prop('checked', true);
33844                        $(t[1]).prop('checked', true);
33845                        $(t[2]).prop('checked', true);
33846                        $(t[3]).prop('checked', true);
33847                        $(t[4]).prop('checked', true);
33848                        if(action == 'click') {
33849                            $(t[0]).next('label').addClass('ui-selected');
33850                            $(t[1]).next('label').addClass('ui-selected');
33851                            $(t[2]).next('label').addClass('ui-selected');
33852                            $(t[3]).next('label').addClass('ui-selected');
33853                            $(t[4]).next('label').addClass('ui-selected');
33854                        }                        
33855                    } else {
33856                        $(t[0]).prop('checked', false);
33857                        $(t[1]).prop('checked', false);
33858                        $(t[2]).prop('checked', false);
33859                        $(t[3]).prop('checked', false);
33860                        $(t[4]).prop('checked', false);
33861                        if(action == 'click') {
33862                            $(t[0]).next('label').removeClass('ui-selected');
33863                            $(t[1]).next('label').removeClass('ui-selected');
33864                            $(t[2]).next('label').removeClass('ui-selected');
33865                            $(t[3]).next('label').removeClass('ui-selected');
33866                            $(t[4]).next('label').removeClass('ui-selected');
33867                        }                                                
33868                    }
33869                    
33870                    break;
33871            }
33872        }
33873
33874        function isSelectedAllTimes() {
33875            let interval = $('input[name=time_interval]:checked').val();
33876            let am = $('.time-interval[data-time="am"] label:not(.hide)').prev('input[type="checkbox"]:checked');
33877            let pm = $('.time-interval[data-time="pm"] label:not(.hide)').prev('input[type="checkbox"]:checked');
33878            let timeCnt = am.length + pm.length;
33879            let allTimeChecked = '';
33880            if (interval == '10' && timeCnt == 144) allTimeChecked = 'checked';
33881            if (interval == '20' && timeCnt == 72) allTimeChecked = 'checked';
33882            if (interval == '30' && timeCnt == 48) allTimeChecked = 'checked';
33883            if (interval == '60' && timeCnt == 24) allTimeChecked = 'checked';
33884
33885            if(allTimeChecked) {
33886                $('#all-time-select').prop('checked', true);
33887            } else {
33888                $('#all-time-select').prop('checked', false);
33889            }
33890        }
33891    }, function() { //hide
33892        
33893        settingModal.modal('hide');
33894    });
33895}
33896
33897function convertTime24(mna, timeString) {
33898    var hour = parseInt(timeString.substring(0, 2));
33899    var minute = timeString.substring(2);
33900    // console.log(timeString, minute);
33901    if (mna == 'am' && hour == 12) {
33902        hour -= 12;
33903    }
33904    if (mna == 'pm' && hour !== 12) {
33905        hour += 12;
33906    }
33907
33908    var formattedHour = hour.toString().padStart(2, '0');
33909
33910    return formattedHour + ':' + minute;
33911}
33912
33913function convertTime12(timeString) {
33914    var hour = parseInt(timeString.split(':')[0]);
33915    var minute = parseInt(timeString.split(':')[1]);
33916    var mna = 'am';
33917    if(hour >= 12) {
33918        if (hour > 12) hour -= 12;
33919        mna = 'pm';   
33920    } else if (hour == 0) hour += 12;
33921    var formattedTime = $.lang[LANG]['config.form.date2.time.' + mna] + ' ' + hour.toString().padStart(2, '0') + ':' +  minute.toString().padStart(2, '0');
33922
33923    return formattedTime;
33924}
33925
33926function convertDateObjToStr(dateObj) {
33927    var year = dateObj.getFullYear();
33928    var month = ("0" + (dateObj.getMonth() + 1)).slice(-2);
33929    var day = ("0" + dateObj.getDate()).slice(-2);
33930    var hours = ("0" + dateObj.getHours()).slice(-2);
33931    var minutes = ("0" + dateObj.getMinutes()).slice(-2);
33932    var seconds = ("0" + dateObj.getSeconds()).slice(-2);
33933    var formattedDate = year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds;
33934    return formattedDate;
33935}
33936
33937var changeStatus = function(status,seq) {
33938    if(status == 'lim') return '';
33939    var s = '\
33940    <span class="status-change"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-caret-down-fill" viewBox="0 0 16 16"><path d="M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z"/></svg></span>\
33941    <ul class="table-item-status" data-seq="' + seq + '">\
33942        <li class="' + ((status == 'on') ? 'active' : '') + '" data-val="on">판매중</li>\
33943        <li class="' + ((status == 'off' || status == '') ? 'active' : '') + '" data-val="off">판매중지</li>\
33944    </ul>\
33945    ';
33946    return s;
33947}
33948
33949var normalizeModalMenuLinkPage = function(value) {
33950    if (typeof normalizeMenuLinkPage == 'function') return normalizeMenuLinkPage(value);
33951    value = $.trim(String(value || ''));
33952    try {
33953        value = decodeURIComponent(value);
33954    } catch(e) {}
33955    value = value.replace(/^\/+/g, '');
33956    if (value.indexOf('#') === 0) value = value.replace(/^#+/g, '');
33957    else if (value.indexOf('#') > -1 && !/^https?:\/\//i.test(value)) value = value.split('#').pop();
33958    value = value.split('?')[0].split(',')[0];
33959    return value
33960        .replace(/ /g, '-')
33961        .replace(/\//g, '/')
33962        .replace(/&/g, '&')
33963        .replace(/\./g, '.')
33964        .replace(/\+/g, '+')
33965        .replace(/\(/g, '(')
33966        .replace(/\)/g, ')');
33967};
33968
33969var isModalMenuPageLink = function(value, list) {
33970    list = list || ((typeof MENULIST != 'undefined') ? MENULIST : []);
33971    return $.inArray(normalizeModalMenuLinkPage(value), list) > -1;
33972};
33973
33974var makeLinkUrl = function(link, one, view) {
33975    var link_url = '';
33976    var link_val = '';
33977    var link_page = normalizeModalMenuLinkPage(link);
33978    var is_menu = ($.inArray(link_page, MENULIST) > -1) ? true : false;
33979    var regex = /^(((http(s?))\:\/\/)?)([0-9a-zA-Z\-]+\.)+[a-zA-Z]{2,7}(\:[0-9]+)?(\/\S[^\{\}]*)?$/;
33980    var regex2 = /^((http(s?))\:\/\/)([0-9a-zA-Z\-]+\.)+[a-zA-Z]{2,7}(\:[0-9]+)?(\/\S[^\{\}]*)?$/;
33981
33982    if (one) {
33983        link_url = (view) ? '/' + CONFIG_URL + 'config/page/view/index#' : '#';
33984        if (is_menu) link_url = '/';
33985    } else {
33986        link_url = (is_menu) ? '/' : '/' + CONFIG_URL + 'config/page/';
33987    }
33988
33989    if (link) {
33990        if (link.match(/^\@/g) !== null) { // link-type: link-bookmark ==> a[attr-bookmark]
33991            var bookmark_seq = link.replace(/^\@/g, '');
33992            if (typeof SETTINGS.blockBookmarkList == 'undefined' || typeof SETTINGS.blockBookmarkList['bookmark' + bookmark_seq] == 'undefined') {
33993                return '';
33994            }
33995        } else if (link.match(/^flink\@[0-9]/gi) !== null) { // link-type: link-file     ==> a[attr-flink]
33996            return link;
33997        } else if ($.inArray(link_page, MENULIST) > -1) { // link-type: link-menu     ==> a[data-user-link]
33998            link_val = link_url + link_page;
33999        } else { // link-type: link-out      ==> a[attr-link]
34000            if(checkBase64Encode(decodeURIComponent(link))) link = Base64.decode(decodeURIComponent(link));
34001            else if (checkBase64Encode(link)) link = Base64.decode(link);
34002
34003            if(!regex2.test(link) && regex.test(link)) link_val = '//' + link;
34004        }
34005
34006        if(link_val == '') link_val = link;
34007    }
34008    return link_val;
34009}
34010
34011var getModalMenuUid = function(obj) {
34012    if (!obj) return '';
34013    return $.trim(String(obj.menu_uid || '')).replace(/[^A-Za-z0-9_-]/g, '').substr(0, 64);
34014};
34015
34016var makeLinkList = function(e, type, id, prev_link, add_arr, prev_link_id) {
34017    // type: editor -  id : text, button, image
34018    var valid_plan = (typeof VALIDPLAN == 'undefined') ? $.gallery.valid_plan : VALIDPLAN;
34019    var valid_type = (typeof VALIDTYPE == 'undefined') ? $.gallery.valid_type : VALIDTYPE;
34020
34021    var link_content = ((type == 'gallery')) ? '' : '<ul class="link-content edit-link-Content" data-type="' + type + '" data-name="' + id + '">';
34022    var link_icon = { 'menu': 'active', 'bookmark': 'active', 'flink': (valid_plan && valid_type != 'PK') ? 'active' : 'inactive', 'imagePopup': (valid_plan && valid_type != 'PK') ? 'active' : 'inactive' };
34023    var link_disabled = { 'submenu': '', 'bookmark': '', 'flink': (valid_plan && valid_type != 'PK') ? '' : 'disabled', 'imagePopup': (valid_plan && valid_type != 'PK') ? '' : 'disabled' };
34024    var isDefault = '';
34025    var isOut = '';
34026    var isFolder = '';
34027    var isInner = '';
34028    var isBookmark = '';
34029    var isFlink = '';
34030    var isTel_link = '';
34031    var isSms_link = '';
34032    var isPopup = '';
34033    var out_link = '';
34034    var flink_link = {};
34035    var popup_link = {};
34036    prev_link = (typeof prev_link != 'undefined' && prev_link !== null) ? String(prev_link) : '';
34037    prev_link_id = (typeof prev_link_id != 'undefined' && prev_link_id !== null) ? String(prev_link_id) : '';
34038    var org_prev_link = (prev_link) ? prev_link : '';
34039    var add_arr = (typeof add_arr!='undefined') ? add_arr : [];
34040    var check_tel = ($.inArray('tel', add_arr) > -1) ? true : false;
34041    var check_sms = ($.inArray('sms', add_arr) > -1) ? true : false;
34042    var telsms_link = '';
34043    var normalizeMenuLinkValue = normalizeModalMenuLinkPage;
34044    var site_smenu = (typeof e != 'undefined' && e) ? e : ((typeof SMENU == 'undefined') ? $.gallery.SMENU : SMENU);
34045    var findMenuByLinkId = function(menu, link_id) {
34046        var found = null;
34047        if (!link_id) return found;
34048
34049        $.each(menu || [], function(idx, obj) {
34050            if (String(getModalMenuUid(obj)) == link_id) {
34051                found = obj;
34052                return false;
34053            }
34054
34055            if (obj.children && obj.children.length > 0) {
34056                found = findMenuByLinkId(obj.children, link_id);
34057                if (found) return false;
34058            }
34059        });
34060
34061        return found;
34062    };
34063    var active_link_id = (findMenuByLinkId(site_smenu, prev_link_id)) ? prev_link_id : '';
34064
34065    if (prev_link.match(/^\@/g) !== null) {
34066        isBookmark = 'active';
34067    } else if (prev_link.match(/^flink\@[0-9]/gi) !== null) {
34068        if (valid_plan) {
34069            $.getJSON('/down/flink/get/id/' + prev_link.replace(/^flink\@/gi, ''), {}, function(data) {
34070                checkError(data);
34071
34072                if (typeof data.data == 'object' && !$.isEmptyObject(data.data)) {
34073                    isFlink = 'active';
34074                    flink_link = data.data;
34075                } else {
34076                    prev_link = '';
34077                }
34078            }, 'json');
34079        } else {
34080            prev_link = '';
34081        }
34082    } else if (prev_link.indexOf('googleusercontent') !== -1 || prev_link.indexOf('storage.googleapis.com/cr-resource/image') !== -1){
34083        isPopup = (valid_plan)? 'active':'';
34084    } else if((check_tel || check_sms) && (prev_link.indexOf('tel')>-1 || prev_link.indexOf('sms')>-1)) {
34085        isTel_link = (prev_link.indexOf('tel') > -1 ) ? 'active' : isTel_link;
34086        isSms_link = (prev_link.indexOf('sms') > -1 ) ? 'active' : isSms_link;
34087        telsms_link = prev_link;
34088    } else {
34089        if (type == 'menu') {
34090            if (!active_link_id && prev_link == id) { isDefault = 'active'; } else if (active_link_id || isModalMenuPageLink(prev_link)) { isInner = 'active'; } else if (prev_link == 'folder-menu') { isFolder = 'active'; } else {
34091                isOut = 'active';
34092                if(checkBase64Encode(decodeURIComponent(prev_link))) out_link = Base64.decode(decodeURIComponent(prev_link));
34093                else out_link = decodeURI(prev_link.replace(/%27/g, '&#39;')).replace(/\"/g, '&#34;');
34094            }
34095        }
34096
34097        if ($.inArray(type, ['image', 'gallery', 'popup', 'popupbanner', 'bandbanner', 'quickmenu','fnav', 'showcase', 'editor']) > -1) {
34098            var check_menu_str = (type == 'editor') ? prev_link.replace(/^\//g, '') 
34098: prev_link;
34099            if (!active_link_id && prev_link == '') {
34100                if (type == 'fnav' || (type == 'editor' && id == 'text')) { 
34101                    isOut = 'active'; 
34102                } else { 
34103                    isDefault = 'active'; 
34104                }
34105            } else if (active_link_id || isModalMenuPageLink(check_menu_str)) {
34106                isInner = 'active'; 
34107            } else {
34108                isOut = 'active';
34109                if(checkBase64Encode(decodeURIComponent(prev_link))) out_link = Base64.decode(decodeURIComponent(prev_link));
34110                else out_link = decodeURI(prev_link.replace(/%27/g, '&#39;')).replace(/\"/g, '&#34;');
34111            }
34112        }
34113    }
34114    var one = (typeof ONE == 'undefined') ? $.gallery.one : ONE;
34115    var temp = (type == 'menu') ? 'editor.link.inner.select.menu' : (one) ? 'editor.link.inner.select.page.1' : 'editor.link.inner.select.page.0';
34116    var escapeLinkSelectHtml = (typeof escapeMenuDisplayHtml == 'function') ? escapeMenuDisplayHtml : function(value) {
34117        return String(value == null ? '' : value)
34118            .replace(/&/g, '&amp;')
34119            .replace(/</g, '&lt;')
34120            .replace(/>/g, '&gt;');
34121    };
34122    var select_menu_str = (isInner) ? prev_link : $.lang[LANG][temp];
34123    var select_menu_html = escapeLinkSelectHtml(select_menu_str);
34124    var select_menu_selected = '';
34125
34126	    var menulist_val = makeMenuLinkList(site_smenu, type, id, prev_link, active_link_id);
34127	    var active_menu_link_id = '';
34128	    var active_menu_page = '';
34129	    if (isInner) {
34130	        var $active_menu = $('<ul>' + menulist_val + '</ul>').find('li.active');
34131	        var active_menu_title = $active_menu.attr('data-userlink-title');
34132	        if (active_menu_title) {
34133	            select_menu_str = active_menu_title;
34134	            select_menu_html = (typeof getMenuDisplayPathHtmlFromData == 'function') ? getMenuDisplayPathHtmlFromData($active_menu.attr('data-userlink-path'), active_menu_title) : escapeLinkSelectHtml(active_menu_title);
34135	        }
34136	        active_menu_link_id = $active_menu.attr('data-link-id') || '';
34137	        active_menu_page = $active_menu.attr('data-userlink') || '';
34138	    }
34139	    var isList = true;
34140    if (menulist_val.length == 0) {
34141        select_menu_str = $.lang[LANG]['editor.link.inner.empty'];
34142        select_menu_html = escapeLinkSelectHtml(select_menu_str);
34143        isList = false;
34144        link_disabled['submenu'] = 'disabled';
34145        if (type == 'menu') {
34146            isInner = (isInner == 'active') ? '' : isInner;
34147            isFolder = (isFolder == 'active') ? '' : isFolder;
34148            link_icon['menu'] = 'inactive';
34149        }
34150    }
34151
34152    var isBookmarkList = true;
34153    var select_bookmark_str = $.lang[LANG]['editor.link.bookmark.select'];
34154    var select_bookmark_selected = '';
34155    var bookmarklist_val = makeBookmarkList(SETTINGS.blockBookmarkList, type, id, org_prev_link);
34156
34157    var blockBookmarkList = (typeof SETTINGS.blockBookmarkList != 'undefined' && SETTINGS.blockBookmarkList) ? SETTINGS.blockBookmarkList : {};
34158    var hideArray = blockBookmarkList?.hide || [];
34159    var bookmark_orgprev_link = org_prev_link.replace('@', '');
34160
34161    if (bookmarklist_val.length == 0) {
34162        if (isBookmark == 'active') {
34163            isBookmark = '';
34164            isDefault = 'active';
34165            select_menu_str = $.lang[LANG][temp];
34166            select_menu_html = escapeLinkSelectHtml(select_menu_str);
34167        }
34168        isBookmarkList = false;
34169        link_disabled['bookmark'] = 'disabled';
34170        link_icon['bookmark'] = 'inactive';
34171        select_bookmark_str = $.lang[LANG]['editor.link.bookmark.empty'];
34172    } else {
34173        if (typeof SETTINGS.blockBookmarkList[org_prev_link.replace(/^\@/g, 'bookmark')] != 'undefined' && SETTINGS.blockBookmarkList[org_prev_link.replace(/^\@/g, 'bookmark')]) {
34174            select_bookmark_str = SETTINGS.blockBookmarkList['bookmark' + org_prev_link.replace(/^\@/g, '')];
34175            select_bookmark_selected = ' data-link-seq="' + org_prev_link.replace(/^\@/g, '') + '"';
34176        } else {
34177            if (isBookmark == 'active') {
34178                isBookmark = '';
34179                isDefault = 'active';
34180                prev_link = $.lang[LANG][temp];
34181                select_menu_html = escapeLinkSelectHtml(select_menu_str);
34182            }
34183        }
34184    }
34185
34186    if (hideArray.length > 0) {
34187        if (hideArray.includes(bookmark_orgprev_link)) {
34188            isBookmark = '';
34189            isDefault = 'active';
34190        }
34191    }
34192
34193    // if($('.' + selectEL).attr('data-img-parallax') == 'true') {
34194    //     link_disabled['imagePopup'] = 'disabled';
34195    //     link_icon['imagePopup'] = 'inactive';
34196    //     if(isPopup == 'active') {
34197    //         isPopup = '';
34198    //         isDefault = 'active';
34199    //     }
34200    // }
34201
34202    if (type == 'menu') {
34203        if (isDefault == '' && isOut == '' && isInner == '' && isBookmark == '' && isFlink == '' && isFolder == '') { isDefault = 'active'; }
34204    }
34205    if (type == 'showcase') {
34206        if (isDefault == '' && isOut == '' && isInner == '' && isBookmark == '') { isDefault = 'active'; }
34207    }
34208    if ($.inArray(type, ['gallery', 'popup', 'popupbanner', 'bandbanner', 'quickmenu']) > -1) {
34209        if (isDefault == '' && isOut == '' && isInner == '' && isBookmark == '' && isFlink == '' && isTel_link == '' && isSms_link == '') { isDefault = 'active'; }
34210    }
34211    if (type == 'image') {
34212        if (isDefault == '' && isOut == '' && isInner == '' && isBookmark == '' && isFlink == '' && isPopup == '') { isDefault = 'active'; }
34213    }
34214    if (type == 'fnav') {
34215        if (isOut == '' && isInner == '' && isBookmark == '') { isOut = 'active'; }
34216    }
34217    if (type == 'editor') {
34218        if (isOut == '' && isInner == '' && isBookmark == '' && isFlink == '') {
34219            if (id == 'text') { isOut = 'active'; } else if (id == 'button' || id == 'image') { isDefault = 'active'; }
34220        }
34221    }
34222
34223    var link_deafult_text = {
34224        'menu': $.lang[LANG]['editor.link.default'],
34225        'gallery': $.lang[LANG]['editor.link.default'],
34226        'image': $.lang[LANG]['editor.link.default.image'],
34227        'popup': $.lang[LANG]['editor.link.default.popup'],
34228        'popupbanner': $.lang[LANG]['editor.link.default.popupbanner'],
34229        'bandbanner': $.lang[LANG]['editor.link.default.bandbanner'],
34230        'quickmenu': $.lang[LANG]['editor.link.default.quickmenu'],
34231        'showcase': $.lang[LANG]['editor.link.default.showcase'],
34232        'editor': $.lang[LANG]['editor.link.default.editor'],
34233    };
34234
34235    link_content += (type == 'fnav' || (type == 'editor' && id == 'text')) ? '' : '\
34236            <li class="link-type ' + isDefault + '">\
34237                <div class="link-default">\
34238                    ' + clSVG('checkbox_active',20,20,false) + '\
34239                    <h5>' + link_deafult_text[type] + '</h5>\
34240                </div>\
34241            </li>\
34242    ';
34243
34244    link_content += '\
34245            <li class="link-type ' + isOut + '">\
34246                <div class="link-out">\
34247                    ' + clSVG('checkbox_active',20,20,false) + '\
34248                    <h5>' + $.lang[LANG]['editor.link.out'] + '</h5>\
34249                    <div class="cl-common-form-wrap nonplace-holder">\
34250                        <div class="cl-common-form-group">\
34251                            <input type="text" class="link-input" placeholder="' + $.lang[LANG]['editor.link.input.info'] + '" value="' + out_link + '">\
34252                        </div>\
34253                    </div>\
34254                </div>\
34255            </li>\
34256    ';
34257
34258    if (type == 'menu') {
34259        link_content += '\
34260            <li class="link-type ' + isInner + ' ' + link_disabled['submenu'] + '">\
34261                <div class="link-inner">\
34262                    ' + clSVG('checkbox_'+link_icon['menu'],20,20,false) + '\
34263                    <h5>' + $.lang[LANG]['editor.link.inner'] + '</h5>\
34264                    <div class="group-wrap">\
34265                        <div class="input-group">\
34266                            <div class="inner-toggle btn btn-sm dropdown-toggle ' + link_disabled['submenu'] + '" data-toggle="dropdown">\
34267                                <span class="select-link">' + select_menu_html + '</span>';
34268        if (isList) link_content += '<svg viewBox="0 0 8 4" width="8" height="4" class="hand"><polygon points="0 0 4 4 8 0 "/></svg>';
34269        link_content += '\
34270                            </div>\
34271                            <ul class="dropdown-menu link-innerlist" role="menu">\
34272                                ' + menulist_val + '\
34273                            </ul>\
34274                        </div>\
34275                    <div>\
34276                </div>\
34277            </li>\
34278        ';
34279    }
34280
34281    if ($.inArray(type, ['image', 'gallery', 'popup', 'popupbanner', 'bandbanner', 'quickmenu', 'fnav', 'showcase', 'editor']) > -1) {
34282        var lang_text = 'editor.link.inner.menu';
34283        if (isInner && type == 'image' && $('<ul>' + menulist_val + '</ul>').children('li[data-userlink="' + prev_link + '"]').length == 0) {
34284            $('<ul>' + menulist_val + '</ul>').children().each(function() {
34285                if (normalizeMenuLinkValue($(this).attr('data-userlink')) == normalizeMenuLinkValue(prev_link)) {
34286                    prev_link = $(this).attr('data-userlink');
34287                }
34288            });
34289        }
34290
34291
34292        var selected_menu_page = active_menu_page || normalizeMenuLinkValue(prev_link);
34293        var select_inner_html = select_menu_html;
34294	        var select_inner_selected = (isInner) ? ' data-link-val="' + selected_menu_page + '" data-link-id="' + active_menu_link_id + '"' : '';
34295
34296        link_content += '\
34297            <li class="link-type ' + isInner + ' ' + link_disabled['submenu'] + '">\
34298                <div class="link-menu">\
34299                    ' + clSVG('checkbox_active',20,20,false) + '\
34300                    <h5>' + $.lang[LANG][lang_text] + '</h5>\
34301                    <svg class="cm-popover-info" viewBox="0 0 13 13" width="13" height="13" tabindex="0" data-toggle="popover" data-trigger="hover" data-html="true" data-placement="top" data-content="' + $.lang[LANG]['editor.link.inner.menu.info'] + '">\
34302                        <path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/>\
34303                        <rect x="6" y="9" width="1" height="1"/>\
34304                        <path d="M6.66 3.01C5.61 3.01 4.58 3.5 4.5 4.8c0 0.06-0.01 0.12 0 0.2h1.02c0-0.07 0.01-0.15 0.02-0.23 0.08-0.62 0.52-0.76 1.08-0.76 0.63 0 1.02 0.37 1.02 0.95 -0.01 0.48-0.3 0.87-0.76 1.34C6.21 6.97 6.02 7.37 6 8h0.99C7 7.
3430466 7.04 7.37 7.67 6.75 8.17 6.27 8.7 5.68 8.7 4.87 8.7 3.85 7.89 3.01 6.66 3.01z"/>\
34305                    </svg>\
34306                    <div class="group-wrap">\
34307                        <div class="btn-group">\
34308                            <div class="inner-toggle btn btn-sm dropdown-toggle ' + link_disabled['submenu'] + '" data-toggle="dropdown">\
34309                                <span class="select-link" ' + select_inner_selected + '>' + select_inner_html + '</span>';
34310        if (isList) link_content += '<svg viewBox="0 0 8 4" width="8" height="4" class="hand"><polygon points="0 0 4 4 8 0 "/></svg>';
34311        link_content += '\
34312                            </div>\
34313                            <ul class="dropdown-menu link-innerlist" role="menu">\
34314                                ' + menulist_val + '\
34315                            </ul>\
34316                        </div>\
34317                    </div>\
34318                </div>\
34319            </li>\
34320        ';
34321    }
34322
34323    link_content += '\
34324            <li class="link-type ' + isBookmark + ' ' + link_disabled['bookmark'] + '">\
34325                <div class="link-bookmark">\
34326                    ' + clSVG('checkbox_'+link_icon['bookmark'],20,20,false) + '\
34327                    <h5>' + $.lang[LANG]['editor.link.bookmark'] + '</h5>\
34328                    <svg class="cm-popover-info" viewBox="0 0 13 13" width="13" height="13" tabindex="0" data-toggle="popover" data-trigger="hover" data-html="true" data-placement="top" data-content="' + $.lang[LANG]['editor.link.bookmark.info'] + '">\
34329                        <path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/>\
34330                        <rect x="6" y="9" width="1" height="1"/>\
34331                        <path d="M6.66 3.01C5.61 3.01 4.58 3.5 4.5 4.8c0 0.06-0.01 0.12 0 0.2h1.02c0-0.07 0.01-0.15 0.02-0.23 0.08-0.62 0.52-0.76 1.08-0.76 0.63 0 1.02 0.37 1.02 0.95 -0.01 0.48-0.3 0.87-0.76 1.34C6.21 6.97 6.02 7.37 6 8h0.99C7 7.66 7.04 7.37 7.67 6.75 8.17 6.27 8.7 5.68 8.7 4.87 8.7 3.85 7.89 3.01 6.66 3.01z"/>\
34332                    </svg>\
34333                    <div class="group-wrap">\
34334                        <div class="btn-group">\
34335                            <div class="bookmark-toggle btn btn-sm dropdown-toggle inner-toggle ' + link_disabled['bookmark'] + '" data-toggle="dropdown">\
34336                                <span class="select-bookmark" ' + select_bookmark_selected + '>' + select_bookmark_str + '</span>\
34337    ';
34338
34339    if (isBookmarkList) link_content += '<svg viewBox="0 0 8 4" width="8" height="4" class="hand"><polygon points="0 0 4 4 8 0 "/></svg>';
34340    link_content += '\
34341                            </div>\
34342                            <ul class="dropdown-menu link-bookmarklist" role="bookmark">\
34343                                ' + bookmarklist_val + '\
34344                            </ul>\
34345                        </div>\
34346                    </div>\
34347                </div>\
34348            </li>\
34349    ';
34350
34351    if ($.inArray(type, ['menu', 'image', 'gallery', 'popup', 'popupbanner', 'bandbanner', 'quickmenu', 'editor']) > -1) {
34352        var service = (typeof SERVICE == 'undefined') ? $.gallery.service : SERVICE;
34353        var flink_popover_str = (service.indexOf('gabia') > -1) ? $.lang[LANG]['editor.link.file.info.gabia'] : $.lang[LANG]['editor.link.file.info'];
34354        var flink_s = Number(flink_link.size);
34355        var flink_unit = (flink_s > 1024) ? 'unit_m' : '';
34356        var flink_size = (flink_s > 1024) ? flink_s / 1024 : flink_s;
34357
34358        if(LUX) flink_popover_str = $.lang[LANG]['editor.link.file.info.lux'];
34359
34360        link_content += '\
34361            <li class="link-type ' + isFlink + ' ' + link_disabled['flink'] + ' flink">\
34362                <div class="link-file">\
34363                    ' + clSVG('checkbox_'+link_icon['flink'],20,20,false) + '\
34364                    <h5>' + $.lang[LANG]['editor.link.file'] + '<svg class="cm-popover-info ' + LANG + '" viewBox="0 0 13 13" width="13" height="13" tabindex="0" data-toggle="popover" data-trigger="hover" data-html="true" data-placement="top" data-content="' + flink_popover_str + '">\
34365                        <path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/>\
34366                        <rect x="6" y="9" width="1" height="1"/>\
34367                        <path d="M6.66 3.01C5.61 3.01 4.58 3.5 4.5 4.8c0 0.06-0.01 0.12 0 0.2h1.02c0-0.07 0.01-0.15 0.02-0.23 0.08-0.62 0.52-0.76 1.08-0.76 0.63 0 1.02 0.37 1.02 0.95 -0.01 0.48-0.3 0.87-0.76 1.34C6.21 6.97 6.02 7.37 6 8h0.99C7 7.
3436766 7.04 7.37 7.67 6.75 8.17 6.27 8.7 5.68 8.7 4.87 8.7 3.85 7.89 3.01 6.66 3.01z"/>\
34368                    </svg></h5>\
34369                    <div class="group-wrap">\
34370        ';
34371
34372        link_content += (valid_plan && valid_type != 'PK') ? '\
34373                        <div class="btn-group">\
34374                            <span class="btn btn-sm fileinput-button flink-add">\
34375                              ' + clSVG('paperclip', '16', '16', false, '') + '\
34376                              <span> ' + $.lang[LANG]['editor.link.file.btn'] + '</span>\
34377                            </span>\
34378                        </div>\
34379                        <span class="prop-flink-ctrl ' + isFlink + '">\
34380                            <span class="flink-info" ' + ((isFlink) ? 'data-id="' + flink_link.seq + '"' : '') + '>\
34381                                <span class="flink-name">' + ((isFlink) ? flink_link.name : '') + '</span>\
34382                                <span class="flink-size ' + flink_unit + '">' + ((isFlink) ? flink_size.toFixed(0) : '') + '</span>\
34383                            </span>\
34384                            <span class="hand flink-cancel"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="10" height="10"><path d="M8.71 8l7.15-7.15c0.2-0.2 0.2-0.51 0-0.71s-0.51-0.2-0.71 0L8 7.29 0.85 0.15c-0.2-0.2-0.51-0.2-0.71 0s-0.2 0.51 0 0.71L7.29 8l-7.15 7.15c-0.2 0.2-0.2 0.51 0 0.71C0.24 15.95 0.37 16 0.5 16s0.26-0.05 0.35-0.15L8 8.71l7.15 7.15c0.1 0.1 0.23 0.15 0.35 0.15s0.26-0.05 0.35-0.15c0.2-0.2 0.2-0.51 0-0.71L8.71 8z"></path></svg></span>\
34385                        </span>\
34386        ' : '\
34387                        <div class="btn-group">\
34388                            <span class="btn btn-sm btn-flink-upgrade">\
34389                              ' + clSVG('paperclip', '16', '16', false, '') + '\
34390                              <span> ' + $.lang[LANG]['editor.link.file.btn'] + '</span>\
34391                            </span>\
34392                        </div>\
34393                        <!--<div class="btn-group">\
34394                            <a class="btn btn-sm btn-flink-upgrade" href="' + ((SERVICE.indexOf('gabia') > -1) ? '//www.gabia.com/mygabia/service" target="_blank' : '/upgrade/site/') + '">\
34395                              ' + clSVG('planupgrade',18,18) + '<span>' + $.lang[LANG]['dashbord.toolbar.upgrade-site'] + '</span>\
34396                            </a>\
34397                        </div>-->\
34398        ';
34399        link_content += '\
34400                  </div>\
34401                </div>\
34402            </li>\
34403        ';
34404    }
34405
34406    var telsms_link_2 = telsms_link.replace(/(tel|sms)\:/gi,'');
34407    var telsms_link_array = [];
34408    var tel_link_array = [];
34409    var sms_link_array = [];
34410   
34411    if(check_tel || check_sms) {
34412        if(telsms_link_2.indexOf('-') > -1) {
34413            if(prev_link.indexOf('tel')>-1) tel_link_array = telsms_link_2.split('-'); 
34414            else if(prev_link.indexOf('sms')>-1) sms_link_array = telsms_link_2.split('-');
34415        }
34416
34417        if(tel_link_array.length === 2) tel_link_array = ['', tel_link_array[0], tel_link_array[1]];
34418        if(sms_link_array.length === 2) sms_link_array = ['', sms_link_array[0], sms_link_array[1]];
34419
34420        link_content += `
34421            <li class="link-type ${isTel_link} tel">
34422                <div class="link-tel">
34423                    ${clSVG('checkbox_active',20,20,false)}
34424                    <h5>${$.lang[LANG]['editor.link.tel']}</h5>
34425                    <div class="cl-common-form-wrap nonplace-holder">
34426                        <div class="cl-common-form-group">
34427                            <input type="number" class="link-input" placeholder="000" value="${tel_link_array[0] || ''}">
34428                        </div>
34429                        <span class="text">-</span>
34430                        <div class="cl-common-form-group">
34431                            <input type="number" class="link-input" placeholder="0000" value="${tel_link_array[1] || ''}">
34432                        </div>
34433                        <span class="text">-</span>
34434                        <div class="cl-common-form-group">
34435                            <input type="number" class="link-input" placeholder="0000" value="${tel_link_array[2] || ''}">
34436                        </div>
34437                    </div>
34438                </div>
34439            </li>
34440            <li class="link-type ${isSms_link} sms">
34441                <div class="link-sms">
34442                    ${clSVG('checkbox_active',20,20,false)}
34443                    <h5>${$.lang[LANG]['editor.link.sms']}</h5>
34444                    <div class="cl-common-form-wrap nonplace-holder">
34445                        <div class="cl-common-form-group">
34446                            <input type="number" class="link-input" placeholder="000" value="${sms_link_array[0] || ''}">
34447                        </div>
34448                        <span class="text">-</span>
34449                        <div class="cl-common-form-group">
34450                            <input type="number" class="link-input" placeholder="0000" value="${sms_link_array[1] || ''}">
34451                        </div>
34452                        <span class="text">-</span>
34453                        <div class="cl-common-form-group">
34454                            <input type="number" class="link-input" placeholder="0000" value="${sms_link_array[2] || ''}">
34455                        </div>
34456                    </div>
34457                </div>
34458            </li>
34459        `;
34460    }
34461
34462    if (type == 'image') {
34463        var popup_popover_str = (SERVICE.indexOf('gabia') > -1) ? $.lang[LANG]['editor.link.imagePopup.info.gabia'] : $.lang[LANG]['editor.link.imagePopup.info'];
34464        var popup_info = prev_link.split('||');
34465        var popupLink = popup_info[0];
34466        var popupName = popup_info[1];
34467
34468        link_content += '\
34469            <li class="link-type ' + isPopup + ' ' + link_disabled['imagePopup'] + ' imagePopup">\
34470                <div class="link-popup">\
34471                    ' + clSVG('checkbox_'+link_icon['imagePopup'],20,20,false) + '\
34472                    <h5>' + $.lang[LANG]['editor.link.imagePopup'] + '<svg class="cm-popover-info hand ' + LANG + '" viewBox="0 0 13 13" width="13" height="13" tabindex="0" data-toggle="popover" data-trigger="focus" data-html="true" data-placement="top" data-content="' + popup_popover_str + '">\
34473                        <path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/>\
34474                        <rect x="6" y="9" width="1" height="1"/>\
34475                        <path d="M6.66 3.01C5.61 3.01 4.58 3.5 4.5 4.8c0 0.06-0.01 0.12 0 0.2h1.02c0-0.07 0.01-0.15 0.02-0.23 0.08-0.62 0.52-0.76 1.08-0.76 0.63 0 1.02 0.37 1.02 0.95 -0.01 0.48-0.3 0.87-0.76 1.34C6.21 6.97 6.02 7.37 6 8h0.99C7 7.66 7.04 7.37 7.67 6.75 8.17 6.27 8.7 5.68 8.7 4.87 8.7 3.85 7.89 3.01 6.66 3.01z"/>\
34476                    </svg></h5>\
34477                    <div class="group-wrap">\
34478        ';
34479
34480        link_content += (VALIDPLAN && VALIDTYPE != 'PK') ? '\
34481                        <div class="btn-group">\
34482                            <span class="btn btn-sm fileinput-button popupImage-add">\
34483                                ' + clSVG('file-image', '13', '13', false, '') + '\
34484                                <span> ' + $.lang[LANG]['editor.link.imagePopup.btn'] + '</span>\
34485                            </span>\
34486                        </div>\
34487                        <span class="prop-popup-ctrl ' + isPopup + '">\
34488                            <span class="popup-info" ' + ((isPopup) ? 'data-popup="' + prev_link + '"' : '') + '>\
34489                                <span class="popup-name">' + ((isPopup) ? popupName : '') + '</span>\
34490                            </span>\
34491                            <span class="hand popup-cancel"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="10" height="10"><path d="M8.71 8l7.15-7.15c0.2-0.2 0.2-0.51 0-0.71s-0.51-0.2-0.71 0L8 7.29 0.85 0.15c-0.2-0.2-0.51-0.2-0.71 0s-0.2 0.51 0 0.71L7.29 8l-7.15 7.15c-0.2 0.2-0.2 0.51 0 0.71C0.24 15.95 0.37 16 0.5 16s0.26-0.05 0.35-0.15L8 8.71l7.15 7.15c0.1 0.1 0.23 0.15 0.35 0.15s0.26-0.05 0.35-0.15c0.2-0.2 0.2-0.51 0-0.71L8.71 8z"></path></svg></span>\
34492                        </span>\
34493        ' : '\
34494                        <div class="btn-group">\
34495                            <span class="btn btn-sm btn-popup-upgrade">\
34496                                ' + clSVG('file-image', '13', '13', false, '') + '\
34497                                <span> ' + $.lang[LANG]['editor.link.imagePopup.btn'] + '</span>\
34498                            </span>\
34499                        </div>\
34500        ';
34501        link_content += '\
34502                  </div>\
34503                </div>\
34504            </li>\
34505        ';
34506    }
34507
34508    if (type == 'menu') {
34509        link_content += '\
34510            <li class="link-type ' + isFolder + ' ' + link_disabled['submenu'] + '">\
34511                <div class="link-folder">' + clSVG('checkbox_'+link_icon['menu'],20,20,false) + '\
34512                    <h5>' + $.lang[LANG]['editor.link.folder'] + '</h5>\
34513                </div>\
34514            </li>\
34515        ';
34516    }
34517    if (type == 'editor') return { 'str': link_content, 'display': select_menu_str };
34518    else return link_content;
34519}
34520
34521var makeMenuLinkList = function(s, type, id, prev_link, prev_link_id) {
34522    // console.log(s);
34523    // console.log('type: '+type+', id: '+id+', prev_link: '+prev_link);
34524    var depth = 0;
34525    var str = '';
34526    var isActive = '';
34527    prev_link_id = (typeof prev_link_id != 'undefined' && prev_link_id) ? String(prev_link_id) : '';
34528    var normalizeMenuLinkValue = normalizeModalMenuLinkPage;
34529    var escapeLinkHtml = (typeof escapeMenuDisplayHtml == 'function') ? escapeMenuDisplayHtml : function(value) {
34530        return String(value == null ? '' : value)
34531            .replace(/&/g, '&amp;')
34532            .replace(/</g, '&lt;')
34533            .replace(/>/g, '&gt;');
34534    };
34535    var escapeLinkAttr = (typeof escapeMenuDisplayAttr == 'function') ? escapeMenuDisplayAttr : function(value) {
34536        return escapeLinkHtml(value)
34537            .replace(/"/g, '&quot;')
34538            .replace(/'/g, '&#39;');
34539    };
34540    var getLinkDisplayName = (typeof getMenuDisplayNameText == 'function') ? getMenuDisplayNameText : function(value) {
34541        return String(value == null ? '' : value).replace(/-/g, ' ');
34542    };
34543    var getLinkDisplayPathText = (typeof getMenuDisplayPathText == 'function') ? getMenuDisplayPathText : function(names) {
34544        var result = [];
34545        $.each(names || [], function(i, name) {
34546            name = getLinkDisplayName(name);
34547            if (name) result.push(name);
34548        });
34549        return result.join(' > ');
34550    };
34551    var getLinkDisplayPathData = (typeof getMenuDisplayPathData == 'function') ? getMenuDisplayPathData : function(names) {
34552        return escapeLinkAttr(JSON.stringify(names || []));
34553    };
34554    var makeLinkMenuItem = function(obj, depth, pathNames, activeClass, extraClass) {
34555        var page = (typeof getMenuPage == 'function') ? getMenuPage(obj) : normalizeMenuLinkValue(obj.name);
34556        var link_id = getModalMenuUid(obj);
34557        var list_title = getLinkDisplayName(obj.name);
34558        var path_title = getLinkDisplayPathText(pathNames);
34559        var depth_class = (depth > 0) ? ' menu-depth-child' : ' menu-depth-root';
34560
34561        return '<li data-userlink="' + escapeLinkAttr(page) + '" data-userlink-title="' + escapeLinkAttr(path_title) + '" data-userlink-path="' + getLinkDisplayPathData(pathNames) + '" data-link-id="' + escapeLinkAttr(link_id) + '" class="' + activeClass + extraClass + depth_class + '"><a href="javascript:;">' + escapeLinkHtml(list_title) + '</a></li>';
34562    };
34563
34564    if (type == 'menu') {
34565        var menu = function(level, depth, parentNames) {
34566            $.each(level || [], function(idx, obj) {
34567                var pathNames = parentNames.concat([obj.name || '']);
34568                if (obj.name == id && obj.children && obj.children.length > 0) {
34569                    menu(obj.children, depth + 1, pathNames);
34570                    return true;
34571                }
34572                if (depth != 0) {
34573                    var page = (typeof getMenuPage == 'function') ? getMenuPage(obj) : normalizeMenuLinkValue(obj.name);
34574                    var link_id = getModalMenuUid(obj);
34575                    isActive = ((prev_link_id && link_id == prev_link_id) || (!prev_link_id && normalizeMenuLinkValue(prev_link) == page)) ? 'active' : '';
34576                    str = str + makeLinkMenuItem(obj, depth, pathNames, isActive, '');
34577                }
34578            });
34579            return str;
34580        }
34581        return menu(s, depth, []);
34582    }
34583
34584    if ($.inArray(type, ['image', 'gallery', 'popup', 'popupbanner', 'bandbanner', 'quickmenu','fnav', 'showcase', 'editor']) > -1) {
34585        var menu = function(level, depth, parentNames) {
34586            $.each(level || [], function(idx, obj) {
34587                var pathNames = parentNames.concat([obj.name || '']);
34588                var check_menu_str = (type == 'editor') ? prev_link.replace(/^\//g, '') 
34588: prev_link;
34589                var page = (typeof getMenuPage == 'function') ? getMenuPage(obj) : normalizeMenuLinkValue(obj.name);
34590                var link_id = getModalMenuUid(obj);
34591                isActive = ((prev_link_id && link_id == prev_link_id) || (!prev_link_id && normalizeMenuLinkValue(check_menu_str) == page)) ? 'active' : '';
34592				var pageLess = (String(obj.link || '') == 'folder-menu');
34593				var onoff = (obj.display == 'on' && !pageLess) ? '' : ' off';
34594				if (pageLess) onoff += ' disabled';
34595                str = str + makeLinkMenuItem(obj, depth, pathNames, isActive, onoff);
34596
34597                if (obj.children) menu(obj.children, depth + 1, pathNames);
34598            });
34599            return str;
34600        }
34601      
34602        return menu(s, depth, []);
34603    }
34604};
34605$('.menu-edit-text .btn-cancel').live('click', function() {
34606    menuEdit = false;
34607    menu_edit_cancel();
34608});
34609
34610var menu_edit_cancel = function() {
34611    var $added = $('#nestable .dd-item[data-id="menu-added"]');
34612    if ($added.length) {
34613        if ($added.find('.menu-edit-text .btn-save.clicked').length) return false;
34614        var $parentList = $added.parent();
34615        var $parentItem = $parentList.parent('.dd-item');
34616        $added.remove();
34617        if ($parentItem.length && !$parentList.children('.dd-item').length) {
34618            $parentList.remove();
34619            $parentItem.children('[data-action]').remove();
34620            $parentItem.removeClass('dd-collapsed');
34621        }
34622        menuEdit = false;
34623        if (typeof refreshMenuTabButtons == 'function') refreshMenuTabButtons();
34624    } else {
34625        $('.menu-edit-text .btn-cancel').parents('.menu-edit-text').hide();
34626    }
34627    $('#menu-add').show();
34628    return true;
34629}
34630
34631$(document)
34632    .on('click', '.flink-cancel', function(e) {
34633        var flinkConfig = $(this).closest('.prop-flink-ctrl');
34634        flinkConfig.removeClass('active');
34635        flinkConfig.find('.flink-info').removeAttr('data-id');
34636        flinkConfig.find('.flink-name,.flink-size').empty();
34637    })
34638    .on('click', '.flink-add', function(e) {
34639        var block_el = (typeof editEL == 'undefined') ? $.gallery.block_el : editEL;
34640    
34641        if(typeof editEL != 'undefined') {
34642            menuConfigToggle('close');
34643            siteConfigToggle('close');
34644        }
34645        var block_el = (typeof editEL == 'undefined') ? $.gallery.block_el : editEL;
34646        $('.g-body .text-menu').removeClass('active').addClass('hide');
34647        if (typeof fr_editor != 'undefined' && fr_editor != '') $(fr_editor.popups.get('link.insert')).addClass('allways');
34648        setResourceBtn(true,{maxcount:1, property:'flink-change', element:`.${block_el}`});
34649    });
34650
34651var setFileLink = function() {
34652    var selectedFlink = $('#filestorage .fitem.selected');
34653    var selected = (selectedFlink.length > 0) ? true : false;
34654    var selected_count = (selected) ? 1 : 0;
34655    var obj = (selected) ? {
34656            'name': selectedFlink.find('p.fitem-name').text(),
34657            'size': selectedFlink.find('p.fitem-size .size').attr('data-size'),
34658            'seq': selectedFlink.find('p.fitem-name').attr('data-seq'),
34659            'file': selectedFlink.find('p.fitem-name').attr('data-source'),
34660        } : {};
34661
34662    var flinkConfig = $('.link-file .prop-flink-ctrl');
34663    var flink_s = Number(obj.size.replace(',', ''));
34664    var flink_unit = (flink_s > 1024) ? 'unit_m' : '';
34665    var flink_size = (flink_s > 1024) ? flink_s / 1024 : flink_s;
34666
34667    flinkConfig.find('.flink-info .flink-name').text(obj.name);
34668    flinkConfig.find('.flink-info .flink-size').text(flink_size.toFixed(0));
34669    if (flink_unit) flinkConfig.find('.flink-info .flink-size').addClass('unit_m');
34670    else flinkConfig.find('.flinkflink-info .flink-size').removeClass('unit_m');
34671    flinkConfig.find('.flink-info').attr('data-id', obj.seq);
34672    flinkConfig.addClass('active');
34673    selectCount = 0;
34674    $('#el-fileupload').modal('hide');
34675}
34676
34677
34678$('.link-type').live({
34679    click: function(e) {
34680        if ($(e.target).is('a') && $(e.target).hasClass('upgrade-link')) return;
34681        if ($(this).hasClass('disabled')) {
34682            $('.link-type').find('.linkguidetext').remove();
34683            var link_type = $(this).children('div[class*="link-"]').attr('class').replace(/^link-/gi, '');
34684            var guide_str = (link_type == 'inner' || link_type == 'folder') ? $.lang[LANG]['editor.link.inner.guide'] : $.lang[LANG]['editor.link.bookmark.guide'];
34685            if (link_type == 'file') {
34686                guide_str = (SERVICE.indexOf('gabia') > -1) ? $.lang[LANG]['editor.link.file.upgrade.gabia'] : $.lang[LANG]['editor.link.file.upgrade'];
34687            } else if (link_type == 'popup') {
34688                if(!VALIDPLAN || VALIDTYPE == 'PK') {
34689                    guide_str = (SERVICE.indexOf('gabia') > -1) ? $.lang[LANG]['editor.link.imagePopup.upgrade.gabia'] : $.lang[LANG]['editor.link.imagePopup.upgrade'];
34690                } else {
34691                    guide_str = '' ;
34692                    return;
34693                }
34694            }
34695
34696            $(this).append('<p class="linkguidetext edit-link-error">' + clSVG('info', 13, 13) + guide_str + '</p>');
34697            return;
34698        }
34699
34700        if ($(this).closest('.link-content[data-type="popup"]').length > 0 && $(this).children('.link-default').length > 0) $('#popup-linktarget-onoff').removeAttr('checked');
34701        $('.link-type').find('.linkguidetext').remove();
34702        $(this).parent().children().removeClass('active');
34703        $(this).addClass('active');
34704
34705        if($(this).children().attr('class') == 'link-default' || $(this).children().attr('class') == 'link-file' || $(this).children().attr('class') == 'link-popup') {
34706            $('#linktarget-onoff').prop('checked', false);
34707            $('#linktarget-onoff').closest('.newcheckbox').addClass('disabled');
34708        } else {
34709            $('#linktarget-onoff').closest('.newcheckbox').removeClass('disabled');
34710        }
34711    }
34712});
34713
34714	var getInputLink = function(type) {
34715	    var link = '';
34716	    var link_id = '';
34717	    var isOkay = true;
34718    var isActive = true;
34719    // var regex = /([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w_\.-]*)/ig;
34720    var regex = /^(((http(s?))\:\/\/||\/\/)?)([0-9a-zA-Z\-]+\.)+[a-zA-Z]{2,7}(\:[0-9]+)?(\/\S[^\{\}]*)?$/; //http://do doesn't
34721    var regex2 = /^((http(s?))\:\/\/||\/\/)([0-9a-zA-Z\-\_]+\.)+[a-zA-Z]{2,7}(\:[0-9]+)?(\/\S[^\{\}]*)?$/; //http://do
34722    var regex3 = /^(https?:\/\/||\/\/)?(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]/; // add punycode
34723    var regexKR = /^(https?:\/\/||\/\/)?((([a-z\d](([a-z\d-]*[a-z\d]))|([ㄱ-힣])*)\.)+(([a-zㄱ-힣]{2,}))|((\d{1,3}\.){3}\d{1,3}))(\:\d+)?(\/[-a-z\d%_.~+]*)*(\?[;&a-z\d%_.~+=-]*)?(\#[-a-z\d_]*)?$/;
34724    var regexTel = /^tel\:[0-9-+]+$/;
34725
34726    function showInputLinkError(linktype, error) {
34727        $('.link-content').find('.linkguidetext').remove();
34728        var activeLinkConfig = $('.link-content').find('.' + linktype);
34729        var error_class = 'linkguidetext edit-link-error';
34730        var error_txt = '';
34731
34732        if (error == 'empty') {
34733            error_txt = $.lang[LANG]['editor.link.empty.' + linktype.replace('link-', '')];
34734        } else {
34735            if (linktype == 'link-out') {
34736                $('.link-input').focus();
34737                if (error == 'config') error_class = 'linkguidetext modal-layout';
34738                error_txt = (error == 'emoji') ? $.lang[LANG]['config.unable.emoji'] : $.lang[LANG]['editor.menu.input-link.' + error];
34739            }
34740        }
34741
34742        if (typeof error_txt == 'undefined' || error_txt.length == 0) return false;
34743        else activeLinkConfig.after('<p class="' + error_class + '">' + clSVG('info', 13, 13) + error_txt + '</p>');
34744    }
34745
34746    switch (type) {
34747        case 'link-default':
34748            link = '';
34749            isActive = false;
34750            break;
34751
34752        case 'link-out':
34753            link = $('.link-input').val().trim();
34754            isOkay = false;
34755            var error_str = '';
34756
34757            if (link == '') { //input value empty
34758                showInputLinkError(type, 'info');
34759
34760                // $('.link-input').focus();
34761                // if($('.link-out').find('.linkguidetext').length == 0) $('.link-out').prepend('<span class="linkguidetext"><i class="fa fa-exclamation-circle"></i>' + $.lang[LANG]['editor.menu.input-link.info'] + '</span>');
34762            } else if (link != '') {
34763                if (checkEmojis(link)) {
34764                    showInputLinkError(type, 'emoji');
34765                } else if (link.match('^(tel:|mailto:|sms:)') !== null) {
34766                    isOkay = true;
34767                } else if (!regex2.test(link)) {
34768                    if (regex.test(link)) {
34769                        isOkay = true;
34770                    } else if (regex3.test(link) || regexKR.test(link)) {
34771                        isOkay = true;
34772                        var check_protocol = /^(http(s?)\:\/\/|\/\/?)/;
34773                        if (!check_protocol.test(link)) link = '//' + link;
34774                    } else if (regexTel.test(link)) {
34775                        isOkay = true;
34776                    } else {
34777                        showInputLinkError(type, 'info');
34778                        // $('.link-input').focus();
34779                        // if($('.link-out').find('.linkguidetext').length == 0) $('.link-out').prepend('<span class="linkguidetext"><i class="fa fa-exclamation-circle"></i>' + $.lang[LANG]['editor.menu.input-link.info'] + '</span>');
34780                    }
34781                } else {
34782                    // if($('.link-out').find('.linkguidetext').length > 0) $('.link-out').find('.linkguidetext').remove();
34783                    isOkay = true;
34784                }
34785            }
34786
34787            if (isOkay) {
34788                if (link.match(/\/config/gi) !== null && link.match(/creatorlink/gi) !== null) {
34789                    isOkay = false;
34790                    showInputLinkError(type, 'config');
34791                } else {
34792                    $('.linkguidetext').remove();
34793                }
34794
34795                if(checkBase64Encode(decodeURIComponent(link))) link = Base64.decode(decodeURIComponent(link));
34796                link = encodeURIComponent(Base64.encode(link));
34797
34798            }
34799            break;
34800
34801	        case 'link-inner':
34802	        case 'link-menu':
34803	            var select_menu = $('.link-innerlist').find('.active');
34804	            isOkay = false;
34805	            if (select_menu.length > 0) {
34806	                link = select_menu.first().attr('data-userlink');
34807	                link_id = select_menu.first().attr('data-link-id') || '';
34808	                isOkay = true;
34809
34810                $('.linkguidetext').remove();
34811            } else {
34812                showInputLinkError(type, 'empty');
34813            }
34814            break;
34815
34816        case 'link-bookmark':
34817            var select_bookmark = $('.link-bookmarklist').find('.active');
34818            isOkay = false;
34819            if (select_bookmark.length > 0) {
34820                link = select_bookmark.first().attr('data-bookmark').replace('bookmark', '\@');
34821                isOkay = true;
34822
34823                $('.linkguidetext').remove();
34824            } else {
34825                showInputLinkError(type, 'empty');
34826            }
34827            break;
34828
34829        case 'link-folder':
34830            link = 'folder-menu';
34831            break;
34832
34833        case 'link-file':
34834            var ctrl_flink = $('.link-file').find('.prop-flink-ctrl');
34835            var select_flink = ctrl_flink.find('.flink-info');
34836            isOkay = false;
34837            if (typeof select_flink.attr('data-id') != 'undefined' && select_flink.attr('data-id')) {
34838                link = 'flink@' + select_flink.attr('data-id');
34839                isOkay = true;
34840
34841                $('.linkguidetext').remove();
34842            } else {
34843                showInputLinkError(type, 'empty');
34844            }
34845            break;
34846        case 'link-popup':
34847            var ctrl_popup = $('.link-popup').find('.prop-popup-ctrl');
34848            var select_popup = ctrl_popup.find('.popup-info');
34849            isOkay = false;
34850            if (typeof select_popup.attr('data-popup') != 'undefined' && select_popup.attr('data-popup')) {
34851                link = select_popup.attr('data-popup');
34852                isOkay = true;
34853
34854                $('.linkguidetext').remove();
34855            } else {
34856                showInputLinkError(type, 'empty');
34857            }
34858            break;
34859
34860        case 'link-tel':
34861        case 'link-sms':
34862            var link = '';
34863            var total = $(`.${type} .cl-common-form-wrap .link-input`).length;
34864            var link_type = `${type.replace(/link\-/gi,'')}:`;
34865
34866            $.each($(`.${type} .cl-common-form-wrap .link-input`), function(i,v){
34867                if($(this).val().trim() == '') showInputLinkError(type, 'info');
34868                else {
34869                    var split_text = (i==(total-1)) ? '' : '-';
34870                    link += $(this).val().trim() + split_text;
34871                }             
34872            });
34873
34874            link = `${link_type}${link}`;
34875           
34876            break;
34877            
34878        default:
34879            break;
34880    }
34881
34882	    var result = [link, isOkay, isActive, link_id];
34883	    return result;
34884	}
34885
34886var getElementType = function() {
34887    var type = '';
34888    var block_el = (typeof selectEL == 'undefined') ? $.gallery.block_el : selectEL;
34889
34890    if(typeof editEL != 'undefined' && editEL != '' && block_el != editEL) block_el = editEL;
34891
34892    switch (block_el) {
34893        case 'el-menu':
34894            type = 'MENU';
34895            break;
34896        case 'el-footer':
34897            type = 'FOOT';
34898            break;
34899        default:
34900            type = 'ELEM';
34901            break;
34902    }
34903    return type;
34904}
34905
34906$('.link-innerlist li').live({
34907    click: function(e) {
34908		if ($(this).hasClass('disabled')) {
34909			e.preventDefault();
34910			return false;
34911		}
34912        $('.link-innerlist li').removeClass('active');
34913        $(this).addClass('active');
34914	    var select_userlink = $(this).attr('data-userlink');
34915	    var select_userlink_title = $(this).attr('data-userlink-title') || select_userlink;
34916	    var escapeLinkClickHtml = (typeof escapeMenuDisplayHtml == 'function') ? escapeMenuDisplayHtml : function(value) {
34917	        return String(value == null ? '' : value)
34918	            .replace(/&/g, '&amp;')
34919	            .replace(/</g, '&lt;')
34920	            .replace(/>/g, '&gt;');
34921	    };
34922	    var select_userlink_html = (typeof getMenuDisplayPathHtmlFromData == 'function') ? getMenuDisplayPathHtmlFromData($(this).attr('data-userlink-path'), select_userlink_title) : escapeLinkClickHtml(select_userlink_title);
34923	    $('.link-content .dropdown-toggle .select-link').html(select_userlink_html).attr('data-link-val', select_userlink).attr('data-link-id', $(this).attr('data-link-id') || '');
34924	}
34925});
34926
34927
34928var fixedConfigBtn = function() {
34929    if($('html').hasClass('_scroll')) return;
34930
34931    var parentDocument = $(window.parent.document);
34932    var $detail_modal = parentDocument.find('.product-detail-modal');
34933    if (typeof selectEL == 'undefined' || !selectEL || $('.el-menu header').length == 0 && $detail_modal.length == 0) return false;
34934    var $configEl = $('.' + selectEL + '_ctrl > .config-element');
34935    var $configTmp = $('.' + selectEL + '_ctrl > .config-template');
34936    var $galleryDetail = $('.' + selectEL + '_ctrl > .galleryDetail');
34937    var $navbar = ($detail_modal.length) ? $('.dsgn-body') : $('.el-menu header');
34938    var navbarOffsetTop = ($('.dsgn-body').hasClass('modoo'))? document.querySelector('.el-menu header').getBoundingClientRect().y : $navbar.offset().top;
34939    var checkSidebar = $('.dsgn-body').is('.sidebar');
34940    var headerOffset = (!checkSidebar) ? $navbar.outerHeight() + Math.ceil(navbarOffsetTop) : Math.ceil(navbarOffsetTop) + 15;
34941    var btnOffset = (document.querySelector('.' + selectEL + '_ctrl'))? document.querySelector('.' + selectEL + '_ctrl').getBoundingClientRect().y : 0;
34942    var topPos = (!checkSidebar) ? headerOffset + 15 : Math.ceil(navbarOffsetTop) + 15;
34943    var distance = (headerOffset - btnOffset) / 2;
34944    var remain = $('.' + selectEL).height() + btnOffset - headerOffset;
34945
34946    $configEl.removeClass('fixed-ctrl').attr('style', '');
34947    $configTmp.removeClass('fixed-ctrl').attr('style', '');
34948    $galleryDetail.removeClass('fixed-ctrl').attr('style', '');
34949
34950    if($detail_modal.length) {
34951        topPos = $('.openBandBanner').length ? 163 : 23;
34952        distance = 0;
34953    }
34954    // console.log('$navbar', $navbar);
34955    // console.log('headerOffset', headerOffset);
34956    // console.log('btnOffset', btnOffset);
34957    // console.log('distance', distance);
34958    // console.log('remain', remain);
34959    // console.log('topPos', topPos);
34960
34961    $('body').find(`.addElementButton, .config-element-section`).removeClass('zindex19');
34962    if (selectEL != 'el-menu' && selectEL != 'el-footer') {
34963        var checkHTMLScroll = ($('body').is('.off-config[data-gjs="fixedscroll2"]')) ? true : false;
34964        if (distance > 0 && remain >= 37 || checkHTMLScroll) {
34965            var s_top = ($('body').hasClass('off-config')) ? $('html').scrollTop() : $('.dsgn-body').scrollTop();
34966            var unset_top = (checkHTMLScroll) ? $('html').scrollTop() : 0;
34967            if (s_top == 0 && $navbar.hasClass('transparent') && selectEL == 'el_0') {
34968                var config_t = headerOffset + 10;
34969                config_t -= unset_top;
34970                $configEl.css('top', config_t + 'px');
34971                $configTmp.css('top', config_t + 'px');
34972            } else {
34973                topPos -= unset_top;
34974                $configEl.addClass('fixed-ctrl').css('top', topPos + 'px');
34975                $configTmp.addClass('fixed-ctrl').css('top', topPos + 'px');
34976                $galleryDetail.addClass('fixed-ctrl').css('top', topPos + 'px');
34977            }
34978
34979            if($('.dsgn-body').hasClass('modoo') == false) {
34980                let rightPos = window.innerWidth - $('.' + selectEL).width();
34981                if(checkSidebar) rightPos -= $('.el-menu header').width();
34982                if(rightPos > 0) {
34983                    $configEl.addClass('fixed-ctrl').css('right', `${rightPos + 8}px`);
34984                }
34985            }
34986
34987        } else {
34988            $configEl.removeClass('fixed-ctrl').attr('style', '');
34989            $configTmp.removeClass('fixed-ctrl').attr('style', '');
34990            $galleryDetail.removeClass('fixed-ctrl').attr('style', '');
34991
34992            if( selectEL != 'el-menu' &&
34993                $('html').scrollTop() == 0 && 
34994                $('.el-menu .cl-menu-option[data-moption="ntoggle"]').hasClass('open')
34995            ) {
34996                $('body').find(`.addElementButton.add${selectEL}, .${selectEL}_ctrl.config-element-section`).addClass('zindex19');
34997            }
34998        }
34999    }
35000}
35001
35002var educationModal = function(edu_seq,type,data='') {
35003    var row = '', temp_cont = '', temp_review = '';
35004    var popup_svg = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 14 10" width="14" height="10"><path d="m5.77 9.49-5-5 1.42-1.41 3.58 3.59L12.36.08l1.41 1.41z"/></svg>';
35005
35006    if(type=='list') {
35007        $.ajax({
35008            url:'/main/eduData/type/getData',
35009            type:'post',
35010            dataType:'json',
35011            async: false,
35012            data:{ 'seq' : edu_seq,'type':'list' },
35013            success:function(data) {
35014                row = data.data;
35015                temp_cont = JSON.parse(data.modal_data.replace('\\', ''));
35016                temp_review =  JSON.parse(data.review_data.replace('\\', ''));
35017            }
35018        });
35019    } else {
35020        $.ajax({
35021            url:'/adm/edu/eduEvent/type/getData',
35022            type:'post',
35023            dataType:'json',
35024            async: false,
35025            data:{ 'seq' : data.edu_temp_idx,'type':'update',data:data },
35026            success:function(data) {
35027                row = data.data;
35028                temp_cont = JSON.parse(data.modal_data.replace('\\', ''));
35029                temp_review =  JSON.parse(data.review_data.replace('\\', ''));
35030            }
35031        });
35032    }
35033
35034    var tp_review = (typeof temp_review == 'undefined' || !temp_review) ? false : true ,
35035        tp_target = (typeof temp_cont.target_cont == 'undefined' || !temp_cont.target_cont) ? false : true ,
35036        tp_curri = (typeof temp_cont.curri_cont == 'undefined' || !temp_cont.curri_cont) ? false : true;
35037    var edu_url = "", edu_btn_text = "", btn_active = "active";
35038    if(row.edu_list_closed) {
35039        edu_url = "";
35040        edu_btn_text = "접수마감";
35041        btn_active = "disabled";
35042    } else {
35043        edu_url = "window.open('"+ row.edu_url +"')";
35044        edu_btn_text = row.edu_btn_text;
35045    }
35046
35047    var help_url = 'https://www.creatorlink.net/help';
35048
35049    var edu_level = ($.isNumeric(temp_cont.guide_level)) ? '<li class="level" data-level="'+temp_cont.guide_level+'">난이도 : <span><span class="level1">입문</span> - <span class="level2">초급</span> - <span class="level3">중급</span> - <span class="level4">고급</span></span></li>'
35050    : '<li class="level" data-level="">난이도 : '+temp_cont.guide_level+'</li>';
35051    var edu_date = row.edu_date,
35052        edu_new = (edu_date >= '2026-08-14 00:00:00') ? 'new' : 'old';
35053
35054    var edu_header = '\
35055        <div class="edu_head_wrap">\
35056            <div class="edu_head_img only-pc" style="background-image: url(\''+temp_cont.head_pc+'\');"></div>\
35057            <div class="edu_head_img not-pc" style="background-image: url(\''+temp_cont.head_m+'\');"></div>\
35058            <div class="main-title">\
35059                '+temp_cont.pc_title+'\
35060            </div>\
35061            <div class="edu_head_m not-pc">\
35062                <div class="guide">\
35063                    <ul class="note">\
35064                        <li>일시 : '+ row.edu_popupDate +'</li>\
35065                        <li>강의 시간 : '+temp_cont.guide_time+'</li>\
35066                        '+edu_level+'\
35067                        <li>가격 : '+temp_cont.guide_pay+'</li>\
35068                        <li>강의 종류 : '+temp_cont.guide_cate+'</li>\
35069                        <li>최소 인원 : 10명</li>\
35070                    </ul>\
35071                    <ul class="notice">';
35072        edu_header += (edu_new == 'new') ? '\
35073                        <li>강의실 입장 링크는 <span>구글 폼 제출 완료 화면에서 바로 확인 가능</span>하며 강의 개설 확정 시, 교육 당일 신청하신 <span>메일 혹은 알림톡으로도 개별 안내</span>됩니다.</li>\
35074                        ' : '\
35075                        <li>접속 링크는 신청 메일 및 <span>교육 1일 전 개별 알림톡</span> 전달</li>\
35076                        <li>강의실 입장 링크는 <span>수강 신청 시 입력하신 메일 주소로 발송</span>됩니다.</li>';
35077        edu_header += '\
35078                        <li>최소 인원이 충족되지 않으면 <span>강의가 진행되지 않습니다.</span></li>\
35079                    </ul>\
35080                </div>\
35081            </div>\
35082        </div>\
35083    ';
35084
35085    var summary_list = '';
35086    $.each(temp_cont.intro_summary,function(i,v) {
35087        summary_list += '<p>'+popup_svg+' '+v+'</p>';
35088    });
35089
35090    var edu_intro = '\
35091        <section id="intro" class="">\
35092            <div class="teacher">\
35093                    <div class="text not-pc">\
35094                        <p class="title">'+ temp_cont.intro_title +'</p>\
35095                    </div>\
35096                    <div class="photo">\
35097                        <img src="'+ temp_cont.intro_pc_img +'" class="img-responsive only-pc">\
35098                        <img src="'+ temp_cont.intro_m_img +'" class="img-responsive not-pc">\
35099                    </div>\
35100                    <div class="text">\
35101                        <p class="title small only-pc">'+ temp_cont.intro_title +'</i></p>\
35102                        <p class="text">'+ temp_cont.intro_text +'</p>\
35103                        <p class="text name">'+ temp_cont.intro_name +'</p>\
35104                    </div>\
35105            </div>\
35106            <div class="line">\
35107                <p class="title">'+ temp_cont.intro_summary_title +'</p>\
35108                <div class="content">\
35109                    '+summary_list+'\
35110                </div>\
35111            </div>\
35112        </section>\
35113    ';
35114
35115    var target_list = '';
35116
35117    if(tp_target) {
35118    $.each(temp_cont.target_cont,function(i,v) {
35119        target_list += '<p>'+popup_svg+' '+v+'</p>';
35120    });
35121    }
35122
35123    var edu_target = (tp_target) ? '\
35124        <section id="target" class="">\
35125            <div class="">\
35126                <p class="title">'+temp_cont.target_title+'</i></p>\
35127                <div class="content">\
35128                    '+target_list+'\
35129                </div>\
35130            </div>\
35131        </section>\
35132        ' : '' ;
35133
35134    if(tp_curri) {
35135    var curri_list = '';
35136    $.each(temp_cont.curri_cont,function(i,v) {
35137        var collapse = (i==0) ? '' : 'collapsed';
35138        var col_in = (i==0) ? 'in' : '';
35139        var col_toggle = 'collapse';
35140        var curri_svg = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path d="m14.3 5.21-.7-.71-5.3 5.3-5.29-5.3-.71.71 5.3 5.29.7.71.71-.71z"/></svg>';
35141        var curri_cont_list = '';
35142        $.each(v.content,function(i,v) {
35143            curri_cont_list += '<p>'+v+'</p>';
35144        });
35145
35146        if((temp_cont.curri_cont.length-1 == i)) {
35147            curri_svg ='';
35148            col_toggle = '';
35149        }
35150
35151        curri_list += '\
35152            <div class="panel-heading '+collapse+'" data-toggle="'+col_toggle+'" href="#collapse'+i+'" aria-expanded="false" aria-controls="collapse'+i+'">\
35153                <h4 class="panel-title">\
35154                    '+v.title+'\
35155                    '+curri_svg+'\
35156                </h4>\
35157            </div>\
35158            <div id="collapse'+i+'" class="panel-collapse collapse '+col_in+' multi-collapse">\
35159                <div class="panel-body">\
35160                    '+curri_cont_list+'\
35161                </div>\
35162            </div>\
35163        ';
35164    });
35165    }
35166    
35167    var edu_curri = (tp_curri) ? '\
35168        <section id="curriculum" class="">\
35169            <div class="">\
35170                <p class="title">'+temp_cont.curri_title+'</p>\
35171                <div class="panel-group" id="curriaccordion">\
35172                    <div class="panel panel-default">\
35173                    '+curri_list+'\
35174                    </div>\
35175                </div>\
35176            </div>\
35177        </section>\
35178        ' : '' ;
35179
35180    var edu_etc = '\
35181        <section id="etc" class="">\
35182            <div class="" id="info1">\
35183                <p class="title">강의를 위해 필요한 <i>준비물</i></p>\
35184                <div class="content">\
35185                    <p>'+popup_svg+' 데스크탑 PC <span class="red">(권장)</span> / 노트북</p>\
35186                    <p>'+popup_svg+' 크롬 브라우저</p>\
35187                    <p>'+popup_svg+' 필기도구</p>\
35188                </div>\
35189            </div>\
35190            <div class="line" id="info2">\
35191                <p class="title">온라인 교육 안내 사항</p>\
35192                <div class="content">';
35193        edu_etc += (edu_new == 'new') ? '\
35194                    <p>'+popup_svg+' 강의실 입장 링크는 <b>구글 폼 제출 완료 화면에서 바로 확인 가능</b>하며,<br>교육 당일 신청하신 메일 or 알림톡으로도 개별 발송됩니다.</p>\
35195                    <p>'+popup_svg+' 교육 시간 <b>10분 전부터 입장이 가능</b>합니다.</p>\
35196                    <p>'+popup_svg+' 본인 확인을 위해 반드시 <b>신청서에 적어주신 이름</b>으로 입장해 주시기 바랍니다.</p>\
35197                    <p>'+popup_svg+' 1개 아이디로 <b>중복 참여는 불가능</b>합니다.</p>\
35198                    ' : '\
35199                    <p>'+popup_svg+' 강의실 입장 링크는 수강 신청하며 <b>입력하신 메일 주소로 발송</b>됩니다.</p>\
35200                    <p>'+popup_svg+' 교육 시간 <b>20분 전부터 입장이 가능</b>합니다.</p>\
35201                    <p>'+popup_svg+' 1개 아이디로 <b>중복 참여는 불가능</b>합니다.</p>\
35202                    <p>'+popup_svg+' 강의 관련 문의는 <a href="'+help_url+'"><u>1:1 문의</u></a>에 남겨주세요.</p>';
35203        edu_etc += '\
35204                </div>\
35205            </div>\
35206        </section>\
35207        ';
35208    var edu_review = (tp_review) ? '\
35209        <section id="review" class="">\
35210            <div class="">\
35211                <p class="point">New</p>\
35212                <p class="title">먼저 수강한 분들의<br><i>후기를 들어보세요!</i></p>\
35213                <div class="review-list">\
35214                </div>\
35215                <div class="review-btn hand">\
35216                  <span>수강평 더보기</span>\
35217                </div>\
35218            </div>\
35219        </section>\
35220        ' : '' ;
35221
35222    var edu_sticky = '\
35223        <div class="edu_content_right sticky">\
35224            <div class="sticky">\
35225                <div class="btn-order hand '+ btn_active +'" onclick="' + edu_url + '">'+ edu_btn_text +'</div>\
35226                <div class="guide">\
35227                    <ul class="note">\
35228                        <li>일시 : '+ row.edu_popupDate +'</li>\
35229                        <li>강의 시간 : '+temp_cont.guide_time+'</li>\
35230                        '+edu_level+'\
35231                        <li>가격 : '+temp_cont.guide_pay+'</li>\
35232                        <li>강의 종류 : '+temp_cont.guide_cate+'</li>\
35233                        <li>최소 인원 : 10명</li>\
35234                    </ul>\
35235                    <ul class="notice">';
35236        edu_sticky += (edu_new == 'new') ? '\
35237                        <li>강의실 입장 링크는 <span>구글 폼 제출 완료 화면에서 바로 확인 가능</span>하며 강의 개설 확정 시, 교육 당일 신청하신 <span>메일 혹은 알림톡으로도 개별 안내</span>됩니다.</li>\
35238                        ' : '\
35239                        <li>접속 링크는 신청 메일 및 <span>교육 1일 전 개별 알림톡</span> 전달</li>\
35240                        <li>강의실 입장 링크는 <span>수강 신청 시 입력하신 메일 주소로 발송</span>됩니다.</li>';
35241        edu_sticky += '\
35242                        <li>최소 인원이 충족되지 않으면 <span>강의가 진행되지 않습니다.</span></li>\
35243                    </ul>\
35244                </div>\
35245            </div>\
35246        </div>\
35247    ';
35248    var edu_review_tab = (tp_review) ? '<li class="hand" data-menulink="review">후기<span class="point">New</span></li>' : '';
35249    var edu_target_tab = (tp_target) ? '<li class="hand" data-menulink="target">강의 대상</li>' : '<li class="hand" data-menulink="info1">준비물</li>';
35250    var edu_curri_tab = (tp_curri) ? '<li class="hand" data-menulink="curriculum">커리큘럼</li>' : '<li class="hand" data-menulink="info2">교육안내</li>';
35251
35252
35253    var edu_html = '\
35254        <div class="education_detail">\
35255            <div class="edu_wrap">\
35256                '+edu_header+'\
35257                <div class="edu_content">\
35258                    <div class="edu_content_left">\
35259                        <div class="edu_tab">\
35260                            <ul>\
35261                                <li class="hand active" data-menulink="intro">강의소개</li>\
35262                                '+edu_target_tab+'\
35263                                '+edu_curri_tab+'\
35264                                '+edu_review_tab+'\
35265                            </ul>\
35266                        </div>\
35267                        <div class="edu_section">\
35268                            '+edu_intro+'\
35269                            '+edu_target+'\
35270                            '+edu_curri+'\
35271                            '+edu_etc+'\
35272                            '+edu_review+'\
35273                        </div>\
35274                    </div>\
35275                    '+edu_sticky+'\
35276                </div>\
35277            </div>\
35278        </div>\
35279    ';
35280    
35281    var modal = $(this).showModalFlat('', edu_html, true, false, '', 'close', '', 'guidePopup cl-cmmodal cl-s-btn cover education-modal', false, '', function() {
35282        $.guidePopup.scrollevent(); 
35283
35284        modal.find('.edu_tab li').off('click').on('click', function(e) {
35285        var target = $(this).attr('data-menulink');
35286
35287        var top = ($(this).index())+1,
35288            hsize = (window.innerWidth <= 768) ? 34 : 55,
35289            tab_pos = (window.innerWidth <= 768) ? $('#'+target).position().top + $('.edu_head_wrap').outerHeight() : $('#'+target).position().top;
35290            move = tab_pos - hsize;
35291
35292            modal.find('.guidePopup .modal-content').animate({scrollTop: move},1000, 'easeInOutExpo');
35293        });
35294
35295        modal.find('.guidePopup .modal-content').bind('scroll', function () {
35296        var hsize = (window.innerWidth <= 768) ? 38 : 55,
35297            scrollValue = $('.guidePopup .modal-content').scrollTop() + hsize,
35298            tab_pos = (window.innerWidth <= 768) ? $('.edu_head_wrap').outerHeight() : 0;
35299
35300            if(tp_review) {
35301                if( scrollValue >= $("#target").position().top + tab_pos && scrollValue < $("#curriculum").position().top + tab_pos) {
35302                    $('.edu_tab li').eq(1).addClass('active').siblings().removeClass('active');
35303                } else if( scrollValue >= $("#curriculum").position().top + tab_pos && scrollValue < $("#review").position().top + tab_pos) {
35304                    $('.edu_tab li').eq(2).addClass('active').siblings().removeClass('active');
35305                } else if( scrollValue >= $("#review").position().top + tab_pos) {
35306                    $('.edu_tab li').eq(3).addClass('active').siblings().removeClass('active');
35307                } else {
35308                    $('.edu_tab li').eq(0).addClass('active').siblings().removeClass('active');
35309                }
35310            } else {
35311                if(tp_target) {
35312                    if( scrollValue >= $("#target").position().top + tab_pos && scrollValue < $("#curriculum").position().top + tab_pos) {
35313                        $('.edu_tab li').eq(1).addClass('active').siblings().removeClass('active');
35314                    } else if( scrollValue >= $("#curriculum").position().top + tab_pos) {
35315                        $('.edu_tab li').eq(2).addClass('active').siblings().removeClass('active');
35316                    } else {
35317                        $('.edu_tab li').eq(0).addClass('active').siblings().removeClass('active');
35318                    }
35319                } else {
35320                    if( scrollValue >= $("#info1").position().top + tab_pos && scrollValue < $("#info2").position().top + tab_pos) {
35321                        $('.edu_tab li').eq(1).addClass('active').siblings().removeClass('active');
35322                    } else if( scrollValue >= $("#info2").position().top + tab_pos) {
35323                        $('.edu_tab li').eq(2).addClass('active').siblings().removeClass('active');
35324                    } else {
35325                        $('.edu_tab li').eq(0).addClass('active').siblings().removeClass('active');
35326                    }
35327                }
35328            }
35329        });
35330        if(tp_review) {
35331            $.each(temp_review,function(i,v) {
35332                modal.find('.review-list').append('<li><p class="review">'+v.review+'</p><p class="name">'+v.name+' 님</p></li>');
35333            });
35334            var targets = modal.find('.review-list').children();
35335            for(var i=0; i<targets.length; i+=4){
35336                $('<ul class="hide"></ul>').append(targets.slice(i, i+4)).appendTo('.review-list');
35337            }
35338            modal.find('.review-list').find('ul:eq(0)').removeClass('hide');
35339            modal.find('.review-list').find('ul:eq(1)').removeClass('hide');
35340
35341            modal.find('.review-btn').off('click').on('click', function(e) {
35342                modal.find('.review-list').find('ul.hide:eq(0)').removeClass('hide');
35343                if(modal.find('.review-list').find('ul.hide').length < 1) $(this).addClass('hide');
35344            });
35345        }
35346    });
35347}
35348
35349
35350$(document).ready(function() {
35351    const icons = {
35352        'all': '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" width="20" height="20"><path d="M13.68 12.41A6.5 6.5 0 0 0 15 8.5 6.5 6.5 0 1 0 8.5 15c1.47 0 2.82-.49 3.91-1.32L16.73 18 18 16.73zm-5.18.79c-2.59 0-4.7-2.11-4.7-4.7s2.11-4.7 4.7-4.7 4.7 2.11 4.7 4.7c0 .97-.3 1.87-.8 2.62-.34.5-.77.93-1.27 1.27-.75.51-1.65.8-2.62.8Z"/></svg>',
35353        'statistics': '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" width="20" height="20"><rect width="3" height="6" x="2" y="10" rx=".4" ry=".4"/><rect width="3" height="8" x="10.67" y="8" rx=".4" ry=".4"/><rect width="3" height="10" x="6.33" y="6" rx=".4" ry=".4"/><rect width="3" height="12" x="15" y="4" rx=".4" ry=".4"/></svg>',
35354        'point': '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" width="20" height="20"><path d="M6.44 7.01h.02c.32.1.67.18 1.03.25h.05c.36.07.74.12 1.14.16h.06c.41.04.84.06 1.27.06s.86-.02 1.27-.06h.06c.4-.04.77-.09 1.14-.16h.05c.36-.07.71-.16 1.03-.25h.02c.33-.1.63-.22.9-.34.95-.44 1.54-1.03 1.54-1.67 0-1.38-2.69-2.5-6-2.5s-6 1.12-6 2.5c0 .82.96 1.55 2.44 2.01ZM10 12.5c.44 0 .86-.02 1.27-.06h.06c.4-.04.78-.09 1.14-.16h.05c.37-.07.71-.16 1.03-.25h.02c1.48-.46 2.44-1.18 2.44-2.01V7.9c0-.31-.33-.49-.6-.34-.4.22-.89.43-1.49.62-.38.12-.77.21-1.17.29l-.05.01c-.4.08-.82.13-1.25.17h-.06c-.46.05-.93.07-1.38.07q-.69 0-1.38-.06h-.06c-.43-.05-.84-.11-1.25-.18h-.05v-.01c-.4-.08-.79-.17-1.17-.29a7 7 0 0 1-1.49-.62c-.27-.15-.6.04-.6.34v2.12c0 .82.96 1.55 2.44 2.01h.02c.32.1.67.18 1.03.25h.05c.36.07.74.12 1.14.16h.06c.41.04.84.06 1.27.06Z"/>
35354<path d="M10 17.5c.44 0 .86-.02 1.27-.06h.06c.4-.04.78-.09 1.14-.16h.05c.37-.07.71-.16 1.03-.25h.02c1.48-.46 2.44-1.18 2.44-2.01V12.9c0-.31-.33-.49-.6-.34-.4.22-.89.43-1.49.62-.38.12-.77.21-1.17.29l-.05.01c-.4.08-.82.13-1.25.17h-.06c-.46.05-.93.07-1.38.07q-.69 0-1.38-.06h-.06c-.43-.05-.84-.11-1.25-.18h-.05v-.01c-.4-.08-.79-.17-1.17-.29a7 7 0 0 1-1.49-.62c-.27-.15-.6.04-.6.34v2.12c0 .82.96 1.55 2.44 2.01h.02c.32.1.67.18 1.03.25h.05c.36.07.74.12 1.14.16h.06c.41.04.84.06 1.27.06Z"/></svg>',
35355        'coupon': '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" width="20" height="20"><path d="M12.31 11.58c-.2 0-.39.08-.53.22-.29.29-.3.77 0 1.06a.75.75 0 1 0 .53-1.28M8.22 8.21c.29-.29.3-.77 0-1.06a.75.75 0 0 0-1.06 0c-.29.29-.3.77 0 1.06a.75.75 0 0 0 1.06 0"/><path d="m17.02 10 .6-1.86a.99.99 0 0 0-.36-1.11l-1.57-1.15-.61-1.85c-.13-.41-.52-.68-.95-.69h-1.95l-1.59-1.15c-.35-.25-.82-.25-1.17 0L7.83 3.33H5.88c-.43.01-.81.29-.95.7l-.61 1.85-1.57 1.15c-.35.25-.49.7-.36 1.11l.6 1.86-.6 1.86c-.13.41.01.86.36 1.11l1.57 1.15.61 1.85c.13.41.52.68.95.69h1.95l1.59 1.15c.35.25.82.25 1.17 0l1.59-1.14h1.95c.43-.01.81-.29.95-.7l.61-1.85 1.57-1.15c.35-.25.49-.7.36-1.11zM6.46 6.43c.34-.34.79-.51 1.23-.51.45 0 .9.17 1.24.52.68.69.68 1.79-.01 2.47a1.734 1.734 0 0 1-2.47-.01c-.68-.69-.68-1.79.01-2.47m1.51 6.35c-.23.23-.61.23-.85 0s-.23-.61 0-.85l4.81-4.81c.23-.23.61-.23.85 0s.23.61 0 .85zm5.57.79a1.734 1.734 0 0 1-2.47-.01c-.68-.69-.68-1.79.01-2.47a1.734 1.734 0 0 1 2.47.01c.68.69.68 1.79-.01 2.47"/></svg>'
35356    };
35357
35358    $('#section-top-menu [data-menu-key]').each(function() {
35359        var key = $(this).data('menu-key');
35360        
35361        if (icons[key]) {
35362            $(this).find('.subnav-title').prepend(icons[key]);
35363        }
35364    });
35365});
35366
35367
35368var getColorisHtml = function(val,clr,input_options,input_layout,iswrap,class_obj,tooltip_title) {
35369    // console.log(`val: ${val}`,`val: ${clr}`,`input_options: `,input_options,`input_layout: ${input_layout}`,`iswrap: ${iswrap}`,`class_obj: `,class_obj,`tooltip_title: ${tooltip_title}`);
35370    if(typeof val == 'undefined' || val == '') val = 'transparent';
35371    if(typeof mode == 'undefined') mode = '';
35372    if(typeof layout == 'undefined') layout = '';
35373    if(typeof iswrap == 'undefined') iswrap = true;
35374    if(typeof class_obj == 'undefined') class_obj = {'wrap':'', 'input':''};
35375    if(typeof class_obj['element'] == 'undefined') class_obj['element'] = 'span';
35376    if(typeof class_obj['wrap'] == 'undefined') class_obj['wrap'] = '';
35377    if(typeof class_obj['wrap_attr'] == 'undefined') class_obj['wrap_attr'] = '';
35378    if(typeof class_obj['input'] == 'undefined') class_obj['input'] = '';
35379
35380    if(Array.isArray(val)) val = val[val.length - 1];
35381
35382    var clr_options = '';
35383    $.each(input_options, function(k,v) {
35384        if(v) clr_options += ` ${k}="${v}"`;
35385    });
35386
35387    var clr_input_class = (class_obj['input']) ? class_obj['input'] + ' ' : '';
35388    switch(input_layout) {
35389        case 'thumbnail': clr_input_class += 'clr-thumbnail '; break;
35390        default: break;
35391    }
35392
35393    var colorValueRegex = Coloris.getColorRegex();
35394    var colorWithImportantRegex = /!important$/g;
35395    var checkWithImportant = (val.match(colorWithImportantRegex) !== null) ? true : false;
35396    if(checkWithImportant) {
35397        var tmp_match = val.match(colorValueRegex);
35398        val = (tmp_match) ? tmp_match[0] : 'transparent';
35399    }
35400
35401    if(/(none|inherit|initial)\b/gi.exec(val)) val = val.replace(/(none|inherit|initial)\b/gi, 'transparent');
35402
35403    if(class_obj['input'].indexOf('clr-alphaoff') > -1) val = Coloris.getChangeColorVal(val,'a',1);
35404
35405    var clr_tooltip_title = (tooltip_title) ? tooltip_title : 'editor.color';
35406
35407    var clr_tooltip = (clr_input_class.indexOf('clr-tooltipoff') > -1) ? '' : `data-toggle="tooltip" data-placement="top" title="${$.lang[LANG][clr_tooltip_title]}"`;
35408    var clr_html = `<input type="text" value="${val}" class="coloris ${clr_input_class}" data-clr="${clr}" ${clr_options} ${clr_tooltip} readonly autocomplete="off" autocorrect="off" spellcheck="false">`;
35409    if(iswrap) {
35410        var clr_wrap_class = class_obj['wrap'];
35411        var clr_wrap_attr = class_obj['wrap_attr'];
35412        var element_type = class_obj['element'];
35413        
35414        clr_html = `<${element_type} class="coloris-picker ${clr_wrap_class}" ${clr_wrap_attr}>${clr_html}</${element_type}>`;
35415    }
35416
35417    return clr_html;
35418}

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.